babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. import { Nullable } from "babylonjs/types";
  431. /**
  432. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  433. */
  434. export class WebRequest implements IWebRequest {
  435. private _xhr;
  436. /**
  437. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  438. * i.e. when loading files, where the server/service expects an Authorization header
  439. */
  440. static CustomRequestHeaders: {
  441. [key: string]: string;
  442. };
  443. /**
  444. * Add callback functions in this array to update all the requests before they get sent to the network
  445. */
  446. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  447. private _injectCustomRequestHeaders;
  448. /**
  449. * Gets or sets a function to be called when loading progress changes
  450. */
  451. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  452. /**
  453. * Returns client's state
  454. */
  455. readonly readyState: number;
  456. /**
  457. * Returns client's status
  458. */
  459. readonly status: number;
  460. /**
  461. * Returns client's status as a text
  462. */
  463. readonly statusText: string;
  464. /**
  465. * Returns client's response
  466. */
  467. readonly response: any;
  468. /**
  469. * Returns client's response url
  470. */
  471. readonly responseURL: string;
  472. /**
  473. * Returns client's response as text
  474. */
  475. readonly responseText: string;
  476. /**
  477. * Gets or sets the expected response type
  478. */
  479. responseType: XMLHttpRequestResponseType;
  480. /** @hidden */
  481. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  482. /** @hidden */
  483. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  484. /**
  485. * Cancels any network activity
  486. */
  487. abort(): void;
  488. /**
  489. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  490. * @param body defines an optional request body
  491. */
  492. send(body?: Document | BodyInit | null): void;
  493. /**
  494. * Sets the request method, request URL
  495. * @param method defines the method to use (GET, POST, etc..)
  496. * @param url defines the url to connect with
  497. */
  498. open(method: string, url: string): void;
  499. /**
  500. * Sets the value of a request header.
  501. * @param name The name of the header whose value is to be set
  502. * @param value The value to set as the body of the header
  503. */
  504. setRequestHeader(name: string, value: string): void;
  505. /**
  506. * Get the string containing the text of a particular header's value.
  507. * @param name The name of the header
  508. * @returns The string containing the text of the given header name
  509. */
  510. getResponseHeader(name: string): Nullable<string>;
  511. }
  512. }
  513. declare module "babylonjs/Misc/fileRequest" {
  514. import { Observable } from "babylonjs/Misc/observable";
  515. /**
  516. * File request interface
  517. */
  518. export interface IFileRequest {
  519. /**
  520. * Raised when the request is complete (success or error).
  521. */
  522. onCompleteObservable: Observable<IFileRequest>;
  523. /**
  524. * Aborts the request for a file.
  525. */
  526. abort: () => void;
  527. }
  528. }
  529. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  530. /**
  531. * Define options used to create a render target texture
  532. */
  533. export class RenderTargetCreationOptions {
  534. /**
  535. * Specifies is mipmaps must be generated
  536. */
  537. generateMipMaps?: boolean;
  538. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  539. generateDepthBuffer?: boolean;
  540. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  541. generateStencilBuffer?: boolean;
  542. /** Defines texture type (int by default) */
  543. type?: number;
  544. /** Defines sampling mode (trilinear by default) */
  545. samplingMode?: number;
  546. /** Defines format (RGBA by default) */
  547. format?: number;
  548. }
  549. }
  550. declare module "babylonjs/Instrumentation/timeToken" {
  551. import { Nullable } from "babylonjs/types";
  552. /**
  553. * @hidden
  554. **/
  555. export class _TimeToken {
  556. _startTimeQuery: Nullable<WebGLQuery>;
  557. _endTimeQuery: Nullable<WebGLQuery>;
  558. _timeElapsedQuery: Nullable<WebGLQuery>;
  559. _timeElapsedQueryEnded: boolean;
  560. }
  561. }
  562. declare module "babylonjs/Engines/constants" {
  563. /** Defines the cross module used constants to avoid circular dependncies */
  564. export class Constants {
  565. /** Defines that alpha blending is disabled */
  566. static readonly ALPHA_DISABLE: number;
  567. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  568. static readonly ALPHA_ADD: number;
  569. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  570. static readonly ALPHA_COMBINE: number;
  571. /** Defines that alpha blending to DEST - SRC * DEST */
  572. static readonly ALPHA_SUBTRACT: number;
  573. /** Defines that alpha blending to SRC * DEST */
  574. static readonly ALPHA_MULTIPLY: number;
  575. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  576. static readonly ALPHA_MAXIMIZED: number;
  577. /** Defines that alpha blending to SRC + DEST */
  578. static readonly ALPHA_ONEONE: number;
  579. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  580. static readonly ALPHA_PREMULTIPLIED: number;
  581. /**
  582. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  583. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  584. */
  585. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  586. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  587. static readonly ALPHA_INTERPOLATE: number;
  588. /**
  589. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  590. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  591. */
  592. static readonly ALPHA_SCREENMODE: number;
  593. /**
  594. * Defines that alpha blending to SRC + DST
  595. * Alpha will be set to SRC ALPHA + DST ALPHA
  596. */
  597. static readonly ALPHA_ONEONE_ONEONE: number;
  598. /**
  599. * Defines that alpha blending to SRC * DST ALPHA + DST
  600. * Alpha will be set to 0
  601. */
  602. static readonly ALPHA_ALPHATOCOLOR: number;
  603. /**
  604. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  605. */
  606. static readonly ALPHA_REVERSEONEMINUS: number;
  607. /**
  608. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  609. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  610. */
  611. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  612. /**
  613. * Defines that alpha blending to SRC + DST
  614. * Alpha will be set to SRC ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEZERO: number;
  617. /** Defines that alpha blending equation a SUM */
  618. static readonly ALPHA_EQUATION_ADD: number;
  619. /** Defines that alpha blending equation a SUBSTRACTION */
  620. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  621. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  622. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  623. /** Defines that alpha blending equation a MAX operation */
  624. static readonly ALPHA_EQUATION_MAX: number;
  625. /** Defines that alpha blending equation a MIN operation */
  626. static readonly ALPHA_EQUATION_MIN: number;
  627. /**
  628. * Defines that alpha blending equation a DARKEN operation:
  629. * It takes the min of the src and sums the alpha channels.
  630. */
  631. static readonly ALPHA_EQUATION_DARKEN: number;
  632. /** Defines that the ressource is not delayed*/
  633. static readonly DELAYLOADSTATE_NONE: number;
  634. /** Defines that the ressource was successfully delay loaded */
  635. static readonly DELAYLOADSTATE_LOADED: number;
  636. /** Defines that the ressource is currently delay loading */
  637. static readonly DELAYLOADSTATE_LOADING: number;
  638. /** Defines that the ressource is delayed and has not started loading */
  639. static readonly DELAYLOADSTATE_NOTLOADED: number;
  640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  641. static readonly NEVER: number;
  642. /** 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 */
  643. static readonly ALWAYS: number;
  644. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  645. static readonly LESS: number;
  646. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  647. static readonly EQUAL: number;
  648. /** 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 */
  649. static readonly LEQUAL: number;
  650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  651. static readonly GREATER: number;
  652. /** 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 */
  653. static readonly GEQUAL: number;
  654. /** 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 */
  655. static readonly NOTEQUAL: number;
  656. /** Passed to stencilOperation to specify that stencil value must be kept */
  657. static readonly KEEP: number;
  658. /** Passed to stencilOperation to specify that stencil value must be replaced */
  659. static readonly REPLACE: number;
  660. /** Passed to stencilOperation to specify that stencil value must be incremented */
  661. static readonly INCR: number;
  662. /** Passed to stencilOperation to specify that stencil value must be decremented */
  663. static readonly DECR: number;
  664. /** Passed to stencilOperation to specify that stencil value must be inverted */
  665. static readonly INVERT: number;
  666. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  667. static readonly INCR_WRAP: number;
  668. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  669. static readonly DECR_WRAP: number;
  670. /** Texture is not repeating outside of 0..1 UVs */
  671. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  672. /** Texture is repeating outside of 0..1 UVs */
  673. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  674. /** Texture is repeating and mirrored */
  675. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  676. /** ALPHA */
  677. static readonly TEXTUREFORMAT_ALPHA: number;
  678. /** LUMINANCE */
  679. static readonly TEXTUREFORMAT_LUMINANCE: number;
  680. /** LUMINANCE_ALPHA */
  681. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  682. /** RGB */
  683. static readonly TEXTUREFORMAT_RGB: number;
  684. /** RGBA */
  685. static readonly TEXTUREFORMAT_RGBA: number;
  686. /** RED */
  687. static readonly TEXTUREFORMAT_RED: number;
  688. /** RED (2nd reference) */
  689. static readonly TEXTUREFORMAT_R: number;
  690. /** RG */
  691. static readonly TEXTUREFORMAT_RG: number;
  692. /** RED_INTEGER */
  693. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  694. /** RED_INTEGER (2nd reference) */
  695. static readonly TEXTUREFORMAT_R_INTEGER: number;
  696. /** RG_INTEGER */
  697. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  698. /** RGB_INTEGER */
  699. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  700. /** RGBA_INTEGER */
  701. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  702. /** UNSIGNED_BYTE */
  703. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  704. /** UNSIGNED_BYTE (2nd reference) */
  705. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  706. /** FLOAT */
  707. static readonly TEXTURETYPE_FLOAT: number;
  708. /** HALF_FLOAT */
  709. static readonly TEXTURETYPE_HALF_FLOAT: number;
  710. /** BYTE */
  711. static readonly TEXTURETYPE_BYTE: number;
  712. /** SHORT */
  713. static readonly TEXTURETYPE_SHORT: number;
  714. /** UNSIGNED_SHORT */
  715. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  716. /** INT */
  717. static readonly TEXTURETYPE_INT: number;
  718. /** UNSIGNED_INT */
  719. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  720. /** UNSIGNED_SHORT_4_4_4_4 */
  721. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  722. /** UNSIGNED_SHORT_5_5_5_1 */
  723. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  724. /** UNSIGNED_SHORT_5_6_5 */
  725. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  726. /** UNSIGNED_INT_2_10_10_10_REV */
  727. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  728. /** UNSIGNED_INT_24_8 */
  729. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  730. /** UNSIGNED_INT_10F_11F_11F_REV */
  731. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  732. /** UNSIGNED_INT_5_9_9_9_REV */
  733. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  734. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  735. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  736. /** nearest is mag = nearest and min = nearest and mip = linear */
  737. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  738. /** Bilinear is mag = linear and min = linear and mip = nearest */
  739. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  740. /** Trilinear is mag = linear and min = linear and mip = linear */
  741. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  742. /** nearest is mag = nearest and min = nearest and mip = linear */
  743. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  744. /** Bilinear is mag = linear and min = linear and mip = nearest */
  745. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  746. /** Trilinear is mag = linear and min = linear and mip = linear */
  747. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  748. /** mag = nearest and min = nearest and mip = nearest */
  749. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  750. /** mag = nearest and min = linear and mip = nearest */
  751. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  752. /** mag = nearest and min = linear and mip = linear */
  753. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  754. /** mag = nearest and min = linear and mip = none */
  755. static readonly TEXTURE_NEAREST_LINEAR: number;
  756. /** mag = nearest and min = nearest and mip = none */
  757. static readonly TEXTURE_NEAREST_NEAREST: number;
  758. /** mag = linear and min = nearest and mip = nearest */
  759. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  760. /** mag = linear and min = nearest and mip = linear */
  761. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  762. /** mag = linear and min = linear and mip = none */
  763. static readonly TEXTURE_LINEAR_LINEAR: number;
  764. /** mag = linear and min = nearest and mip = none */
  765. static readonly TEXTURE_LINEAR_NEAREST: number;
  766. /** Explicit coordinates mode */
  767. static readonly TEXTURE_EXPLICIT_MODE: number;
  768. /** Spherical coordinates mode */
  769. static readonly TEXTURE_SPHERICAL_MODE: number;
  770. /** Planar coordinates mode */
  771. static readonly TEXTURE_PLANAR_MODE: number;
  772. /** Cubic coordinates mode */
  773. static readonly TEXTURE_CUBIC_MODE: number;
  774. /** Projection coordinates mode */
  775. static readonly TEXTURE_PROJECTION_MODE: number;
  776. /** Skybox coordinates mode */
  777. static readonly TEXTURE_SKYBOX_MODE: number;
  778. /** Inverse Cubic coordinates mode */
  779. static readonly TEXTURE_INVCUBIC_MODE: number;
  780. /** Equirectangular coordinates mode */
  781. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  782. /** Equirectangular Fixed coordinates mode */
  783. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  784. /** Equirectangular Fixed Mirrored coordinates mode */
  785. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  786. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  787. static readonly SCALEMODE_FLOOR: number;
  788. /** Defines that texture rescaling will look for the nearest power of 2 size */
  789. static readonly SCALEMODE_NEAREST: number;
  790. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  791. static readonly SCALEMODE_CEILING: number;
  792. /**
  793. * The dirty texture flag value
  794. */
  795. static readonly MATERIAL_TextureDirtyFlag: number;
  796. /**
  797. * The dirty light flag value
  798. */
  799. static readonly MATERIAL_LightDirtyFlag: number;
  800. /**
  801. * The dirty fresnel flag value
  802. */
  803. static readonly MATERIAL_FresnelDirtyFlag: number;
  804. /**
  805. * The dirty attribute flag value
  806. */
  807. static readonly MATERIAL_AttributesDirtyFlag: number;
  808. /**
  809. * The dirty misc flag value
  810. */
  811. static readonly MATERIAL_MiscDirtyFlag: number;
  812. /**
  813. * The all dirty flag value
  814. */
  815. static readonly MATERIAL_AllDirtyFlag: number;
  816. /**
  817. * Returns the triangle fill mode
  818. */
  819. static readonly MATERIAL_TriangleFillMode: number;
  820. /**
  821. * Returns the wireframe mode
  822. */
  823. static readonly MATERIAL_WireFrameFillMode: number;
  824. /**
  825. * Returns the point fill mode
  826. */
  827. static readonly MATERIAL_PointFillMode: number;
  828. /**
  829. * Returns the point list draw mode
  830. */
  831. static readonly MATERIAL_PointListDrawMode: number;
  832. /**
  833. * Returns the line list draw mode
  834. */
  835. static readonly MATERIAL_LineListDrawMode: number;
  836. /**
  837. * Returns the line loop draw mode
  838. */
  839. static readonly MATERIAL_LineLoopDrawMode: number;
  840. /**
  841. * Returns the line strip draw mode
  842. */
  843. static readonly MATERIAL_LineStripDrawMode: number;
  844. /**
  845. * Returns the triangle strip draw mode
  846. */
  847. static readonly MATERIAL_TriangleStripDrawMode: number;
  848. /**
  849. * Returns the triangle fan draw mode
  850. */
  851. static readonly MATERIAL_TriangleFanDrawMode: number;
  852. /**
  853. * Stores the clock-wise side orientation
  854. */
  855. static readonly MATERIAL_ClockWiseSideOrientation: number;
  856. /**
  857. * Stores the counter clock-wise side orientation
  858. */
  859. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  860. /**
  861. * Nothing
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_NothingTrigger: number;
  865. /**
  866. * On pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnPickTrigger: number;
  870. /**
  871. * On left pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnLeftPickTrigger: number;
  875. /**
  876. * On right pick
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnRightPickTrigger: number;
  880. /**
  881. * On center pick
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnCenterPickTrigger: number;
  885. /**
  886. * On pick down
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnPickDownTrigger: number;
  890. /**
  891. * On double pick
  892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  893. */
  894. static readonly ACTION_OnDoublePickTrigger: number;
  895. /**
  896. * On pick up
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_OnPickUpTrigger: number;
  900. /**
  901. * On pick out.
  902. * This trigger will only be raised if you also declared a OnPickDown
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickOutTrigger: number;
  906. /**
  907. * On long press
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLongPressTrigger: number;
  911. /**
  912. * On pointer over
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnPointerOverTrigger: number;
  916. /**
  917. * On pointer out
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPointerOutTrigger: number;
  921. /**
  922. * On every frame
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnEveryFrameTrigger: number;
  926. /**
  927. * On intersection enter
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnIntersectionEnterTrigger: number;
  931. /**
  932. * On intersection exit
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnIntersectionExitTrigger: number;
  936. /**
  937. * On key down
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnKeyDownTrigger: number;
  941. /**
  942. * On key up
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnKeyUpTrigger: number;
  946. /**
  947. * Billboard mode will only apply to Y axis
  948. */
  949. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  950. /**
  951. * Billboard mode will apply to all axes
  952. */
  953. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  954. /**
  955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  956. */
  957. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  958. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  959. * Test order :
  960. * Is the bounding sphere outside the frustum ?
  961. * If not, are the bounding box vertices outside the frustum ?
  962. * It not, then the cullable object is in the frustum.
  963. */
  964. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  965. /** Culling strategy : Bounding Sphere Only.
  966. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  967. * It's also less accurate than the standard because some not visible objects can still be selected.
  968. * Test : is the bounding sphere outside the frustum ?
  969. * If not, then the cullable object is in the frustum.
  970. */
  971. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  972. /** Culling strategy : Optimistic Inclusion.
  973. * This in an inclusion test first, then the standard exclusion test.
  974. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  975. * 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.
  976. * Anyway, it's as accurate as the standard strategy.
  977. * Test :
  978. * Is the cullable object bounding sphere center in the frustum ?
  979. * If not, apply the default culling strategy.
  980. */
  981. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  982. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  983. * This in an inclusion test first, then the bounding sphere only exclusion test.
  984. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  985. * 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.
  986. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  987. * Test :
  988. * Is the cullable object bounding sphere center in the frustum ?
  989. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  990. */
  991. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  992. /**
  993. * No logging while loading
  994. */
  995. static readonly SCENELOADER_NO_LOGGING: number;
  996. /**
  997. * Minimal logging while loading
  998. */
  999. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1000. /**
  1001. * Summary logging while loading
  1002. */
  1003. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1004. /**
  1005. * Detailled logging while loading
  1006. */
  1007. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1008. }
  1009. }
  1010. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1011. import { Nullable } from "babylonjs/types";
  1012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1013. /**
  1014. * This represents the required contract to create a new type of texture loader.
  1015. */
  1016. export interface IInternalTextureLoader {
  1017. /**
  1018. * Defines wether the loader supports cascade loading the different faces.
  1019. */
  1020. supportCascades: boolean;
  1021. /**
  1022. * This returns if the loader support the current file information.
  1023. * @param extension defines the file extension of the file being loaded
  1024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1025. * @param fallback defines the fallback internal texture if any
  1026. * @param isBase64 defines whether the texture is encoded as a base64
  1027. * @param isBuffer defines whether the texture data are stored as a buffer
  1028. * @returns true if the loader can load the specified file
  1029. */
  1030. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1031. /**
  1032. * Transform the url before loading if required.
  1033. * @param rootUrl the url of the texture
  1034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1035. * @returns the transformed texture
  1036. */
  1037. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1038. /**
  1039. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1040. * @param rootUrl the url of the texture
  1041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1042. * @returns the fallback texture
  1043. */
  1044. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1045. /**
  1046. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param createPolynomials will be true if polynomials have been requested
  1050. * @param onLoad defines the callback to trigger once the texture is ready
  1051. * @param onError defines the callback to trigger in case of error
  1052. */
  1053. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1054. /**
  1055. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1056. * @param data contains the texture data
  1057. * @param texture defines the BabylonJS internal texture
  1058. * @param callback defines the method to call once ready to upload
  1059. */
  1060. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1061. }
  1062. }
  1063. declare module "babylonjs/Engines/IPipelineContext" {
  1064. /**
  1065. * Class used to store and describe the pipeline context associated with an effect
  1066. */
  1067. export interface IPipelineContext {
  1068. /**
  1069. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1070. */
  1071. isAsync: boolean;
  1072. /**
  1073. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1074. */
  1075. isReady: boolean;
  1076. /** @hidden */
  1077. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Meshes/dataBuffer" {
  1081. /**
  1082. * Class used to store gfx data (like WebGLBuffer)
  1083. */
  1084. export class DataBuffer {
  1085. /**
  1086. * Gets or sets the number of objects referencing this buffer
  1087. */
  1088. references: number;
  1089. /** Gets or sets the size of the underlying buffer */
  1090. capacity: number;
  1091. /**
  1092. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1093. */
  1094. is32Bits: boolean;
  1095. /**
  1096. * Gets the underlying buffer
  1097. */
  1098. readonly underlyingResource: any;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1102. /** @hidden */
  1103. export interface IShaderProcessor {
  1104. attributeProcessor?: (attribute: string) => string;
  1105. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1106. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1107. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1108. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1109. lineProcessor?: (line: string, isFragment: boolean) => string;
  1110. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1111. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1112. }
  1113. }
  1114. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1115. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1116. /** @hidden */
  1117. export interface ProcessingOptions {
  1118. defines: string[];
  1119. indexParameters: any;
  1120. isFragment: boolean;
  1121. shouldUseHighPrecisionShader: boolean;
  1122. supportsUniformBuffers: boolean;
  1123. shadersRepository: string;
  1124. includesShadersStore: {
  1125. [key: string]: string;
  1126. };
  1127. processor?: IShaderProcessor;
  1128. version: string;
  1129. platformName: string;
  1130. lookForClosingBracketForUniformBuffer?: boolean;
  1131. }
  1132. }
  1133. declare module "babylonjs/Misc/stringTools" {
  1134. /**
  1135. * Helper to manipulate strings
  1136. */
  1137. export class StringTools {
  1138. /**
  1139. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1140. * @param str Source string
  1141. * @param suffix Suffix to search for in the source string
  1142. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1143. */
  1144. static EndsWith(str: string, suffix: string): boolean;
  1145. /**
  1146. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1147. * @param str Source string
  1148. * @param suffix Suffix to search for in the source string
  1149. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1150. */
  1151. static StartsWith(str: string, suffix: string): boolean;
  1152. /**
  1153. * Decodes a buffer into a string
  1154. * @param buffer The buffer to decode
  1155. * @returns The decoded string
  1156. */
  1157. static Decode(buffer: Uint8Array | Uint16Array): string;
  1158. }
  1159. }
  1160. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1161. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1162. /** @hidden */
  1163. export class ShaderCodeNode {
  1164. line: string;
  1165. children: ShaderCodeNode[];
  1166. additionalDefineKey?: string;
  1167. additionalDefineValue?: string;
  1168. isValid(preprocessors: {
  1169. [key: string]: string;
  1170. }): boolean;
  1171. process(preprocessors: {
  1172. [key: string]: string;
  1173. }, options: ProcessingOptions): string;
  1174. }
  1175. }
  1176. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1177. /** @hidden */
  1178. export class ShaderCodeCursor {
  1179. private _lines;
  1180. lineIndex: number;
  1181. readonly currentLine: string;
  1182. readonly canRead: boolean;
  1183. lines: string[];
  1184. }
  1185. }
  1186. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1187. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1188. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1189. /** @hidden */
  1190. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1191. process(preprocessors: {
  1192. [key: string]: string;
  1193. }, options: ProcessingOptions): string;
  1194. }
  1195. }
  1196. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1197. /** @hidden */
  1198. export class ShaderDefineExpression {
  1199. isTrue(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1205. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1206. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1216. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1217. /** @hidden */
  1218. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1219. define: string;
  1220. not: boolean;
  1221. constructor(define: string, not?: boolean);
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1228. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1229. /** @hidden */
  1230. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1231. leftOperand: ShaderDefineExpression;
  1232. rightOperand: ShaderDefineExpression;
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1253. define: string;
  1254. operand: string;
  1255. testValue: string;
  1256. constructor(define: string, operand: string, testValue: string);
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Offline/IOfflineProvider" {
  1263. /**
  1264. * Class used to enable access to offline support
  1265. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1266. */
  1267. export interface IOfflineProvider {
  1268. /**
  1269. * Gets a boolean indicating if scene must be saved in the database
  1270. */
  1271. enableSceneOffline: boolean;
  1272. /**
  1273. * Gets a boolean indicating if textures must be saved in the database
  1274. */
  1275. enableTexturesOffline: boolean;
  1276. /**
  1277. * Open the offline support and make it available
  1278. * @param successCallback defines the callback to call on success
  1279. * @param errorCallback defines the callback to call on error
  1280. */
  1281. open(successCallback: () => void, errorCallback: () => void): void;
  1282. /**
  1283. * Loads an image from the offline support
  1284. * @param url defines the url to load from
  1285. * @param image defines the target DOM image
  1286. */
  1287. loadImage(url: string, image: HTMLImageElement): void;
  1288. /**
  1289. * Loads a file from offline support
  1290. * @param url defines the URL to load from
  1291. * @param sceneLoaded defines a callback to call on success
  1292. * @param progressCallBack defines a callback to call when progress changed
  1293. * @param errorCallback defines a callback to call on error
  1294. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1295. */
  1296. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1297. }
  1298. }
  1299. declare module "babylonjs/Misc/filesInputStore" {
  1300. /**
  1301. * Class used to help managing file picking and drag'n'drop
  1302. * File Storage
  1303. */
  1304. export class FilesInputStore {
  1305. /**
  1306. * List of files ready to be loaded
  1307. */
  1308. static FilesToLoad: {
  1309. [key: string]: File;
  1310. };
  1311. }
  1312. }
  1313. declare module "babylonjs/Misc/retryStrategy" {
  1314. import { WebRequest } from "babylonjs/Misc/webRequest";
  1315. /**
  1316. * Class used to define a retry strategy when error happens while loading assets
  1317. */
  1318. export class RetryStrategy {
  1319. /**
  1320. * Function used to defines an exponential back off strategy
  1321. * @param maxRetries defines the maximum number of retries (3 by default)
  1322. * @param baseInterval defines the interval between retries
  1323. * @returns the strategy function to use
  1324. */
  1325. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1326. }
  1327. }
  1328. declare module "babylonjs/Misc/baseError" {
  1329. /**
  1330. * @ignore
  1331. * Application error to support additional information when loading a file
  1332. */
  1333. export abstract class BaseError extends Error {
  1334. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1335. }
  1336. }
  1337. declare module "babylonjs/Misc/fileTools" {
  1338. import { WebRequest } from "babylonjs/Misc/webRequest";
  1339. import { Nullable } from "babylonjs/types";
  1340. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1341. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1342. import { BaseError } from "babylonjs/Misc/baseError";
  1343. /** @ignore */
  1344. export class LoadFileError extends BaseError {
  1345. request?: WebRequest;
  1346. file?: File;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. * @param file defines the optional file
  1352. */
  1353. constructor(message: string, object?: WebRequest | File);
  1354. }
  1355. /** @ignore */
  1356. export class RequestFileError extends BaseError {
  1357. request: WebRequest;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. */
  1363. constructor(message: string, request: WebRequest);
  1364. }
  1365. /** @ignore */
  1366. export class ReadFileError extends BaseError {
  1367. file: File;
  1368. /**
  1369. * Creates a new ReadFileError
  1370. * @param message defines the message of the error
  1371. * @param file defines the optional file
  1372. */
  1373. constructor(message: string, file: File);
  1374. }
  1375. /**
  1376. * @hidden
  1377. */
  1378. export class FileTools {
  1379. /**
  1380. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1381. */
  1382. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1383. /**
  1384. * Gets or sets the base URL to use to load assets
  1385. */
  1386. static BaseUrl: string;
  1387. /**
  1388. * Default behaviour for cors in the application.
  1389. * It can be a string if the expected behavior is identical in the entire app.
  1390. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1391. */
  1392. static CorsBehavior: string | ((url: string | string[]) => string);
  1393. /**
  1394. * Gets or sets a function used to pre-process url before using them to load assets
  1395. */
  1396. static PreprocessUrl: (url: string) => string;
  1397. /**
  1398. * Removes unwanted characters from an url
  1399. * @param url defines the url to clean
  1400. * @returns the cleaned url
  1401. */
  1402. private static _CleanUrl;
  1403. /**
  1404. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1405. * @param url define the url we are trying
  1406. * @param element define the dom element where to configure the cors policy
  1407. */
  1408. static SetCorsBehavior(url: string | string[], element: {
  1409. crossOrigin: string | null;
  1410. }): void;
  1411. private static _ArrayBufferToBase64;
  1412. /**
  1413. * Loads an image as an HTMLImageElement.
  1414. * @param input url string, ArrayBuffer, or Blob to load
  1415. * @param onLoad callback called when the image successfully loads
  1416. * @param onError callback called when the image fails to load
  1417. * @param offlineProvider offline provider for caching
  1418. * @param mimeType optional mime type
  1419. * @returns the HTMLImageElement of the loaded image
  1420. */
  1421. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1422. /**
  1423. * Reads a file from a File object
  1424. * @param file defines the file to load
  1425. * @param onSuccess defines the callback to call when data is loaded
  1426. * @param onProgress defines the callback to call during loading process
  1427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1428. * @param onError defines the callback to call when an error occurs
  1429. * @returns a file request object
  1430. */
  1431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file from a url
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param offlineProvider defines the offline provider for caching
  1438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1439. * @param onError callback called when the file fails to load
  1440. * @returns a file request object
  1441. */
  1442. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @param onOpened callback called when the web request is opened
  1451. * @returns a file request object
  1452. */
  1453. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1454. /**
  1455. * Checks if the loaded document was accessed via `file:`-Protocol.
  1456. * @returns boolean
  1457. */
  1458. static IsFileURL(): boolean;
  1459. }
  1460. }
  1461. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1462. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1463. /** @hidden */
  1464. export class ShaderProcessor {
  1465. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1466. private static _ProcessPrecision;
  1467. private static _ExtractOperation;
  1468. private static _BuildSubExpression;
  1469. private static _BuildExpression;
  1470. private static _MoveCursorWithinIf;
  1471. private static _MoveCursor;
  1472. private static _EvaluatePreProcessors;
  1473. private static _PreparePreProcessors;
  1474. private static _ProcessShaderConversion;
  1475. private static _ProcessIncludes;
  1476. }
  1477. }
  1478. declare module "babylonjs/Maths/math.like" {
  1479. import { float, int, DeepImmutable } from "babylonjs/types";
  1480. /**
  1481. * @hidden
  1482. */
  1483. export interface IColor4Like {
  1484. r: float;
  1485. g: float;
  1486. b: float;
  1487. a: float;
  1488. }
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor3Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. }
  1497. /**
  1498. * @hidden
  1499. */
  1500. export interface IVector4Like {
  1501. x: float;
  1502. y: float;
  1503. z: float;
  1504. w: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector3Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. }
  1514. /**
  1515. * @hidden
  1516. */
  1517. export interface IVector2Like {
  1518. x: float;
  1519. y: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IMatrixLike {
  1525. toArray(): DeepImmutable<Float32Array>;
  1526. updateFlag: int;
  1527. }
  1528. /**
  1529. * @hidden
  1530. */
  1531. export interface IViewportLike {
  1532. x: float;
  1533. y: float;
  1534. width: float;
  1535. height: float;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IPlaneLike {
  1541. normal: IVector3Like;
  1542. d: float;
  1543. normalize(): void;
  1544. }
  1545. }
  1546. declare module "babylonjs/Materials/iEffectFallbacks" {
  1547. import { Effect } from "babylonjs/Materials/effect";
  1548. /**
  1549. * Interface used to define common properties for effect fallbacks
  1550. */
  1551. export interface IEffectFallbacks {
  1552. /**
  1553. * Removes the defines that should be removed when falling back.
  1554. * @param currentDefines defines the current define statements for the shader.
  1555. * @param effect defines the current effect we try to compile
  1556. * @returns The resulting defines with defines of the current rank removed.
  1557. */
  1558. reduce(currentDefines: string, effect: Effect): string;
  1559. /**
  1560. * Removes the fallback from the bound mesh.
  1561. */
  1562. unBindMesh(): void;
  1563. /**
  1564. * Checks to see if more fallbacks are still availible.
  1565. */
  1566. hasMoreFallbacks: boolean;
  1567. }
  1568. }
  1569. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1570. /**
  1571. * Class used to evalaute queries containing `and` and `or` operators
  1572. */
  1573. export class AndOrNotEvaluator {
  1574. /**
  1575. * Evaluate a query
  1576. * @param query defines the query to evaluate
  1577. * @param evaluateCallback defines the callback used to filter result
  1578. * @returns true if the query matches
  1579. */
  1580. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1581. private static _HandleParenthesisContent;
  1582. private static _SimplifyNegation;
  1583. }
  1584. }
  1585. declare module "babylonjs/Misc/tags" {
  1586. /**
  1587. * Class used to store custom tags
  1588. */
  1589. export class Tags {
  1590. /**
  1591. * Adds support for tags on the given object
  1592. * @param obj defines the object to use
  1593. */
  1594. static EnableFor(obj: any): void;
  1595. /**
  1596. * Removes tags support
  1597. * @param obj defines the object to use
  1598. */
  1599. static DisableFor(obj: any): void;
  1600. /**
  1601. * Gets a boolean indicating if the given object has tags
  1602. * @param obj defines the object to use
  1603. * @returns a boolean
  1604. */
  1605. static HasTags(obj: any): boolean;
  1606. /**
  1607. * Gets the tags available on a given object
  1608. * @param obj defines the object to use
  1609. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1610. * @returns the tags
  1611. */
  1612. static GetTags(obj: any, asString?: boolean): any;
  1613. /**
  1614. * Adds tags to an object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1617. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1618. */
  1619. static AddTagsTo(obj: any, tagsString: string): void;
  1620. /**
  1621. * @hidden
  1622. */
  1623. static _AddTagTo(obj: any, tag: string): void;
  1624. /**
  1625. * Removes specific tags from a specific object
  1626. * @param obj defines the object to use
  1627. * @param tagsString defines the tags to remove
  1628. */
  1629. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1630. /**
  1631. * @hidden
  1632. */
  1633. static _RemoveTagFrom(obj: any, tag: string): void;
  1634. /**
  1635. * Defines if tags hosted on an object match a given query
  1636. * @param obj defines the object to use
  1637. * @param tagsQuery defines the tag query
  1638. * @returns a boolean
  1639. */
  1640. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1641. }
  1642. }
  1643. declare module "babylonjs/Maths/math.scalar" {
  1644. /**
  1645. * Scalar computation library
  1646. */
  1647. export class Scalar {
  1648. /**
  1649. * Two pi constants convenient for computation.
  1650. */
  1651. static TwoPi: number;
  1652. /**
  1653. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1654. * @param a number
  1655. * @param b number
  1656. * @param epsilon (default = 1.401298E-45)
  1657. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1658. */
  1659. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1660. /**
  1661. * Returns a string : the upper case translation of the number i to hexadecimal.
  1662. * @param i number
  1663. * @returns the upper case translation of the number i to hexadecimal.
  1664. */
  1665. static ToHex(i: number): string;
  1666. /**
  1667. * Returns -1 if value is negative and +1 is value is positive.
  1668. * @param value the value
  1669. * @returns the value itself if it's equal to zero.
  1670. */
  1671. static Sign(value: number): number;
  1672. /**
  1673. * Returns the value itself if it's between min and max.
  1674. * Returns min if the value is lower than min.
  1675. * Returns max if the value is greater than max.
  1676. * @param value the value to clmap
  1677. * @param min the min value to clamp to (default: 0)
  1678. * @param max the max value to clamp to (default: 1)
  1679. * @returns the clamped value
  1680. */
  1681. static Clamp(value: number, min?: number, max?: number): number;
  1682. /**
  1683. * the log2 of value.
  1684. * @param value the value to compute log2 of
  1685. * @returns the log2 of value.
  1686. */
  1687. static Log2(value: number): number;
  1688. /**
  1689. * Loops the value, so that it is never larger than length and never smaller than 0.
  1690. *
  1691. * This is similar to the modulo operator but it works with floating point numbers.
  1692. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1693. * With t = 5 and length = 2.5, the result would be 0.0.
  1694. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1695. * @param value the value
  1696. * @param length the length
  1697. * @returns the looped value
  1698. */
  1699. static Repeat(value: number, length: number): number;
  1700. /**
  1701. * Normalize the value between 0.0 and 1.0 using min and max values
  1702. * @param value value to normalize
  1703. * @param min max to normalize between
  1704. * @param max min to normalize between
  1705. * @returns the normalized value
  1706. */
  1707. static Normalize(value: number, min: number, max: number): number;
  1708. /**
  1709. * Denormalize the value from 0.0 and 1.0 using min and max values
  1710. * @param normalized value to denormalize
  1711. * @param min max to denormalize between
  1712. * @param max min to denormalize between
  1713. * @returns the denormalized value
  1714. */
  1715. static Denormalize(normalized: number, min: number, max: number): number;
  1716. /**
  1717. * Calculates the shortest difference between two given angles given in degrees.
  1718. * @param current current angle in degrees
  1719. * @param target target angle in degrees
  1720. * @returns the delta
  1721. */
  1722. static DeltaAngle(current: number, target: number): number;
  1723. /**
  1724. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1725. * @param tx value
  1726. * @param length length
  1727. * @returns The returned value will move back and forth between 0 and length
  1728. */
  1729. static PingPong(tx: number, length: number): number;
  1730. /**
  1731. * Interpolates between min and max with smoothing at the limits.
  1732. *
  1733. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1734. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1735. * @param from from
  1736. * @param to to
  1737. * @param tx value
  1738. * @returns the smooth stepped value
  1739. */
  1740. static SmoothStep(from: number, to: number, tx: number): number;
  1741. /**
  1742. * Moves a value current towards target.
  1743. *
  1744. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1745. * Negative values of maxDelta pushes the value away from target.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting value
  1750. */
  1751. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1754. *
  1755. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1756. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1757. * @param current current value
  1758. * @param target target value
  1759. * @param maxDelta max distance to move
  1760. * @returns resulting angle
  1761. */
  1762. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1763. /**
  1764. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1765. * @param start start value
  1766. * @param end target value
  1767. * @param amount amount to lerp between
  1768. * @returns the lerped value
  1769. */
  1770. static Lerp(start: number, end: number, amount: number): number;
  1771. /**
  1772. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1773. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static LerpAngle(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1782. * @param a start value
  1783. * @param b target value
  1784. * @param value value between a and b
  1785. * @returns the inverseLerp value
  1786. */
  1787. static InverseLerp(a: number, b: number, value: number): number;
  1788. /**
  1789. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1790. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1791. * @param value1 spline value
  1792. * @param tangent1 spline value
  1793. * @param value2 spline value
  1794. * @param tangent2 spline value
  1795. * @param amount input value
  1796. * @returns hermite result
  1797. */
  1798. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1799. /**
  1800. * Returns a random float number between and min and max values
  1801. * @param min min value of random
  1802. * @param max max value of random
  1803. * @returns random value
  1804. */
  1805. static RandomRange(min: number, max: number): number;
  1806. /**
  1807. * This function returns percentage of a number in a given range.
  1808. *
  1809. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1810. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1811. * @param number to convert to percentage
  1812. * @param min min range
  1813. * @param max max range
  1814. * @returns the percentage
  1815. */
  1816. static RangeToPercent(number: number, min: number, max: number): number;
  1817. /**
  1818. * This function returns number that corresponds to the percentage in a given range.
  1819. *
  1820. * PercentToRange(0.34,0,100) will return 34.
  1821. * @param percent to convert to number
  1822. * @param min min range
  1823. * @param max max range
  1824. * @returns the number
  1825. */
  1826. static PercentToRange(percent: number, min: number, max: number): number;
  1827. /**
  1828. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1829. * @param angle The angle to normalize in radian.
  1830. * @return The converted angle.
  1831. */
  1832. static NormalizeRadians(angle: number): number;
  1833. }
  1834. }
  1835. declare module "babylonjs/Maths/math.constants" {
  1836. /**
  1837. * Constant used to convert a value to gamma space
  1838. * @ignorenaming
  1839. */
  1840. export const ToGammaSpace: number;
  1841. /**
  1842. * Constant used to convert a value to linear space
  1843. * @ignorenaming
  1844. */
  1845. export const ToLinearSpace = 2.2;
  1846. /**
  1847. * Constant used to define the minimal number value in Babylon.js
  1848. * @ignorenaming
  1849. */
  1850. let Epsilon: number;
  1851. export { Epsilon };
  1852. }
  1853. declare module "babylonjs/Maths/math.viewport" {
  1854. /**
  1855. * Class used to represent a viewport on screen
  1856. */
  1857. export class Viewport {
  1858. /** viewport left coordinate */
  1859. x: number;
  1860. /** viewport top coordinate */
  1861. y: number;
  1862. /**viewport width */
  1863. width: number;
  1864. /** viewport height */
  1865. height: number;
  1866. /**
  1867. * Creates a Viewport object located at (x, y) and sized (width, height)
  1868. * @param x defines viewport left coordinate
  1869. * @param y defines viewport top coordinate
  1870. * @param width defines the viewport width
  1871. * @param height defines the viewport height
  1872. */
  1873. constructor(
  1874. /** viewport left coordinate */
  1875. x: number,
  1876. /** viewport top coordinate */
  1877. y: number,
  1878. /**viewport width */
  1879. width: number,
  1880. /** viewport height */
  1881. height: number);
  1882. /**
  1883. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1884. * @param renderWidth defines the rendering width
  1885. * @param renderHeight defines the rendering height
  1886. * @returns a new Viewport
  1887. */
  1888. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1889. /**
  1890. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1891. * @param renderWidth defines the rendering width
  1892. * @param renderHeight defines the rendering height
  1893. * @param ref defines the target viewport
  1894. * @returns the current viewport
  1895. */
  1896. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1897. /**
  1898. * Returns a new Viewport copied from the current one
  1899. * @returns a new Viewport
  1900. */
  1901. clone(): Viewport;
  1902. }
  1903. }
  1904. declare module "babylonjs/Misc/arrayTools" {
  1905. /**
  1906. * Class containing a set of static utilities functions for arrays.
  1907. */
  1908. export class ArrayTools {
  1909. /**
  1910. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1911. * @param size the number of element to construct and put in the array
  1912. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1913. * @returns a new array filled with new objects
  1914. */
  1915. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1916. }
  1917. }
  1918. declare module "babylonjs/Maths/math.vector" {
  1919. import { Viewport } from "babylonjs/Maths/math.viewport";
  1920. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1921. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1922. /**
  1923. * Class representing a vector containing 2 coordinates
  1924. */
  1925. export class Vector2 {
  1926. /** defines the first coordinate */
  1927. x: number;
  1928. /** defines the second coordinate */
  1929. y: number;
  1930. /**
  1931. * Creates a new Vector2 from the given x and y coordinates
  1932. * @param x defines the first coordinate
  1933. * @param y defines the second coordinate
  1934. */
  1935. constructor(
  1936. /** defines the first coordinate */
  1937. x?: number,
  1938. /** defines the second coordinate */
  1939. y?: number);
  1940. /**
  1941. * Gets a string with the Vector2 coordinates
  1942. * @returns a string with the Vector2 coordinates
  1943. */
  1944. toString(): string;
  1945. /**
  1946. * Gets class name
  1947. * @returns the string "Vector2"
  1948. */
  1949. getClassName(): string;
  1950. /**
  1951. * Gets current vector hash code
  1952. * @returns the Vector2 hash code as a number
  1953. */
  1954. getHashCode(): number;
  1955. /**
  1956. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1957. * @param array defines the source array
  1958. * @param index defines the offset in source array
  1959. * @returns the current Vector2
  1960. */
  1961. toArray(array: FloatArray, index?: number): Vector2;
  1962. /**
  1963. * Copy the current vector to an array
  1964. * @returns a new array with 2 elements: the Vector2 coordinates.
  1965. */
  1966. asArray(): number[];
  1967. /**
  1968. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1969. * @param source defines the source Vector2
  1970. * @returns the current updated Vector2
  1971. */
  1972. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the Vector2 coordinates with the given floats
  1975. * @param x defines the first coordinate
  1976. * @param y defines the second coordinate
  1977. * @returns the current updated Vector2
  1978. */
  1979. copyFromFloats(x: number, y: number): Vector2;
  1980. /**
  1981. * Sets the Vector2 coordinates with the given floats
  1982. * @param x defines the first coordinate
  1983. * @param y defines the second coordinate
  1984. * @returns the current updated Vector2
  1985. */
  1986. set(x: number, y: number): Vector2;
  1987. /**
  1988. * Add another vector with the current one
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1991. */
  1992. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. addVector3(otherVector: Vector3): Vector2;
  2012. /**
  2013. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. subtract(otherVector: Vector2): Vector2;
  2018. /**
  2019. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Multiplies in place the current Vector2 coordinates by the given ones
  2033. * @param otherVector defines the other vector
  2034. * @returns the current updated Vector2
  2035. */
  2036. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2052. * @param x defines the first coordinate
  2053. * @param y defines the second coordinate
  2054. * @returns a new Vector2
  2055. */
  2056. multiplyByFloats(x: number, y: number): Vector2;
  2057. /**
  2058. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @returns a new Vector2
  2061. */
  2062. divide(otherVector: Vector2): Vector2;
  2063. /**
  2064. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2065. * @param otherVector defines the other vector
  2066. * @param result defines the target vector
  2067. * @returns the unmodified current Vector2
  2068. */
  2069. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2070. /**
  2071. * Divides the current Vector2 coordinates by the given ones
  2072. * @param otherVector defines the other vector
  2073. * @returns the current updated Vector2
  2074. */
  2075. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2076. /**
  2077. * Gets a new Vector2 with current Vector2 negated coordinates
  2078. * @returns a new Vector2
  2079. */
  2080. negate(): Vector2;
  2081. /**
  2082. * Multiply the Vector2 coordinates by scale
  2083. * @param scale defines the scaling factor
  2084. * @returns the current updated Vector2
  2085. */
  2086. scaleInPlace(scale: number): Vector2;
  2087. /**
  2088. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2089. * @param scale defines the scaling factor
  2090. * @returns a new Vector2
  2091. */
  2092. scale(scale: number): Vector2;
  2093. /**
  2094. * Scale the current Vector2 values by a factor to a given Vector2
  2095. * @param scale defines the scale factor
  2096. * @param result defines the Vector2 object where to store the result
  2097. * @returns the unmodified current Vector2
  2098. */
  2099. scaleToRef(scale: number, result: Vector2): Vector2;
  2100. /**
  2101. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2102. * @param scale defines the scale factor
  2103. * @param result defines the Vector2 object where to store the result
  2104. * @returns the unmodified current Vector2
  2105. */
  2106. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2107. /**
  2108. * Gets a boolean if two vectors are equals
  2109. * @param otherVector defines the other vector
  2110. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2111. */
  2112. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2113. /**
  2114. * Gets a boolean if two vectors are equals (using an epsilon value)
  2115. * @param otherVector defines the other vector
  2116. * @param epsilon defines the minimal distance to consider equality
  2117. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2118. */
  2119. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2120. /**
  2121. * Gets a new Vector2 from current Vector2 floored values
  2122. * @returns a new Vector2
  2123. */
  2124. floor(): Vector2;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. fract(): Vector2;
  2130. /**
  2131. * Gets the length of the vector
  2132. * @returns the vector length (float)
  2133. */
  2134. length(): number;
  2135. /**
  2136. * Gets the vector squared length
  2137. * @returns the vector squared length (float)
  2138. */
  2139. lengthSquared(): number;
  2140. /**
  2141. * Normalize the vector
  2142. * @returns the current updated Vector2
  2143. */
  2144. normalize(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 copied from the Vector2
  2147. * @returns a new Vector2
  2148. */
  2149. clone(): Vector2;
  2150. /**
  2151. * Gets a new Vector2(0, 0)
  2152. * @returns a new Vector2
  2153. */
  2154. static Zero(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(1, 1)
  2157. * @returns a new Vector2
  2158. */
  2159. static One(): Vector2;
  2160. /**
  2161. * Gets a new Vector2 set from the given index element of the given array
  2162. * @param array defines the data source
  2163. * @param offset defines the offset in the data source
  2164. * @returns a new Vector2
  2165. */
  2166. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2167. /**
  2168. * Sets "result" from the given index element of the given array
  2169. * @param array defines the data source
  2170. * @param offset defines the offset in the data source
  2171. * @param result defines the target vector
  2172. */
  2173. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2174. /**
  2175. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2176. * @param value1 defines 1st point of control
  2177. * @param value2 defines 2nd point of control
  2178. * @param value3 defines 3rd point of control
  2179. * @param value4 defines 4th point of control
  2180. * @param amount defines the interpolation factor
  2181. * @returns a new Vector2
  2182. */
  2183. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2184. /**
  2185. * 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".
  2186. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2187. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2188. * @param value defines the value to clamp
  2189. * @param min defines the lower limit
  2190. * @param max defines the upper limit
  2191. * @returns a new Vector2
  2192. */
  2193. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2194. /**
  2195. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2196. * @param value1 defines the 1st control point
  2197. * @param tangent1 defines the outgoing tangent
  2198. * @param value2 defines the 2nd control point
  2199. * @param tangent2 defines the incoming tangent
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2206. * @param start defines the start vector
  2207. * @param end defines the end vector
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * Gets the dot product of the vector "left" and the vector "right"
  2214. * @param left defines first vector
  2215. * @param right defines second vector
  2216. * @returns the dot product (float)
  2217. */
  2218. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2219. /**
  2220. * Returns a new Vector2 equal to the normalized given vector
  2221. * @param vector defines the vector to normalize
  2222. * @returns a new Vector2
  2223. */
  2224. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2225. /**
  2226. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2227. * @param left defines 1st vector
  2228. * @param right defines 2nd vector
  2229. * @returns a new Vector2
  2230. */
  2231. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2234. * @param left defines 1st vector
  2235. * @param right defines 2nd vector
  2236. * @returns a new Vector2
  2237. */
  2238. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2239. /**
  2240. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2241. * @param vector defines the vector to transform
  2242. * @param transformation defines the matrix to apply
  2243. * @returns a new Vector2
  2244. */
  2245. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2246. /**
  2247. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2248. * @param vector defines the vector to transform
  2249. * @param transformation defines the matrix to apply
  2250. * @param result defines the target vector
  2251. */
  2252. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2253. /**
  2254. * Determines if a given vector is included in a triangle
  2255. * @param p defines the vector to test
  2256. * @param p0 defines 1st triangle point
  2257. * @param p1 defines 2nd triangle point
  2258. * @param p2 defines 3rd triangle point
  2259. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2260. */
  2261. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2262. /**
  2263. * Gets the distance between the vectors "value1" and "value2"
  2264. * @param value1 defines first vector
  2265. * @param value2 defines second vector
  2266. * @returns the distance between vectors
  2267. */
  2268. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2269. /**
  2270. * Returns the squared distance between the vectors "value1" and "value2"
  2271. * @param value1 defines first vector
  2272. * @param value2 defines second vector
  2273. * @returns the squared distance between vectors
  2274. */
  2275. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2276. /**
  2277. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2278. * @param value1 defines first vector
  2279. * @param value2 defines second vector
  2280. * @returns a new Vector2
  2281. */
  2282. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2283. /**
  2284. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2285. * @param p defines the middle point
  2286. * @param segA defines one point of the segment
  2287. * @param segB defines the other point of the segment
  2288. * @returns the shortest distance
  2289. */
  2290. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2291. }
  2292. /**
  2293. * Classed used to store (x,y,z) vector representation
  2294. * A Vector3 is the main object used in 3D geometry
  2295. * It can represent etiher the coordinates of a point the space, either a direction
  2296. * Reminder: js uses a left handed forward facing system
  2297. */
  2298. export class Vector3 {
  2299. /**
  2300. * Defines the first coordinates (on X axis)
  2301. */
  2302. x: number;
  2303. /**
  2304. * Defines the second coordinates (on Y axis)
  2305. */
  2306. y: number;
  2307. /**
  2308. * Defines the third coordinates (on Z axis)
  2309. */
  2310. z: number;
  2311. private static _UpReadOnly;
  2312. private static _ZeroReadOnly;
  2313. /**
  2314. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2315. * @param x defines the first coordinates (on X axis)
  2316. * @param y defines the second coordinates (on Y axis)
  2317. * @param z defines the third coordinates (on Z axis)
  2318. */
  2319. constructor(
  2320. /**
  2321. * Defines the first coordinates (on X axis)
  2322. */
  2323. x?: number,
  2324. /**
  2325. * Defines the second coordinates (on Y axis)
  2326. */
  2327. y?: number,
  2328. /**
  2329. * Defines the third coordinates (on Z axis)
  2330. */
  2331. z?: number);
  2332. /**
  2333. * Creates a string representation of the Vector3
  2334. * @returns a string with the Vector3 coordinates.
  2335. */
  2336. toString(): string;
  2337. /**
  2338. * Gets the class name
  2339. * @returns the string "Vector3"
  2340. */
  2341. getClassName(): string;
  2342. /**
  2343. * Creates the Vector3 hash code
  2344. * @returns a number which tends to be unique between Vector3 instances
  2345. */
  2346. getHashCode(): number;
  2347. /**
  2348. * Creates an array containing three elements : the coordinates of the Vector3
  2349. * @returns a new array of numbers
  2350. */
  2351. asArray(): number[];
  2352. /**
  2353. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2354. * @param array defines the destination array
  2355. * @param index defines the offset in the destination array
  2356. * @returns the current Vector3
  2357. */
  2358. toArray(array: FloatArray, index?: number): Vector3;
  2359. /**
  2360. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2361. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2362. */
  2363. toQuaternion(): Quaternion;
  2364. /**
  2365. * Adds the given vector to the current Vector3
  2366. * @param otherVector defines the second operand
  2367. * @returns the current updated Vector3
  2368. */
  2369. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2370. /**
  2371. * Adds the given coordinates to the current Vector3
  2372. * @param x defines the x coordinate of the operand
  2373. * @param y defines the y coordinate of the operand
  2374. * @param z defines the z coordinate of the operand
  2375. * @returns the current updated Vector3
  2376. */
  2377. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2378. /**
  2379. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2380. * @param otherVector defines the second operand
  2381. * @returns the resulting Vector3
  2382. */
  2383. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2386. * @param otherVector defines the second operand
  2387. * @param result defines the Vector3 object where to store the result
  2388. * @returns the current Vector3
  2389. */
  2390. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2391. /**
  2392. * Subtract the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the current updated Vector3
  2395. */
  2396. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2399. * @param otherVector defines the second operand
  2400. * @returns the resulting Vector3
  2401. */
  2402. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2403. /**
  2404. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2405. * @param otherVector defines the second operand
  2406. * @param result defines the Vector3 object where to store the result
  2407. * @returns the current Vector3
  2408. */
  2409. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2410. /**
  2411. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2412. * @param x defines the x coordinate of the operand
  2413. * @param y defines the y coordinate of the operand
  2414. * @param z defines the z coordinate of the operand
  2415. * @returns the resulting Vector3
  2416. */
  2417. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2418. /**
  2419. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2420. * @param x defines the x coordinate of the operand
  2421. * @param y defines the y coordinate of the operand
  2422. * @param z defines the z coordinate of the operand
  2423. * @param result defines the Vector3 object where to store the result
  2424. * @returns the current Vector3
  2425. */
  2426. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2427. /**
  2428. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2429. * @returns a new Vector3
  2430. */
  2431. negate(): Vector3;
  2432. /**
  2433. * Multiplies the Vector3 coordinates by the float "scale"
  2434. * @param scale defines the multiplier factor
  2435. * @returns the current updated Vector3
  2436. */
  2437. scaleInPlace(scale: number): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2440. * @param scale defines the multiplier factor
  2441. * @returns a new Vector3
  2442. */
  2443. scale(scale: number): Vector3;
  2444. /**
  2445. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2446. * @param scale defines the multiplier factor
  2447. * @param result defines the Vector3 object where to store the result
  2448. * @returns the current Vector3
  2449. */
  2450. scaleToRef(scale: number, result: Vector3): Vector3;
  2451. /**
  2452. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2453. * @param scale defines the scale factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the unmodified current Vector3
  2456. */
  2457. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2460. * @param otherVector defines the second operand
  2461. * @returns true if both vectors are equals
  2462. */
  2463. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2464. /**
  2465. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2466. * @param otherVector defines the second operand
  2467. * @param epsilon defines the minimal distance to define values as equals
  2468. * @returns true if both vectors are distant less than epsilon
  2469. */
  2470. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 coordinates equals the given floats
  2473. * @param x defines the x coordinate of the operand
  2474. * @param y defines the y coordinate of the operand
  2475. * @param z defines the z coordinate of the operand
  2476. * @returns true if both vectors are equals
  2477. */
  2478. equalsToFloats(x: number, y: number, z: number): boolean;
  2479. /**
  2480. * Multiplies the current Vector3 coordinates by the given ones
  2481. * @param otherVector defines the second operand
  2482. * @returns the current updated Vector3
  2483. */
  2484. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2485. /**
  2486. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2487. * @param otherVector defines the second operand
  2488. * @returns the new Vector3
  2489. */
  2490. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2491. /**
  2492. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2493. * @param otherVector defines the second operand
  2494. * @param result defines the Vector3 object where to store the result
  2495. * @returns the current Vector3
  2496. */
  2497. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2498. /**
  2499. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2500. * @param x defines the x coordinate of the operand
  2501. * @param y defines the y coordinate of the operand
  2502. * @param z defines the z coordinate of the operand
  2503. * @returns the new Vector3
  2504. */
  2505. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2506. /**
  2507. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2508. * @param otherVector defines the second operand
  2509. * @returns the new Vector3
  2510. */
  2511. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2514. * @param otherVector defines the second operand
  2515. * @param result defines the Vector3 object where to store the result
  2516. * @returns the current Vector3
  2517. */
  2518. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones.
  2521. * @param otherVector defines the second operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. divideInPlace(otherVector: Vector3): Vector3;
  2525. /**
  2526. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2527. * @param other defines the second operand
  2528. * @returns the current updated Vector3
  2529. */
  2530. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2531. /**
  2532. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2533. * @param other defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2537. /**
  2538. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2539. * @param x defines the x coordinate of the operand
  2540. * @param y defines the y coordinate of the operand
  2541. * @param z defines the z coordinate of the operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2547. * @param x defines the x coordinate of the operand
  2548. * @param y defines the y coordinate of the operand
  2549. * @param z defines the z coordinate of the operand
  2550. * @returns the current updated Vector3
  2551. */
  2552. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2553. /**
  2554. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2555. * Check if is non uniform within a certain amount of decimal places to account for this
  2556. * @param epsilon the amount the values can differ
  2557. * @returns if the the vector is non uniform to a certain number of decimal places
  2558. */
  2559. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2560. /**
  2561. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2562. */
  2563. readonly isNonUniform: boolean;
  2564. /**
  2565. * Gets a new Vector3 from current Vector3 floored values
  2566. * @returns a new Vector3
  2567. */
  2568. floor(): Vector3;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. fract(): Vector3;
  2574. /**
  2575. * Gets the length of the Vector3
  2576. * @returns the length of the Vector3
  2577. */
  2578. length(): number;
  2579. /**
  2580. * Gets the squared length of the Vector3
  2581. * @returns squared length of the Vector3
  2582. */
  2583. lengthSquared(): number;
  2584. /**
  2585. * Normalize the current Vector3.
  2586. * Please note that this is an in place operation.
  2587. * @returns the current updated Vector3
  2588. */
  2589. normalize(): Vector3;
  2590. /**
  2591. * Reorders the x y z properties of the vector in place
  2592. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2593. * @returns the current updated vector
  2594. */
  2595. reorderInPlace(order: string): this;
  2596. /**
  2597. * Rotates the vector around 0,0,0 by a quaternion
  2598. * @param quaternion the rotation quaternion
  2599. * @param result vector to store the result
  2600. * @returns the resulting vector
  2601. */
  2602. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2603. /**
  2604. * Rotates a vector around a given point
  2605. * @param quaternion the rotation quaternion
  2606. * @param point the point to rotate around
  2607. * @param result vector to store the result
  2608. * @returns the resulting vector
  2609. */
  2610. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2611. /**
  2612. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2613. * The cross product is then orthogonal to both current and "other"
  2614. * @param other defines the right operand
  2615. * @returns the cross product
  2616. */
  2617. cross(other: Vector3): Vector3;
  2618. /**
  2619. * Normalize the current Vector3 with the given input length.
  2620. * Please note that this is an in place operation.
  2621. * @param len the length of the vector
  2622. * @returns the current updated Vector3
  2623. */
  2624. normalizeFromLength(len: number): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 to a new vector
  2627. * @returns the new Vector3
  2628. */
  2629. normalizeToNew(): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to the reference
  2632. * @param reference define the Vector3 to update
  2633. * @returns the updated Vector3
  2634. */
  2635. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2636. /**
  2637. * Creates a new Vector3 copied from the current Vector3
  2638. * @returns the new Vector3
  2639. */
  2640. clone(): Vector3;
  2641. /**
  2642. * Copies the given vector coordinates to the current Vector3 ones
  2643. * @param source defines the source Vector3
  2644. * @returns the current updated Vector3
  2645. */
  2646. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2647. /**
  2648. * Copies the given floats to the current Vector3 coordinates
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns the current updated Vector3
  2653. */
  2654. copyFromFloats(x: number, y: number, z: number): Vector3;
  2655. /**
  2656. * Copies the given floats to the current Vector3 coordinates
  2657. * @param x defines the x coordinate of the operand
  2658. * @param y defines the y coordinate of the operand
  2659. * @param z defines the z coordinate of the operand
  2660. * @returns the current updated Vector3
  2661. */
  2662. set(x: number, y: number, z: number): Vector3;
  2663. /**
  2664. * Copies the given float to the current Vector3 coordinates
  2665. * @param v defines the x, y and z coordinates of the operand
  2666. * @returns the current updated Vector3
  2667. */
  2668. setAll(v: number): Vector3;
  2669. /**
  2670. * Get the clip factor between two vectors
  2671. * @param vector0 defines the first operand
  2672. * @param vector1 defines the second operand
  2673. * @param axis defines the axis to use
  2674. * @param size defines the size along the axis
  2675. * @returns the clip factor
  2676. */
  2677. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2678. /**
  2679. * Get angle between two vectors
  2680. * @param vector0 angle between vector0 and vector1
  2681. * @param vector1 angle between vector0 and vector1
  2682. * @param normal direction of the normal
  2683. * @return the angle between vector0 and vector1
  2684. */
  2685. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2686. /**
  2687. * Returns a new Vector3 set from the index "offset" of the given array
  2688. * @param array defines the source array
  2689. * @param offset defines the offset in the source array
  2690. * @returns the new Vector3
  2691. */
  2692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2695. * This function is deprecated. Use FromArray instead
  2696. * @param array defines the source array
  2697. * @param offset defines the offset in the source array
  2698. * @returns the new Vector3
  2699. */
  2700. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2701. /**
  2702. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2703. * @param array defines the source array
  2704. * @param offset defines the offset in the source array
  2705. * @param result defines the Vector3 where to store the result
  2706. */
  2707. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2710. * This function is deprecated. Use FromArrayToRef instead.
  2711. * @param array defines the source array
  2712. * @param offset defines the offset in the source array
  2713. * @param result defines the Vector3 where to store the result
  2714. */
  2715. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2716. /**
  2717. * Sets the given vector "result" with the given floats.
  2718. * @param x defines the x coordinate of the source
  2719. * @param y defines the y coordinate of the source
  2720. * @param z defines the z coordinate of the source
  2721. * @param result defines the Vector3 where to store the result
  2722. */
  2723. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2724. /**
  2725. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2726. * @returns a new empty Vector3
  2727. */
  2728. static Zero(): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2731. * @returns a new unit Vector3
  2732. */
  2733. static One(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2736. * @returns a new up Vector3
  2737. */
  2738. static Up(): Vector3;
  2739. /**
  2740. * Gets a up Vector3 that must not be updated
  2741. */
  2742. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2743. /**
  2744. * Gets a zero Vector3 that must not be updated
  2745. */
  2746. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2747. /**
  2748. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2749. * @returns a new down Vector3
  2750. */
  2751. static Down(): Vector3;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2754. * @returns a new forward Vector3
  2755. */
  2756. static Forward(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Backward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2764. * @returns a new right Vector3
  2765. */
  2766. static Right(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2769. * @returns a new left Vector3
  2770. */
  2771. static Left(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2774. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2775. * @param vector defines the Vector3 to transform
  2776. * @param transformation defines the transformation matrix
  2777. * @returns the transformed Vector3
  2778. */
  2779. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2780. /**
  2781. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2782. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2783. * @param vector defines the Vector3 to transform
  2784. * @param transformation defines the transformation matrix
  2785. * @param result defines the Vector3 where to store the result
  2786. */
  2787. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2788. /**
  2789. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2790. * This method computes tranformed coordinates only, not transformed direction vectors
  2791. * @param x define the x coordinate of the source vector
  2792. * @param y define the y coordinate of the source vector
  2793. * @param z define the z coordinate of the source vector
  2794. * @param transformation defines the transformation matrix
  2795. * @param result defines the Vector3 where to store the result
  2796. */
  2797. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2798. /**
  2799. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2800. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2801. * @param vector defines the Vector3 to transform
  2802. * @param transformation defines the transformation matrix
  2803. * @returns the new Vector3
  2804. */
  2805. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2806. /**
  2807. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2808. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2809. * @param vector defines the Vector3 to transform
  2810. * @param transformation defines the transformation matrix
  2811. * @param result defines the Vector3 where to store the result
  2812. */
  2813. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2814. /**
  2815. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2816. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2817. * @param x define the x coordinate of the source vector
  2818. * @param y define the y coordinate of the source vector
  2819. * @param z define the z coordinate of the source vector
  2820. * @param transformation defines the transformation matrix
  2821. * @param result defines the Vector3 where to store the result
  2822. */
  2823. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2824. /**
  2825. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2826. * @param value1 defines the first control point
  2827. * @param value2 defines the second control point
  2828. * @param value3 defines the third control point
  2829. * @param value4 defines the fourth control point
  2830. * @param amount defines the amount on the spline to use
  2831. * @returns the new Vector3
  2832. */
  2833. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2834. /**
  2835. * 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"
  2836. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2837. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2838. * @param value defines the current value
  2839. * @param min defines the lower range value
  2840. * @param max defines the upper range value
  2841. * @returns the new Vector3
  2842. */
  2843. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2844. /**
  2845. * 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"
  2846. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2847. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2848. * @param value defines the current value
  2849. * @param min defines the lower range value
  2850. * @param max defines the upper range value
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2854. /**
  2855. * Checks if a given vector is inside a specific range
  2856. * @param v defines the vector to test
  2857. * @param min defines the minimum range
  2858. * @param max defines the maximum range
  2859. */
  2860. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2863. * @param value1 defines the first control point
  2864. * @param tangent1 defines the first tangent vector
  2865. * @param value2 defines the second control point
  2866. * @param tangent2 defines the second tangent vector
  2867. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2868. * @returns the new Vector3
  2869. */
  2870. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2871. /**
  2872. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2873. * @param start defines the start value
  2874. * @param end defines the end value
  2875. * @param amount max defines amount between both (between 0 and 1)
  2876. * @returns the new Vector3
  2877. */
  2878. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2879. /**
  2880. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2881. * @param start defines the start value
  2882. * @param end defines the end value
  2883. * @param amount max defines amount between both (between 0 and 1)
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2887. /**
  2888. * Returns the dot product (float) between the vectors "left" and "right"
  2889. * @param left defines the left operand
  2890. * @param right defines the right operand
  2891. * @returns the dot product
  2892. */
  2893. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2894. /**
  2895. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2896. * The cross product is then orthogonal to both "left" and "right"
  2897. * @param left defines the left operand
  2898. * @param right defines the right operand
  2899. * @returns the cross product
  2900. */
  2901. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2902. /**
  2903. * Sets the given vector "result" with the cross product of "left" and "right"
  2904. * The cross product is then orthogonal to both "left" and "right"
  2905. * @param left defines the left operand
  2906. * @param right defines the right operand
  2907. * @param result defines the Vector3 where to store the result
  2908. */
  2909. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2910. /**
  2911. * Returns a new Vector3 as the normalization of the given vector
  2912. * @param vector defines the Vector3 to normalize
  2913. * @returns the new Vector3
  2914. */
  2915. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2916. /**
  2917. * Sets the given vector "result" with the normalization of the given first vector
  2918. * @param vector defines the Vector3 to normalize
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2922. /**
  2923. * Project a Vector3 onto screen space
  2924. * @param vector defines the Vector3 to project
  2925. * @param world defines the world matrix to use
  2926. * @param transform defines the transform (view x projection) matrix to use
  2927. * @param viewport defines the screen viewport to use
  2928. * @returns the new Vector3
  2929. */
  2930. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2931. /** @hidden */
  2932. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2933. /**
  2934. * Unproject from screen space to object space
  2935. * @param source defines the screen space Vector3 to use
  2936. * @param viewportWidth defines the current width of the viewport
  2937. * @param viewportHeight defines the current height of the viewport
  2938. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2939. * @param transform defines the transform (view x projection) matrix to use
  2940. * @returns the new Vector3
  2941. */
  2942. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2943. /**
  2944. * Unproject from screen space to object space
  2945. * @param source defines the screen space Vector3 to use
  2946. * @param viewportWidth defines the current width of the viewport
  2947. * @param viewportHeight defines the current height of the viewport
  2948. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2949. * @param view defines the view matrix to use
  2950. * @param projection defines the projection matrix to use
  2951. * @returns the new Vector3
  2952. */
  2953. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2954. /**
  2955. * Unproject from screen space to object space
  2956. * @param source defines the screen space Vector3 to use
  2957. * @param viewportWidth defines the current width of the viewport
  2958. * @param viewportHeight defines the current height of the viewport
  2959. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2960. * @param view defines the view matrix to use
  2961. * @param projection defines the projection matrix to use
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Unproject from screen space to object space
  2967. * @param sourceX defines the screen space x coordinate to use
  2968. * @param sourceY defines the screen space y coordinate to use
  2969. * @param sourceZ defines the screen space z coordinate to use
  2970. * @param viewportWidth defines the current width of the viewport
  2971. * @param viewportHeight defines the current height of the viewport
  2972. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2973. * @param view defines the view matrix to use
  2974. * @param projection defines the projection matrix to use
  2975. * @param result defines the Vector3 where to store the result
  2976. */
  2977. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2978. /**
  2979. * Gets the minimal coordinate values between two Vector3
  2980. * @param left defines the first operand
  2981. * @param right defines the second operand
  2982. * @returns the new Vector3
  2983. */
  2984. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2985. /**
  2986. * Gets the maximal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Returns the distance between the vectors "value1" and "value2"
  2994. * @param value1 defines the first operand
  2995. * @param value2 defines the second operand
  2996. * @returns the distance
  2997. */
  2998. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2999. /**
  3000. * Returns the squared distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the squared distance
  3004. */
  3005. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns a new Vector3 located at the center between "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the new Vector3
  3011. */
  3012. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3013. /**
  3014. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3015. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3016. * to something in order to rotate it from its local system to the given target system
  3017. * Note: axis1, axis2 and axis3 are normalized during this operation
  3018. * @param axis1 defines the first axis
  3019. * @param axis2 defines the second axis
  3020. * @param axis3 defines the third axis
  3021. * @returns a new Vector3
  3022. */
  3023. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3024. /**
  3025. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3026. * @param axis1 defines the first axis
  3027. * @param axis2 defines the second axis
  3028. * @param axis3 defines the third axis
  3029. * @param ref defines the Vector3 where to store the result
  3030. */
  3031. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3032. }
  3033. /**
  3034. * Vector4 class created for EulerAngle class conversion to Quaternion
  3035. */
  3036. export class Vector4 {
  3037. /** x value of the vector */
  3038. x: number;
  3039. /** y value of the vector */
  3040. y: number;
  3041. /** z value of the vector */
  3042. z: number;
  3043. /** w value of the vector */
  3044. w: number;
  3045. /**
  3046. * Creates a Vector4 object from the given floats.
  3047. * @param x x value of the vector
  3048. * @param y y value of the vector
  3049. * @param z z value of the vector
  3050. * @param w w value of the vector
  3051. */
  3052. constructor(
  3053. /** x value of the vector */
  3054. x: number,
  3055. /** y value of the vector */
  3056. y: number,
  3057. /** z value of the vector */
  3058. z: number,
  3059. /** w value of the vector */
  3060. w: number);
  3061. /**
  3062. * Returns the string with the Vector4 coordinates.
  3063. * @returns a string containing all the vector values
  3064. */
  3065. toString(): string;
  3066. /**
  3067. * Returns the string "Vector4".
  3068. * @returns "Vector4"
  3069. */
  3070. getClassName(): string;
  3071. /**
  3072. * Returns the Vector4 hash code.
  3073. * @returns a unique hash code
  3074. */
  3075. getHashCode(): number;
  3076. /**
  3077. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3078. * @returns the resulting array
  3079. */
  3080. asArray(): number[];
  3081. /**
  3082. * Populates the given array from the given index with the Vector4 coordinates.
  3083. * @param array array to populate
  3084. * @param index index of the array to start at (default: 0)
  3085. * @returns the Vector4.
  3086. */
  3087. toArray(array: FloatArray, index?: number): Vector4;
  3088. /**
  3089. * Adds the given vector to the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the updated Vector4.
  3092. */
  3093. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3096. * @param otherVector the vector to add
  3097. * @returns the resulting vector
  3098. */
  3099. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3100. /**
  3101. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3102. * @param otherVector the vector to add
  3103. * @param result the vector to store the result
  3104. * @returns the current Vector4.
  3105. */
  3106. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3107. /**
  3108. * Subtract in place the given vector from the current Vector4.
  3109. * @param otherVector the vector to subtract
  3110. * @returns the updated Vector4.
  3111. */
  3112. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3113. /**
  3114. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3115. * @param otherVector the vector to add
  3116. * @returns the new vector with the result
  3117. */
  3118. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3119. /**
  3120. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3121. * @param otherVector the vector to subtract
  3122. * @param result the vector to store the result
  3123. * @returns the current Vector4.
  3124. */
  3125. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3126. /**
  3127. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3128. */
  3129. /**
  3130. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3131. * @param x value to subtract
  3132. * @param y value to subtract
  3133. * @param z value to subtract
  3134. * @param w value to subtract
  3135. * @returns new vector containing the result
  3136. */
  3137. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3138. /**
  3139. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3140. * @param x value to subtract
  3141. * @param y value to subtract
  3142. * @param z value to subtract
  3143. * @param w value to subtract
  3144. * @param result the vector to store the result in
  3145. * @returns the current Vector4.
  3146. */
  3147. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3148. /**
  3149. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3150. * @returns a new vector with the negated values
  3151. */
  3152. negate(): Vector4;
  3153. /**
  3154. * Multiplies the current Vector4 coordinates by scale (float).
  3155. * @param scale the number to scale with
  3156. * @returns the updated Vector4.
  3157. */
  3158. scaleInPlace(scale: number): Vector4;
  3159. /**
  3160. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3161. * @param scale the number to scale with
  3162. * @returns a new vector with the result
  3163. */
  3164. scale(scale: number): Vector4;
  3165. /**
  3166. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3167. * @param scale the number to scale with
  3168. * @param result a vector to store the result in
  3169. * @returns the current Vector4.
  3170. */
  3171. scaleToRef(scale: number, result: Vector4): Vector4;
  3172. /**
  3173. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3174. * @param scale defines the scale factor
  3175. * @param result defines the Vector4 object where to store the result
  3176. * @returns the unmodified current Vector4
  3177. */
  3178. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3179. /**
  3180. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3181. * @param otherVector the vector to compare against
  3182. * @returns true if they are equal
  3183. */
  3184. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3185. /**
  3186. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3187. * @param otherVector vector to compare against
  3188. * @param epsilon (Default: very small number)
  3189. * @returns true if they are equal
  3190. */
  3191. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3192. /**
  3193. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3194. * @param x x value to compare against
  3195. * @param y y value to compare against
  3196. * @param z z value to compare against
  3197. * @param w w value to compare against
  3198. * @returns true if equal
  3199. */
  3200. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3201. /**
  3202. * Multiplies in place the current Vector4 by the given one.
  3203. * @param otherVector vector to multiple with
  3204. * @returns the updated Vector4.
  3205. */
  3206. multiplyInPlace(otherVector: Vector4): Vector4;
  3207. /**
  3208. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3209. * @param otherVector vector to multiple with
  3210. * @returns resulting new vector
  3211. */
  3212. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3213. /**
  3214. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3215. * @param otherVector vector to multiple with
  3216. * @param result vector to store the result
  3217. * @returns the current Vector4.
  3218. */
  3219. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3220. /**
  3221. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3222. * @param x x value multiply with
  3223. * @param y y value multiply with
  3224. * @param z z value multiply with
  3225. * @param w w value multiply with
  3226. * @returns resulting new vector
  3227. */
  3228. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3231. * @param otherVector vector to devide with
  3232. * @returns resulting new vector
  3233. */
  3234. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3237. * @param otherVector vector to devide with
  3238. * @param result vector to store the result
  3239. * @returns the current Vector4.
  3240. */
  3241. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3242. /**
  3243. * Divides the current Vector3 coordinates by the given ones.
  3244. * @param otherVector vector to devide with
  3245. * @returns the updated Vector3.
  3246. */
  3247. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3250. * @param other defines the second operand
  3251. * @returns the current updated Vector4
  3252. */
  3253. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3254. /**
  3255. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3256. * @param other defines the second operand
  3257. * @returns the current updated Vector4
  3258. */
  3259. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3260. /**
  3261. * Gets a new Vector4 from current Vector4 floored values
  3262. * @returns a new Vector4
  3263. */
  3264. floor(): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector3 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. fract(): Vector4;
  3270. /**
  3271. * Returns the Vector4 length (float).
  3272. * @returns the length
  3273. */
  3274. length(): number;
  3275. /**
  3276. * Returns the Vector4 squared length (float).
  3277. * @returns the length squared
  3278. */
  3279. lengthSquared(): number;
  3280. /**
  3281. * Normalizes in place the Vector4.
  3282. * @returns the updated Vector4.
  3283. */
  3284. normalize(): Vector4;
  3285. /**
  3286. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3287. * @returns this converted to a new vector3
  3288. */
  3289. toVector3(): Vector3;
  3290. /**
  3291. * Returns a new Vector4 copied from the current one.
  3292. * @returns the new cloned vector
  3293. */
  3294. clone(): Vector4;
  3295. /**
  3296. * Updates the current Vector4 with the given one coordinates.
  3297. * @param source the source vector to copy from
  3298. * @returns the updated Vector4.
  3299. */
  3300. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3301. /**
  3302. * Updates the current Vector4 coordinates with the given floats.
  3303. * @param x float to copy from
  3304. * @param y float to copy from
  3305. * @param z float to copy from
  3306. * @param w float to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to set from
  3313. * @param y float to set from
  3314. * @param z float to set from
  3315. * @param w float to set from
  3316. * @returns the updated Vector4.
  3317. */
  3318. set(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Copies the given float to the current Vector3 coordinates
  3321. * @param v defines the x, y, z and w coordinates of the operand
  3322. * @returns the current updated Vector3
  3323. */
  3324. setAll(v: number): Vector4;
  3325. /**
  3326. * Returns a new Vector4 set from the starting index of the given array.
  3327. * @param array the array to pull values from
  3328. * @param offset the offset into the array to start at
  3329. * @returns the new vector
  3330. */
  3331. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3332. /**
  3333. * Updates the given vector "result" from the starting index of the given array.
  3334. * @param array the array to pull values from
  3335. * @param offset the offset into the array to start at
  3336. * @param result the vector to store the result in
  3337. */
  3338. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3339. /**
  3340. * Updates the given vector "result" from the starting index of the given Float32Array.
  3341. * @param array the array to pull values from
  3342. * @param offset the offset into the array to start at
  3343. * @param result the vector to store the result in
  3344. */
  3345. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3346. /**
  3347. * Updates the given vector "result" coordinates from the given floats.
  3348. * @param x float to set from
  3349. * @param y float to set from
  3350. * @param z float to set from
  3351. * @param w float to set from
  3352. * @param result the vector to the floats in
  3353. */
  3354. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3355. /**
  3356. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3357. * @returns the new vector
  3358. */
  3359. static Zero(): Vector4;
  3360. /**
  3361. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3362. * @returns the new vector
  3363. */
  3364. static One(): Vector4;
  3365. /**
  3366. * Returns a new normalized Vector4 from the given one.
  3367. * @param vector the vector to normalize
  3368. * @returns the vector
  3369. */
  3370. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3371. /**
  3372. * Updates the given vector "result" from the normalization of the given one.
  3373. * @param vector the vector to normalize
  3374. * @param result the vector to store the result in
  3375. */
  3376. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3377. /**
  3378. * Returns a vector with the minimum values from the left and right vectors
  3379. * @param left left vector to minimize
  3380. * @param right right vector to minimize
  3381. * @returns a new vector with the minimum of the left and right vector values
  3382. */
  3383. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3384. /**
  3385. * Returns a vector with the maximum values from the left and right vectors
  3386. * @param left left vector to maximize
  3387. * @param right right vector to maximize
  3388. * @returns a new vector with the maximum of the left and right vector values
  3389. */
  3390. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Returns the distance (float) between the vectors "value1" and "value2".
  3393. * @param value1 value to calulate the distance between
  3394. * @param value2 value to calulate the distance between
  3395. * @return the distance between the two vectors
  3396. */
  3397. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3398. /**
  3399. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3400. * @param value1 value to calulate the distance between
  3401. * @param value2 value to calulate the distance between
  3402. * @return the distance between the two vectors squared
  3403. */
  3404. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3405. /**
  3406. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3407. * @param value1 value to calulate the center between
  3408. * @param value2 value to calulate the center between
  3409. * @return the center between the two vectors
  3410. */
  3411. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3412. /**
  3413. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3414. * This methods computes transformed normalized direction vectors only.
  3415. * @param vector the vector to transform
  3416. * @param transformation the transformation matrix to apply
  3417. * @returns the new vector
  3418. */
  3419. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3420. /**
  3421. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3422. * This methods computes transformed normalized direction vectors only.
  3423. * @param vector the vector to transform
  3424. * @param transformation the transformation matrix to apply
  3425. * @param result the vector to store the result in
  3426. */
  3427. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3428. /**
  3429. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3430. * This methods computes transformed normalized direction vectors only.
  3431. * @param x value to transform
  3432. * @param y value to transform
  3433. * @param z value to transform
  3434. * @param w value to transform
  3435. * @param transformation the transformation matrix to apply
  3436. * @param result the vector to store the results in
  3437. */
  3438. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3439. /**
  3440. * Creates a new Vector4 from a Vector3
  3441. * @param source defines the source data
  3442. * @param w defines the 4th component (default is 0)
  3443. * @returns a new Vector4
  3444. */
  3445. static FromVector3(source: Vector3, w?: number): Vector4;
  3446. }
  3447. /**
  3448. * Class used to store quaternion data
  3449. * @see https://en.wikipedia.org/wiki/Quaternion
  3450. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3451. */
  3452. export class Quaternion {
  3453. /** defines the first component (0 by default) */
  3454. x: number;
  3455. /** defines the second component (0 by default) */
  3456. y: number;
  3457. /** defines the third component (0 by default) */
  3458. z: number;
  3459. /** defines the fourth component (1.0 by default) */
  3460. w: number;
  3461. /**
  3462. * Creates a new Quaternion from the given floats
  3463. * @param x defines the first component (0 by default)
  3464. * @param y defines the second component (0 by default)
  3465. * @param z defines the third component (0 by default)
  3466. * @param w defines the fourth component (1.0 by default)
  3467. */
  3468. constructor(
  3469. /** defines the first component (0 by default) */
  3470. x?: number,
  3471. /** defines the second component (0 by default) */
  3472. y?: number,
  3473. /** defines the third component (0 by default) */
  3474. z?: number,
  3475. /** defines the fourth component (1.0 by default) */
  3476. w?: number);
  3477. /**
  3478. * Gets a string representation for the current quaternion
  3479. * @returns a string with the Quaternion coordinates
  3480. */
  3481. toString(): string;
  3482. /**
  3483. * Gets the class name of the quaternion
  3484. * @returns the string "Quaternion"
  3485. */
  3486. getClassName(): string;
  3487. /**
  3488. * Gets a hash code for this quaternion
  3489. * @returns the quaternion hash code
  3490. */
  3491. getHashCode(): number;
  3492. /**
  3493. * Copy the quaternion to an array
  3494. * @returns a new array populated with 4 elements from the quaternion coordinates
  3495. */
  3496. asArray(): number[];
  3497. /**
  3498. * Check if two quaternions are equals
  3499. * @param otherQuaternion defines the second operand
  3500. * @return true if the current quaternion and the given one coordinates are strictly equals
  3501. */
  3502. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3503. /**
  3504. * Clone the current quaternion
  3505. * @returns a new quaternion copied from the current one
  3506. */
  3507. clone(): Quaternion;
  3508. /**
  3509. * Copy a quaternion to the current one
  3510. * @param other defines the other quaternion
  3511. * @returns the updated current quaternion
  3512. */
  3513. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3514. /**
  3515. * Updates the current quaternion with the given float coordinates
  3516. * @param x defines the x coordinate
  3517. * @param y defines the y coordinate
  3518. * @param z defines the z coordinate
  3519. * @param w defines the w coordinate
  3520. * @returns the updated current quaternion
  3521. */
  3522. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3523. /**
  3524. * Updates the current quaternion from the given float coordinates
  3525. * @param x defines the x coordinate
  3526. * @param y defines the y coordinate
  3527. * @param z defines the z coordinate
  3528. * @param w defines the w coordinate
  3529. * @returns the updated current quaternion
  3530. */
  3531. set(x: number, y: number, z: number, w: number): Quaternion;
  3532. /**
  3533. * Adds two quaternions
  3534. * @param other defines the second operand
  3535. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3536. */
  3537. add(other: DeepImmutable<Quaternion>): Quaternion;
  3538. /**
  3539. * Add a quaternion to the current one
  3540. * @param other defines the quaternion to add
  3541. * @returns the current quaternion
  3542. */
  3543. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Subtract two quaternions
  3546. * @param other defines the second operand
  3547. * @returns a new quaternion as the subtraction result of the given one from the current one
  3548. */
  3549. subtract(other: Quaternion): Quaternion;
  3550. /**
  3551. * Multiplies the current quaternion by a scale factor
  3552. * @param value defines the scale factor
  3553. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3554. */
  3555. scale(value: number): Quaternion;
  3556. /**
  3557. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3558. * @param scale defines the scale factor
  3559. * @param result defines the Quaternion object where to store the result
  3560. * @returns the unmodified current quaternion
  3561. */
  3562. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3563. /**
  3564. * Multiplies in place the current quaternion by a scale factor
  3565. * @param value defines the scale factor
  3566. * @returns the current modified quaternion
  3567. */
  3568. scaleInPlace(value: number): Quaternion;
  3569. /**
  3570. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3571. * @param scale defines the scale factor
  3572. * @param result defines the Quaternion object where to store the result
  3573. * @returns the unmodified current quaternion
  3574. */
  3575. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3576. /**
  3577. * Multiplies two quaternions
  3578. * @param q1 defines the second operand
  3579. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3580. */
  3581. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3584. * @param q1 defines the second operand
  3585. * @param result defines the target quaternion
  3586. * @returns the current quaternion
  3587. */
  3588. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3589. /**
  3590. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3591. * @param q1 defines the second operand
  3592. * @returns the currentupdated quaternion
  3593. */
  3594. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3595. /**
  3596. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3597. * @param ref defines the target quaternion
  3598. * @returns the current quaternion
  3599. */
  3600. conjugateToRef(ref: Quaternion): Quaternion;
  3601. /**
  3602. * Conjugates in place (1-q) the current quaternion
  3603. * @returns the current updated quaternion
  3604. */
  3605. conjugateInPlace(): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns a new quaternion
  3609. */
  3610. conjugate(): Quaternion;
  3611. /**
  3612. * Gets length of current quaternion
  3613. * @returns the quaternion length (float)
  3614. */
  3615. length(): number;
  3616. /**
  3617. * Normalize in place the current quaternion
  3618. * @returns the current updated quaternion
  3619. */
  3620. normalize(): Quaternion;
  3621. /**
  3622. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3623. * @param order is a reserved parameter and is ignore for now
  3624. * @returns a new Vector3 containing the Euler angles
  3625. */
  3626. toEulerAngles(order?: string): Vector3;
  3627. /**
  3628. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3629. * @param result defines the vector which will be filled with the Euler angles
  3630. * @param order is a reserved parameter and is ignore for now
  3631. * @returns the current unchanged quaternion
  3632. */
  3633. toEulerAnglesToRef(result: Vector3): Quaternion;
  3634. /**
  3635. * Updates the given rotation matrix with the current quaternion values
  3636. * @param result defines the target matrix
  3637. * @returns the current unchanged quaternion
  3638. */
  3639. toRotationMatrix(result: Matrix): Quaternion;
  3640. /**
  3641. * Updates the current quaternion from the given rotation matrix values
  3642. * @param matrix defines the source matrix
  3643. * @returns the current updated quaternion
  3644. */
  3645. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3646. /**
  3647. * Creates a new quaternion from a rotation matrix
  3648. * @param matrix defines the source matrix
  3649. * @returns a new quaternion created from the given rotation matrix values
  3650. */
  3651. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3652. /**
  3653. * Updates the given quaternion with the given rotation matrix values
  3654. * @param matrix defines the source matrix
  3655. * @param result defines the target quaternion
  3656. */
  3657. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3658. /**
  3659. * Returns the dot product (float) between the quaternions "left" and "right"
  3660. * @param left defines the left operand
  3661. * @param right defines the right operand
  3662. * @returns the dot product
  3663. */
  3664. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3665. /**
  3666. * Checks if the two quaternions are close to each other
  3667. * @param quat0 defines the first quaternion to check
  3668. * @param quat1 defines the second quaternion to check
  3669. * @returns true if the two quaternions are close to each other
  3670. */
  3671. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3672. /**
  3673. * Creates an empty quaternion
  3674. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3675. */
  3676. static Zero(): Quaternion;
  3677. /**
  3678. * Inverse a given quaternion
  3679. * @param q defines the source quaternion
  3680. * @returns a new quaternion as the inverted current quaternion
  3681. */
  3682. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3683. /**
  3684. * Inverse a given quaternion
  3685. * @param q defines the source quaternion
  3686. * @param result the quaternion the result will be stored in
  3687. * @returns the result quaternion
  3688. */
  3689. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3690. /**
  3691. * Creates an identity quaternion
  3692. * @returns the identity quaternion
  3693. */
  3694. static Identity(): Quaternion;
  3695. /**
  3696. * Gets a boolean indicating if the given quaternion is identity
  3697. * @param quaternion defines the quaternion to check
  3698. * @returns true if the quaternion is identity
  3699. */
  3700. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3701. /**
  3702. * Creates a quaternion from a rotation around an axis
  3703. * @param axis defines the axis to use
  3704. * @param angle defines the angle to use
  3705. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3706. */
  3707. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3708. /**
  3709. * Creates a rotation around an axis and stores it into the given quaternion
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle to use
  3712. * @param result defines the target quaternion
  3713. * @returns the target quaternion
  3714. */
  3715. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3716. /**
  3717. * Creates a new quaternion from data stored into an array
  3718. * @param array defines the data source
  3719. * @param offset defines the offset in the source array where the data starts
  3720. * @returns a new quaternion
  3721. */
  3722. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3723. /**
  3724. * Create a quaternion from Euler rotation angles
  3725. * @param x Pitch
  3726. * @param y Yaw
  3727. * @param z Roll
  3728. * @returns the new Quaternion
  3729. */
  3730. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3731. /**
  3732. * Updates a quaternion from Euler rotation angles
  3733. * @param x Pitch
  3734. * @param y Yaw
  3735. * @param z Roll
  3736. * @param result the quaternion to store the result
  3737. * @returns the updated quaternion
  3738. */
  3739. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3740. /**
  3741. * Create a quaternion from Euler rotation vector
  3742. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3743. * @returns the new Quaternion
  3744. */
  3745. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3746. /**
  3747. * Updates a quaternion from Euler rotation vector
  3748. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3749. * @param result the quaternion to store the result
  3750. * @returns the updated quaternion
  3751. */
  3752. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3753. /**
  3754. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3755. * @param yaw defines the rotation around Y axis
  3756. * @param pitch defines the rotation around X axis
  3757. * @param roll defines the rotation around Z axis
  3758. * @returns the new quaternion
  3759. */
  3760. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3761. /**
  3762. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3763. * @param yaw defines the rotation around Y axis
  3764. * @param pitch defines the rotation around X axis
  3765. * @param roll defines the rotation around Z axis
  3766. * @param result defines the target quaternion
  3767. */
  3768. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3769. /**
  3770. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3771. * @param alpha defines the rotation around first axis
  3772. * @param beta defines the rotation around second axis
  3773. * @param gamma defines the rotation around third axis
  3774. * @returns the new quaternion
  3775. */
  3776. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3777. /**
  3778. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3779. * @param alpha defines the rotation around first axis
  3780. * @param beta defines the rotation around second axis
  3781. * @param gamma defines the rotation around third axis
  3782. * @param result defines the target quaternion
  3783. */
  3784. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3785. /**
  3786. * 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)
  3787. * @param axis1 defines the first axis
  3788. * @param axis2 defines the second axis
  3789. * @param axis3 defines the third axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3793. /**
  3794. * 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
  3795. * @param axis1 defines the first axis
  3796. * @param axis2 defines the second axis
  3797. * @param axis3 defines the third axis
  3798. * @param ref defines the target quaternion
  3799. */
  3800. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3801. /**
  3802. * Interpolates between two quaternions
  3803. * @param left defines first quaternion
  3804. * @param right defines second quaternion
  3805. * @param amount defines the gradient to use
  3806. * @returns the new interpolated quaternion
  3807. */
  3808. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3809. /**
  3810. * Interpolates between two quaternions and stores it into a target quaternion
  3811. * @param left defines first quaternion
  3812. * @param right defines second quaternion
  3813. * @param amount defines the gradient to use
  3814. * @param result defines the target quaternion
  3815. */
  3816. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3817. /**
  3818. * Interpolate between two quaternions using Hermite interpolation
  3819. * @param value1 defines first quaternion
  3820. * @param tangent1 defines the incoming tangent
  3821. * @param value2 defines second quaternion
  3822. * @param tangent2 defines the outgoing tangent
  3823. * @param amount defines the target quaternion
  3824. * @returns the new interpolated quaternion
  3825. */
  3826. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3827. }
  3828. /**
  3829. * Class used to store matrix data (4x4)
  3830. */
  3831. export class Matrix {
  3832. private static _updateFlagSeed;
  3833. private static _identityReadOnly;
  3834. private _isIdentity;
  3835. private _isIdentityDirty;
  3836. private _isIdentity3x2;
  3837. private _isIdentity3x2Dirty;
  3838. /**
  3839. * Gets the update flag of the matrix which is an unique number for the matrix.
  3840. * It will be incremented every time the matrix data change.
  3841. * You can use it to speed the comparison between two versions of the same matrix.
  3842. */
  3843. updateFlag: number;
  3844. private readonly _m;
  3845. /**
  3846. * Gets the internal data of the matrix
  3847. */
  3848. readonly m: DeepImmutable<Float32Array>;
  3849. /** @hidden */
  3850. _markAsUpdated(): void;
  3851. /** @hidden */
  3852. private _updateIdentityStatus;
  3853. /**
  3854. * Creates an empty matrix (filled with zeros)
  3855. */
  3856. constructor();
  3857. /**
  3858. * Check if the current matrix is identity
  3859. * @returns true is the matrix is the identity matrix
  3860. */
  3861. isIdentity(): boolean;
  3862. /**
  3863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentityAs3x2(): boolean;
  3867. /**
  3868. * Gets the determinant of the matrix
  3869. * @returns the matrix determinant
  3870. */
  3871. determinant(): number;
  3872. /**
  3873. * Returns the matrix as a Float32Array
  3874. * @returns the matrix underlying array
  3875. */
  3876. toArray(): DeepImmutable<Float32Array>;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array.
  3880. */
  3881. asArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Inverts the current matrix in place
  3884. * @returns the current inverted matrix
  3885. */
  3886. invert(): Matrix;
  3887. /**
  3888. * Sets all the matrix elements to zero
  3889. * @returns the current matrix
  3890. */
  3891. reset(): Matrix;
  3892. /**
  3893. * Adds the current matrix with a second one
  3894. * @param other defines the matrix to add
  3895. * @returns a new matrix as the addition of the current matrix and the given one
  3896. */
  3897. add(other: DeepImmutable<Matrix>): Matrix;
  3898. /**
  3899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3900. * @param other defines the matrix to add
  3901. * @param result defines the target matrix
  3902. * @returns the current matrix
  3903. */
  3904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3905. /**
  3906. * Adds in place the given matrix to the current matrix
  3907. * @param other defines the second operand
  3908. * @returns the current updated matrix
  3909. */
  3910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3911. /**
  3912. * Sets the given matrix to the current inverted Matrix
  3913. * @param other defines the target matrix
  3914. * @returns the unmodified current matrix
  3915. */
  3916. invertToRef(other: Matrix): Matrix;
  3917. /**
  3918. * add a value at the specified position in the current Matrix
  3919. * @param index the index of the value within the matrix. between 0 and 15.
  3920. * @param value the value to be added
  3921. * @returns the current updated matrix
  3922. */
  3923. addAtIndex(index: number, value: number): Matrix;
  3924. /**
  3925. * mutiply the specified position in the current Matrix by a value
  3926. * @param index the index of the value within the matrix. between 0 and 15.
  3927. * @param value the value to be added
  3928. * @returns the current updated matrix
  3929. */
  3930. multiplyAtIndex(index: number, value: number): Matrix;
  3931. /**
  3932. * Inserts the translation vector (using 3 floats) in the current matrix
  3933. * @param x defines the 1st component of the translation
  3934. * @param y defines the 2nd component of the translation
  3935. * @param z defines the 3rd component of the translation
  3936. * @returns the current updated matrix
  3937. */
  3938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3939. /**
  3940. * Adds the translation vector (using 3 floats) in the current matrix
  3941. * @param x defines the 1st component of the translation
  3942. * @param y defines the 2nd component of the translation
  3943. * @param z defines the 3rd component of the translation
  3944. * @returns the current updated matrix
  3945. */
  3946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3947. /**
  3948. * Inserts the translation vector in the current matrix
  3949. * @param vector3 defines the translation to insert
  3950. * @returns the current updated matrix
  3951. */
  3952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3953. /**
  3954. * Gets the translation value of the current matrix
  3955. * @returns a new Vector3 as the extracted translation from the matrix
  3956. */
  3957. getTranslation(): Vector3;
  3958. /**
  3959. * Fill a Vector3 with the extracted translation from the matrix
  3960. * @param result defines the Vector3 where to store the translation
  3961. * @returns the current matrix
  3962. */
  3963. getTranslationToRef(result: Vector3): Matrix;
  3964. /**
  3965. * Remove rotation and scaling part from the matrix
  3966. * @returns the updated matrix
  3967. */
  3968. removeRotationAndScaling(): Matrix;
  3969. /**
  3970. * Multiply two matrices
  3971. * @param other defines the second operand
  3972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3973. */
  3974. multiply(other: DeepImmutable<Matrix>): Matrix;
  3975. /**
  3976. * Copy the current matrix from the given one
  3977. * @param other defines the source matrix
  3978. * @returns the current updated matrix
  3979. */
  3980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3981. /**
  3982. * Populates the given array from the starting index with the current matrix values
  3983. * @param array defines the target array
  3984. * @param offset defines the offset in the target array where to start storing values
  3985. * @returns the current matrix
  3986. */
  3987. copyToArray(array: Float32Array, offset?: number): Matrix;
  3988. /**
  3989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3990. * @param other defines the second operand
  3991. * @param result defines the matrix where to store the multiplication
  3992. * @returns the current matrix
  3993. */
  3994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3995. /**
  3996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3997. * @param other defines the second operand
  3998. * @param result defines the array where to store the multiplication
  3999. * @param offset defines the offset in the target array where to start storing values
  4000. * @returns the current matrix
  4001. */
  4002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4003. /**
  4004. * Check equality between this matrix and a second one
  4005. * @param value defines the second matrix to compare
  4006. * @returns true is the current matrix and the given one values are strictly equal
  4007. */
  4008. equals(value: DeepImmutable<Matrix>): boolean;
  4009. /**
  4010. * Clone the current matrix
  4011. * @returns a new matrix from the current matrix
  4012. */
  4013. clone(): Matrix;
  4014. /**
  4015. * Returns the name of the current matrix class
  4016. * @returns the string "Matrix"
  4017. */
  4018. getClassName(): string;
  4019. /**
  4020. * Gets the hash code of the current matrix
  4021. * @returns the hash code
  4022. */
  4023. getHashCode(): number;
  4024. /**
  4025. * Decomposes the current Matrix into a translation, rotation and scaling components
  4026. * @param scale defines the scale vector3 given as a reference to update
  4027. * @param rotation defines the rotation quaternion given as a reference to update
  4028. * @param translation defines the translation vector3 given as a reference to update
  4029. * @returns true if operation was successful
  4030. */
  4031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4032. /**
  4033. * Gets specific row of the matrix
  4034. * @param index defines the number of the row to get
  4035. * @returns the index-th row of the current matrix as a new Vector4
  4036. */
  4037. getRow(index: number): Nullable<Vector4>;
  4038. /**
  4039. * Sets the index-th row of the current matrix to the vector4 values
  4040. * @param index defines the number of the row to set
  4041. * @param row defines the target vector4
  4042. * @returns the updated current matrix
  4043. */
  4044. setRow(index: number, row: Vector4): Matrix;
  4045. /**
  4046. * Compute the transpose of the matrix
  4047. * @returns the new transposed matrix
  4048. */
  4049. transpose(): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix and store it in a given matrix
  4052. * @param result defines the target matrix
  4053. * @returns the current matrix
  4054. */
  4055. transposeToRef(result: Matrix): Matrix;
  4056. /**
  4057. * Sets the index-th row of the current matrix with the given 4 x float values
  4058. * @param index defines the row index
  4059. * @param x defines the x component to set
  4060. * @param y defines the y component to set
  4061. * @param z defines the z component to set
  4062. * @param w defines the w component to set
  4063. * @returns the updated current matrix
  4064. */
  4065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4066. /**
  4067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4068. * @param scale defines the scale factor
  4069. * @returns a new matrix
  4070. */
  4071. scale(scale: number): Matrix;
  4072. /**
  4073. * Scale the current matrix values by a factor to a given result matrix
  4074. * @param scale defines the scale factor
  4075. * @param result defines the matrix to store the result
  4076. * @returns the current matrix
  4077. */
  4078. scaleToRef(scale: number, result: Matrix): Matrix;
  4079. /**
  4080. * Scale the current matrix values by a factor and add the result to a given matrix
  4081. * @param scale defines the scale factor
  4082. * @param result defines the Matrix to store the result
  4083. * @returns the current matrix
  4084. */
  4085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4086. /**
  4087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4088. * @param ref matrix to store the result
  4089. */
  4090. toNormalMatrix(ref: Matrix): void;
  4091. /**
  4092. * Gets only rotation part of the current matrix
  4093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4094. */
  4095. getRotationMatrix(): Matrix;
  4096. /**
  4097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4098. * @param result defines the target matrix to store data to
  4099. * @returns the current matrix
  4100. */
  4101. getRotationMatrixToRef(result: Matrix): Matrix;
  4102. /**
  4103. * Toggles model matrix from being right handed to left handed in place and vice versa
  4104. */
  4105. toggleModelMatrixHandInPlace(): void;
  4106. /**
  4107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4108. */
  4109. toggleProjectionMatrixHandInPlace(): void;
  4110. /**
  4111. * Creates a matrix from an array
  4112. * @param array defines the source array
  4113. * @param offset defines an offset in the source array
  4114. * @returns a new Matrix set from the starting index of the given array
  4115. */
  4116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4117. /**
  4118. * Copy the content of an array into a given matrix
  4119. * @param array defines the source array
  4120. * @param offset defines an offset in the source array
  4121. * @param result defines the target matrix
  4122. */
  4123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4124. /**
  4125. * Stores an array into a matrix after having multiplied each component by a given factor
  4126. * @param array defines the source array
  4127. * @param offset defines the offset in the source array
  4128. * @param scale defines the scaling factor
  4129. * @param result defines the target matrix
  4130. */
  4131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4132. /**
  4133. * Gets an identity matrix that must not be updated
  4134. */
  4135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4136. /**
  4137. * Stores a list of values (16) inside a given matrix
  4138. * @param initialM11 defines 1st value of 1st row
  4139. * @param initialM12 defines 2nd value of 1st row
  4140. * @param initialM13 defines 3rd value of 1st row
  4141. * @param initialM14 defines 4th value of 1st row
  4142. * @param initialM21 defines 1st value of 2nd row
  4143. * @param initialM22 defines 2nd value of 2nd row
  4144. * @param initialM23 defines 3rd value of 2nd row
  4145. * @param initialM24 defines 4th value of 2nd row
  4146. * @param initialM31 defines 1st value of 3rd row
  4147. * @param initialM32 defines 2nd value of 3rd row
  4148. * @param initialM33 defines 3rd value of 3rd row
  4149. * @param initialM34 defines 4th value of 3rd row
  4150. * @param initialM41 defines 1st value of 4th row
  4151. * @param initialM42 defines 2nd value of 4th row
  4152. * @param initialM43 defines 3rd value of 4th row
  4153. * @param initialM44 defines 4th value of 4th row
  4154. * @param result defines the target matrix
  4155. */
  4156. 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;
  4157. /**
  4158. * Creates new matrix from a list of values (16)
  4159. * @param initialM11 defines 1st value of 1st row
  4160. * @param initialM12 defines 2nd value of 1st row
  4161. * @param initialM13 defines 3rd value of 1st row
  4162. * @param initialM14 defines 4th value of 1st row
  4163. * @param initialM21 defines 1st value of 2nd row
  4164. * @param initialM22 defines 2nd value of 2nd row
  4165. * @param initialM23 defines 3rd value of 2nd row
  4166. * @param initialM24 defines 4th value of 2nd row
  4167. * @param initialM31 defines 1st value of 3rd row
  4168. * @param initialM32 defines 2nd value of 3rd row
  4169. * @param initialM33 defines 3rd value of 3rd row
  4170. * @param initialM34 defines 4th value of 3rd row
  4171. * @param initialM41 defines 1st value of 4th row
  4172. * @param initialM42 defines 2nd value of 4th row
  4173. * @param initialM43 defines 3rd value of 4th row
  4174. * @param initialM44 defines 4th value of 4th row
  4175. * @returns the new matrix
  4176. */
  4177. 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;
  4178. /**
  4179. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4180. * @param scale defines the scale vector3
  4181. * @param rotation defines the rotation quaternion
  4182. * @param translation defines the translation vector3
  4183. * @returns a new matrix
  4184. */
  4185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4186. /**
  4187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4188. * @param scale defines the scale vector3
  4189. * @param rotation defines the rotation quaternion
  4190. * @param translation defines the translation vector3
  4191. * @param result defines the target matrix
  4192. */
  4193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4194. /**
  4195. * Creates a new identity matrix
  4196. * @returns a new identity matrix
  4197. */
  4198. static Identity(): Matrix;
  4199. /**
  4200. * Creates a new identity matrix and stores the result in a given matrix
  4201. * @param result defines the target matrix
  4202. */
  4203. static IdentityToRef(result: Matrix): void;
  4204. /**
  4205. * Creates a new zero matrix
  4206. * @returns a new zero matrix
  4207. */
  4208. static Zero(): Matrix;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the X axis
  4211. * @param angle defines the angle (in radians) to use
  4212. * @return the new matrix
  4213. */
  4214. static RotationX(angle: number): Matrix;
  4215. /**
  4216. * Creates a new matrix as the invert of a given matrix
  4217. * @param source defines the source matrix
  4218. * @returns the new matrix
  4219. */
  4220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4223. * @param angle defines the angle (in radians) to use
  4224. * @param result defines the target matrix
  4225. */
  4226. static RotationXToRef(angle: number, result: Matrix): void;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the Y axis
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationY(angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4235. * @param angle defines the angle (in radians) to use
  4236. * @param result defines the target matrix
  4237. */
  4238. static RotationYToRef(angle: number, result: Matrix): void;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Z axis
  4241. * @param angle defines the angle (in radians) to use
  4242. * @return the new matrix
  4243. */
  4244. static RotationZ(angle: number): Matrix;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4247. * @param angle defines the angle (in radians) to use
  4248. * @param result defines the target matrix
  4249. */
  4250. static RotationZToRef(angle: number, result: Matrix): void;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the given axis
  4253. * @param axis defines the axis to use
  4254. * @param angle defines the angle (in radians) to use
  4255. * @return the new matrix
  4256. */
  4257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4258. /**
  4259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4260. * @param axis defines the axis to use
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4265. /**
  4266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4268. * @param from defines the vector to align
  4269. * @param to defines the vector to align to
  4270. * @param result defines the target matrix
  4271. */
  4272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4273. /**
  4274. * Creates a rotation matrix
  4275. * @param yaw defines the yaw angle in radians (Y axis)
  4276. * @param pitch defines the pitch angle in radians (X axis)
  4277. * @param roll defines the roll angle in radians (X axis)
  4278. * @returns the new rotation matrix
  4279. */
  4280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4281. /**
  4282. * Creates a rotation matrix and stores it in a given matrix
  4283. * @param yaw defines the yaw angle in radians (Y axis)
  4284. * @param pitch defines the pitch angle in radians (X axis)
  4285. * @param roll defines the roll angle in radians (X axis)
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4289. /**
  4290. * Creates a scaling matrix
  4291. * @param x defines the scale factor on X axis
  4292. * @param y defines the scale factor on Y axis
  4293. * @param z defines the scale factor on Z axis
  4294. * @returns the new matrix
  4295. */
  4296. static Scaling(x: number, y: number, z: number): Matrix;
  4297. /**
  4298. * Creates a scaling matrix and stores it in a given matrix
  4299. * @param x defines the scale factor on X axis
  4300. * @param y defines the scale factor on Y axis
  4301. * @param z defines the scale factor on Z axis
  4302. * @param result defines the target matrix
  4303. */
  4304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4305. /**
  4306. * Creates a translation matrix
  4307. * @param x defines the translation on X axis
  4308. * @param y defines the translation on Y axis
  4309. * @param z defines the translationon Z axis
  4310. * @returns the new matrix
  4311. */
  4312. static Translation(x: number, y: number, z: number): Matrix;
  4313. /**
  4314. * Creates a translation matrix and stores it in a given matrix
  4315. * @param x defines the translation on X axis
  4316. * @param y defines the translation on Y axis
  4317. * @param z defines the translationon Z axis
  4318. * @param result defines the target matrix
  4319. */
  4320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4321. /**
  4322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4323. * @param startValue defines the start value
  4324. * @param endValue defines the end value
  4325. * @param gradient defines the gradient factor
  4326. * @returns the new matrix
  4327. */
  4328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4329. /**
  4330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4331. * @param startValue defines the start value
  4332. * @param endValue defines the end value
  4333. * @param gradient defines the gradient factor
  4334. * @param result defines the Matrix object where to store data
  4335. */
  4336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4337. /**
  4338. * Builds a new matrix whose values are computed by:
  4339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4342. * @param startValue defines the first matrix
  4343. * @param endValue defines the second matrix
  4344. * @param gradient defines the gradient between the two matrices
  4345. * @returns the new matrix
  4346. */
  4347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4348. /**
  4349. * Update a matrix to values which are computed by:
  4350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4353. * @param startValue defines the first matrix
  4354. * @param endValue defines the second matrix
  4355. * @param gradient defines the gradient between the two matrices
  4356. * @param result defines the target matrix
  4357. */
  4358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4359. /**
  4360. * 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"
  4361. * This function works in left handed mode
  4362. * @param eye defines the final position of the entity
  4363. * @param target defines where the entity should look at
  4364. * @param up defines the up vector for the entity
  4365. * @returns the new matrix
  4366. */
  4367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4368. /**
  4369. * 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".
  4370. * This function works in left handed mode
  4371. * @param eye defines the final position of the entity
  4372. * @param target defines where the entity should look at
  4373. * @param up defines the up vector for the entity
  4374. * @param result defines the target matrix
  4375. */
  4376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4377. /**
  4378. * 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"
  4379. * This function works in right handed mode
  4380. * @param eye defines the final position of the entity
  4381. * @param target defines where the entity should look at
  4382. * @param up defines the up vector for the entity
  4383. * @returns the new matrix
  4384. */
  4385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * 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".
  4388. * This function works in right handed mode
  4389. * @param eye defines the final position of the entity
  4390. * @param target defines where the entity should look at
  4391. * @param up defines the up vector for the entity
  4392. * @param result defines the target matrix
  4393. */
  4394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4395. /**
  4396. * Create a left-handed orthographic projection matrix
  4397. * @param width defines the viewport width
  4398. * @param height defines the viewport height
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @returns a new matrix as a left-handed orthographic projection matrix
  4402. */
  4403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4404. /**
  4405. * Store a left-handed orthographic projection to a given matrix
  4406. * @param width defines the viewport width
  4407. * @param height defines the viewport height
  4408. * @param znear defines the near clip plane
  4409. * @param zfar defines the far clip plane
  4410. * @param result defines the target matrix
  4411. */
  4412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4413. /**
  4414. * Create a left-handed orthographic projection matrix
  4415. * @param left defines the viewport left coordinate
  4416. * @param right defines the viewport right coordinate
  4417. * @param bottom defines the viewport bottom coordinate
  4418. * @param top defines the viewport top coordinate
  4419. * @param znear defines the near clip plane
  4420. * @param zfar defines the far clip plane
  4421. * @returns a new matrix as a left-handed orthographic projection matrix
  4422. */
  4423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4424. /**
  4425. * Stores a left-handed orthographic projection into a given matrix
  4426. * @param left defines the viewport left coordinate
  4427. * @param right defines the viewport right coordinate
  4428. * @param bottom defines the viewport bottom coordinate
  4429. * @param top defines the viewport top coordinate
  4430. * @param znear defines the near clip plane
  4431. * @param zfar defines the far clip plane
  4432. * @param result defines the target matrix
  4433. */
  4434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4435. /**
  4436. * Creates a right-handed orthographic projection matrix
  4437. * @param left defines the viewport left coordinate
  4438. * @param right defines the viewport right coordinate
  4439. * @param bottom defines the viewport bottom coordinate
  4440. * @param top defines the viewport top coordinate
  4441. * @param znear defines the near clip plane
  4442. * @param zfar defines the far clip plane
  4443. * @returns a new matrix as a right-handed orthographic projection matrix
  4444. */
  4445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4446. /**
  4447. * Stores a right-handed orthographic projection into a given matrix
  4448. * @param left defines the viewport left coordinate
  4449. * @param right defines the viewport right coordinate
  4450. * @param bottom defines the viewport bottom coordinate
  4451. * @param top defines the viewport top coordinate
  4452. * @param znear defines the near clip plane
  4453. * @param zfar defines the far clip plane
  4454. * @param result defines the target matrix
  4455. */
  4456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4457. /**
  4458. * Creates a left-handed perspective projection matrix
  4459. * @param width defines the viewport width
  4460. * @param height defines the viewport height
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @returns a new matrix as a left-handed perspective projection matrix
  4464. */
  4465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4466. /**
  4467. * Creates a left-handed perspective projection matrix
  4468. * @param fov defines the horizontal field of view
  4469. * @param aspect defines the aspect ratio
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @returns a new matrix as a left-handed perspective projection matrix
  4473. */
  4474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4475. /**
  4476. * Stores a left-handed perspective projection into a given matrix
  4477. * @param fov defines the horizontal field of view
  4478. * @param aspect defines the aspect ratio
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @param result defines the target matrix
  4482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4483. */
  4484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4485. /**
  4486. * Creates a right-handed perspective projection matrix
  4487. * @param fov defines the horizontal field of view
  4488. * @param aspect defines the aspect ratio
  4489. * @param znear defines the near clip plane
  4490. * @param zfar defines the far clip plane
  4491. * @returns a new matrix as a right-handed perspective projection matrix
  4492. */
  4493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4494. /**
  4495. * Stores a right-handed perspective projection into a given matrix
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar defines the far clip plane
  4500. * @param result defines the target matrix
  4501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4502. */
  4503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4504. /**
  4505. * Stores a perspective projection for WebVR info a given matrix
  4506. * @param fov defines the field of view
  4507. * @param znear defines the near clip plane
  4508. * @param zfar defines the far clip plane
  4509. * @param result defines the target matrix
  4510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4511. */
  4512. static PerspectiveFovWebVRToRef(fov: {
  4513. upDegrees: number;
  4514. downDegrees: number;
  4515. leftDegrees: number;
  4516. rightDegrees: number;
  4517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4518. /**
  4519. * Computes a complete transformation matrix
  4520. * @param viewport defines the viewport to use
  4521. * @param world defines the world matrix
  4522. * @param view defines the view matrix
  4523. * @param projection defines the projection matrix
  4524. * @param zmin defines the near clip plane
  4525. * @param zmax defines the far clip plane
  4526. * @returns the transformation matrix
  4527. */
  4528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4529. /**
  4530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4531. * @param matrix defines the matrix to use
  4532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4533. */
  4534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4535. /**
  4536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4537. * @param matrix defines the matrix to use
  4538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4539. */
  4540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4541. /**
  4542. * Compute the transpose of a given matrix
  4543. * @param matrix defines the matrix to transpose
  4544. * @returns the new matrix
  4545. */
  4546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4547. /**
  4548. * Compute the transpose of a matrix and store it in a target matrix
  4549. * @param matrix defines the matrix to transpose
  4550. * @param result defines the target matrix
  4551. */
  4552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4553. /**
  4554. * Computes a reflection matrix from a plane
  4555. * @param plane defines the reflection plane
  4556. * @returns a new matrix
  4557. */
  4558. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4559. /**
  4560. * Computes a reflection matrix from a plane
  4561. * @param plane defines the reflection plane
  4562. * @param result defines the target matrix
  4563. */
  4564. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4565. /**
  4566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4567. * @param xaxis defines the value of the 1st axis
  4568. * @param yaxis defines the value of the 2nd axis
  4569. * @param zaxis defines the value of the 3rd axis
  4570. * @param result defines the target matrix
  4571. */
  4572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4573. /**
  4574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4575. * @param quat defines the quaternion to use
  4576. * @param result defines the target matrix
  4577. */
  4578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4579. }
  4580. /**
  4581. * @hidden
  4582. */
  4583. export class TmpVectors {
  4584. static Vector2: Vector2[];
  4585. static Vector3: Vector3[];
  4586. static Vector4: Vector4[];
  4587. static Quaternion: Quaternion[];
  4588. static Matrix: Matrix[];
  4589. }
  4590. }
  4591. declare module "babylonjs/Maths/math.path" {
  4592. import { DeepImmutable, Nullable } from "babylonjs/types";
  4593. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4594. /**
  4595. * Defines potential orientation for back face culling
  4596. */
  4597. export enum Orientation {
  4598. /**
  4599. * Clockwise
  4600. */
  4601. CW = 0,
  4602. /** Counter clockwise */
  4603. CCW = 1
  4604. }
  4605. /** Class used to represent a Bezier curve */
  4606. export class BezierCurve {
  4607. /**
  4608. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4609. * @param t defines the time
  4610. * @param x1 defines the left coordinate on X axis
  4611. * @param y1 defines the left coordinate on Y axis
  4612. * @param x2 defines the right coordinate on X axis
  4613. * @param y2 defines the right coordinate on Y axis
  4614. * @returns the interpolated value
  4615. */
  4616. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4617. }
  4618. /**
  4619. * Defines angle representation
  4620. */
  4621. export class Angle {
  4622. private _radians;
  4623. /**
  4624. * Creates an Angle object of "radians" radians (float).
  4625. * @param radians the angle in radians
  4626. */
  4627. constructor(radians: number);
  4628. /**
  4629. * Get value in degrees
  4630. * @returns the Angle value in degrees (float)
  4631. */
  4632. degrees(): number;
  4633. /**
  4634. * Get value in radians
  4635. * @returns the Angle value in radians (float)
  4636. */
  4637. radians(): number;
  4638. /**
  4639. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4640. * @param a defines first vector
  4641. * @param b defines second vector
  4642. * @returns a new Angle
  4643. */
  4644. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4645. /**
  4646. * Gets a new Angle object from the given float in radians
  4647. * @param radians defines the angle value in radians
  4648. * @returns a new Angle
  4649. */
  4650. static FromRadians(radians: number): Angle;
  4651. /**
  4652. * Gets a new Angle object from the given float in degrees
  4653. * @param degrees defines the angle value in degrees
  4654. * @returns a new Angle
  4655. */
  4656. static FromDegrees(degrees: number): Angle;
  4657. }
  4658. /**
  4659. * This represents an arc in a 2d space.
  4660. */
  4661. export class Arc2 {
  4662. /** Defines the start point of the arc */
  4663. startPoint: Vector2;
  4664. /** Defines the mid point of the arc */
  4665. midPoint: Vector2;
  4666. /** Defines the end point of the arc */
  4667. endPoint: Vector2;
  4668. /**
  4669. * Defines the center point of the arc.
  4670. */
  4671. centerPoint: Vector2;
  4672. /**
  4673. * Defines the radius of the arc.
  4674. */
  4675. radius: number;
  4676. /**
  4677. * Defines the angle of the arc (from mid point to end point).
  4678. */
  4679. angle: Angle;
  4680. /**
  4681. * Defines the start angle of the arc (from start point to middle point).
  4682. */
  4683. startAngle: Angle;
  4684. /**
  4685. * Defines the orientation of the arc (clock wise/counter clock wise).
  4686. */
  4687. orientation: Orientation;
  4688. /**
  4689. * Creates an Arc object from the three given points : start, middle and end.
  4690. * @param startPoint Defines the start point of the arc
  4691. * @param midPoint Defines the midlle point of the arc
  4692. * @param endPoint Defines the end point of the arc
  4693. */
  4694. constructor(
  4695. /** Defines the start point of the arc */
  4696. startPoint: Vector2,
  4697. /** Defines the mid point of the arc */
  4698. midPoint: Vector2,
  4699. /** Defines the end point of the arc */
  4700. endPoint: Vector2);
  4701. }
  4702. /**
  4703. * Represents a 2D path made up of multiple 2D points
  4704. */
  4705. export class Path2 {
  4706. private _points;
  4707. private _length;
  4708. /**
  4709. * If the path start and end point are the same
  4710. */
  4711. closed: boolean;
  4712. /**
  4713. * Creates a Path2 object from the starting 2D coordinates x and y.
  4714. * @param x the starting points x value
  4715. * @param y the starting points y value
  4716. */
  4717. constructor(x: number, y: number);
  4718. /**
  4719. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4720. * @param x the added points x value
  4721. * @param y the added points y value
  4722. * @returns the updated Path2.
  4723. */
  4724. addLineTo(x: number, y: number): Path2;
  4725. /**
  4726. * 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.
  4727. * @param midX middle point x value
  4728. * @param midY middle point y value
  4729. * @param endX end point x value
  4730. * @param endY end point y value
  4731. * @param numberOfSegments (default: 36)
  4732. * @returns the updated Path2.
  4733. */
  4734. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4735. /**
  4736. * Closes the Path2.
  4737. * @returns the Path2.
  4738. */
  4739. close(): Path2;
  4740. /**
  4741. * Gets the sum of the distance between each sequential point in the path
  4742. * @returns the Path2 total length (float).
  4743. */
  4744. length(): number;
  4745. /**
  4746. * Gets the points which construct the path
  4747. * @returns the Path2 internal array of points.
  4748. */
  4749. getPoints(): Vector2[];
  4750. /**
  4751. * Retreives the point at the distance aways from the starting point
  4752. * @param normalizedLengthPosition the length along the path to retreive the point from
  4753. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4754. */
  4755. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4756. /**
  4757. * Creates a new path starting from an x and y position
  4758. * @param x starting x value
  4759. * @param y starting y value
  4760. * @returns a new Path2 starting at the coordinates (x, y).
  4761. */
  4762. static StartingAt(x: number, y: number): Path2;
  4763. }
  4764. /**
  4765. * Represents a 3D path made up of multiple 3D points
  4766. */
  4767. export class Path3D {
  4768. /**
  4769. * an array of Vector3, the curve axis of the Path3D
  4770. */
  4771. path: Vector3[];
  4772. private _curve;
  4773. private _distances;
  4774. private _tangents;
  4775. private _normals;
  4776. private _binormals;
  4777. private _raw;
  4778. /**
  4779. * new Path3D(path, normal, raw)
  4780. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4781. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4782. * @param path an array of Vector3, the curve axis of the Path3D
  4783. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4784. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4785. */
  4786. constructor(
  4787. /**
  4788. * an array of Vector3, the curve axis of the Path3D
  4789. */
  4790. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4791. /**
  4792. * Returns the Path3D array of successive Vector3 designing its curve.
  4793. * @returns the Path3D array of successive Vector3 designing its curve.
  4794. */
  4795. getCurve(): Vector3[];
  4796. /**
  4797. * Returns an array populated with tangent vectors on each Path3D curve point.
  4798. * @returns an array populated with tangent vectors on each Path3D curve point.
  4799. */
  4800. getTangents(): Vector3[];
  4801. /**
  4802. * Returns an array populated with normal vectors on each Path3D curve point.
  4803. * @returns an array populated with normal vectors on each Path3D curve point.
  4804. */
  4805. getNormals(): Vector3[];
  4806. /**
  4807. * Returns an array populated with binormal vectors on each Path3D curve point.
  4808. * @returns an array populated with binormal vectors on each Path3D curve point.
  4809. */
  4810. getBinormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4813. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4814. */
  4815. getDistances(): number[];
  4816. /**
  4817. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4818. * @param path path which all values are copied into the curves points
  4819. * @param firstNormal which should be projected onto the curve
  4820. * @returns the same object updated.
  4821. */
  4822. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4823. private _compute;
  4824. private _getFirstNonNullVector;
  4825. private _getLastNonNullVector;
  4826. private _normalVector;
  4827. }
  4828. /**
  4829. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4830. * A Curve3 is designed from a series of successive Vector3.
  4831. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4832. */
  4833. export class Curve3 {
  4834. private _points;
  4835. private _length;
  4836. /**
  4837. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4838. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4839. * @param v1 (Vector3) the control point
  4840. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4841. * @param nbPoints (integer) the wanted number of points in the curve
  4842. * @returns the created Curve3
  4843. */
  4844. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4845. /**
  4846. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4847. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4848. * @param v1 (Vector3) the first control point
  4849. * @param v2 (Vector3) the second control point
  4850. * @param v3 (Vector3) the end point of the Cubic Bezier
  4851. * @param nbPoints (integer) the wanted number of points in the curve
  4852. * @returns the created Curve3
  4853. */
  4854. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4855. /**
  4856. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4857. * @param p1 (Vector3) the origin point of the Hermite Spline
  4858. * @param t1 (Vector3) the tangent vector at the origin point
  4859. * @param p2 (Vector3) the end point of the Hermite Spline
  4860. * @param t2 (Vector3) the tangent vector at the end point
  4861. * @param nbPoints (integer) the wanted number of points in the curve
  4862. * @returns the created Curve3
  4863. */
  4864. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4865. /**
  4866. * Returns a Curve3 object along a CatmullRom Spline curve :
  4867. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4868. * @param nbPoints (integer) the wanted number of points between each curve control points
  4869. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4870. * @returns the created Curve3
  4871. */
  4872. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4873. /**
  4874. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4875. * A Curve3 is designed from a series of successive Vector3.
  4876. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4877. * @param points points which make up the curve
  4878. */
  4879. constructor(points: Vector3[]);
  4880. /**
  4881. * @returns the Curve3 stored array of successive Vector3
  4882. */
  4883. getPoints(): Vector3[];
  4884. /**
  4885. * @returns the computed length (float) of the curve.
  4886. */
  4887. length(): number;
  4888. /**
  4889. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4890. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4891. * curveA and curveB keep unchanged.
  4892. * @param curve the curve to continue from this curve
  4893. * @returns the newly constructed curve
  4894. */
  4895. continue(curve: DeepImmutable<Curve3>): Curve3;
  4896. private _computeLength;
  4897. }
  4898. }
  4899. declare module "babylonjs/Animations/easing" {
  4900. /**
  4901. * This represents the main contract an easing function should follow.
  4902. * Easing functions are used throughout the animation system.
  4903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4904. */
  4905. export interface IEasingFunction {
  4906. /**
  4907. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4908. * of the easing function.
  4909. * The link below provides some of the most common examples of easing functions.
  4910. * @see https://easings.net/
  4911. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4912. * @returns the corresponding value on the curve defined by the easing function
  4913. */
  4914. ease(gradient: number): number;
  4915. }
  4916. /**
  4917. * Base class used for every default easing function.
  4918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4919. */
  4920. export class EasingFunction implements IEasingFunction {
  4921. /**
  4922. * Interpolation follows the mathematical formula associated with the easing function.
  4923. */
  4924. static readonly EASINGMODE_EASEIN: number;
  4925. /**
  4926. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4927. */
  4928. static readonly EASINGMODE_EASEOUT: number;
  4929. /**
  4930. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4931. */
  4932. static readonly EASINGMODE_EASEINOUT: number;
  4933. private _easingMode;
  4934. /**
  4935. * Sets the easing mode of the current function.
  4936. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4937. */
  4938. setEasingMode(easingMode: number): void;
  4939. /**
  4940. * Gets the current easing mode.
  4941. * @returns the easing mode
  4942. */
  4943. getEasingMode(): number;
  4944. /**
  4945. * @hidden
  4946. */
  4947. easeInCore(gradient: number): number;
  4948. /**
  4949. * Given an input gradient between 0 and 1, this returns the corresponding value
  4950. * of the easing function.
  4951. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4952. * @returns the corresponding value on the curve defined by the easing function
  4953. */
  4954. ease(gradient: number): number;
  4955. }
  4956. /**
  4957. * Easing function with a circle shape (see link below).
  4958. * @see https://easings.net/#easeInCirc
  4959. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4960. */
  4961. export class CircleEase extends EasingFunction implements IEasingFunction {
  4962. /** @hidden */
  4963. easeInCore(gradient: number): number;
  4964. }
  4965. /**
  4966. * Easing function with a ease back shape (see link below).
  4967. * @see https://easings.net/#easeInBack
  4968. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4969. */
  4970. export class BackEase extends EasingFunction implements IEasingFunction {
  4971. /** Defines the amplitude of the function */
  4972. amplitude: number;
  4973. /**
  4974. * Instantiates a back ease easing
  4975. * @see https://easings.net/#easeInBack
  4976. * @param amplitude Defines the amplitude of the function
  4977. */
  4978. constructor(
  4979. /** Defines the amplitude of the function */
  4980. amplitude?: number);
  4981. /** @hidden */
  4982. easeInCore(gradient: number): number;
  4983. }
  4984. /**
  4985. * Easing function with a bouncing shape (see link below).
  4986. * @see https://easings.net/#easeInBounce
  4987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4988. */
  4989. export class BounceEase extends EasingFunction implements IEasingFunction {
  4990. /** Defines the number of bounces */
  4991. bounces: number;
  4992. /** Defines the amplitude of the bounce */
  4993. bounciness: number;
  4994. /**
  4995. * Instantiates a bounce easing
  4996. * @see https://easings.net/#easeInBounce
  4997. * @param bounces Defines the number of bounces
  4998. * @param bounciness Defines the amplitude of the bounce
  4999. */
  5000. constructor(
  5001. /** Defines the number of bounces */
  5002. bounces?: number,
  5003. /** Defines the amplitude of the bounce */
  5004. bounciness?: number);
  5005. /** @hidden */
  5006. easeInCore(gradient: number): number;
  5007. }
  5008. /**
  5009. * Easing function with a power of 3 shape (see link below).
  5010. * @see https://easings.net/#easeInCubic
  5011. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5012. */
  5013. export class CubicEase extends EasingFunction implements IEasingFunction {
  5014. /** @hidden */
  5015. easeInCore(gradient: number): number;
  5016. }
  5017. /**
  5018. * Easing function with an elastic shape (see link below).
  5019. * @see https://easings.net/#easeInElastic
  5020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5021. */
  5022. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5023. /** Defines the number of oscillations*/
  5024. oscillations: number;
  5025. /** Defines the amplitude of the oscillations*/
  5026. springiness: number;
  5027. /**
  5028. * Instantiates an elastic easing function
  5029. * @see https://easings.net/#easeInElastic
  5030. * @param oscillations Defines the number of oscillations
  5031. * @param springiness Defines the amplitude of the oscillations
  5032. */
  5033. constructor(
  5034. /** Defines the number of oscillations*/
  5035. oscillations?: number,
  5036. /** Defines the amplitude of the oscillations*/
  5037. springiness?: number);
  5038. /** @hidden */
  5039. easeInCore(gradient: number): number;
  5040. }
  5041. /**
  5042. * Easing function with an exponential shape (see link below).
  5043. * @see https://easings.net/#easeInExpo
  5044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5045. */
  5046. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5047. /** Defines the exponent of the function */
  5048. exponent: number;
  5049. /**
  5050. * Instantiates an exponential easing function
  5051. * @see https://easings.net/#easeInExpo
  5052. * @param exponent Defines the exponent of the function
  5053. */
  5054. constructor(
  5055. /** Defines the exponent of the function */
  5056. exponent?: number);
  5057. /** @hidden */
  5058. easeInCore(gradient: number): number;
  5059. }
  5060. /**
  5061. * Easing function with a power shape (see link below).
  5062. * @see https://easings.net/#easeInQuad
  5063. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5064. */
  5065. export class PowerEase extends EasingFunction implements IEasingFunction {
  5066. /** Defines the power of the function */
  5067. power: number;
  5068. /**
  5069. * Instantiates an power base easing function
  5070. * @see https://easings.net/#easeInQuad
  5071. * @param power Defines the power of the function
  5072. */
  5073. constructor(
  5074. /** Defines the power of the function */
  5075. power?: number);
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a power of 2 shape (see link below).
  5081. * @see https://easings.net/#easeInQuad
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5085. /** @hidden */
  5086. easeInCore(gradient: number): number;
  5087. }
  5088. /**
  5089. * Easing function with a power of 4 shape (see link below).
  5090. * @see https://easings.net/#easeInQuart
  5091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5092. */
  5093. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a power of 5 shape (see link below).
  5099. * @see https://easings.net/#easeInQuint
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with a sin shape (see link below).
  5108. * @see https://easings.net/#easeInSine
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class SineEase extends EasingFunction implements IEasingFunction {
  5112. /** @hidden */
  5113. easeInCore(gradient: number): number;
  5114. }
  5115. /**
  5116. * Easing function with a bezier shape (see link below).
  5117. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5118. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5119. */
  5120. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5121. /** Defines the x component of the start tangent in the bezier curve */
  5122. x1: number;
  5123. /** Defines the y component of the start tangent in the bezier curve */
  5124. y1: number;
  5125. /** Defines the x component of the end tangent in the bezier curve */
  5126. x2: number;
  5127. /** Defines the y component of the end tangent in the bezier curve */
  5128. y2: number;
  5129. /**
  5130. * Instantiates a bezier function
  5131. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5132. * @param x1 Defines the x component of the start tangent in the bezier curve
  5133. * @param y1 Defines the y component of the start tangent in the bezier curve
  5134. * @param x2 Defines the x component of the end tangent in the bezier curve
  5135. * @param y2 Defines the y component of the end tangent in the bezier curve
  5136. */
  5137. constructor(
  5138. /** Defines the x component of the start tangent in the bezier curve */
  5139. x1?: number,
  5140. /** Defines the y component of the start tangent in the bezier curve */
  5141. y1?: number,
  5142. /** Defines the x component of the end tangent in the bezier curve */
  5143. x2?: number,
  5144. /** Defines the y component of the end tangent in the bezier curve */
  5145. y2?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. }
  5150. declare module "babylonjs/Maths/math.color" {
  5151. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5152. /**
  5153. * Class used to hold a RBG color
  5154. */
  5155. export class Color3 {
  5156. /**
  5157. * Defines the red component (between 0 and 1, default is 0)
  5158. */
  5159. r: number;
  5160. /**
  5161. * Defines the green component (between 0 and 1, default is 0)
  5162. */
  5163. g: number;
  5164. /**
  5165. * Defines the blue component (between 0 and 1, default is 0)
  5166. */
  5167. b: number;
  5168. /**
  5169. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5170. * @param r defines the red component (between 0 and 1, default is 0)
  5171. * @param g defines the green component (between 0 and 1, default is 0)
  5172. * @param b defines the blue component (between 0 and 1, default is 0)
  5173. */
  5174. constructor(
  5175. /**
  5176. * Defines the red component (between 0 and 1, default is 0)
  5177. */
  5178. r?: number,
  5179. /**
  5180. * Defines the green component (between 0 and 1, default is 0)
  5181. */
  5182. g?: number,
  5183. /**
  5184. * Defines the blue component (between 0 and 1, default is 0)
  5185. */
  5186. b?: number);
  5187. /**
  5188. * Creates a string with the Color3 current values
  5189. * @returns the string representation of the Color3 object
  5190. */
  5191. toString(): string;
  5192. /**
  5193. * Returns the string "Color3"
  5194. * @returns "Color3"
  5195. */
  5196. getClassName(): string;
  5197. /**
  5198. * Compute the Color3 hash code
  5199. * @returns an unique number that can be used to hash Color3 objects
  5200. */
  5201. getHashCode(): number;
  5202. /**
  5203. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5204. * @param array defines the array where to store the r,g,b components
  5205. * @param index defines an optional index in the target array to define where to start storing values
  5206. * @returns the current Color3 object
  5207. */
  5208. toArray(array: FloatArray, index?: number): Color3;
  5209. /**
  5210. * Returns a new Color4 object from the current Color3 and the given alpha
  5211. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5212. * @returns a new Color4 object
  5213. */
  5214. toColor4(alpha?: number): Color4;
  5215. /**
  5216. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5217. * @returns the new array
  5218. */
  5219. asArray(): number[];
  5220. /**
  5221. * Returns the luminance value
  5222. * @returns a float value
  5223. */
  5224. toLuminance(): number;
  5225. /**
  5226. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5227. * @param otherColor defines the second operand
  5228. * @returns the new Color3 object
  5229. */
  5230. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5231. /**
  5232. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5233. * @param otherColor defines the second operand
  5234. * @param result defines the Color3 object where to store the result
  5235. * @returns the current Color3
  5236. */
  5237. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5238. /**
  5239. * Determines equality between Color3 objects
  5240. * @param otherColor defines the second operand
  5241. * @returns true if the rgb values are equal to the given ones
  5242. */
  5243. equals(otherColor: DeepImmutable<Color3>): boolean;
  5244. /**
  5245. * Determines equality between the current Color3 object and a set of r,b,g values
  5246. * @param r defines the red component to check
  5247. * @param g defines the green component to check
  5248. * @param b defines the blue component to check
  5249. * @returns true if the rgb values are equal to the given ones
  5250. */
  5251. equalsFloats(r: number, g: number, b: number): boolean;
  5252. /**
  5253. * Multiplies in place each rgb value by scale
  5254. * @param scale defines the scaling factor
  5255. * @returns the updated Color3
  5256. */
  5257. scale(scale: number): Color3;
  5258. /**
  5259. * Multiplies the rgb values by scale and stores the result into "result"
  5260. * @param scale defines the scaling factor
  5261. * @param result defines the Color3 object where to store the result
  5262. * @returns the unmodified current Color3
  5263. */
  5264. scaleToRef(scale: number, result: Color3): Color3;
  5265. /**
  5266. * Scale the current Color3 values by a factor and add the result to a given Color3
  5267. * @param scale defines the scale factor
  5268. * @param result defines color to store the result into
  5269. * @returns the unmodified current Color3
  5270. */
  5271. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5272. /**
  5273. * Clamps the rgb values by the min and max values and stores the result into "result"
  5274. * @param min defines minimum clamping value (default is 0)
  5275. * @param max defines maximum clamping value (default is 1)
  5276. * @param result defines color to store the result into
  5277. * @returns the original Color3
  5278. */
  5279. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5280. /**
  5281. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5282. * @param otherColor defines the second operand
  5283. * @returns the new Color3
  5284. */
  5285. add(otherColor: DeepImmutable<Color3>): Color3;
  5286. /**
  5287. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5288. * @param otherColor defines the second operand
  5289. * @param result defines Color3 object to store the result into
  5290. * @returns the unmodified current Color3
  5291. */
  5292. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5293. /**
  5294. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5295. * @param otherColor defines the second operand
  5296. * @returns the new Color3
  5297. */
  5298. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5299. /**
  5300. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5301. * @param otherColor defines the second operand
  5302. * @param result defines Color3 object to store the result into
  5303. * @returns the unmodified current Color3
  5304. */
  5305. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5306. /**
  5307. * Copy the current object
  5308. * @returns a new Color3 copied the current one
  5309. */
  5310. clone(): Color3;
  5311. /**
  5312. * Copies the rgb values from the source in the current Color3
  5313. * @param source defines the source Color3 object
  5314. * @returns the updated Color3 object
  5315. */
  5316. copyFrom(source: DeepImmutable<Color3>): Color3;
  5317. /**
  5318. * Updates the Color3 rgb values from the given floats
  5319. * @param r defines the red component to read from
  5320. * @param g defines the green component to read from
  5321. * @param b defines the blue component to read from
  5322. * @returns the current Color3 object
  5323. */
  5324. copyFromFloats(r: number, g: number, b: number): Color3;
  5325. /**
  5326. * Updates the Color3 rgb values from the given floats
  5327. * @param r defines the red component to read from
  5328. * @param g defines the green component to read from
  5329. * @param b defines the blue component to read from
  5330. * @returns the current Color3 object
  5331. */
  5332. set(r: number, g: number, b: number): Color3;
  5333. /**
  5334. * Compute the Color3 hexadecimal code as a string
  5335. * @returns a string containing the hexadecimal representation of the Color3 object
  5336. */
  5337. toHexString(): string;
  5338. /**
  5339. * Computes a new Color3 converted from the current one to linear space
  5340. * @returns a new Color3 object
  5341. */
  5342. toLinearSpace(): Color3;
  5343. /**
  5344. * Converts current color in rgb space to HSV values
  5345. * @returns a new color3 representing the HSV values
  5346. */
  5347. toHSV(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @param result defines the Color3 where to store the HSV values
  5351. */
  5352. toHSVToRef(result: Color3): void;
  5353. /**
  5354. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5355. * @param convertedColor defines the Color3 object where to store the linear space version
  5356. * @returns the unmodified Color3
  5357. */
  5358. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5359. /**
  5360. * Computes a new Color3 converted from the current one to gamma space
  5361. * @returns a new Color3 object
  5362. */
  5363. toGammaSpace(): Color3;
  5364. /**
  5365. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5366. * @param convertedColor defines the Color3 object where to store the gamma space version
  5367. * @returns the unmodified Color3
  5368. */
  5369. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5370. private static _BlackReadOnly;
  5371. /**
  5372. * Convert Hue, saturation and value to a Color3 (RGB)
  5373. * @param hue defines the hue
  5374. * @param saturation defines the saturation
  5375. * @param value defines the value
  5376. * @param result defines the Color3 where to store the RGB values
  5377. */
  5378. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5379. /**
  5380. * Creates a new Color3 from the string containing valid hexadecimal values
  5381. * @param hex defines a string containing valid hexadecimal values
  5382. * @returns a new Color3 object
  5383. */
  5384. static FromHexString(hex: string): Color3;
  5385. /**
  5386. * Creates a new Color3 from the starting index of the given array
  5387. * @param array defines the source array
  5388. * @param offset defines an offset in the source array
  5389. * @returns a new Color3 object
  5390. */
  5391. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5392. /**
  5393. * Creates a new Color3 from integer values (< 256)
  5394. * @param r defines the red component to read from (value between 0 and 255)
  5395. * @param g defines the green component to read from (value between 0 and 255)
  5396. * @param b defines the blue component to read from (value between 0 and 255)
  5397. * @returns a new Color3 object
  5398. */
  5399. static FromInts(r: number, g: number, b: number): Color3;
  5400. /**
  5401. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5402. * @param start defines the start Color3 value
  5403. * @param end defines the end Color3 value
  5404. * @param amount defines the gradient value between start and end
  5405. * @returns a new Color3 object
  5406. */
  5407. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5408. /**
  5409. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5410. * @param left defines the start value
  5411. * @param right defines the end value
  5412. * @param amount defines the gradient factor
  5413. * @param result defines the Color3 object where to store the result
  5414. */
  5415. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5416. /**
  5417. * Returns a Color3 value containing a red color
  5418. * @returns a new Color3 object
  5419. */
  5420. static Red(): Color3;
  5421. /**
  5422. * Returns a Color3 value containing a green color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Green(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a blue color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Blue(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a black color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Black(): Color3;
  5436. /**
  5437. * Gets a Color3 value containing a black color that must not be updated
  5438. */
  5439. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5440. /**
  5441. * Returns a Color3 value containing a white color
  5442. * @returns a new Color3 object
  5443. */
  5444. static White(): Color3;
  5445. /**
  5446. * Returns a Color3 value containing a purple color
  5447. * @returns a new Color3 object
  5448. */
  5449. static Purple(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a magenta color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Magenta(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a yellow color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Yellow(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a gray color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Gray(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a teal color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Teal(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a random color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Random(): Color3;
  5475. }
  5476. /**
  5477. * Class used to hold a RBGA color
  5478. */
  5479. export class Color4 {
  5480. /**
  5481. * Defines the red component (between 0 and 1, default is 0)
  5482. */
  5483. r: number;
  5484. /**
  5485. * Defines the green component (between 0 and 1, default is 0)
  5486. */
  5487. g: number;
  5488. /**
  5489. * Defines the blue component (between 0 and 1, default is 0)
  5490. */
  5491. b: number;
  5492. /**
  5493. * Defines the alpha component (between 0 and 1, default is 1)
  5494. */
  5495. a: number;
  5496. /**
  5497. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5498. * @param r defines the red component (between 0 and 1, default is 0)
  5499. * @param g defines the green component (between 0 and 1, default is 0)
  5500. * @param b defines the blue component (between 0 and 1, default is 0)
  5501. * @param a defines the alpha component (between 0 and 1, default is 1)
  5502. */
  5503. constructor(
  5504. /**
  5505. * Defines the red component (between 0 and 1, default is 0)
  5506. */
  5507. r?: number,
  5508. /**
  5509. * Defines the green component (between 0 and 1, default is 0)
  5510. */
  5511. g?: number,
  5512. /**
  5513. * Defines the blue component (between 0 and 1, default is 0)
  5514. */
  5515. b?: number,
  5516. /**
  5517. * Defines the alpha component (between 0 and 1, default is 1)
  5518. */
  5519. a?: number);
  5520. /**
  5521. * Adds in place the given Color4 values to the current Color4 object
  5522. * @param right defines the second operand
  5523. * @returns the current updated Color4 object
  5524. */
  5525. addInPlace(right: DeepImmutable<Color4>): Color4;
  5526. /**
  5527. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5528. * @returns the new array
  5529. */
  5530. asArray(): number[];
  5531. /**
  5532. * Stores from the starting index in the given array the Color4 successive values
  5533. * @param array defines the array where to store the r,g,b components
  5534. * @param index defines an optional index in the target array to define where to start storing values
  5535. * @returns the current Color4 object
  5536. */
  5537. toArray(array: number[], index?: number): Color4;
  5538. /**
  5539. * Determines equality between Color4 objects
  5540. * @param otherColor defines the second operand
  5541. * @returns true if the rgba values are equal to the given ones
  5542. */
  5543. equals(otherColor: DeepImmutable<Color4>): boolean;
  5544. /**
  5545. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5546. * @param right defines the second operand
  5547. * @returns a new Color4 object
  5548. */
  5549. add(right: DeepImmutable<Color4>): Color4;
  5550. /**
  5551. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5552. * @param right defines the second operand
  5553. * @returns a new Color4 object
  5554. */
  5555. subtract(right: DeepImmutable<Color4>): Color4;
  5556. /**
  5557. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5558. * @param right defines the second operand
  5559. * @param result defines the Color4 object where to store the result
  5560. * @returns the current Color4 object
  5561. */
  5562. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5563. /**
  5564. * Creates a new Color4 with the current Color4 values multiplied by scale
  5565. * @param scale defines the scaling factor to apply
  5566. * @returns a new Color4 object
  5567. */
  5568. scale(scale: number): Color4;
  5569. /**
  5570. * Multiplies the current Color4 values by scale and stores the result in "result"
  5571. * @param scale defines the scaling factor to apply
  5572. * @param result defines the Color4 object where to store the result
  5573. * @returns the current unmodified Color4
  5574. */
  5575. scaleToRef(scale: number, result: Color4): Color4;
  5576. /**
  5577. * Scale the current Color4 values by a factor and add the result to a given Color4
  5578. * @param scale defines the scale factor
  5579. * @param result defines the Color4 object where to store the result
  5580. * @returns the unmodified current Color4
  5581. */
  5582. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5583. /**
  5584. * Clamps the rgb values by the min and max values and stores the result into "result"
  5585. * @param min defines minimum clamping value (default is 0)
  5586. * @param max defines maximum clamping value (default is 1)
  5587. * @param result defines color to store the result into.
  5588. * @returns the cuurent Color4
  5589. */
  5590. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5591. /**
  5592. * Multipy an Color4 value by another and return a new Color4 object
  5593. * @param color defines the Color4 value to multiply by
  5594. * @returns a new Color4 object
  5595. */
  5596. multiply(color: Color4): Color4;
  5597. /**
  5598. * Multipy a Color4 value by another and push the result in a reference value
  5599. * @param color defines the Color4 value to multiply by
  5600. * @param result defines the Color4 to fill the result in
  5601. * @returns the result Color4
  5602. */
  5603. multiplyToRef(color: Color4, result: Color4): Color4;
  5604. /**
  5605. * Creates a string with the Color4 current values
  5606. * @returns the string representation of the Color4 object
  5607. */
  5608. toString(): string;
  5609. /**
  5610. * Returns the string "Color4"
  5611. * @returns "Color4"
  5612. */
  5613. getClassName(): string;
  5614. /**
  5615. * Compute the Color4 hash code
  5616. * @returns an unique number that can be used to hash Color4 objects
  5617. */
  5618. getHashCode(): number;
  5619. /**
  5620. * Creates a new Color4 copied from the current one
  5621. * @returns a new Color4 object
  5622. */
  5623. clone(): Color4;
  5624. /**
  5625. * Copies the given Color4 values into the current one
  5626. * @param source defines the source Color4 object
  5627. * @returns the current updated Color4 object
  5628. */
  5629. copyFrom(source: Color4): Color4;
  5630. /**
  5631. * Copies the given float values into the current one
  5632. * @param r defines the red component to read from
  5633. * @param g defines the green component to read from
  5634. * @param b defines the blue component to read from
  5635. * @param a defines the alpha component to read from
  5636. * @returns the current updated Color4 object
  5637. */
  5638. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5639. /**
  5640. * Copies the given float values into the current one
  5641. * @param r defines the red component to read from
  5642. * @param g defines the green component to read from
  5643. * @param b defines the blue component to read from
  5644. * @param a defines the alpha component to read from
  5645. * @returns the current updated Color4 object
  5646. */
  5647. set(r: number, g: number, b: number, a: number): Color4;
  5648. /**
  5649. * Compute the Color4 hexadecimal code as a string
  5650. * @returns a string containing the hexadecimal representation of the Color4 object
  5651. */
  5652. toHexString(): string;
  5653. /**
  5654. * Computes a new Color4 converted from the current one to linear space
  5655. * @returns a new Color4 object
  5656. */
  5657. toLinearSpace(): Color4;
  5658. /**
  5659. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5660. * @param convertedColor defines the Color4 object where to store the linear space version
  5661. * @returns the unmodified Color4
  5662. */
  5663. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5664. /**
  5665. * Computes a new Color4 converted from the current one to gamma space
  5666. * @returns a new Color4 object
  5667. */
  5668. toGammaSpace(): Color4;
  5669. /**
  5670. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5671. * @param convertedColor defines the Color4 object where to store the gamma space version
  5672. * @returns the unmodified Color4
  5673. */
  5674. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5675. /**
  5676. * Creates a new Color4 from the string containing valid hexadecimal values
  5677. * @param hex defines a string containing valid hexadecimal values
  5678. * @returns a new Color4 object
  5679. */
  5680. static FromHexString(hex: string): Color4;
  5681. /**
  5682. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5683. * @param left defines the start value
  5684. * @param right defines the end value
  5685. * @param amount defines the gradient factor
  5686. * @returns a new Color4 object
  5687. */
  5688. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5689. /**
  5690. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5691. * @param left defines the start value
  5692. * @param right defines the end value
  5693. * @param amount defines the gradient factor
  5694. * @param result defines the Color4 object where to store data
  5695. */
  5696. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5697. /**
  5698. * Creates a new Color4 from a Color3 and an alpha value
  5699. * @param color3 defines the source Color3 to read from
  5700. * @param alpha defines the alpha component (1.0 by default)
  5701. * @returns a new Color4 object
  5702. */
  5703. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5704. /**
  5705. * Creates a new Color4 from the starting index element of the given array
  5706. * @param array defines the source array to read from
  5707. * @param offset defines the offset in the source array
  5708. * @returns a new Color4 object
  5709. */
  5710. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5711. /**
  5712. * Creates a new Color3 from integer values (< 256)
  5713. * @param r defines the red component to read from (value between 0 and 255)
  5714. * @param g defines the green component to read from (value between 0 and 255)
  5715. * @param b defines the blue component to read from (value between 0 and 255)
  5716. * @param a defines the alpha component to read from (value between 0 and 255)
  5717. * @returns a new Color3 object
  5718. */
  5719. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5720. /**
  5721. * Check the content of a given array and convert it to an array containing RGBA data
  5722. * If the original array was already containing count * 4 values then it is returned directly
  5723. * @param colors defines the array to check
  5724. * @param count defines the number of RGBA data to expect
  5725. * @returns an array containing count * 4 values (RGBA)
  5726. */
  5727. static CheckColors4(colors: number[], count: number): number[];
  5728. }
  5729. /**
  5730. * @hidden
  5731. */
  5732. export class TmpColors {
  5733. static Color3: Color3[];
  5734. static Color4: Color4[];
  5735. }
  5736. }
  5737. declare module "babylonjs/Animations/animationKey" {
  5738. /**
  5739. * Defines an interface which represents an animation key frame
  5740. */
  5741. export interface IAnimationKey {
  5742. /**
  5743. * Frame of the key frame
  5744. */
  5745. frame: number;
  5746. /**
  5747. * Value at the specifies key frame
  5748. */
  5749. value: any;
  5750. /**
  5751. * The input tangent for the cubic hermite spline
  5752. */
  5753. inTangent?: any;
  5754. /**
  5755. * The output tangent for the cubic hermite spline
  5756. */
  5757. outTangent?: any;
  5758. /**
  5759. * The animation interpolation type
  5760. */
  5761. interpolation?: AnimationKeyInterpolation;
  5762. }
  5763. /**
  5764. * Enum for the animation key frame interpolation type
  5765. */
  5766. export enum AnimationKeyInterpolation {
  5767. /**
  5768. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5769. */
  5770. STEP = 1
  5771. }
  5772. }
  5773. declare module "babylonjs/Animations/animationRange" {
  5774. /**
  5775. * Represents the range of an animation
  5776. */
  5777. export class AnimationRange {
  5778. /**The name of the animation range**/
  5779. name: string;
  5780. /**The starting frame of the animation */
  5781. from: number;
  5782. /**The ending frame of the animation*/
  5783. to: number;
  5784. /**
  5785. * Initializes the range of an animation
  5786. * @param name The name of the animation range
  5787. * @param from The starting frame of the animation
  5788. * @param to The ending frame of the animation
  5789. */
  5790. constructor(
  5791. /**The name of the animation range**/
  5792. name: string,
  5793. /**The starting frame of the animation */
  5794. from: number,
  5795. /**The ending frame of the animation*/
  5796. to: number);
  5797. /**
  5798. * Makes a copy of the animation range
  5799. * @returns A copy of the animation range
  5800. */
  5801. clone(): AnimationRange;
  5802. }
  5803. }
  5804. declare module "babylonjs/Animations/animationEvent" {
  5805. /**
  5806. * Composed of a frame, and an action function
  5807. */
  5808. export class AnimationEvent {
  5809. /** The frame for which the event is triggered **/
  5810. frame: number;
  5811. /** The event to perform when triggered **/
  5812. action: (currentFrame: number) => void;
  5813. /** Specifies if the event should be triggered only once**/
  5814. onlyOnce?: boolean | undefined;
  5815. /**
  5816. * Specifies if the animation event is done
  5817. */
  5818. isDone: boolean;
  5819. /**
  5820. * Initializes the animation event
  5821. * @param frame The frame for which the event is triggered
  5822. * @param action The event to perform when triggered
  5823. * @param onlyOnce Specifies if the event should be triggered only once
  5824. */
  5825. constructor(
  5826. /** The frame for which the event is triggered **/
  5827. frame: number,
  5828. /** The event to perform when triggered **/
  5829. action: (currentFrame: number) => void,
  5830. /** Specifies if the event should be triggered only once**/
  5831. onlyOnce?: boolean | undefined);
  5832. /** @hidden */
  5833. _clone(): AnimationEvent;
  5834. }
  5835. }
  5836. declare module "babylonjs/Behaviors/behavior" {
  5837. import { Nullable } from "babylonjs/types";
  5838. /**
  5839. * Interface used to define a behavior
  5840. */
  5841. export interface Behavior<T> {
  5842. /** gets or sets behavior's name */
  5843. name: string;
  5844. /**
  5845. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5846. */
  5847. init(): void;
  5848. /**
  5849. * Called when the behavior is attached to a target
  5850. * @param target defines the target where the behavior is attached to
  5851. */
  5852. attach(target: T): void;
  5853. /**
  5854. * Called when the behavior is detached from its target
  5855. */
  5856. detach(): void;
  5857. }
  5858. /**
  5859. * Interface implemented by classes supporting behaviors
  5860. */
  5861. export interface IBehaviorAware<T> {
  5862. /**
  5863. * Attach a behavior
  5864. * @param behavior defines the behavior to attach
  5865. * @returns the current host
  5866. */
  5867. addBehavior(behavior: Behavior<T>): T;
  5868. /**
  5869. * Remove a behavior from the current object
  5870. * @param behavior defines the behavior to detach
  5871. * @returns the current host
  5872. */
  5873. removeBehavior(behavior: Behavior<T>): T;
  5874. /**
  5875. * Gets a behavior using its name to search
  5876. * @param name defines the name to search
  5877. * @returns the behavior or null if not found
  5878. */
  5879. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5880. }
  5881. }
  5882. declare module "babylonjs/Misc/smartArray" {
  5883. /**
  5884. * Defines an array and its length.
  5885. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5886. */
  5887. export interface ISmartArrayLike<T> {
  5888. /**
  5889. * The data of the array.
  5890. */
  5891. data: Array<T>;
  5892. /**
  5893. * The active length of the array.
  5894. */
  5895. length: number;
  5896. }
  5897. /**
  5898. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5899. */
  5900. export class SmartArray<T> implements ISmartArrayLike<T> {
  5901. /**
  5902. * The full set of data from the array.
  5903. */
  5904. data: Array<T>;
  5905. /**
  5906. * The active length of the array.
  5907. */
  5908. length: number;
  5909. protected _id: number;
  5910. /**
  5911. * Instantiates a Smart Array.
  5912. * @param capacity defines the default capacity of the array.
  5913. */
  5914. constructor(capacity: number);
  5915. /**
  5916. * Pushes a value at the end of the active data.
  5917. * @param value defines the object to push in the array.
  5918. */
  5919. push(value: T): void;
  5920. /**
  5921. * Iterates over the active data and apply the lambda to them.
  5922. * @param func defines the action to apply on each value.
  5923. */
  5924. forEach(func: (content: T) => void): void;
  5925. /**
  5926. * Sorts the full sets of data.
  5927. * @param compareFn defines the comparison function to apply.
  5928. */
  5929. sort(compareFn: (a: T, b: T) => number): void;
  5930. /**
  5931. * Resets the active data to an empty array.
  5932. */
  5933. reset(): void;
  5934. /**
  5935. * Releases all the data from the array as well as the array.
  5936. */
  5937. dispose(): void;
  5938. /**
  5939. * Concats the active data with a given array.
  5940. * @param array defines the data to concatenate with.
  5941. */
  5942. concat(array: any): void;
  5943. /**
  5944. * Returns the position of a value in the active data.
  5945. * @param value defines the value to find the index for
  5946. * @returns the index if found in the active data otherwise -1
  5947. */
  5948. indexOf(value: T): number;
  5949. /**
  5950. * Returns whether an element is part of the active data.
  5951. * @param value defines the value to look for
  5952. * @returns true if found in the active data otherwise false
  5953. */
  5954. contains(value: T): boolean;
  5955. private static _GlobalId;
  5956. }
  5957. /**
  5958. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5959. * The data in this array can only be present once
  5960. */
  5961. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5962. private _duplicateId;
  5963. /**
  5964. * Pushes a value at the end of the active data.
  5965. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5966. * @param value defines the object to push in the array.
  5967. */
  5968. push(value: T): void;
  5969. /**
  5970. * Pushes a value at the end of the active data.
  5971. * If the data is already present, it won t be added again
  5972. * @param value defines the object to push in the array.
  5973. * @returns true if added false if it was already present
  5974. */
  5975. pushNoDuplicate(value: T): boolean;
  5976. /**
  5977. * Resets the active data to an empty array.
  5978. */
  5979. reset(): void;
  5980. /**
  5981. * Concats the active data with a given array.
  5982. * This ensures no dupplicate will be present in the result.
  5983. * @param array defines the data to concatenate with.
  5984. */
  5985. concatWithNoDuplicate(array: any): void;
  5986. }
  5987. }
  5988. declare module "babylonjs/Cameras/cameraInputsManager" {
  5989. import { Nullable } from "babylonjs/types";
  5990. import { Camera } from "babylonjs/Cameras/camera";
  5991. /**
  5992. * @ignore
  5993. * This is a list of all the different input types that are available in the application.
  5994. * Fo instance: ArcRotateCameraGamepadInput...
  5995. */
  5996. export var CameraInputTypes: {};
  5997. /**
  5998. * This is the contract to implement in order to create a new input class.
  5999. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6000. */
  6001. export interface ICameraInput<TCamera extends Camera> {
  6002. /**
  6003. * Defines the camera the input is attached to.
  6004. */
  6005. camera: Nullable<TCamera>;
  6006. /**
  6007. * Gets the class name of the current intput.
  6008. * @returns the class name
  6009. */
  6010. getClassName(): string;
  6011. /**
  6012. * Get the friendly name associated with the input class.
  6013. * @returns the input friendly name
  6014. */
  6015. getSimpleName(): string;
  6016. /**
  6017. * Attach the input controls to a specific dom element to get the input from.
  6018. * @param element Defines the element the controls should be listened from
  6019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6020. */
  6021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6022. /**
  6023. * Detach the current controls from the specified dom element.
  6024. * @param element Defines the element to stop listening the inputs from
  6025. */
  6026. detachControl(element: Nullable<HTMLElement>): void;
  6027. /**
  6028. * Update the current camera state depending on the inputs that have been used this frame.
  6029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6030. */
  6031. checkInputs?: () => void;
  6032. }
  6033. /**
  6034. * Represents a map of input types to input instance or input index to input instance.
  6035. */
  6036. export interface CameraInputsMap<TCamera extends Camera> {
  6037. /**
  6038. * Accessor to the input by input type.
  6039. */
  6040. [name: string]: ICameraInput<TCamera>;
  6041. /**
  6042. * Accessor to the input by input index.
  6043. */
  6044. [idx: number]: ICameraInput<TCamera>;
  6045. }
  6046. /**
  6047. * This represents the input manager used within a camera.
  6048. * It helps dealing with all the different kind of input attached to a camera.
  6049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6050. */
  6051. export class CameraInputsManager<TCamera extends Camera> {
  6052. /**
  6053. * Defines the list of inputs attahed to the camera.
  6054. */
  6055. attached: CameraInputsMap<TCamera>;
  6056. /**
  6057. * Defines the dom element the camera is collecting inputs from.
  6058. * This is null if the controls have not been attached.
  6059. */
  6060. attachedElement: Nullable<HTMLElement>;
  6061. /**
  6062. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6063. */
  6064. noPreventDefault: boolean;
  6065. /**
  6066. * Defined the camera the input manager belongs to.
  6067. */
  6068. camera: TCamera;
  6069. /**
  6070. * Update the current camera state depending on the inputs that have been used this frame.
  6071. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6072. */
  6073. checkInputs: () => void;
  6074. /**
  6075. * Instantiate a new Camera Input Manager.
  6076. * @param camera Defines the camera the input manager blongs to
  6077. */
  6078. constructor(camera: TCamera);
  6079. /**
  6080. * Add an input method to a camera
  6081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6082. * @param input camera input method
  6083. */
  6084. add(input: ICameraInput<TCamera>): void;
  6085. /**
  6086. * Remove a specific input method from a camera
  6087. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6088. * @param inputToRemove camera input method
  6089. */
  6090. remove(inputToRemove: ICameraInput<TCamera>): void;
  6091. /**
  6092. * Remove a specific input type from a camera
  6093. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6094. * @param inputType the type of the input to remove
  6095. */
  6096. removeByType(inputType: string): void;
  6097. private _addCheckInputs;
  6098. /**
  6099. * Attach the input controls to the currently attached dom element to listen the events from.
  6100. * @param input Defines the input to attach
  6101. */
  6102. attachInput(input: ICameraInput<TCamera>): void;
  6103. /**
  6104. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6105. * @param element Defines the dom element to collect the events from
  6106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6107. */
  6108. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6109. /**
  6110. * Detach the current manager inputs controls from a specific dom element.
  6111. * @param element Defines the dom element to collect the events from
  6112. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6113. */
  6114. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6115. /**
  6116. * Rebuild the dynamic inputCheck function from the current list of
  6117. * defined inputs in the manager.
  6118. */
  6119. rebuildInputCheck(): void;
  6120. /**
  6121. * Remove all attached input methods from a camera
  6122. */
  6123. clear(): void;
  6124. /**
  6125. * Serialize the current input manager attached to a camera.
  6126. * This ensures than once parsed,
  6127. * the input associated to the camera will be identical to the current ones
  6128. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6129. */
  6130. serialize(serializedCamera: any): void;
  6131. /**
  6132. * Parses an input manager serialized JSON to restore the previous list of inputs
  6133. * and states associated to a camera.
  6134. * @param parsedCamera Defines the JSON to parse
  6135. */
  6136. parse(parsedCamera: any): void;
  6137. }
  6138. }
  6139. declare module "babylonjs/Meshes/buffer" {
  6140. import { Nullable, DataArray } from "babylonjs/types";
  6141. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6142. /**
  6143. * Class used to store data that will be store in GPU memory
  6144. */
  6145. export class Buffer {
  6146. private _engine;
  6147. private _buffer;
  6148. /** @hidden */
  6149. _data: Nullable<DataArray>;
  6150. private _updatable;
  6151. private _instanced;
  6152. private _divisor;
  6153. /**
  6154. * Gets the byte stride.
  6155. */
  6156. readonly byteStride: number;
  6157. /**
  6158. * Constructor
  6159. * @param engine the engine
  6160. * @param data the data to use for this buffer
  6161. * @param updatable whether the data is updatable
  6162. * @param stride the stride (optional)
  6163. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6164. * @param instanced whether the buffer is instanced (optional)
  6165. * @param useBytes set to true if the stride in in bytes (optional)
  6166. * @param divisor sets an optional divisor for instances (1 by default)
  6167. */
  6168. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6169. /**
  6170. * Create a new VertexBuffer based on the current buffer
  6171. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6172. * @param offset defines offset in the buffer (0 by default)
  6173. * @param size defines the size in floats of attributes (position is 3 for instance)
  6174. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6175. * @param instanced defines if the vertex buffer contains indexed data
  6176. * @param useBytes defines if the offset and stride are in bytes *
  6177. * @param divisor sets an optional divisor for instances (1 by default)
  6178. * @returns the new vertex buffer
  6179. */
  6180. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6181. /**
  6182. * Gets a boolean indicating if the Buffer is updatable?
  6183. * @returns true if the buffer is updatable
  6184. */
  6185. isUpdatable(): boolean;
  6186. /**
  6187. * Gets current buffer's data
  6188. * @returns a DataArray or null
  6189. */
  6190. getData(): Nullable<DataArray>;
  6191. /**
  6192. * Gets underlying native buffer
  6193. * @returns underlying native buffer
  6194. */
  6195. getBuffer(): Nullable<DataBuffer>;
  6196. /**
  6197. * Gets the stride in float32 units (i.e. byte stride / 4).
  6198. * May not be an integer if the byte stride is not divisible by 4.
  6199. * DEPRECATED. Use byteStride instead.
  6200. * @returns the stride in float32 units
  6201. */
  6202. getStrideSize(): number;
  6203. /**
  6204. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6205. * @param data defines the data to store
  6206. */
  6207. create(data?: Nullable<DataArray>): void;
  6208. /** @hidden */
  6209. _rebuild(): void;
  6210. /**
  6211. * Update current buffer data
  6212. * @param data defines the data to store
  6213. */
  6214. update(data: DataArray): void;
  6215. /**
  6216. * Updates the data directly.
  6217. * @param data the new data
  6218. * @param offset the new offset
  6219. * @param vertexCount the vertex count (optional)
  6220. * @param useBytes set to true if the offset is in bytes
  6221. */
  6222. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6223. /**
  6224. * Release all resources
  6225. */
  6226. dispose(): void;
  6227. }
  6228. /**
  6229. * Specialized buffer used to store vertex data
  6230. */
  6231. export class VertexBuffer {
  6232. /** @hidden */
  6233. _buffer: Buffer;
  6234. private _kind;
  6235. private _size;
  6236. private _ownsBuffer;
  6237. private _instanced;
  6238. private _instanceDivisor;
  6239. /**
  6240. * The byte type.
  6241. */
  6242. static readonly BYTE: number;
  6243. /**
  6244. * The unsigned byte type.
  6245. */
  6246. static readonly UNSIGNED_BYTE: number;
  6247. /**
  6248. * The short type.
  6249. */
  6250. static readonly SHORT: number;
  6251. /**
  6252. * The unsigned short type.
  6253. */
  6254. static readonly UNSIGNED_SHORT: number;
  6255. /**
  6256. * The integer type.
  6257. */
  6258. static readonly INT: number;
  6259. /**
  6260. * The unsigned integer type.
  6261. */
  6262. static readonly UNSIGNED_INT: number;
  6263. /**
  6264. * The float type.
  6265. */
  6266. static readonly FLOAT: number;
  6267. /**
  6268. * Gets or sets the instance divisor when in instanced mode
  6269. */
  6270. instanceDivisor: number;
  6271. /**
  6272. * Gets the byte stride.
  6273. */
  6274. readonly byteStride: number;
  6275. /**
  6276. * Gets the byte offset.
  6277. */
  6278. readonly byteOffset: number;
  6279. /**
  6280. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6281. */
  6282. readonly normalized: boolean;
  6283. /**
  6284. * Gets the data type of each component in the array.
  6285. */
  6286. readonly type: number;
  6287. /**
  6288. * Constructor
  6289. * @param engine the engine
  6290. * @param data the data to use for this vertex buffer
  6291. * @param kind the vertex buffer kind
  6292. * @param updatable whether the data is updatable
  6293. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6294. * @param stride the stride (optional)
  6295. * @param instanced whether the buffer is instanced (optional)
  6296. * @param offset the offset of the data (optional)
  6297. * @param size the number of components (optional)
  6298. * @param type the type of the component (optional)
  6299. * @param normalized whether the data contains normalized data (optional)
  6300. * @param useBytes set to true if stride and offset are in bytes (optional)
  6301. * @param divisor defines the instance divisor to use (1 by default)
  6302. */
  6303. 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, divisor?: number);
  6304. /** @hidden */
  6305. _rebuild(): void;
  6306. /**
  6307. * Returns the kind of the VertexBuffer (string)
  6308. * @returns a string
  6309. */
  6310. getKind(): string;
  6311. /**
  6312. * Gets a boolean indicating if the VertexBuffer is updatable?
  6313. * @returns true if the buffer is updatable
  6314. */
  6315. isUpdatable(): boolean;
  6316. /**
  6317. * Gets current buffer's data
  6318. * @returns a DataArray or null
  6319. */
  6320. getData(): Nullable<DataArray>;
  6321. /**
  6322. * Gets underlying native buffer
  6323. * @returns underlying native buffer
  6324. */
  6325. getBuffer(): Nullable<DataBuffer>;
  6326. /**
  6327. * Gets the stride in float32 units (i.e. byte stride / 4).
  6328. * May not be an integer if the byte stride is not divisible by 4.
  6329. * DEPRECATED. Use byteStride instead.
  6330. * @returns the stride in float32 units
  6331. */
  6332. getStrideSize(): number;
  6333. /**
  6334. * Returns the offset as a multiple of the type byte length.
  6335. * DEPRECATED. Use byteOffset instead.
  6336. * @returns the offset in bytes
  6337. */
  6338. getOffset(): number;
  6339. /**
  6340. * Returns the number of components per vertex attribute (integer)
  6341. * @returns the size in float
  6342. */
  6343. getSize(): number;
  6344. /**
  6345. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6346. * @returns true if this buffer is instanced
  6347. */
  6348. getIsInstanced(): boolean;
  6349. /**
  6350. * Returns the instancing divisor, zero for non-instanced (integer).
  6351. * @returns a number
  6352. */
  6353. getInstanceDivisor(): number;
  6354. /**
  6355. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6356. * @param data defines the data to store
  6357. */
  6358. create(data?: DataArray): void;
  6359. /**
  6360. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6361. * This function will create a new buffer if the current one is not updatable
  6362. * @param data defines the data to store
  6363. */
  6364. update(data: DataArray): void;
  6365. /**
  6366. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6367. * Returns the directly updated WebGLBuffer.
  6368. * @param data the new data
  6369. * @param offset the new offset
  6370. * @param useBytes set to true if the offset is in bytes
  6371. */
  6372. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6373. /**
  6374. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6375. */
  6376. dispose(): void;
  6377. /**
  6378. * Enumerates each value of this vertex buffer as numbers.
  6379. * @param count the number of values to enumerate
  6380. * @param callback the callback function called for each value
  6381. */
  6382. forEach(count: number, callback: (value: number, index: number) => void): void;
  6383. /**
  6384. * Positions
  6385. */
  6386. static readonly PositionKind: string;
  6387. /**
  6388. * Normals
  6389. */
  6390. static readonly NormalKind: string;
  6391. /**
  6392. * Tangents
  6393. */
  6394. static readonly TangentKind: string;
  6395. /**
  6396. * Texture coordinates
  6397. */
  6398. static readonly UVKind: string;
  6399. /**
  6400. * Texture coordinates 2
  6401. */
  6402. static readonly UV2Kind: string;
  6403. /**
  6404. * Texture coordinates 3
  6405. */
  6406. static readonly UV3Kind: string;
  6407. /**
  6408. * Texture coordinates 4
  6409. */
  6410. static readonly UV4Kind: string;
  6411. /**
  6412. * Texture coordinates 5
  6413. */
  6414. static readonly UV5Kind: string;
  6415. /**
  6416. * Texture coordinates 6
  6417. */
  6418. static readonly UV6Kind: string;
  6419. /**
  6420. * Colors
  6421. */
  6422. static readonly ColorKind: string;
  6423. /**
  6424. * Matrix indices (for bones)
  6425. */
  6426. static readonly MatricesIndicesKind: string;
  6427. /**
  6428. * Matrix weights (for bones)
  6429. */
  6430. static readonly MatricesWeightsKind: string;
  6431. /**
  6432. * Additional matrix indices (for bones)
  6433. */
  6434. static readonly MatricesIndicesExtraKind: string;
  6435. /**
  6436. * Additional matrix weights (for bones)
  6437. */
  6438. static readonly MatricesWeightsExtraKind: string;
  6439. /**
  6440. * Deduces the stride given a kind.
  6441. * @param kind The kind string to deduce
  6442. * @returns The deduced stride
  6443. */
  6444. static DeduceStride(kind: string): number;
  6445. /**
  6446. * Gets the byte length of the given type.
  6447. * @param type the type
  6448. * @returns the number of bytes
  6449. */
  6450. static GetTypeByteLength(type: number): number;
  6451. /**
  6452. * Enumerates each value of the given parameters as numbers.
  6453. * @param data the data to enumerate
  6454. * @param byteOffset the byte offset of the data
  6455. * @param byteStride the byte stride of the data
  6456. * @param componentCount the number of components per element
  6457. * @param componentType the type of the component
  6458. * @param count the number of values to enumerate
  6459. * @param normalized whether the data is normalized
  6460. * @param callback the callback function called for each value
  6461. */
  6462. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6463. private static _GetFloatValue;
  6464. }
  6465. }
  6466. declare module "babylonjs/Collisions/intersectionInfo" {
  6467. import { Nullable } from "babylonjs/types";
  6468. /**
  6469. * @hidden
  6470. */
  6471. export class IntersectionInfo {
  6472. bu: Nullable<number>;
  6473. bv: Nullable<number>;
  6474. distance: number;
  6475. faceId: number;
  6476. subMeshId: number;
  6477. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6478. }
  6479. }
  6480. declare module "babylonjs/Maths/math.plane" {
  6481. import { DeepImmutable } from "babylonjs/types";
  6482. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6483. /**
  6484. * Represens a plane by the equation ax + by + cz + d = 0
  6485. */
  6486. export class Plane {
  6487. private static _TmpMatrix;
  6488. /**
  6489. * Normal of the plane (a,b,c)
  6490. */
  6491. normal: Vector3;
  6492. /**
  6493. * d component of the plane
  6494. */
  6495. d: number;
  6496. /**
  6497. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6498. * @param a a component of the plane
  6499. * @param b b component of the plane
  6500. * @param c c component of the plane
  6501. * @param d d component of the plane
  6502. */
  6503. constructor(a: number, b: number, c: number, d: number);
  6504. /**
  6505. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6506. */
  6507. asArray(): number[];
  6508. /**
  6509. * @returns a new plane copied from the current Plane.
  6510. */
  6511. clone(): Plane;
  6512. /**
  6513. * @returns the string "Plane".
  6514. */
  6515. getClassName(): string;
  6516. /**
  6517. * @returns the Plane hash code.
  6518. */
  6519. getHashCode(): number;
  6520. /**
  6521. * Normalize the current Plane in place.
  6522. * @returns the updated Plane.
  6523. */
  6524. normalize(): Plane;
  6525. /**
  6526. * Applies a transformation the plane and returns the result
  6527. * @param transformation the transformation matrix to be applied to the plane
  6528. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6529. */
  6530. transform(transformation: DeepImmutable<Matrix>): Plane;
  6531. /**
  6532. * Calcualtte the dot product between the point and the plane normal
  6533. * @param point point to calculate the dot product with
  6534. * @returns the dot product (float) of the point coordinates and the plane normal.
  6535. */
  6536. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6537. /**
  6538. * Updates the current Plane from the plane defined by the three given points.
  6539. * @param point1 one of the points used to contruct the plane
  6540. * @param point2 one of the points used to contruct the plane
  6541. * @param point3 one of the points used to contruct the plane
  6542. * @returns the updated Plane.
  6543. */
  6544. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6545. /**
  6546. * Checks if the plane is facing a given direction
  6547. * @param direction the direction to check if the plane is facing
  6548. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6549. * @returns True is the vector "direction" is the same side than the plane normal.
  6550. */
  6551. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6552. /**
  6553. * Calculates the distance to a point
  6554. * @param point point to calculate distance to
  6555. * @returns the signed distance (float) from the given point to the Plane.
  6556. */
  6557. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6558. /**
  6559. * Creates a plane from an array
  6560. * @param array the array to create a plane from
  6561. * @returns a new Plane from the given array.
  6562. */
  6563. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6564. /**
  6565. * Creates a plane from three points
  6566. * @param point1 point used to create the plane
  6567. * @param point2 point used to create the plane
  6568. * @param point3 point used to create the plane
  6569. * @returns a new Plane defined by the three given points.
  6570. */
  6571. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6572. /**
  6573. * Creates a plane from an origin point and a normal
  6574. * @param origin origin of the plane to be constructed
  6575. * @param normal normal of the plane to be constructed
  6576. * @returns a new Plane the normal vector to this plane at the given origin point.
  6577. * Note : the vector "normal" is updated because normalized.
  6578. */
  6579. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6580. /**
  6581. * Calculates the distance from a plane and a point
  6582. * @param origin origin of the plane to be constructed
  6583. * @param normal normal of the plane to be constructed
  6584. * @param point point to calculate distance to
  6585. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6586. */
  6587. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6588. }
  6589. }
  6590. declare module "babylonjs/Culling/boundingSphere" {
  6591. import { DeepImmutable } from "babylonjs/types";
  6592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6593. import { Plane } from "babylonjs/Maths/math.plane";
  6594. /**
  6595. * Class used to store bounding sphere information
  6596. */
  6597. export class BoundingSphere {
  6598. /**
  6599. * Gets the center of the bounding sphere in local space
  6600. */
  6601. readonly center: Vector3;
  6602. /**
  6603. * Radius of the bounding sphere in local space
  6604. */
  6605. radius: number;
  6606. /**
  6607. * Gets the center of the bounding sphere in world space
  6608. */
  6609. readonly centerWorld: Vector3;
  6610. /**
  6611. * Radius of the bounding sphere in world space
  6612. */
  6613. radiusWorld: number;
  6614. /**
  6615. * Gets the minimum vector in local space
  6616. */
  6617. readonly minimum: Vector3;
  6618. /**
  6619. * Gets the maximum vector in local space
  6620. */
  6621. readonly maximum: Vector3;
  6622. private _worldMatrix;
  6623. private static readonly TmpVector3;
  6624. /**
  6625. * Creates a new bounding sphere
  6626. * @param min defines the minimum vector (in local space)
  6627. * @param max defines the maximum vector (in local space)
  6628. * @param worldMatrix defines the new world matrix
  6629. */
  6630. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6631. /**
  6632. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6633. * @param min defines the new minimum vector (in local space)
  6634. * @param max defines the new maximum vector (in local space)
  6635. * @param worldMatrix defines the new world matrix
  6636. */
  6637. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6638. /**
  6639. * Scale the current bounding sphere by applying a scale factor
  6640. * @param factor defines the scale factor to apply
  6641. * @returns the current bounding box
  6642. */
  6643. scale(factor: number): BoundingSphere;
  6644. /**
  6645. * Gets the world matrix of the bounding box
  6646. * @returns a matrix
  6647. */
  6648. getWorldMatrix(): DeepImmutable<Matrix>;
  6649. /** @hidden */
  6650. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6651. /**
  6652. * Tests if the bounding sphere is intersecting the frustum planes
  6653. * @param frustumPlanes defines the frustum planes to test
  6654. * @returns true if there is an intersection
  6655. */
  6656. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6657. /**
  6658. * Tests if the bounding sphere center is in between the frustum planes.
  6659. * Used for optimistic fast inclusion.
  6660. * @param frustumPlanes defines the frustum planes to test
  6661. * @returns true if the sphere center is in between the frustum planes
  6662. */
  6663. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6664. /**
  6665. * Tests if a point is inside the bounding sphere
  6666. * @param point defines the point to test
  6667. * @returns true if the point is inside the bounding sphere
  6668. */
  6669. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6670. /**
  6671. * Checks if two sphere intersct
  6672. * @param sphere0 sphere 0
  6673. * @param sphere1 sphere 1
  6674. * @returns true if the speres intersect
  6675. */
  6676. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6677. }
  6678. }
  6679. declare module "babylonjs/Culling/boundingBox" {
  6680. import { DeepImmutable } from "babylonjs/types";
  6681. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6682. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6683. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6684. import { Plane } from "babylonjs/Maths/math.plane";
  6685. /**
  6686. * Class used to store bounding box information
  6687. */
  6688. export class BoundingBox implements ICullable {
  6689. /**
  6690. * Gets the 8 vectors representing the bounding box in local space
  6691. */
  6692. readonly vectors: Vector3[];
  6693. /**
  6694. * Gets the center of the bounding box in local space
  6695. */
  6696. readonly center: Vector3;
  6697. /**
  6698. * Gets the center of the bounding box in world space
  6699. */
  6700. readonly centerWorld: Vector3;
  6701. /**
  6702. * Gets the extend size in local space
  6703. */
  6704. readonly extendSize: Vector3;
  6705. /**
  6706. * Gets the extend size in world space
  6707. */
  6708. readonly extendSizeWorld: Vector3;
  6709. /**
  6710. * Gets the OBB (object bounding box) directions
  6711. */
  6712. readonly directions: Vector3[];
  6713. /**
  6714. * Gets the 8 vectors representing the bounding box in world space
  6715. */
  6716. readonly vectorsWorld: Vector3[];
  6717. /**
  6718. * Gets the minimum vector in world space
  6719. */
  6720. readonly minimumWorld: Vector3;
  6721. /**
  6722. * Gets the maximum vector in world space
  6723. */
  6724. readonly maximumWorld: Vector3;
  6725. /**
  6726. * Gets the minimum vector in local space
  6727. */
  6728. readonly minimum: Vector3;
  6729. /**
  6730. * Gets the maximum vector in local space
  6731. */
  6732. readonly maximum: Vector3;
  6733. private _worldMatrix;
  6734. private static readonly TmpVector3;
  6735. /**
  6736. * @hidden
  6737. */
  6738. _tag: number;
  6739. /**
  6740. * Creates a new bounding box
  6741. * @param min defines the minimum vector (in local space)
  6742. * @param max defines the maximum vector (in local space)
  6743. * @param worldMatrix defines the new world matrix
  6744. */
  6745. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6746. /**
  6747. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6748. * @param min defines the new minimum vector (in local space)
  6749. * @param max defines the new maximum vector (in local space)
  6750. * @param worldMatrix defines the new world matrix
  6751. */
  6752. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6753. /**
  6754. * Scale the current bounding box by applying a scale factor
  6755. * @param factor defines the scale factor to apply
  6756. * @returns the current bounding box
  6757. */
  6758. scale(factor: number): BoundingBox;
  6759. /**
  6760. * Gets the world matrix of the bounding box
  6761. * @returns a matrix
  6762. */
  6763. getWorldMatrix(): DeepImmutable<Matrix>;
  6764. /** @hidden */
  6765. _update(world: DeepImmutable<Matrix>): void;
  6766. /**
  6767. * Tests if the bounding box is intersecting the frustum planes
  6768. * @param frustumPlanes defines the frustum planes to test
  6769. * @returns true if there is an intersection
  6770. */
  6771. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6772. /**
  6773. * Tests if the bounding box is entirely inside the frustum planes
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if there is an inclusion
  6776. */
  6777. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding box
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding box
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Tests if the bounding box intersects with a bounding sphere
  6786. * @param sphere defines the sphere to test
  6787. * @returns true if there is an intersection
  6788. */
  6789. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6790. /**
  6791. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6792. * @param min defines the min vector to use
  6793. * @param max defines the max vector to use
  6794. * @returns true if there is an intersection
  6795. */
  6796. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6797. /**
  6798. * Tests if two bounding boxes are intersections
  6799. * @param box0 defines the first box to test
  6800. * @param box1 defines the second box to test
  6801. * @returns true if there is an intersection
  6802. */
  6803. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6804. /**
  6805. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6806. * @param minPoint defines the minimum vector of the bounding box
  6807. * @param maxPoint defines the maximum vector of the bounding box
  6808. * @param sphereCenter defines the sphere center
  6809. * @param sphereRadius defines the sphere radius
  6810. * @returns true if there is an intersection
  6811. */
  6812. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6813. /**
  6814. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6815. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6816. * @param frustumPlanes defines the frustum planes to test
  6817. * @return true if there is an inclusion
  6818. */
  6819. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6820. /**
  6821. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6822. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6823. * @param frustumPlanes defines the frustum planes to test
  6824. * @return true if there is an intersection
  6825. */
  6826. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6827. }
  6828. }
  6829. declare module "babylonjs/Collisions/collider" {
  6830. import { Nullable, IndicesArray } from "babylonjs/types";
  6831. import { Vector3 } from "babylonjs/Maths/math.vector";
  6832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6833. import { Plane } from "babylonjs/Maths/math.plane";
  6834. /** @hidden */
  6835. export class Collider {
  6836. /** Define if a collision was found */
  6837. collisionFound: boolean;
  6838. /**
  6839. * Define last intersection point in local space
  6840. */
  6841. intersectionPoint: Vector3;
  6842. /**
  6843. * Define last collided mesh
  6844. */
  6845. collidedMesh: Nullable<AbstractMesh>;
  6846. private _collisionPoint;
  6847. private _planeIntersectionPoint;
  6848. private _tempVector;
  6849. private _tempVector2;
  6850. private _tempVector3;
  6851. private _tempVector4;
  6852. private _edge;
  6853. private _baseToVertex;
  6854. private _destinationPoint;
  6855. private _slidePlaneNormal;
  6856. private _displacementVector;
  6857. /** @hidden */
  6858. _radius: Vector3;
  6859. /** @hidden */
  6860. _retry: number;
  6861. private _velocity;
  6862. private _basePoint;
  6863. private _epsilon;
  6864. /** @hidden */
  6865. _velocityWorldLength: number;
  6866. /** @hidden */
  6867. _basePointWorld: Vector3;
  6868. private _velocityWorld;
  6869. private _normalizedVelocity;
  6870. /** @hidden */
  6871. _initialVelocity: Vector3;
  6872. /** @hidden */
  6873. _initialPosition: Vector3;
  6874. private _nearestDistance;
  6875. private _collisionMask;
  6876. collisionMask: number;
  6877. /**
  6878. * Gets the plane normal used to compute the sliding response (in local space)
  6879. */
  6880. readonly slidePlaneNormal: Vector3;
  6881. /** @hidden */
  6882. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6883. /** @hidden */
  6884. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6885. /** @hidden */
  6886. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6887. /** @hidden */
  6888. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6889. /** @hidden */
  6890. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6891. /** @hidden */
  6892. _getResponse(pos: Vector3, vel: Vector3): void;
  6893. }
  6894. }
  6895. declare module "babylonjs/Culling/boundingInfo" {
  6896. import { DeepImmutable } from "babylonjs/types";
  6897. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6898. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6899. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6900. import { Plane } from "babylonjs/Maths/math.plane";
  6901. import { Collider } from "babylonjs/Collisions/collider";
  6902. /**
  6903. * Interface for cullable objects
  6904. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6905. */
  6906. export interface ICullable {
  6907. /**
  6908. * Checks if the object or part of the object is in the frustum
  6909. * @param frustumPlanes Camera near/planes
  6910. * @returns true if the object is in frustum otherwise false
  6911. */
  6912. isInFrustum(frustumPlanes: Plane[]): boolean;
  6913. /**
  6914. * Checks if a cullable object (mesh...) is in the camera frustum
  6915. * Unlike isInFrustum this cheks the full bounding box
  6916. * @param frustumPlanes Camera near/planes
  6917. * @returns true if the object is in frustum otherwise false
  6918. */
  6919. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6920. }
  6921. /**
  6922. * Info for a bounding data of a mesh
  6923. */
  6924. export class BoundingInfo implements ICullable {
  6925. /**
  6926. * Bounding box for the mesh
  6927. */
  6928. readonly boundingBox: BoundingBox;
  6929. /**
  6930. * Bounding sphere for the mesh
  6931. */
  6932. readonly boundingSphere: BoundingSphere;
  6933. private _isLocked;
  6934. private static readonly TmpVector3;
  6935. /**
  6936. * Constructs bounding info
  6937. * @param minimum min vector of the bounding box/sphere
  6938. * @param maximum max vector of the bounding box/sphere
  6939. * @param worldMatrix defines the new world matrix
  6940. */
  6941. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6942. /**
  6943. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6944. * @param min defines the new minimum vector (in local space)
  6945. * @param max defines the new maximum vector (in local space)
  6946. * @param worldMatrix defines the new world matrix
  6947. */
  6948. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6949. /**
  6950. * min vector of the bounding box/sphere
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * max vector of the bounding box/sphere
  6955. */
  6956. readonly maximum: Vector3;
  6957. /**
  6958. * If the info is locked and won't be updated to avoid perf overhead
  6959. */
  6960. isLocked: boolean;
  6961. /**
  6962. * Updates the bounding sphere and box
  6963. * @param world world matrix to be used to update
  6964. */
  6965. update(world: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6968. * @param center New center of the bounding info
  6969. * @param extend New extend of the bounding info
  6970. * @returns the current bounding info
  6971. */
  6972. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6973. /**
  6974. * Scale the current bounding info by applying a scale factor
  6975. * @param factor defines the scale factor to apply
  6976. * @returns the current bounding info
  6977. */
  6978. scale(factor: number): BoundingInfo;
  6979. /**
  6980. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6981. * @param frustumPlanes defines the frustum to test
  6982. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6983. * @returns true if the bounding info is in the frustum planes
  6984. */
  6985. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6986. /**
  6987. * Gets the world distance between the min and max points of the bounding box
  6988. */
  6989. readonly diagonalLength: number;
  6990. /**
  6991. * Checks if a cullable object (mesh...) is in the camera frustum
  6992. * Unlike isInFrustum this cheks the full bounding box
  6993. * @param frustumPlanes Camera near/planes
  6994. * @returns true if the object is in frustum otherwise false
  6995. */
  6996. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6997. /** @hidden */
  6998. _checkCollision(collider: Collider): boolean;
  6999. /**
  7000. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7001. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7002. * @param point the point to check intersection with
  7003. * @returns if the point intersects
  7004. */
  7005. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7006. /**
  7007. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7008. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7009. * @param boundingInfo the bounding info to check intersection with
  7010. * @param precise if the intersection should be done using OBB
  7011. * @returns if the bounding info intersects
  7012. */
  7013. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7014. }
  7015. }
  7016. declare module "babylonjs/Maths/math.functions" {
  7017. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7018. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7019. /**
  7020. * Extracts minimum and maximum values from a list of indexed positions
  7021. * @param positions defines the positions to use
  7022. * @param indices defines the indices to the positions
  7023. * @param indexStart defines the start index
  7024. * @param indexCount defines the end index
  7025. * @param bias defines bias value to add to the result
  7026. * @return minimum and maximum values
  7027. */
  7028. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7029. minimum: Vector3;
  7030. maximum: Vector3;
  7031. };
  7032. /**
  7033. * Extracts minimum and maximum values from a list of positions
  7034. * @param positions defines the positions to use
  7035. * @param start defines the start index in the positions array
  7036. * @param count defines the number of positions to handle
  7037. * @param bias defines bias value to add to the result
  7038. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7039. * @return minimum and maximum values
  7040. */
  7041. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7042. minimum: Vector3;
  7043. maximum: Vector3;
  7044. };
  7045. }
  7046. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7047. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7048. /** @hidden */
  7049. export class WebGLDataBuffer extends DataBuffer {
  7050. private _buffer;
  7051. constructor(resource: WebGLBuffer);
  7052. readonly underlyingResource: any;
  7053. }
  7054. }
  7055. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7056. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7057. import { Nullable } from "babylonjs/types";
  7058. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7059. /** @hidden */
  7060. export class WebGLPipelineContext implements IPipelineContext {
  7061. engine: ThinEngine;
  7062. program: Nullable<WebGLProgram>;
  7063. context?: WebGLRenderingContext;
  7064. vertexShader?: WebGLShader;
  7065. fragmentShader?: WebGLShader;
  7066. isParallelCompiled: boolean;
  7067. onCompiled?: () => void;
  7068. transformFeedback?: WebGLTransformFeedback | null;
  7069. readonly isAsync: boolean;
  7070. readonly isReady: boolean;
  7071. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7072. }
  7073. }
  7074. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7075. import { FloatArray, Nullable } from "babylonjs/types";
  7076. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7078. module "babylonjs/Engines/thinEngine" {
  7079. interface ThinEngine {
  7080. /**
  7081. * Create an uniform buffer
  7082. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7083. * @param elements defines the content of the uniform buffer
  7084. * @returns the webGL uniform buffer
  7085. */
  7086. createUniformBuffer(elements: FloatArray): DataBuffer;
  7087. /**
  7088. * Create a dynamic uniform buffer
  7089. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7090. * @param elements defines the content of the uniform buffer
  7091. * @returns the webGL uniform buffer
  7092. */
  7093. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7094. /**
  7095. * Update an existing uniform buffer
  7096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7097. * @param uniformBuffer defines the target uniform buffer
  7098. * @param elements defines the content to update
  7099. * @param offset defines the offset in the uniform buffer where update should start
  7100. * @param count defines the size of the data to update
  7101. */
  7102. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7103. /**
  7104. * Bind an uniform buffer to the current webGL context
  7105. * @param buffer defines the buffer to bind
  7106. */
  7107. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7108. /**
  7109. * Bind a buffer to the current webGL context at a given location
  7110. * @param buffer defines the buffer to bind
  7111. * @param location defines the index where to bind the buffer
  7112. */
  7113. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7114. /**
  7115. * Bind a specific block at a given index in a specific shader program
  7116. * @param pipelineContext defines the pipeline context to use
  7117. * @param blockName defines the block name
  7118. * @param index defines the index where to bind the block
  7119. */
  7120. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7121. }
  7122. }
  7123. }
  7124. declare module "babylonjs/Materials/uniformBuffer" {
  7125. import { Nullable, FloatArray } from "babylonjs/types";
  7126. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7127. import { Engine } from "babylonjs/Engines/engine";
  7128. import { Effect } from "babylonjs/Materials/effect";
  7129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7130. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7131. import { Color3 } from "babylonjs/Maths/math.color";
  7132. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7133. /**
  7134. * Uniform buffer objects.
  7135. *
  7136. * Handles blocks of uniform on the GPU.
  7137. *
  7138. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7139. *
  7140. * For more information, please refer to :
  7141. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7142. */
  7143. export class UniformBuffer {
  7144. private _engine;
  7145. private _buffer;
  7146. private _data;
  7147. private _bufferData;
  7148. private _dynamic?;
  7149. private _uniformLocations;
  7150. private _uniformSizes;
  7151. private _uniformLocationPointer;
  7152. private _needSync;
  7153. private _noUBO;
  7154. private _currentEffect;
  7155. /** @hidden */
  7156. _alreadyBound: boolean;
  7157. private static _MAX_UNIFORM_SIZE;
  7158. private static _tempBuffer;
  7159. /**
  7160. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7161. * This is dynamic to allow compat with webgl 1 and 2.
  7162. * You will need to pass the name of the uniform as well as the value.
  7163. */
  7164. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7165. /**
  7166. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7167. * This is dynamic to allow compat with webgl 1 and 2.
  7168. * You will need to pass the name of the uniform as well as the value.
  7169. */
  7170. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7171. /**
  7172. * Lambda to Update a single float in a uniform buffer.
  7173. * This is dynamic to allow compat with webgl 1 and 2.
  7174. * You will need to pass the name of the uniform as well as the value.
  7175. */
  7176. updateFloat: (name: string, x: number) => void;
  7177. /**
  7178. * Lambda to Update a vec2 of float in a uniform buffer.
  7179. * This is dynamic to allow compat with webgl 1 and 2.
  7180. * You will need to pass the name of the uniform as well as the value.
  7181. */
  7182. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7183. /**
  7184. * Lambda to Update a vec3 of float in a uniform buffer.
  7185. * This is dynamic to allow compat with webgl 1 and 2.
  7186. * You will need to pass the name of the uniform as well as the value.
  7187. */
  7188. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7189. /**
  7190. * Lambda to Update a vec4 of float in a uniform buffer.
  7191. * This is dynamic to allow compat with webgl 1 and 2.
  7192. * You will need to pass the name of the uniform as well as the value.
  7193. */
  7194. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7195. /**
  7196. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7197. * This is dynamic to allow compat with webgl 1 and 2.
  7198. * You will need to pass the name of the uniform as well as the value.
  7199. */
  7200. updateMatrix: (name: string, mat: Matrix) => void;
  7201. /**
  7202. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7203. * This is dynamic to allow compat with webgl 1 and 2.
  7204. * You will need to pass the name of the uniform as well as the value.
  7205. */
  7206. updateVector3: (name: string, vector: Vector3) => void;
  7207. /**
  7208. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7209. * This is dynamic to allow compat with webgl 1 and 2.
  7210. * You will need to pass the name of the uniform as well as the value.
  7211. */
  7212. updateVector4: (name: string, vector: Vector4) => void;
  7213. /**
  7214. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7215. * This is dynamic to allow compat with webgl 1 and 2.
  7216. * You will need to pass the name of the uniform as well as the value.
  7217. */
  7218. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7219. /**
  7220. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7221. * This is dynamic to allow compat with webgl 1 and 2.
  7222. * You will need to pass the name of the uniform as well as the value.
  7223. */
  7224. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7225. /**
  7226. * Instantiates a new Uniform buffer objects.
  7227. *
  7228. * Handles blocks of uniform on the GPU.
  7229. *
  7230. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7231. *
  7232. * For more information, please refer to :
  7233. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7234. * @param engine Define the engine the buffer is associated with
  7235. * @param data Define the data contained in the buffer
  7236. * @param dynamic Define if the buffer is updatable
  7237. */
  7238. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7239. /**
  7240. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7241. * or just falling back on setUniformXXX calls.
  7242. */
  7243. readonly useUbo: boolean;
  7244. /**
  7245. * Indicates if the WebGL underlying uniform buffer is in sync
  7246. * with the javascript cache data.
  7247. */
  7248. readonly isSync: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7251. * Also, a dynamic UniformBuffer will disable cache verification and always
  7252. * update the underlying WebGL uniform buffer to the GPU.
  7253. * @returns if Dynamic, otherwise false
  7254. */
  7255. isDynamic(): boolean;
  7256. /**
  7257. * The data cache on JS side.
  7258. * @returns the underlying data as a float array
  7259. */
  7260. getData(): Float32Array;
  7261. /**
  7262. * The underlying WebGL Uniform buffer.
  7263. * @returns the webgl buffer
  7264. */
  7265. getBuffer(): Nullable<DataBuffer>;
  7266. /**
  7267. * std140 layout specifies how to align data within an UBO structure.
  7268. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7269. * for specs.
  7270. */
  7271. private _fillAlignment;
  7272. /**
  7273. * Adds an uniform in the buffer.
  7274. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7275. * for the layout to be correct !
  7276. * @param name Name of the uniform, as used in the uniform block in the shader.
  7277. * @param size Data size, or data directly.
  7278. */
  7279. addUniform(name: string, size: number | number[]): void;
  7280. /**
  7281. * Adds a Matrix 4x4 to the uniform buffer.
  7282. * @param name Name of the uniform, as used in the uniform block in the shader.
  7283. * @param mat A 4x4 matrix.
  7284. */
  7285. addMatrix(name: string, mat: Matrix): void;
  7286. /**
  7287. * Adds a vec2 to the uniform buffer.
  7288. * @param name Name of the uniform, as used in the uniform block in the shader.
  7289. * @param x Define the x component value of the vec2
  7290. * @param y Define the y component value of the vec2
  7291. */
  7292. addFloat2(name: string, x: number, y: number): void;
  7293. /**
  7294. * Adds a vec3 to the uniform buffer.
  7295. * @param name Name of the uniform, as used in the uniform block in the shader.
  7296. * @param x Define the x component value of the vec3
  7297. * @param y Define the y component value of the vec3
  7298. * @param z Define the z component value of the vec3
  7299. */
  7300. addFloat3(name: string, x: number, y: number, z: number): void;
  7301. /**
  7302. * Adds a vec3 to the uniform buffer.
  7303. * @param name Name of the uniform, as used in the uniform block in the shader.
  7304. * @param color Define the vec3 from a Color
  7305. */
  7306. addColor3(name: string, color: Color3): void;
  7307. /**
  7308. * Adds a vec4 to the uniform buffer.
  7309. * @param name Name of the uniform, as used in the uniform block in the shader.
  7310. * @param color Define the rgb components from a Color
  7311. * @param alpha Define the a component of the vec4
  7312. */
  7313. addColor4(name: string, color: Color3, alpha: number): void;
  7314. /**
  7315. * Adds a vec3 to the uniform buffer.
  7316. * @param name Name of the uniform, as used in the uniform block in the shader.
  7317. * @param vector Define the vec3 components from a Vector
  7318. */
  7319. addVector3(name: string, vector: Vector3): void;
  7320. /**
  7321. * Adds a Matrix 3x3 to the uniform buffer.
  7322. * @param name Name of the uniform, as used in the uniform block in the shader.
  7323. */
  7324. addMatrix3x3(name: string): void;
  7325. /**
  7326. * Adds a Matrix 2x2 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix2x2(name: string): void;
  7330. /**
  7331. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7332. */
  7333. create(): void;
  7334. /** @hidden */
  7335. _rebuild(): void;
  7336. /**
  7337. * Updates the WebGL Uniform Buffer on the GPU.
  7338. * If the `dynamic` flag is set to true, no cache comparison is done.
  7339. * Otherwise, the buffer will be updated only if the cache differs.
  7340. */
  7341. update(): void;
  7342. /**
  7343. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7344. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7345. * @param data Define the flattened data
  7346. * @param size Define the size of the data.
  7347. */
  7348. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7349. private _valueCache;
  7350. private _cacheMatrix;
  7351. private _updateMatrix3x3ForUniform;
  7352. private _updateMatrix3x3ForEffect;
  7353. private _updateMatrix2x2ForEffect;
  7354. private _updateMatrix2x2ForUniform;
  7355. private _updateFloatForEffect;
  7356. private _updateFloatForUniform;
  7357. private _updateFloat2ForEffect;
  7358. private _updateFloat2ForUniform;
  7359. private _updateFloat3ForEffect;
  7360. private _updateFloat3ForUniform;
  7361. private _updateFloat4ForEffect;
  7362. private _updateFloat4ForUniform;
  7363. private _updateMatrixForEffect;
  7364. private _updateMatrixForUniform;
  7365. private _updateVector3ForEffect;
  7366. private _updateVector3ForUniform;
  7367. private _updateVector4ForEffect;
  7368. private _updateVector4ForUniform;
  7369. private _updateColor3ForEffect;
  7370. private _updateColor3ForUniform;
  7371. private _updateColor4ForEffect;
  7372. private _updateColor4ForUniform;
  7373. /**
  7374. * Sets a sampler uniform on the effect.
  7375. * @param name Define the name of the sampler.
  7376. * @param texture Define the texture to set in the sampler
  7377. */
  7378. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7379. /**
  7380. * Directly updates the value of the uniform in the cache AND on the GPU.
  7381. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7382. * @param data Define the flattened data
  7383. */
  7384. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7385. /**
  7386. * Binds this uniform buffer to an effect.
  7387. * @param effect Define the effect to bind the buffer to
  7388. * @param name Name of the uniform block in the shader.
  7389. */
  7390. bindToEffect(effect: Effect, name: string): void;
  7391. /**
  7392. * Disposes the uniform buffer.
  7393. */
  7394. dispose(): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/iInspectable" {
  7398. /**
  7399. * Enum that determines the text-wrapping mode to use.
  7400. */
  7401. export enum InspectableType {
  7402. /**
  7403. * Checkbox for booleans
  7404. */
  7405. Checkbox = 0,
  7406. /**
  7407. * Sliders for numbers
  7408. */
  7409. Slider = 1,
  7410. /**
  7411. * Vector3
  7412. */
  7413. Vector3 = 2,
  7414. /**
  7415. * Quaternions
  7416. */
  7417. Quaternion = 3,
  7418. /**
  7419. * Color3
  7420. */
  7421. Color3 = 4,
  7422. /**
  7423. * String
  7424. */
  7425. String = 5
  7426. }
  7427. /**
  7428. * Interface used to define custom inspectable properties.
  7429. * This interface is used by the inspector to display custom property grids
  7430. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7431. */
  7432. export interface IInspectable {
  7433. /**
  7434. * Gets the label to display
  7435. */
  7436. label: string;
  7437. /**
  7438. * Gets the name of the property to edit
  7439. */
  7440. propertyName: string;
  7441. /**
  7442. * Gets the type of the editor to use
  7443. */
  7444. type: InspectableType;
  7445. /**
  7446. * Gets the minimum value of the property when using in "slider" mode
  7447. */
  7448. min?: number;
  7449. /**
  7450. * Gets the maximum value of the property when using in "slider" mode
  7451. */
  7452. max?: number;
  7453. /**
  7454. * Gets the setp to use when using in "slider" mode
  7455. */
  7456. step?: number;
  7457. }
  7458. }
  7459. declare module "babylonjs/Misc/timingTools" {
  7460. /**
  7461. * Class used to provide helper for timing
  7462. */
  7463. export class TimingTools {
  7464. /**
  7465. * Polyfill for setImmediate
  7466. * @param action defines the action to execute after the current execution block
  7467. */
  7468. static SetImmediate(action: () => void): void;
  7469. }
  7470. }
  7471. declare module "babylonjs/Misc/instantiationTools" {
  7472. /**
  7473. * Class used to enable instatition of objects by class name
  7474. */
  7475. export class InstantiationTools {
  7476. /**
  7477. * Use this object to register external classes like custom textures or material
  7478. * to allow the laoders to instantiate them
  7479. */
  7480. static RegisteredExternalClasses: {
  7481. [key: string]: Object;
  7482. };
  7483. /**
  7484. * Tries to instantiate a new object from a given class name
  7485. * @param className defines the class name to instantiate
  7486. * @returns the new object or null if the system was not able to do the instantiation
  7487. */
  7488. static Instantiate(className: string): any;
  7489. }
  7490. }
  7491. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7492. /**
  7493. * Define options used to create a depth texture
  7494. */
  7495. export class DepthTextureCreationOptions {
  7496. /** Specifies whether or not a stencil should be allocated in the texture */
  7497. generateStencil?: boolean;
  7498. /** Specifies whether or not bilinear filtering is enable on the texture */
  7499. bilinearFiltering?: boolean;
  7500. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7501. comparisonFunction?: number;
  7502. /** Specifies if the created texture is a cube texture */
  7503. isCube?: boolean;
  7504. }
  7505. }
  7506. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7507. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7508. import { Nullable } from "babylonjs/types";
  7509. import { Scene } from "babylonjs/scene";
  7510. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7511. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7512. module "babylonjs/Engines/thinEngine" {
  7513. interface ThinEngine {
  7514. /**
  7515. * Creates a depth stencil cube texture.
  7516. * This is only available in WebGL 2.
  7517. * @param size The size of face edge in the cube texture.
  7518. * @param options The options defining the cube texture.
  7519. * @returns The cube texture
  7520. */
  7521. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7522. /**
  7523. * Creates a cube texture
  7524. * @param rootUrl defines the url where the files to load is located
  7525. * @param scene defines the current scene
  7526. * @param files defines the list of files to load (1 per face)
  7527. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7528. * @param onLoad defines an optional callback raised when the texture is loaded
  7529. * @param onError defines an optional callback raised if there is an issue to load the texture
  7530. * @param format defines the format of the data
  7531. * @param forcedExtension defines the extension to use to pick the right loader
  7532. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7533. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7534. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7535. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7536. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7537. * @returns the cube texture as an InternalTexture
  7538. */
  7539. 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;
  7540. /**
  7541. * Creates a cube texture
  7542. * @param rootUrl defines the url where the files to load is located
  7543. * @param scene defines the current scene
  7544. * @param files defines the list of files to load (1 per face)
  7545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7546. * @param onLoad defines an optional callback raised when the texture is loaded
  7547. * @param onError defines an optional callback raised if there is an issue to load the texture
  7548. * @param format defines the format of the data
  7549. * @param forcedExtension defines the extension to use to pick the right loader
  7550. * @returns the cube texture as an InternalTexture
  7551. */
  7552. 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;
  7553. /**
  7554. * Creates a cube texture
  7555. * @param rootUrl defines the url where the files to load is located
  7556. * @param scene defines the current scene
  7557. * @param files defines the list of files to load (1 per face)
  7558. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7559. * @param onLoad defines an optional callback raised when the texture is loaded
  7560. * @param onError defines an optional callback raised if there is an issue to load the texture
  7561. * @param format defines the format of the data
  7562. * @param forcedExtension defines the extension to use to pick the right loader
  7563. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7564. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7565. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7566. * @returns the cube texture as an InternalTexture
  7567. */
  7568. 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;
  7569. /** @hidden */
  7570. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7571. /** @hidden */
  7572. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7573. /** @hidden */
  7574. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7575. /** @hidden */
  7576. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7577. }
  7578. }
  7579. }
  7580. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7581. import { Nullable } from "babylonjs/types";
  7582. import { Scene } from "babylonjs/scene";
  7583. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7585. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7586. /**
  7587. * Class for creating a cube texture
  7588. */
  7589. export class CubeTexture extends BaseTexture {
  7590. private _delayedOnLoad;
  7591. /**
  7592. * The url of the texture
  7593. */
  7594. url: string;
  7595. /**
  7596. * Gets or sets the center of the bounding box associated with the cube texture.
  7597. * It must define where the camera used to render the texture was set
  7598. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7599. */
  7600. boundingBoxPosition: Vector3;
  7601. private _boundingBoxSize;
  7602. /**
  7603. * Gets or sets the size of the bounding box associated with the cube texture
  7604. * When defined, the cubemap will switch to local mode
  7605. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7606. * @example https://www.babylonjs-playground.com/#RNASML
  7607. */
  7608. /**
  7609. * Returns the bounding box size
  7610. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7611. */
  7612. boundingBoxSize: Vector3;
  7613. protected _rotationY: number;
  7614. /**
  7615. * Sets texture matrix rotation angle around Y axis in radians.
  7616. */
  7617. /**
  7618. * Gets texture matrix rotation angle around Y axis radians.
  7619. */
  7620. rotationY: number;
  7621. /**
  7622. * Are mip maps generated for this texture or not.
  7623. */
  7624. readonly noMipmap: boolean;
  7625. private _noMipmap;
  7626. private _files;
  7627. protected _forcedExtension: Nullable<string>;
  7628. private _extensions;
  7629. private _textureMatrix;
  7630. private _format;
  7631. private _createPolynomials;
  7632. /** @hidden */
  7633. _prefiltered: boolean;
  7634. /**
  7635. * Creates a cube texture from an array of image urls
  7636. * @param files defines an array of image urls
  7637. * @param scene defines the hosting scene
  7638. * @param noMipmap specifies if mip maps are not used
  7639. * @returns a cube texture
  7640. */
  7641. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7642. /**
  7643. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7644. * @param url defines the url of the prefiltered texture
  7645. * @param scene defines the scene the texture is attached to
  7646. * @param forcedExtension defines the extension of the file if different from the url
  7647. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7648. * @return the prefiltered texture
  7649. */
  7650. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7651. /**
  7652. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7653. * as prefiltered data.
  7654. * @param rootUrl defines the url of the texture or the root name of the six images
  7655. * @param scene defines the scene the texture is attached to
  7656. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7657. * @param noMipmap defines if mipmaps should be created or not
  7658. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7659. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7660. * @param onError defines a callback triggered in case of error during load
  7661. * @param format defines the internal format to use for the texture once loaded
  7662. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7663. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7664. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7665. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7666. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7667. * @return the cube texture
  7668. */
  7669. 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);
  7670. /**
  7671. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7672. */
  7673. readonly isPrefiltered: boolean;
  7674. /**
  7675. * Get the current class name of the texture useful for serialization or dynamic coding.
  7676. * @returns "CubeTexture"
  7677. */
  7678. getClassName(): string;
  7679. /**
  7680. * Update the url (and optional buffer) of this texture if url was null during construction.
  7681. * @param url the url of the texture
  7682. * @param forcedExtension defines the extension to use
  7683. * @param onLoad callback called when the texture is loaded (defaults to null)
  7684. */
  7685. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7686. /**
  7687. * Delays loading of the cube texture
  7688. * @param forcedExtension defines the extension to use
  7689. */
  7690. delayLoad(forcedExtension?: string): void;
  7691. /**
  7692. * Returns the reflection texture matrix
  7693. * @returns the reflection texture matrix
  7694. */
  7695. getReflectionTextureMatrix(): Matrix;
  7696. /**
  7697. * Sets the reflection texture matrix
  7698. * @param value Reflection texture matrix
  7699. */
  7700. setReflectionTextureMatrix(value: Matrix): void;
  7701. /**
  7702. * Parses text to create a cube texture
  7703. * @param parsedTexture define the serialized text to read from
  7704. * @param scene defines the hosting scene
  7705. * @param rootUrl defines the root url of the cube texture
  7706. * @returns a cube texture
  7707. */
  7708. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7709. /**
  7710. * Makes a clone, or deep copy, of the cube texture
  7711. * @returns a new cube texture
  7712. */
  7713. clone(): CubeTexture;
  7714. }
  7715. }
  7716. declare module "babylonjs/Materials/materialDefines" {
  7717. /**
  7718. * Manages the defines for the Material
  7719. */
  7720. export class MaterialDefines {
  7721. /** @hidden */
  7722. protected _keys: string[];
  7723. private _isDirty;
  7724. /** @hidden */
  7725. _renderId: number;
  7726. /** @hidden */
  7727. _areLightsDirty: boolean;
  7728. /** @hidden */
  7729. _areLightsDisposed: boolean;
  7730. /** @hidden */
  7731. _areAttributesDirty: boolean;
  7732. /** @hidden */
  7733. _areTexturesDirty: boolean;
  7734. /** @hidden */
  7735. _areFresnelDirty: boolean;
  7736. /** @hidden */
  7737. _areMiscDirty: boolean;
  7738. /** @hidden */
  7739. _areImageProcessingDirty: boolean;
  7740. /** @hidden */
  7741. _normals: boolean;
  7742. /** @hidden */
  7743. _uvs: boolean;
  7744. /** @hidden */
  7745. _needNormals: boolean;
  7746. /** @hidden */
  7747. _needUVs: boolean;
  7748. [id: string]: any;
  7749. /**
  7750. * Specifies if the material needs to be re-calculated
  7751. */
  7752. readonly isDirty: boolean;
  7753. /**
  7754. * Marks the material to indicate that it has been re-calculated
  7755. */
  7756. markAsProcessed(): void;
  7757. /**
  7758. * Marks the material to indicate that it needs to be re-calculated
  7759. */
  7760. markAsUnprocessed(): void;
  7761. /**
  7762. * Marks the material to indicate all of its defines need to be re-calculated
  7763. */
  7764. markAllAsDirty(): void;
  7765. /**
  7766. * Marks the material to indicate that image processing needs to be re-calculated
  7767. */
  7768. markAsImageProcessingDirty(): void;
  7769. /**
  7770. * Marks the material to indicate the lights need to be re-calculated
  7771. * @param disposed Defines whether the light is dirty due to dispose or not
  7772. */
  7773. markAsLightDirty(disposed?: boolean): void;
  7774. /**
  7775. * Marks the attribute state as changed
  7776. */
  7777. markAsAttributesDirty(): void;
  7778. /**
  7779. * Marks the texture state as changed
  7780. */
  7781. markAsTexturesDirty(): void;
  7782. /**
  7783. * Marks the fresnel state as changed
  7784. */
  7785. markAsFresnelDirty(): void;
  7786. /**
  7787. * Marks the misc state as changed
  7788. */
  7789. markAsMiscDirty(): void;
  7790. /**
  7791. * Rebuilds the material defines
  7792. */
  7793. rebuild(): void;
  7794. /**
  7795. * Specifies if two material defines are equal
  7796. * @param other - A material define instance to compare to
  7797. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7798. */
  7799. isEqual(other: MaterialDefines): boolean;
  7800. /**
  7801. * Clones this instance's defines to another instance
  7802. * @param other - material defines to clone values to
  7803. */
  7804. cloneTo(other: MaterialDefines): void;
  7805. /**
  7806. * Resets the material define values
  7807. */
  7808. reset(): void;
  7809. /**
  7810. * Converts the material define values to a string
  7811. * @returns - String of material define information
  7812. */
  7813. toString(): string;
  7814. }
  7815. }
  7816. declare module "babylonjs/Materials/colorCurves" {
  7817. import { Effect } from "babylonjs/Materials/effect";
  7818. /**
  7819. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7820. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7821. * 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;
  7822. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7823. */
  7824. export class ColorCurves {
  7825. private _dirty;
  7826. private _tempColor;
  7827. private _globalCurve;
  7828. private _highlightsCurve;
  7829. private _midtonesCurve;
  7830. private _shadowsCurve;
  7831. private _positiveCurve;
  7832. private _negativeCurve;
  7833. private _globalHue;
  7834. private _globalDensity;
  7835. private _globalSaturation;
  7836. private _globalExposure;
  7837. /**
  7838. * Gets the global Hue value.
  7839. * 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).
  7840. */
  7841. /**
  7842. * Sets the global Hue value.
  7843. * 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).
  7844. */
  7845. globalHue: number;
  7846. /**
  7847. * Gets the global Density value.
  7848. * 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.
  7849. * Values less than zero provide a filter of opposite hue.
  7850. */
  7851. /**
  7852. * Sets the global Density value.
  7853. * 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.
  7854. * Values less than zero provide a filter of opposite hue.
  7855. */
  7856. globalDensity: number;
  7857. /**
  7858. * Gets the global Saturation value.
  7859. * 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.
  7860. */
  7861. /**
  7862. * Sets the global Saturation value.
  7863. * 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.
  7864. */
  7865. globalSaturation: number;
  7866. /**
  7867. * Gets the global Exposure value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the global Exposure value.
  7872. * 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.
  7873. */
  7874. globalExposure: number;
  7875. private _highlightsHue;
  7876. private _highlightsDensity;
  7877. private _highlightsSaturation;
  7878. private _highlightsExposure;
  7879. /**
  7880. * Gets the highlights Hue value.
  7881. * 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).
  7882. */
  7883. /**
  7884. * Sets the highlights Hue value.
  7885. * 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).
  7886. */
  7887. highlightsHue: number;
  7888. /**
  7889. * Gets the highlights Density value.
  7890. * 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.
  7891. * Values less than zero provide a filter of opposite hue.
  7892. */
  7893. /**
  7894. * Sets the highlights Density value.
  7895. * 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.
  7896. * Values less than zero provide a filter of opposite hue.
  7897. */
  7898. highlightsDensity: number;
  7899. /**
  7900. * Gets the highlights Saturation value.
  7901. * 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.
  7902. */
  7903. /**
  7904. * Sets the highlights Saturation value.
  7905. * 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.
  7906. */
  7907. highlightsSaturation: number;
  7908. /**
  7909. * Gets the highlights Exposure value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the highlights Exposure value.
  7914. * 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.
  7915. */
  7916. highlightsExposure: number;
  7917. private _midtonesHue;
  7918. private _midtonesDensity;
  7919. private _midtonesSaturation;
  7920. private _midtonesExposure;
  7921. /**
  7922. * Gets the midtones Hue value.
  7923. * 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).
  7924. */
  7925. /**
  7926. * Sets the midtones Hue value.
  7927. * 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).
  7928. */
  7929. midtonesHue: number;
  7930. /**
  7931. * Gets the midtones Density value.
  7932. * 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.
  7933. * Values less than zero provide a filter of opposite hue.
  7934. */
  7935. /**
  7936. * Sets the midtones Density value.
  7937. * 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.
  7938. * Values less than zero provide a filter of opposite hue.
  7939. */
  7940. midtonesDensity: number;
  7941. /**
  7942. * Gets the midtones Saturation value.
  7943. * 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.
  7944. */
  7945. /**
  7946. * Sets the midtones Saturation value.
  7947. * 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.
  7948. */
  7949. midtonesSaturation: number;
  7950. /**
  7951. * Gets the midtones Exposure value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the midtones Exposure value.
  7956. * 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.
  7957. */
  7958. midtonesExposure: number;
  7959. private _shadowsHue;
  7960. private _shadowsDensity;
  7961. private _shadowsSaturation;
  7962. private _shadowsExposure;
  7963. /**
  7964. * Gets the shadows Hue value.
  7965. * 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).
  7966. */
  7967. /**
  7968. * Sets the shadows Hue value.
  7969. * 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).
  7970. */
  7971. shadowsHue: number;
  7972. /**
  7973. * Gets the shadows Density value.
  7974. * 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.
  7975. * Values less than zero provide a filter of opposite hue.
  7976. */
  7977. /**
  7978. * Sets the shadows Density value.
  7979. * 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.
  7980. * Values less than zero provide a filter of opposite hue.
  7981. */
  7982. shadowsDensity: number;
  7983. /**
  7984. * Gets the shadows Saturation value.
  7985. * 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.
  7986. */
  7987. /**
  7988. * Sets the shadows Saturation value.
  7989. * 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.
  7990. */
  7991. shadowsSaturation: number;
  7992. /**
  7993. * Gets the shadows Exposure value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the shadows Exposure value.
  7998. * 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.
  7999. */
  8000. shadowsExposure: number;
  8001. /**
  8002. * Returns the class name
  8003. * @returns The class name
  8004. */
  8005. getClassName(): string;
  8006. /**
  8007. * Binds the color curves to the shader.
  8008. * @param colorCurves The color curve to bind
  8009. * @param effect The effect to bind to
  8010. * @param positiveUniform The positive uniform shader parameter
  8011. * @param neutralUniform The neutral uniform shader parameter
  8012. * @param negativeUniform The negative uniform shader parameter
  8013. */
  8014. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8015. /**
  8016. * Prepare the list of uniforms associated with the ColorCurves effects.
  8017. * @param uniformsList The list of uniforms used in the effect
  8018. */
  8019. static PrepareUniforms(uniformsList: string[]): void;
  8020. /**
  8021. * Returns color grading data based on a hue, density, saturation and exposure value.
  8022. * @param filterHue The hue of the color filter.
  8023. * @param filterDensity The density of the color filter.
  8024. * @param saturation The saturation.
  8025. * @param exposure The exposure.
  8026. * @param result The result data container.
  8027. */
  8028. private getColorGradingDataToRef;
  8029. /**
  8030. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8031. * @param value The input slider value in range [-100,100].
  8032. * @returns Adjusted value.
  8033. */
  8034. private static applyColorGradingSliderNonlinear;
  8035. /**
  8036. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8037. * @param hue The hue (H) input.
  8038. * @param saturation The saturation (S) input.
  8039. * @param brightness The brightness (B) input.
  8040. * @result An RGBA color represented as Vector4.
  8041. */
  8042. private static fromHSBToRef;
  8043. /**
  8044. * Returns a value clamped between min and max
  8045. * @param value The value to clamp
  8046. * @param min The minimum of value
  8047. * @param max The maximum of value
  8048. * @returns The clamped value.
  8049. */
  8050. private static clamp;
  8051. /**
  8052. * Clones the current color curve instance.
  8053. * @return The cloned curves
  8054. */
  8055. clone(): ColorCurves;
  8056. /**
  8057. * Serializes the current color curve instance to a json representation.
  8058. * @return a JSON representation
  8059. */
  8060. serialize(): any;
  8061. /**
  8062. * Parses the color curve from a json representation.
  8063. * @param source the JSON source to parse
  8064. * @return The parsed curves
  8065. */
  8066. static Parse(source: any): ColorCurves;
  8067. }
  8068. }
  8069. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8070. import { Observable } from "babylonjs/Misc/observable";
  8071. import { Nullable } from "babylonjs/types";
  8072. import { Color4 } from "babylonjs/Maths/math.color";
  8073. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8074. import { Effect } from "babylonjs/Materials/effect";
  8075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8076. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8077. /**
  8078. * Interface to follow in your material defines to integrate easily the
  8079. * Image proccessing functions.
  8080. * @hidden
  8081. */
  8082. export interface IImageProcessingConfigurationDefines {
  8083. IMAGEPROCESSING: boolean;
  8084. VIGNETTE: boolean;
  8085. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8086. VIGNETTEBLENDMODEOPAQUE: boolean;
  8087. TONEMAPPING: boolean;
  8088. TONEMAPPING_ACES: boolean;
  8089. CONTRAST: boolean;
  8090. EXPOSURE: boolean;
  8091. COLORCURVES: boolean;
  8092. COLORGRADING: boolean;
  8093. COLORGRADING3D: boolean;
  8094. SAMPLER3DGREENDEPTH: boolean;
  8095. SAMPLER3DBGRMAP: boolean;
  8096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8097. }
  8098. /**
  8099. * @hidden
  8100. */
  8101. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8102. IMAGEPROCESSING: boolean;
  8103. VIGNETTE: boolean;
  8104. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8105. VIGNETTEBLENDMODEOPAQUE: boolean;
  8106. TONEMAPPING: boolean;
  8107. TONEMAPPING_ACES: boolean;
  8108. CONTRAST: boolean;
  8109. COLORCURVES: boolean;
  8110. COLORGRADING: boolean;
  8111. COLORGRADING3D: boolean;
  8112. SAMPLER3DGREENDEPTH: boolean;
  8113. SAMPLER3DBGRMAP: boolean;
  8114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8115. EXPOSURE: boolean;
  8116. constructor();
  8117. }
  8118. /**
  8119. * This groups together the common properties used for image processing either in direct forward pass
  8120. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8121. * or not.
  8122. */
  8123. export class ImageProcessingConfiguration {
  8124. /**
  8125. * Default tone mapping applied in BabylonJS.
  8126. */
  8127. static readonly TONEMAPPING_STANDARD: number;
  8128. /**
  8129. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8130. * to other engines rendering to increase portability.
  8131. */
  8132. static readonly TONEMAPPING_ACES: number;
  8133. /**
  8134. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8135. */
  8136. colorCurves: Nullable<ColorCurves>;
  8137. private _colorCurvesEnabled;
  8138. /**
  8139. * Gets wether the color curves effect is enabled.
  8140. */
  8141. /**
  8142. * Sets wether the color curves effect is enabled.
  8143. */
  8144. colorCurvesEnabled: boolean;
  8145. private _colorGradingTexture;
  8146. /**
  8147. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8148. */
  8149. /**
  8150. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8151. */
  8152. colorGradingTexture: Nullable<BaseTexture>;
  8153. private _colorGradingEnabled;
  8154. /**
  8155. * Gets wether the color grading effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the color grading effect is enabled.
  8159. */
  8160. colorGradingEnabled: boolean;
  8161. private _colorGradingWithGreenDepth;
  8162. /**
  8163. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8164. */
  8165. /**
  8166. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8167. */
  8168. colorGradingWithGreenDepth: boolean;
  8169. private _colorGradingBGR;
  8170. /**
  8171. * Gets wether the color grading texture contains BGR values.
  8172. */
  8173. /**
  8174. * Sets wether the color grading texture contains BGR values.
  8175. */
  8176. colorGradingBGR: boolean;
  8177. /** @hidden */
  8178. _exposure: number;
  8179. /**
  8180. * Gets the Exposure used in the effect.
  8181. */
  8182. /**
  8183. * Sets the Exposure used in the effect.
  8184. */
  8185. exposure: number;
  8186. private _toneMappingEnabled;
  8187. /**
  8188. * Gets wether the tone mapping effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the tone mapping effect is enabled.
  8192. */
  8193. toneMappingEnabled: boolean;
  8194. private _toneMappingType;
  8195. /**
  8196. * Gets the type of tone mapping effect.
  8197. */
  8198. /**
  8199. * Sets the type of tone mapping effect used in BabylonJS.
  8200. */
  8201. toneMappingType: number;
  8202. protected _contrast: number;
  8203. /**
  8204. * Gets the contrast used in the effect.
  8205. */
  8206. /**
  8207. * Sets the contrast used in the effect.
  8208. */
  8209. contrast: number;
  8210. /**
  8211. * Vignette stretch size.
  8212. */
  8213. vignetteStretch: number;
  8214. /**
  8215. * Vignette centre X Offset.
  8216. */
  8217. vignetteCentreX: number;
  8218. /**
  8219. * Vignette centre Y Offset.
  8220. */
  8221. vignetteCentreY: number;
  8222. /**
  8223. * Vignette weight or intensity of the vignette effect.
  8224. */
  8225. vignetteWeight: number;
  8226. /**
  8227. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8228. * if vignetteEnabled is set to true.
  8229. */
  8230. vignetteColor: Color4;
  8231. /**
  8232. * Camera field of view used by the Vignette effect.
  8233. */
  8234. vignetteCameraFov: number;
  8235. private _vignetteBlendMode;
  8236. /**
  8237. * Gets the vignette blend mode allowing different kind of effect.
  8238. */
  8239. /**
  8240. * Sets the vignette blend mode allowing different kind of effect.
  8241. */
  8242. vignetteBlendMode: number;
  8243. private _vignetteEnabled;
  8244. /**
  8245. * Gets wether the vignette effect is enabled.
  8246. */
  8247. /**
  8248. * Sets wether the vignette effect is enabled.
  8249. */
  8250. vignetteEnabled: boolean;
  8251. private _applyByPostProcess;
  8252. /**
  8253. * Gets wether the image processing is applied through a post process or not.
  8254. */
  8255. /**
  8256. * Sets wether the image processing is applied through a post process or not.
  8257. */
  8258. applyByPostProcess: boolean;
  8259. private _isEnabled;
  8260. /**
  8261. * Gets wether the image processing is enabled or not.
  8262. */
  8263. /**
  8264. * Sets wether the image processing is enabled or not.
  8265. */
  8266. isEnabled: boolean;
  8267. /**
  8268. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8269. */
  8270. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8271. /**
  8272. * Method called each time the image processing information changes requires to recompile the effect.
  8273. */
  8274. protected _updateParameters(): void;
  8275. /**
  8276. * Gets the current class name.
  8277. * @return "ImageProcessingConfiguration"
  8278. */
  8279. getClassName(): string;
  8280. /**
  8281. * Prepare the list of uniforms associated with the Image Processing effects.
  8282. * @param uniforms The list of uniforms used in the effect
  8283. * @param defines the list of defines currently in use
  8284. */
  8285. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8286. /**
  8287. * Prepare the list of samplers associated with the Image Processing effects.
  8288. * @param samplersList The list of uniforms used in the effect
  8289. * @param defines the list of defines currently in use
  8290. */
  8291. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8292. /**
  8293. * Prepare the list of defines associated to the shader.
  8294. * @param defines the list of defines to complete
  8295. * @param forPostProcess Define if we are currently in post process mode or not
  8296. */
  8297. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8298. /**
  8299. * Returns true if all the image processing information are ready.
  8300. * @returns True if ready, otherwise, false
  8301. */
  8302. isReady(): boolean;
  8303. /**
  8304. * Binds the image processing to the shader.
  8305. * @param effect The effect to bind to
  8306. * @param aspectRatio Define the current aspect ratio of the effect
  8307. */
  8308. bind(effect: Effect, aspectRatio?: number): void;
  8309. /**
  8310. * Clones the current image processing instance.
  8311. * @return The cloned image processing
  8312. */
  8313. clone(): ImageProcessingConfiguration;
  8314. /**
  8315. * Serializes the current image processing instance to a json representation.
  8316. * @return a JSON representation
  8317. */
  8318. serialize(): any;
  8319. /**
  8320. * Parses the image processing from a json representation.
  8321. * @param source the JSON source to parse
  8322. * @return The parsed image processing
  8323. */
  8324. static Parse(source: any): ImageProcessingConfiguration;
  8325. private static _VIGNETTEMODE_MULTIPLY;
  8326. private static _VIGNETTEMODE_OPAQUE;
  8327. /**
  8328. * Used to apply the vignette as a mix with the pixel color.
  8329. */
  8330. static readonly VIGNETTEMODE_MULTIPLY: number;
  8331. /**
  8332. * Used to apply the vignette as a replacement of the pixel color.
  8333. */
  8334. static readonly VIGNETTEMODE_OPAQUE: number;
  8335. }
  8336. }
  8337. declare module "babylonjs/Shaders/postprocess.vertex" {
  8338. /** @hidden */
  8339. export var postprocessVertexShader: {
  8340. name: string;
  8341. shader: string;
  8342. };
  8343. }
  8344. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8346. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8347. module "babylonjs/Engines/thinEngine" {
  8348. interface ThinEngine {
  8349. /**
  8350. * Creates a new render target texture
  8351. * @param size defines the size of the texture
  8352. * @param options defines the options used to create the texture
  8353. * @returns a new render target texture stored in an InternalTexture
  8354. */
  8355. createRenderTargetTexture(size: number | {
  8356. width: number;
  8357. height: number;
  8358. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8359. }
  8360. }
  8361. }
  8362. declare module "babylonjs/Maths/math.axis" {
  8363. import { Vector3 } from "babylonjs/Maths/math.vector";
  8364. /** Defines supported spaces */
  8365. export enum Space {
  8366. /** Local (object) space */
  8367. LOCAL = 0,
  8368. /** World space */
  8369. WORLD = 1,
  8370. /** Bone space */
  8371. BONE = 2
  8372. }
  8373. /** Defines the 3 main axes */
  8374. export class Axis {
  8375. /** X axis */
  8376. static X: Vector3;
  8377. /** Y axis */
  8378. static Y: Vector3;
  8379. /** Z axis */
  8380. static Z: Vector3;
  8381. }
  8382. }
  8383. declare module "babylonjs/Cameras/targetCamera" {
  8384. import { Nullable } from "babylonjs/types";
  8385. import { Camera } from "babylonjs/Cameras/camera";
  8386. import { Scene } from "babylonjs/scene";
  8387. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8388. /**
  8389. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8390. * This is the base of the follow, arc rotate cameras and Free camera
  8391. * @see http://doc.babylonjs.com/features/cameras
  8392. */
  8393. export class TargetCamera extends Camera {
  8394. private static _RigCamTransformMatrix;
  8395. private static _TargetTransformMatrix;
  8396. private static _TargetFocalPoint;
  8397. /**
  8398. * Define the current direction the camera is moving to
  8399. */
  8400. cameraDirection: Vector3;
  8401. /**
  8402. * Define the current rotation the camera is rotating to
  8403. */
  8404. cameraRotation: Vector2;
  8405. /**
  8406. * When set, the up vector of the camera will be updated by the rotation of the camera
  8407. */
  8408. updateUpVectorFromRotation: boolean;
  8409. private _tmpQuaternion;
  8410. /**
  8411. * Define the current rotation of the camera
  8412. */
  8413. rotation: Vector3;
  8414. /**
  8415. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8416. */
  8417. rotationQuaternion: Quaternion;
  8418. /**
  8419. * Define the current speed of the camera
  8420. */
  8421. speed: number;
  8422. /**
  8423. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8424. * around all axis.
  8425. */
  8426. noRotationConstraint: boolean;
  8427. /**
  8428. * Define the current target of the camera as an object or a position.
  8429. */
  8430. lockedTarget: any;
  8431. /** @hidden */
  8432. _currentTarget: Vector3;
  8433. /** @hidden */
  8434. _initialFocalDistance: number;
  8435. /** @hidden */
  8436. _viewMatrix: Matrix;
  8437. /** @hidden */
  8438. _camMatrix: Matrix;
  8439. /** @hidden */
  8440. _cameraTransformMatrix: Matrix;
  8441. /** @hidden */
  8442. _cameraRotationMatrix: Matrix;
  8443. /** @hidden */
  8444. _referencePoint: Vector3;
  8445. /** @hidden */
  8446. _transformedReferencePoint: Vector3;
  8447. protected _globalCurrentTarget: Vector3;
  8448. protected _globalCurrentUpVector: Vector3;
  8449. /** @hidden */
  8450. _reset: () => void;
  8451. private _defaultUp;
  8452. /**
  8453. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8454. * This is the base of the follow, arc rotate cameras and Free camera
  8455. * @see http://doc.babylonjs.com/features/cameras
  8456. * @param name Defines the name of the camera in the scene
  8457. * @param position Defines the start position of the camera in the scene
  8458. * @param scene Defines the scene the camera belongs to
  8459. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8460. */
  8461. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8462. /**
  8463. * Gets the position in front of the camera at a given distance.
  8464. * @param distance The distance from the camera we want the position to be
  8465. * @returns the position
  8466. */
  8467. getFrontPosition(distance: number): Vector3;
  8468. /** @hidden */
  8469. _getLockedTargetPosition(): Nullable<Vector3>;
  8470. private _storedPosition;
  8471. private _storedRotation;
  8472. private _storedRotationQuaternion;
  8473. /**
  8474. * Store current camera state of the camera (fov, position, rotation, etc..)
  8475. * @returns the camera
  8476. */
  8477. storeState(): Camera;
  8478. /**
  8479. * Restored camera state. You must call storeState() first
  8480. * @returns whether it was successful or not
  8481. * @hidden
  8482. */
  8483. _restoreStateValues(): boolean;
  8484. /** @hidden */
  8485. _initCache(): void;
  8486. /** @hidden */
  8487. _updateCache(ignoreParentClass?: boolean): void;
  8488. /** @hidden */
  8489. _isSynchronizedViewMatrix(): boolean;
  8490. /** @hidden */
  8491. _computeLocalCameraSpeed(): number;
  8492. /**
  8493. * Defines the target the camera should look at.
  8494. * @param target Defines the new target as a Vector or a mesh
  8495. */
  8496. setTarget(target: Vector3): void;
  8497. /**
  8498. * Return the current target position of the camera. This value is expressed in local space.
  8499. * @returns the target position
  8500. */
  8501. getTarget(): Vector3;
  8502. /** @hidden */
  8503. _decideIfNeedsToMove(): boolean;
  8504. /** @hidden */
  8505. _updatePosition(): void;
  8506. /** @hidden */
  8507. _checkInputs(): void;
  8508. protected _updateCameraRotationMatrix(): void;
  8509. /**
  8510. * 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)
  8511. * @returns the current camera
  8512. */
  8513. private _rotateUpVectorWithCameraRotationMatrix;
  8514. private _cachedRotationZ;
  8515. private _cachedQuaternionRotationZ;
  8516. /** @hidden */
  8517. _getViewMatrix(): Matrix;
  8518. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8519. /**
  8520. * @hidden
  8521. */
  8522. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8523. /**
  8524. * @hidden
  8525. */
  8526. _updateRigCameras(): void;
  8527. private _getRigCamPositionAndTarget;
  8528. /**
  8529. * Gets the current object class name.
  8530. * @return the class name
  8531. */
  8532. getClassName(): string;
  8533. }
  8534. }
  8535. declare module "babylonjs/Events/keyboardEvents" {
  8536. /**
  8537. * Gather the list of keyboard event types as constants.
  8538. */
  8539. export class KeyboardEventTypes {
  8540. /**
  8541. * The keydown event is fired when a key becomes active (pressed).
  8542. */
  8543. static readonly KEYDOWN: number;
  8544. /**
  8545. * The keyup event is fired when a key has been released.
  8546. */
  8547. static readonly KEYUP: number;
  8548. }
  8549. /**
  8550. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8551. */
  8552. export class KeyboardInfo {
  8553. /**
  8554. * Defines the type of event (KeyboardEventTypes)
  8555. */
  8556. type: number;
  8557. /**
  8558. * Defines the related dom event
  8559. */
  8560. event: KeyboardEvent;
  8561. /**
  8562. * Instantiates a new keyboard info.
  8563. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8564. * @param type Defines the type of event (KeyboardEventTypes)
  8565. * @param event Defines the related dom event
  8566. */
  8567. constructor(
  8568. /**
  8569. * Defines the type of event (KeyboardEventTypes)
  8570. */
  8571. type: number,
  8572. /**
  8573. * Defines the related dom event
  8574. */
  8575. event: KeyboardEvent);
  8576. }
  8577. /**
  8578. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8579. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8580. */
  8581. export class KeyboardInfoPre extends KeyboardInfo {
  8582. /**
  8583. * Defines the type of event (KeyboardEventTypes)
  8584. */
  8585. type: number;
  8586. /**
  8587. * Defines the related dom event
  8588. */
  8589. event: KeyboardEvent;
  8590. /**
  8591. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8592. */
  8593. skipOnPointerObservable: boolean;
  8594. /**
  8595. * Instantiates a new keyboard pre info.
  8596. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8597. * @param type Defines the type of event (KeyboardEventTypes)
  8598. * @param event Defines the related dom event
  8599. */
  8600. constructor(
  8601. /**
  8602. * Defines the type of event (KeyboardEventTypes)
  8603. */
  8604. type: number,
  8605. /**
  8606. * Defines the related dom event
  8607. */
  8608. event: KeyboardEvent);
  8609. }
  8610. }
  8611. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8612. import { Nullable } from "babylonjs/types";
  8613. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8614. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8615. /**
  8616. * Manage the keyboard inputs to control the movement of a free camera.
  8617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8618. */
  8619. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8620. /**
  8621. * Defines the camera the input is attached to.
  8622. */
  8623. camera: FreeCamera;
  8624. /**
  8625. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8626. */
  8627. keysUp: number[];
  8628. /**
  8629. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8630. */
  8631. keysDown: number[];
  8632. /**
  8633. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8634. */
  8635. keysLeft: number[];
  8636. /**
  8637. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8638. */
  8639. keysRight: number[];
  8640. private _keys;
  8641. private _onCanvasBlurObserver;
  8642. private _onKeyboardObserver;
  8643. private _engine;
  8644. private _scene;
  8645. /**
  8646. * Attach the input controls to a specific dom element to get the input from.
  8647. * @param element Defines the element the controls should be listened from
  8648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8649. */
  8650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8651. /**
  8652. * Detach the current controls from the specified dom element.
  8653. * @param element Defines the element to stop listening the inputs from
  8654. */
  8655. detachControl(element: Nullable<HTMLElement>): void;
  8656. /**
  8657. * Update the current camera state depending on the inputs that have been used this frame.
  8658. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8659. */
  8660. checkInputs(): void;
  8661. /**
  8662. * Gets the class name of the current intput.
  8663. * @returns the class name
  8664. */
  8665. getClassName(): string;
  8666. /** @hidden */
  8667. _onLostFocus(): void;
  8668. /**
  8669. * Get the friendly name associated with the input class.
  8670. * @returns the input friendly name
  8671. */
  8672. getSimpleName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Lights/shadowLight" {
  8676. import { Camera } from "babylonjs/Cameras/camera";
  8677. import { Scene } from "babylonjs/scene";
  8678. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8680. import { Light } from "babylonjs/Lights/light";
  8681. /**
  8682. * Interface describing all the common properties and methods a shadow light needs to implement.
  8683. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8684. * as well as binding the different shadow properties to the effects.
  8685. */
  8686. export interface IShadowLight extends Light {
  8687. /**
  8688. * The light id in the scene (used in scene.findLighById for instance)
  8689. */
  8690. id: string;
  8691. /**
  8692. * The position the shdow will be casted from.
  8693. */
  8694. position: Vector3;
  8695. /**
  8696. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8697. */
  8698. direction: Vector3;
  8699. /**
  8700. * The transformed position. Position of the light in world space taking parenting in account.
  8701. */
  8702. transformedPosition: Vector3;
  8703. /**
  8704. * The transformed direction. Direction of the light in world space taking parenting in account.
  8705. */
  8706. transformedDirection: Vector3;
  8707. /**
  8708. * The friendly name of the light in the scene.
  8709. */
  8710. name: string;
  8711. /**
  8712. * Defines the shadow projection clipping minimum z value.
  8713. */
  8714. shadowMinZ: number;
  8715. /**
  8716. * Defines the shadow projection clipping maximum z value.
  8717. */
  8718. shadowMaxZ: number;
  8719. /**
  8720. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8721. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8722. */
  8723. computeTransformedInformation(): boolean;
  8724. /**
  8725. * Gets the scene the light belongs to.
  8726. * @returns The scene
  8727. */
  8728. getScene(): Scene;
  8729. /**
  8730. * Callback defining a custom Projection Matrix Builder.
  8731. * This can be used to override the default projection matrix computation.
  8732. */
  8733. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8734. /**
  8735. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8736. * @param matrix The materix to updated with the projection information
  8737. * @param viewMatrix The transform matrix of the light
  8738. * @param renderList The list of mesh to render in the map
  8739. * @returns The current light
  8740. */
  8741. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8742. /**
  8743. * Gets the current depth scale used in ESM.
  8744. * @returns The scale
  8745. */
  8746. getDepthScale(): number;
  8747. /**
  8748. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8749. * @returns true if a cube texture needs to be use
  8750. */
  8751. needCube(): boolean;
  8752. /**
  8753. * Detects if the projection matrix requires to be recomputed this frame.
  8754. * @returns true if it requires to be recomputed otherwise, false.
  8755. */
  8756. needProjectionMatrixCompute(): boolean;
  8757. /**
  8758. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8759. */
  8760. forceProjectionMatrixCompute(): void;
  8761. /**
  8762. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8763. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8764. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8765. */
  8766. getShadowDirection(faceIndex?: number): Vector3;
  8767. /**
  8768. * Gets the minZ used for shadow according to both the scene and the light.
  8769. * @param activeCamera The camera we are returning the min for
  8770. * @returns the depth min z
  8771. */
  8772. getDepthMinZ(activeCamera: Camera): number;
  8773. /**
  8774. * Gets the maxZ used for shadow according to both the scene and the light.
  8775. * @param activeCamera The camera we are returning the max for
  8776. * @returns the depth max z
  8777. */
  8778. getDepthMaxZ(activeCamera: Camera): number;
  8779. }
  8780. /**
  8781. * Base implementation IShadowLight
  8782. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8783. */
  8784. export abstract class ShadowLight extends Light implements IShadowLight {
  8785. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8786. protected _position: Vector3;
  8787. protected _setPosition(value: Vector3): void;
  8788. /**
  8789. * Sets the position the shadow will be casted from. Also use as the light position for both
  8790. * point and spot lights.
  8791. */
  8792. /**
  8793. * Sets the position the shadow will be casted from. Also use as the light position for both
  8794. * point and spot lights.
  8795. */
  8796. position: Vector3;
  8797. protected _direction: Vector3;
  8798. protected _setDirection(value: Vector3): void;
  8799. /**
  8800. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8801. * Also use as the light direction on spot and directional lights.
  8802. */
  8803. /**
  8804. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8805. * Also use as the light direction on spot and directional lights.
  8806. */
  8807. direction: Vector3;
  8808. private _shadowMinZ;
  8809. /**
  8810. * Gets the shadow projection clipping minimum z value.
  8811. */
  8812. /**
  8813. * Sets the shadow projection clipping minimum z value.
  8814. */
  8815. shadowMinZ: number;
  8816. private _shadowMaxZ;
  8817. /**
  8818. * Sets the shadow projection clipping maximum z value.
  8819. */
  8820. /**
  8821. * Gets the shadow projection clipping maximum z value.
  8822. */
  8823. shadowMaxZ: number;
  8824. /**
  8825. * Callback defining a custom Projection Matrix Builder.
  8826. * This can be used to override the default projection matrix computation.
  8827. */
  8828. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8829. /**
  8830. * The transformed position. Position of the light in world space taking parenting in account.
  8831. */
  8832. transformedPosition: Vector3;
  8833. /**
  8834. * The transformed direction. Direction of the light in world space taking parenting in account.
  8835. */
  8836. transformedDirection: Vector3;
  8837. private _needProjectionMatrixCompute;
  8838. /**
  8839. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8840. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8841. */
  8842. computeTransformedInformation(): boolean;
  8843. /**
  8844. * Return the depth scale used for the shadow map.
  8845. * @returns the depth scale.
  8846. */
  8847. getDepthScale(): number;
  8848. /**
  8849. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8850. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8851. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8852. */
  8853. getShadowDirection(faceIndex?: number): Vector3;
  8854. /**
  8855. * Returns the ShadowLight absolute position in the World.
  8856. * @returns the position vector in world space
  8857. */
  8858. getAbsolutePosition(): Vector3;
  8859. /**
  8860. * Sets the ShadowLight direction toward the passed target.
  8861. * @param target The point to target in local space
  8862. * @returns the updated ShadowLight direction
  8863. */
  8864. setDirectionToTarget(target: Vector3): Vector3;
  8865. /**
  8866. * Returns the light rotation in euler definition.
  8867. * @returns the x y z rotation in local space.
  8868. */
  8869. getRotation(): Vector3;
  8870. /**
  8871. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8872. * @returns true if a cube texture needs to be use
  8873. */
  8874. needCube(): boolean;
  8875. /**
  8876. * Detects if the projection matrix requires to be recomputed this frame.
  8877. * @returns true if it requires to be recomputed otherwise, false.
  8878. */
  8879. needProjectionMatrixCompute(): boolean;
  8880. /**
  8881. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8882. */
  8883. forceProjectionMatrixCompute(): void;
  8884. /** @hidden */
  8885. _initCache(): void;
  8886. /** @hidden */
  8887. _isSynchronized(): boolean;
  8888. /**
  8889. * Computes the world matrix of the node
  8890. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8891. * @returns the world matrix
  8892. */
  8893. computeWorldMatrix(force?: boolean): Matrix;
  8894. /**
  8895. * Gets the minZ used for shadow according to both the scene and the light.
  8896. * @param activeCamera The camera we are returning the min for
  8897. * @returns the depth min z
  8898. */
  8899. getDepthMinZ(activeCamera: Camera): number;
  8900. /**
  8901. * Gets the maxZ used for shadow according to both the scene and the light.
  8902. * @param activeCamera The camera we are returning the max for
  8903. * @returns the depth max z
  8904. */
  8905. getDepthMaxZ(activeCamera: Camera): number;
  8906. /**
  8907. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8908. * @param matrix The materix to updated with the projection information
  8909. * @param viewMatrix The transform matrix of the light
  8910. * @param renderList The list of mesh to render in the map
  8911. * @returns The current light
  8912. */
  8913. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8914. }
  8915. }
  8916. declare module "babylonjs/Materials/effectFallbacks" {
  8917. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8918. import { Effect } from "babylonjs/Materials/effect";
  8919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8920. /**
  8921. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8922. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8923. */
  8924. export class EffectFallbacks implements IEffectFallbacks {
  8925. private _defines;
  8926. private _currentRank;
  8927. private _maxRank;
  8928. private _mesh;
  8929. /**
  8930. * Removes the fallback from the bound mesh.
  8931. */
  8932. unBindMesh(): void;
  8933. /**
  8934. * Adds a fallback on the specified property.
  8935. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8936. * @param define The name of the define in the shader
  8937. */
  8938. addFallback(rank: number, define: string): void;
  8939. /**
  8940. * Sets the mesh to use CPU skinning when needing to fallback.
  8941. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8942. * @param mesh The mesh to use the fallbacks.
  8943. */
  8944. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8945. /**
  8946. * Checks to see if more fallbacks are still availible.
  8947. */
  8948. readonly hasMoreFallbacks: boolean;
  8949. /**
  8950. * Removes the defines that should be removed when falling back.
  8951. * @param currentDefines defines the current define statements for the shader.
  8952. * @param effect defines the current effect we try to compile
  8953. * @returns The resulting defines with defines of the current rank removed.
  8954. */
  8955. reduce(currentDefines: string, effect: Effect): string;
  8956. }
  8957. }
  8958. declare module "babylonjs/Materials/materialHelper" {
  8959. import { Nullable } from "babylonjs/types";
  8960. import { Scene } from "babylonjs/scene";
  8961. import { Engine } from "babylonjs/Engines/engine";
  8962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8963. import { Light } from "babylonjs/Lights/light";
  8964. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8965. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8967. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8968. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8969. /**
  8970. * "Static Class" containing the most commonly used helper while dealing with material for
  8971. * rendering purpose.
  8972. *
  8973. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8974. *
  8975. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8976. */
  8977. export class MaterialHelper {
  8978. /**
  8979. * Bind the current view position to an effect.
  8980. * @param effect The effect to be bound
  8981. * @param scene The scene the eyes position is used from
  8982. */
  8983. static BindEyePosition(effect: Effect, scene: Scene): void;
  8984. /**
  8985. * Helps preparing the defines values about the UVs in used in the effect.
  8986. * UVs are shared as much as we can accross channels in the shaders.
  8987. * @param texture The texture we are preparing the UVs for
  8988. * @param defines The defines to update
  8989. * @param key The channel key "diffuse", "specular"... used in the shader
  8990. */
  8991. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8992. /**
  8993. * Binds a texture matrix value to its corrsponding uniform
  8994. * @param texture The texture to bind the matrix for
  8995. * @param uniformBuffer The uniform buffer receivin the data
  8996. * @param key The channel key "diffuse", "specular"... used in the shader
  8997. */
  8998. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8999. /**
  9000. * Gets the current status of the fog (should it be enabled?)
  9001. * @param mesh defines the mesh to evaluate for fog support
  9002. * @param scene defines the hosting scene
  9003. * @returns true if fog must be enabled
  9004. */
  9005. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9006. /**
  9007. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9008. * @param mesh defines the current mesh
  9009. * @param scene defines the current scene
  9010. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9011. * @param pointsCloud defines if point cloud rendering has to be turned on
  9012. * @param fogEnabled defines if fog has to be turned on
  9013. * @param alphaTest defines if alpha testing has to be turned on
  9014. * @param defines defines the current list of defines
  9015. */
  9016. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9017. /**
  9018. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9019. * @param scene defines the current scene
  9020. * @param engine defines the current engine
  9021. * @param defines specifies the list of active defines
  9022. * @param useInstances defines if instances have to be turned on
  9023. * @param useClipPlane defines if clip plane have to be turned on
  9024. */
  9025. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9026. /**
  9027. * Prepares the defines for bones
  9028. * @param mesh The mesh containing the geometry data we will draw
  9029. * @param defines The defines to update
  9030. */
  9031. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9032. /**
  9033. * Prepares the defines for morph targets
  9034. * @param mesh The mesh containing the geometry data we will draw
  9035. * @param defines The defines to update
  9036. */
  9037. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9038. /**
  9039. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9040. * @param mesh The mesh containing the geometry data we will draw
  9041. * @param defines The defines to update
  9042. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9043. * @param useBones Precise whether bones should be used or not (override mesh info)
  9044. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9045. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9046. * @returns false if defines are considered not dirty and have not been checked
  9047. */
  9048. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9049. /**
  9050. * Prepares the defines related to multiview
  9051. * @param scene The scene we are intending to draw
  9052. * @param defines The defines to update
  9053. */
  9054. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9055. /**
  9056. * Prepares the defines related to the light information passed in parameter
  9057. * @param scene The scene we are intending to draw
  9058. * @param mesh The mesh the effect is compiling for
  9059. * @param light The light the effect is compiling for
  9060. * @param lightIndex The index of the light
  9061. * @param defines The defines to update
  9062. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9063. * @param state Defines the current state regarding what is needed (normals, etc...)
  9064. */
  9065. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9066. needNormals: boolean;
  9067. needRebuild: boolean;
  9068. shadowEnabled: boolean;
  9069. specularEnabled: boolean;
  9070. lightmapMode: boolean;
  9071. }): void;
  9072. /**
  9073. * Prepares the defines related to the light information passed in parameter
  9074. * @param scene The scene we are intending to draw
  9075. * @param mesh The mesh the effect is compiling for
  9076. * @param defines The defines to update
  9077. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9078. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9079. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9080. * @returns true if normals will be required for the rest of the effect
  9081. */
  9082. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9083. /**
  9084. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9085. * @param lightIndex defines the light index
  9086. * @param uniformsList The uniform list
  9087. * @param samplersList The sampler list
  9088. * @param projectedLightTexture defines if projected texture must be used
  9089. * @param uniformBuffersList defines an optional list of uniform buffers
  9090. */
  9091. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9092. /**
  9093. * Prepares the uniforms and samplers list to be used in the effect
  9094. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9095. * @param samplersList The sampler list
  9096. * @param defines The defines helping in the list generation
  9097. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9098. */
  9099. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9100. /**
  9101. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9102. * @param defines The defines to update while falling back
  9103. * @param fallbacks The authorized effect fallbacks
  9104. * @param maxSimultaneousLights The maximum number of lights allowed
  9105. * @param rank the current rank of the Effect
  9106. * @returns The newly affected rank
  9107. */
  9108. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9109. private static _TmpMorphInfluencers;
  9110. /**
  9111. * Prepares the list of attributes required for morph targets according to the effect defines.
  9112. * @param attribs The current list of supported attribs
  9113. * @param mesh The mesh to prepare the morph targets attributes for
  9114. * @param influencers The number of influencers
  9115. */
  9116. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9117. /**
  9118. * Prepares the list of attributes required for morph targets according to the effect defines.
  9119. * @param attribs The current list of supported attribs
  9120. * @param mesh The mesh to prepare the morph targets attributes for
  9121. * @param defines The current Defines of the effect
  9122. */
  9123. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9124. /**
  9125. * Prepares the list of attributes required for bones according to the effect defines.
  9126. * @param attribs The current list of supported attribs
  9127. * @param mesh The mesh to prepare the bones attributes for
  9128. * @param defines The current Defines of the effect
  9129. * @param fallbacks The current efffect fallback strategy
  9130. */
  9131. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9132. /**
  9133. * Check and prepare the list of attributes required for instances according to the effect defines.
  9134. * @param attribs The current list of supported attribs
  9135. * @param defines The current MaterialDefines of the effect
  9136. */
  9137. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9138. /**
  9139. * Add the list of attributes required for instances to the attribs array.
  9140. * @param attribs The current list of supported attribs
  9141. */
  9142. static PushAttributesForInstances(attribs: string[]): void;
  9143. /**
  9144. * Binds the light information to the effect.
  9145. * @param light The light containing the generator
  9146. * @param effect The effect we are binding the data to
  9147. * @param lightIndex The light index in the effect used to render
  9148. */
  9149. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9150. /**
  9151. * Binds the lights information from the scene to the effect for the given mesh.
  9152. * @param light Light to bind
  9153. * @param lightIndex Light index
  9154. * @param scene The scene where the light belongs to
  9155. * @param effect The effect we are binding the data to
  9156. * @param useSpecular Defines if specular is supported
  9157. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9158. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9159. */
  9160. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9161. /**
  9162. * Binds the lights information from the scene to the effect for the given mesh.
  9163. * @param scene The scene the lights belongs to
  9164. * @param mesh The mesh we are binding the information to render
  9165. * @param effect The effect we are binding the data to
  9166. * @param defines The generated defines for the effect
  9167. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9168. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9169. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9170. */
  9171. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9172. private static _tempFogColor;
  9173. /**
  9174. * Binds the fog information from the scene to the effect for the given mesh.
  9175. * @param scene The scene the lights belongs to
  9176. * @param mesh The mesh we are binding the information to render
  9177. * @param effect The effect we are binding the data to
  9178. * @param linearSpace Defines if the fog effect is applied in linear space
  9179. */
  9180. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9181. /**
  9182. * Binds the bones information from the mesh to the effect.
  9183. * @param mesh The mesh we are binding the information to render
  9184. * @param effect The effect we are binding the data to
  9185. */
  9186. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9187. /**
  9188. * Binds the morph targets information from the mesh to the effect.
  9189. * @param abstractMesh The mesh we are binding the information to render
  9190. * @param effect The effect we are binding the data to
  9191. */
  9192. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9193. /**
  9194. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9195. * @param defines The generated defines used in the effect
  9196. * @param effect The effect we are binding the data to
  9197. * @param scene The scene we are willing to render with logarithmic scale for
  9198. */
  9199. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9200. /**
  9201. * Binds the clip plane information from the scene to the effect.
  9202. * @param scene The scene the clip plane information are extracted from
  9203. * @param effect The effect we are binding the data to
  9204. */
  9205. static BindClipPlane(effect: Effect, scene: Scene): void;
  9206. }
  9207. }
  9208. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9209. /** @hidden */
  9210. export var packingFunctions: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9216. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9217. /** @hidden */
  9218. export var shadowMapPixelShader: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9224. /** @hidden */
  9225. export var bonesDeclaration: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9231. /** @hidden */
  9232. export var morphTargetsVertexGlobalDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9238. /** @hidden */
  9239. export var morphTargetsVertexDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9245. /** @hidden */
  9246. export var instancesDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9252. /** @hidden */
  9253. export var helperFunctions: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9259. /** @hidden */
  9260. export var morphTargetsVertex: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9266. /** @hidden */
  9267. export var instancesVertex: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9273. /** @hidden */
  9274. export var bonesVertex: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9280. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9281. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9283. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9286. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9287. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9288. /** @hidden */
  9289. export var shadowMapVertexShader: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9295. /** @hidden */
  9296. export var depthBoxBlurPixelShader: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9302. import { Nullable } from "babylonjs/types";
  9303. import { Scene } from "babylonjs/scene";
  9304. import { Matrix } from "babylonjs/Maths/math.vector";
  9305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9307. import { Mesh } from "babylonjs/Meshes/mesh";
  9308. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9309. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9310. import { Effect } from "babylonjs/Materials/effect";
  9311. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9312. import "babylonjs/Shaders/shadowMap.fragment";
  9313. import "babylonjs/Shaders/shadowMap.vertex";
  9314. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9315. import { Observable } from "babylonjs/Misc/observable";
  9316. /**
  9317. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9318. */
  9319. export interface ICustomShaderOptions {
  9320. /**
  9321. * Gets or sets the custom shader name to use
  9322. */
  9323. shaderName: string;
  9324. /**
  9325. * The list of attribute names used in the shader
  9326. */
  9327. attributes?: string[];
  9328. /**
  9329. * The list of unifrom names used in the shader
  9330. */
  9331. uniforms?: string[];
  9332. /**
  9333. * The list of sampler names used in the shader
  9334. */
  9335. samplers?: string[];
  9336. /**
  9337. * The list of defines used in the shader
  9338. */
  9339. defines?: string[];
  9340. }
  9341. /**
  9342. * Interface to implement to create a shadow generator compatible with BJS.
  9343. */
  9344. export interface IShadowGenerator {
  9345. /**
  9346. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9347. * @returns The render target texture if present otherwise, null
  9348. */
  9349. getShadowMap(): Nullable<RenderTargetTexture>;
  9350. /**
  9351. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9352. * @returns The render target texture if the shadow map is present otherwise, null
  9353. */
  9354. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9355. /**
  9356. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9357. * @param subMesh The submesh we want to render in the shadow map
  9358. * @param useInstances Defines wether will draw in the map using instances
  9359. * @returns true if ready otherwise, false
  9360. */
  9361. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9362. /**
  9363. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9364. * @param defines Defines of the material we want to update
  9365. * @param lightIndex Index of the light in the enabled light list of the material
  9366. */
  9367. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9368. /**
  9369. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9370. * defined in the generator but impacting the effect).
  9371. * It implies the unifroms available on the materials are the standard BJS ones.
  9372. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9373. * @param effect The effect we are binfing the information for
  9374. */
  9375. bindShadowLight(lightIndex: string, effect: Effect): void;
  9376. /**
  9377. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9378. * (eq to shadow prjection matrix * light transform matrix)
  9379. * @returns The transform matrix used to create the shadow map
  9380. */
  9381. getTransformMatrix(): Matrix;
  9382. /**
  9383. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9384. * Cube and 2D textures for instance.
  9385. */
  9386. recreateShadowMap(): void;
  9387. /**
  9388. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9389. * @param onCompiled Callback triggered at the and of the effects compilation
  9390. * @param options Sets of optional options forcing the compilation with different modes
  9391. */
  9392. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9393. useInstances: boolean;
  9394. }>): void;
  9395. /**
  9396. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9397. * @param options Sets of optional options forcing the compilation with different modes
  9398. * @returns A promise that resolves when the compilation completes
  9399. */
  9400. forceCompilationAsync(options?: Partial<{
  9401. useInstances: boolean;
  9402. }>): Promise<void>;
  9403. /**
  9404. * Serializes the shadow generator setup to a json object.
  9405. * @returns The serialized JSON object
  9406. */
  9407. serialize(): any;
  9408. /**
  9409. * Disposes the Shadow map and related Textures and effects.
  9410. */
  9411. dispose(): void;
  9412. }
  9413. /**
  9414. * Default implementation IShadowGenerator.
  9415. * This is the main object responsible of generating shadows in the framework.
  9416. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9417. */
  9418. export class ShadowGenerator implements IShadowGenerator {
  9419. /**
  9420. * Shadow generator mode None: no filtering applied.
  9421. */
  9422. static readonly FILTER_NONE: number;
  9423. /**
  9424. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9426. */
  9427. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9428. /**
  9429. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9430. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9431. */
  9432. static readonly FILTER_POISSONSAMPLING: number;
  9433. /**
  9434. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9436. */
  9437. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9438. /**
  9439. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9440. * edge artifacts on steep falloff.
  9441. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9442. */
  9443. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9444. /**
  9445. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9446. * edge artifacts on steep falloff.
  9447. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9448. */
  9449. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9450. /**
  9451. * Shadow generator mode PCF: Percentage Closer Filtering
  9452. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9453. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9454. */
  9455. static readonly FILTER_PCF: number;
  9456. /**
  9457. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9458. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9459. * Contact Hardening
  9460. */
  9461. static readonly FILTER_PCSS: number;
  9462. /**
  9463. * Reserved for PCF and PCSS
  9464. * Highest Quality.
  9465. *
  9466. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9467. *
  9468. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9469. */
  9470. static readonly QUALITY_HIGH: number;
  9471. /**
  9472. * Reserved for PCF and PCSS
  9473. * Good tradeoff for quality/perf cross devices
  9474. *
  9475. * Execute PCF on a 3*3 kernel.
  9476. *
  9477. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9478. */
  9479. static readonly QUALITY_MEDIUM: number;
  9480. /**
  9481. * Reserved for PCF and PCSS
  9482. * The lowest quality but the fastest.
  9483. *
  9484. * Execute PCF on a 1*1 kernel.
  9485. *
  9486. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9487. */
  9488. static readonly QUALITY_LOW: number;
  9489. /** Gets or sets the custom shader name to use */
  9490. customShaderOptions: ICustomShaderOptions;
  9491. /**
  9492. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9493. */
  9494. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9495. /**
  9496. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9497. */
  9498. onAfterShadowMapRenderObservable: Observable<Effect>;
  9499. /**
  9500. * Observable triggered before a mesh is rendered in the shadow map.
  9501. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9502. */
  9503. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9504. /**
  9505. * Observable triggered after a mesh is rendered in the shadow map.
  9506. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9507. */
  9508. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9509. private _bias;
  9510. /**
  9511. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9512. */
  9513. /**
  9514. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9515. */
  9516. bias: number;
  9517. private _normalBias;
  9518. /**
  9519. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9520. */
  9521. /**
  9522. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9523. */
  9524. normalBias: number;
  9525. private _blurBoxOffset;
  9526. /**
  9527. * Gets the blur box offset: offset applied during the blur pass.
  9528. * Only useful if useKernelBlur = false
  9529. */
  9530. /**
  9531. * Sets the blur box offset: offset applied during the blur pass.
  9532. * Only useful if useKernelBlur = false
  9533. */
  9534. blurBoxOffset: number;
  9535. private _blurScale;
  9536. /**
  9537. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9538. * 2 means half of the size.
  9539. */
  9540. /**
  9541. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9542. * 2 means half of the size.
  9543. */
  9544. blurScale: number;
  9545. private _blurKernel;
  9546. /**
  9547. * Gets the blur kernel: kernel size of the blur pass.
  9548. * Only useful if useKernelBlur = true
  9549. */
  9550. /**
  9551. * Sets the blur kernel: kernel size of the blur pass.
  9552. * Only useful if useKernelBlur = true
  9553. */
  9554. blurKernel: number;
  9555. private _useKernelBlur;
  9556. /**
  9557. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9558. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9559. */
  9560. /**
  9561. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9562. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9563. */
  9564. useKernelBlur: boolean;
  9565. private _depthScale;
  9566. /**
  9567. * Gets the depth scale used in ESM mode.
  9568. */
  9569. /**
  9570. * Sets the depth scale used in ESM mode.
  9571. * This can override the scale stored on the light.
  9572. */
  9573. depthScale: number;
  9574. private _filter;
  9575. /**
  9576. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9577. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9578. */
  9579. /**
  9580. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9581. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9582. */
  9583. filter: number;
  9584. /**
  9585. * Gets if the current filter is set to Poisson Sampling.
  9586. */
  9587. /**
  9588. * Sets the current filter to Poisson Sampling.
  9589. */
  9590. usePoissonSampling: boolean;
  9591. /**
  9592. * Gets if the current filter is set to ESM.
  9593. */
  9594. /**
  9595. * Sets the current filter is to ESM.
  9596. */
  9597. useExponentialShadowMap: boolean;
  9598. /**
  9599. * Gets if the current filter is set to filtered ESM.
  9600. */
  9601. /**
  9602. * Gets if the current filter is set to filtered ESM.
  9603. */
  9604. useBlurExponentialShadowMap: boolean;
  9605. /**
  9606. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9607. * exponential to prevent steep falloff artifacts).
  9608. */
  9609. /**
  9610. * Sets the current filter to "close ESM" (using the inverse of the
  9611. * exponential to prevent steep falloff artifacts).
  9612. */
  9613. useCloseExponentialShadowMap: boolean;
  9614. /**
  9615. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9616. * exponential to prevent steep falloff artifacts).
  9617. */
  9618. /**
  9619. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9620. * exponential to prevent steep falloff artifacts).
  9621. */
  9622. useBlurCloseExponentialShadowMap: boolean;
  9623. /**
  9624. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9625. */
  9626. /**
  9627. * Sets the current filter to "PCF" (percentage closer filtering).
  9628. */
  9629. usePercentageCloserFiltering: boolean;
  9630. private _filteringQuality;
  9631. /**
  9632. * Gets the PCF or PCSS Quality.
  9633. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9634. */
  9635. /**
  9636. * Sets the PCF or PCSS Quality.
  9637. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9638. */
  9639. filteringQuality: number;
  9640. /**
  9641. * Gets if the current filter is set to "PCSS" (contact hardening).
  9642. */
  9643. /**
  9644. * Sets the current filter to "PCSS" (contact hardening).
  9645. */
  9646. useContactHardeningShadow: boolean;
  9647. private _contactHardeningLightSizeUVRatio;
  9648. /**
  9649. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9650. * Using a ratio helps keeping shape stability independently of the map size.
  9651. *
  9652. * It does not account for the light projection as it was having too much
  9653. * instability during the light setup or during light position changes.
  9654. *
  9655. * Only valid if useContactHardeningShadow is true.
  9656. */
  9657. /**
  9658. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9659. * Using a ratio helps keeping shape stability independently of the map size.
  9660. *
  9661. * It does not account for the light projection as it was having too much
  9662. * instability during the light setup or during light position changes.
  9663. *
  9664. * Only valid if useContactHardeningShadow is true.
  9665. */
  9666. contactHardeningLightSizeUVRatio: number;
  9667. private _darkness;
  9668. /** Gets or sets the actual darkness of a shadow */
  9669. darkness: number;
  9670. /**
  9671. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9672. * 0 means strongest and 1 would means no shadow.
  9673. * @returns the darkness.
  9674. */
  9675. getDarkness(): number;
  9676. /**
  9677. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9678. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9679. * @returns the shadow generator allowing fluent coding.
  9680. */
  9681. setDarkness(darkness: number): ShadowGenerator;
  9682. private _transparencyShadow;
  9683. /** Gets or sets the ability to have transparent shadow */
  9684. transparencyShadow: boolean;
  9685. /**
  9686. * Sets the ability to have transparent shadow (boolean).
  9687. * @param transparent True if transparent else False
  9688. * @returns the shadow generator allowing fluent coding
  9689. */
  9690. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9691. private _shadowMap;
  9692. private _shadowMap2;
  9693. /**
  9694. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9695. * @returns The render target texture if present otherwise, null
  9696. */
  9697. getShadowMap(): Nullable<RenderTargetTexture>;
  9698. /**
  9699. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9700. * @returns The render target texture if the shadow map is present otherwise, null
  9701. */
  9702. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9703. /**
  9704. * Gets the class name of that object
  9705. * @returns "ShadowGenerator"
  9706. */
  9707. getClassName(): string;
  9708. /**
  9709. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9710. * @param mesh Mesh to add
  9711. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9712. * @returns the Shadow Generator itself
  9713. */
  9714. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9715. /**
  9716. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9717. * @param mesh Mesh to remove
  9718. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9719. * @returns the Shadow Generator itself
  9720. */
  9721. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9722. /**
  9723. * Controls the extent to which the shadows fade out at the edge of the frustum
  9724. * Used only by directionals and spots
  9725. */
  9726. frustumEdgeFalloff: number;
  9727. private _light;
  9728. /**
  9729. * Returns the associated light object.
  9730. * @returns the light generating the shadow
  9731. */
  9732. getLight(): IShadowLight;
  9733. /**
  9734. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9735. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9736. * It might on the other hand introduce peter panning.
  9737. */
  9738. forceBackFacesOnly: boolean;
  9739. private _scene;
  9740. private _lightDirection;
  9741. private _effect;
  9742. private _viewMatrix;
  9743. private _projectionMatrix;
  9744. private _transformMatrix;
  9745. private _cachedPosition;
  9746. private _cachedDirection;
  9747. private _cachedDefines;
  9748. private _currentRenderID;
  9749. private _boxBlurPostprocess;
  9750. private _kernelBlurXPostprocess;
  9751. private _kernelBlurYPostprocess;
  9752. private _blurPostProcesses;
  9753. private _mapSize;
  9754. private _currentFaceIndex;
  9755. private _currentFaceIndexCache;
  9756. private _textureType;
  9757. private _defaultTextureMatrix;
  9758. private _storedUniqueId;
  9759. /** @hidden */
  9760. static _SceneComponentInitialization: (scene: Scene) => void;
  9761. /**
  9762. * Creates a ShadowGenerator object.
  9763. * A ShadowGenerator is the required tool to use the shadows.
  9764. * Each light casting shadows needs to use its own ShadowGenerator.
  9765. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9766. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9767. * @param light The light object generating the shadows.
  9768. * @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.
  9769. */
  9770. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9771. private _initializeGenerator;
  9772. private _initializeShadowMap;
  9773. private _initializeBlurRTTAndPostProcesses;
  9774. private _renderForShadowMap;
  9775. private _renderSubMeshForShadowMap;
  9776. private _applyFilterValues;
  9777. /**
  9778. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9779. * @param onCompiled Callback triggered at the and of the effects compilation
  9780. * @param options Sets of optional options forcing the compilation with different modes
  9781. */
  9782. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9783. useInstances: boolean;
  9784. }>): void;
  9785. /**
  9786. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9787. * @param options Sets of optional options forcing the compilation with different modes
  9788. * @returns A promise that resolves when the compilation completes
  9789. */
  9790. forceCompilationAsync(options?: Partial<{
  9791. useInstances: boolean;
  9792. }>): Promise<void>;
  9793. /**
  9794. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9795. * @param subMesh The submesh we want to render in the shadow map
  9796. * @param useInstances Defines wether will draw in the map using instances
  9797. * @returns true if ready otherwise, false
  9798. */
  9799. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9800. /**
  9801. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9802. * @param defines Defines of the material we want to update
  9803. * @param lightIndex Index of the light in the enabled light list of the material
  9804. */
  9805. prepareDefines(defines: any, lightIndex: number): void;
  9806. /**
  9807. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9808. * defined in the generator but impacting the effect).
  9809. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9810. * @param effect The effect we are binfing the information for
  9811. */
  9812. bindShadowLight(lightIndex: string, effect: Effect): void;
  9813. /**
  9814. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9815. * (eq to shadow prjection matrix * light transform matrix)
  9816. * @returns The transform matrix used to create the shadow map
  9817. */
  9818. getTransformMatrix(): Matrix;
  9819. /**
  9820. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9821. * Cube and 2D textures for instance.
  9822. */
  9823. recreateShadowMap(): void;
  9824. private _disposeBlurPostProcesses;
  9825. private _disposeRTTandPostProcesses;
  9826. /**
  9827. * Disposes the ShadowGenerator.
  9828. * Returns nothing.
  9829. */
  9830. dispose(): void;
  9831. /**
  9832. * Serializes the shadow generator setup to a json object.
  9833. * @returns The serialized JSON object
  9834. */
  9835. serialize(): any;
  9836. /**
  9837. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9838. * @param parsedShadowGenerator The JSON object to parse
  9839. * @param scene The scene to create the shadow map for
  9840. * @returns The parsed shadow generator
  9841. */
  9842. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9843. }
  9844. }
  9845. declare module "babylonjs/Lights/light" {
  9846. import { Nullable } from "babylonjs/types";
  9847. import { Scene } from "babylonjs/scene";
  9848. import { Vector3 } from "babylonjs/Maths/math.vector";
  9849. import { Color3 } from "babylonjs/Maths/math.color";
  9850. import { Node } from "babylonjs/node";
  9851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9852. import { Effect } from "babylonjs/Materials/effect";
  9853. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9854. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9855. /**
  9856. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9857. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9858. * 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.
  9859. */
  9860. export abstract class Light extends Node {
  9861. /**
  9862. * Falloff Default: light is falling off following the material specification:
  9863. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9864. */
  9865. static readonly FALLOFF_DEFAULT: number;
  9866. /**
  9867. * Falloff Physical: light is falling off following the inverse squared distance law.
  9868. */
  9869. static readonly FALLOFF_PHYSICAL: number;
  9870. /**
  9871. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9872. * to enhance interoperability with other engines.
  9873. */
  9874. static readonly FALLOFF_GLTF: number;
  9875. /**
  9876. * Falloff Standard: light is falling off like in the standard material
  9877. * to enhance interoperability with other materials.
  9878. */
  9879. static readonly FALLOFF_STANDARD: number;
  9880. /**
  9881. * If every light affecting the material is in this lightmapMode,
  9882. * material.lightmapTexture adds or multiplies
  9883. * (depends on material.useLightmapAsShadowmap)
  9884. * after every other light calculations.
  9885. */
  9886. static readonly LIGHTMAP_DEFAULT: number;
  9887. /**
  9888. * material.lightmapTexture as only diffuse lighting from this light
  9889. * adds only specular lighting from this light
  9890. * adds dynamic shadows
  9891. */
  9892. static readonly LIGHTMAP_SPECULAR: number;
  9893. /**
  9894. * material.lightmapTexture as only lighting
  9895. * no light calculation from this light
  9896. * only adds dynamic shadows from this light
  9897. */
  9898. static readonly LIGHTMAP_SHADOWSONLY: number;
  9899. /**
  9900. * Each light type uses the default quantity according to its type:
  9901. * point/spot lights use luminous intensity
  9902. * directional lights use illuminance
  9903. */
  9904. static readonly INTENSITYMODE_AUTOMATIC: number;
  9905. /**
  9906. * lumen (lm)
  9907. */
  9908. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9909. /**
  9910. * candela (lm/sr)
  9911. */
  9912. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9913. /**
  9914. * lux (lm/m^2)
  9915. */
  9916. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9917. /**
  9918. * nit (cd/m^2)
  9919. */
  9920. static readonly INTENSITYMODE_LUMINANCE: number;
  9921. /**
  9922. * Light type const id of the point light.
  9923. */
  9924. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9925. /**
  9926. * Light type const id of the directional light.
  9927. */
  9928. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9929. /**
  9930. * Light type const id of the spot light.
  9931. */
  9932. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9933. /**
  9934. * Light type const id of the hemispheric light.
  9935. */
  9936. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9937. /**
  9938. * Diffuse gives the basic color to an object.
  9939. */
  9940. diffuse: Color3;
  9941. /**
  9942. * Specular produces a highlight color on an object.
  9943. * Note: This is note affecting PBR materials.
  9944. */
  9945. specular: Color3;
  9946. /**
  9947. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9948. * falling off base on range or angle.
  9949. * This can be set to any values in Light.FALLOFF_x.
  9950. *
  9951. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9952. * other types of materials.
  9953. */
  9954. falloffType: number;
  9955. /**
  9956. * Strength of the light.
  9957. * Note: By default it is define in the framework own unit.
  9958. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9959. */
  9960. intensity: number;
  9961. private _range;
  9962. protected _inverseSquaredRange: number;
  9963. /**
  9964. * Defines how far from the source the light is impacting in scene units.
  9965. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9966. */
  9967. /**
  9968. * Defines how far from the source the light is impacting in scene units.
  9969. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9970. */
  9971. range: number;
  9972. /**
  9973. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9974. * of light.
  9975. */
  9976. private _photometricScale;
  9977. private _intensityMode;
  9978. /**
  9979. * Gets the photometric scale used to interpret the intensity.
  9980. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9981. */
  9982. /**
  9983. * Sets the photometric scale used to interpret the intensity.
  9984. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9985. */
  9986. intensityMode: number;
  9987. private _radius;
  9988. /**
  9989. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9990. */
  9991. /**
  9992. * sets the light radius used by PBR Materials to simulate soft area lights.
  9993. */
  9994. radius: number;
  9995. private _renderPriority;
  9996. /**
  9997. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9998. * exceeding the number allowed of the materials.
  9999. */
  10000. renderPriority: number;
  10001. private _shadowEnabled;
  10002. /**
  10003. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10004. * the current shadow generator.
  10005. */
  10006. /**
  10007. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10008. * the current shadow generator.
  10009. */
  10010. shadowEnabled: boolean;
  10011. private _includedOnlyMeshes;
  10012. /**
  10013. * Gets the only meshes impacted by this light.
  10014. */
  10015. /**
  10016. * Sets the only meshes impacted by this light.
  10017. */
  10018. includedOnlyMeshes: AbstractMesh[];
  10019. private _excludedMeshes;
  10020. /**
  10021. * Gets the meshes not impacted by this light.
  10022. */
  10023. /**
  10024. * Sets the meshes not impacted by this light.
  10025. */
  10026. excludedMeshes: AbstractMesh[];
  10027. private _excludeWithLayerMask;
  10028. /**
  10029. * Gets the layer id use to find what meshes are not impacted by the light.
  10030. * Inactive if 0
  10031. */
  10032. /**
  10033. * Sets the layer id use to find what meshes are not impacted by the light.
  10034. * Inactive if 0
  10035. */
  10036. excludeWithLayerMask: number;
  10037. private _includeOnlyWithLayerMask;
  10038. /**
  10039. * Gets the layer id use to find what meshes are impacted by the light.
  10040. * Inactive if 0
  10041. */
  10042. /**
  10043. * Sets the layer id use to find what meshes are impacted by the light.
  10044. * Inactive if 0
  10045. */
  10046. includeOnlyWithLayerMask: number;
  10047. private _lightmapMode;
  10048. /**
  10049. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10050. */
  10051. /**
  10052. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10053. */
  10054. lightmapMode: number;
  10055. /**
  10056. * Shadow generator associted to the light.
  10057. * @hidden Internal use only.
  10058. */
  10059. _shadowGenerator: Nullable<IShadowGenerator>;
  10060. /**
  10061. * @hidden Internal use only.
  10062. */
  10063. _excludedMeshesIds: string[];
  10064. /**
  10065. * @hidden Internal use only.
  10066. */
  10067. _includedOnlyMeshesIds: string[];
  10068. /**
  10069. * The current light unifom buffer.
  10070. * @hidden Internal use only.
  10071. */
  10072. _uniformBuffer: UniformBuffer;
  10073. /** @hidden */
  10074. _renderId: number;
  10075. /**
  10076. * Creates a Light object in the scene.
  10077. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10078. * @param name The firendly name of the light
  10079. * @param scene The scene the light belongs too
  10080. */
  10081. constructor(name: string, scene: Scene);
  10082. protected abstract _buildUniformLayout(): void;
  10083. /**
  10084. * Sets the passed Effect "effect" with the Light information.
  10085. * @param effect The effect to update
  10086. * @param lightIndex The index of the light in the effect to update
  10087. * @returns The light
  10088. */
  10089. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10090. /**
  10091. * Sets the passed Effect "effect" with the Light information.
  10092. * @param effect The effect to update
  10093. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10094. * @returns The light
  10095. */
  10096. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10097. /**
  10098. * Returns the string "Light".
  10099. * @returns the class name
  10100. */
  10101. getClassName(): string;
  10102. /** @hidden */
  10103. readonly _isLight: boolean;
  10104. /**
  10105. * Converts the light information to a readable string for debug purpose.
  10106. * @param fullDetails Supports for multiple levels of logging within scene loading
  10107. * @returns the human readable light info
  10108. */
  10109. toString(fullDetails?: boolean): string;
  10110. /** @hidden */
  10111. protected _syncParentEnabledState(): void;
  10112. /**
  10113. * Set the enabled state of this node.
  10114. * @param value - the new enabled state
  10115. */
  10116. setEnabled(value: boolean): void;
  10117. /**
  10118. * Returns the Light associated shadow generator if any.
  10119. * @return the associated shadow generator.
  10120. */
  10121. getShadowGenerator(): Nullable<IShadowGenerator>;
  10122. /**
  10123. * Returns a Vector3, the absolute light position in the World.
  10124. * @returns the world space position of the light
  10125. */
  10126. getAbsolutePosition(): Vector3;
  10127. /**
  10128. * Specifies if the light will affect the passed mesh.
  10129. * @param mesh The mesh to test against the light
  10130. * @return true the mesh is affected otherwise, false.
  10131. */
  10132. canAffectMesh(mesh: AbstractMesh): boolean;
  10133. /**
  10134. * Sort function to order lights for rendering.
  10135. * @param a First Light object to compare to second.
  10136. * @param b Second Light object to compare first.
  10137. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10138. */
  10139. static CompareLightsPriority(a: Light, b: Light): number;
  10140. /**
  10141. * Releases resources associated with this node.
  10142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10144. */
  10145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10146. /**
  10147. * Returns the light type ID (integer).
  10148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10149. */
  10150. getTypeID(): number;
  10151. /**
  10152. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10153. * @returns the scaled intensity in intensity mode unit
  10154. */
  10155. getScaledIntensity(): number;
  10156. /**
  10157. * Returns a new Light object, named "name", from the current one.
  10158. * @param name The name of the cloned light
  10159. * @returns the new created light
  10160. */
  10161. clone(name: string): Nullable<Light>;
  10162. /**
  10163. * Serializes the current light into a Serialization object.
  10164. * @returns the serialized object.
  10165. */
  10166. serialize(): any;
  10167. /**
  10168. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10169. * This new light is named "name" and added to the passed scene.
  10170. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10171. * @param name The friendly name of the light
  10172. * @param scene The scene the new light will belong to
  10173. * @returns the constructor function
  10174. */
  10175. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10176. /**
  10177. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10178. * @param parsedLight The JSON representation of the light
  10179. * @param scene The scene to create the parsed light in
  10180. * @returns the created light after parsing
  10181. */
  10182. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10183. private _hookArrayForExcluded;
  10184. private _hookArrayForIncludedOnly;
  10185. private _resyncMeshes;
  10186. /**
  10187. * Forces the meshes to update their light related information in their rendering used effects
  10188. * @hidden Internal Use Only
  10189. */
  10190. _markMeshesAsLightDirty(): void;
  10191. /**
  10192. * Recomputes the cached photometric scale if needed.
  10193. */
  10194. private _computePhotometricScale;
  10195. /**
  10196. * Returns the Photometric Scale according to the light type and intensity mode.
  10197. */
  10198. private _getPhotometricScale;
  10199. /**
  10200. * Reorder the light in the scene according to their defined priority.
  10201. * @hidden Internal Use Only
  10202. */
  10203. _reorderLightsInScene(): void;
  10204. /**
  10205. * Prepares the list of defines specific to the light type.
  10206. * @param defines the list of defines
  10207. * @param lightIndex defines the index of the light for the effect
  10208. */
  10209. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10210. }
  10211. }
  10212. declare module "babylonjs/Actions/action" {
  10213. import { Observable } from "babylonjs/Misc/observable";
  10214. import { Condition } from "babylonjs/Actions/condition";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. import { ActionManager } from "babylonjs/Actions/actionManager";
  10217. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10218. /**
  10219. * Interface used to define Action
  10220. */
  10221. export interface IAction {
  10222. /**
  10223. * Trigger for the action
  10224. */
  10225. trigger: number;
  10226. /** Options of the trigger */
  10227. triggerOptions: any;
  10228. /**
  10229. * Gets the trigger parameters
  10230. * @returns the trigger parameters
  10231. */
  10232. getTriggerParameter(): any;
  10233. /**
  10234. * Internal only - executes current action event
  10235. * @hidden
  10236. */
  10237. _executeCurrent(evt?: ActionEvent): void;
  10238. /**
  10239. * Serialize placeholder for child classes
  10240. * @param parent of child
  10241. * @returns the serialized object
  10242. */
  10243. serialize(parent: any): any;
  10244. /**
  10245. * Internal only
  10246. * @hidden
  10247. */
  10248. _prepare(): void;
  10249. /**
  10250. * Internal only - manager for action
  10251. * @hidden
  10252. */
  10253. _actionManager: AbstractActionManager;
  10254. /**
  10255. * Adds action to chain of actions, may be a DoNothingAction
  10256. * @param action defines the next action to execute
  10257. * @returns The action passed in
  10258. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10259. */
  10260. then(action: IAction): IAction;
  10261. }
  10262. /**
  10263. * The action to be carried out following a trigger
  10264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10265. */
  10266. export class Action implements IAction {
  10267. /** the trigger, with or without parameters, for the action */
  10268. triggerOptions: any;
  10269. /**
  10270. * Trigger for the action
  10271. */
  10272. trigger: number;
  10273. /**
  10274. * Internal only - manager for action
  10275. * @hidden
  10276. */
  10277. _actionManager: ActionManager;
  10278. private _nextActiveAction;
  10279. private _child;
  10280. private _condition?;
  10281. private _triggerParameter;
  10282. /**
  10283. * An event triggered prior to action being executed.
  10284. */
  10285. onBeforeExecuteObservable: Observable<Action>;
  10286. /**
  10287. * Creates a new Action
  10288. * @param triggerOptions the trigger, with or without parameters, for the action
  10289. * @param condition an optional determinant of action
  10290. */
  10291. constructor(
  10292. /** the trigger, with or without parameters, for the action */
  10293. triggerOptions: any, condition?: Condition);
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _prepare(): void;
  10299. /**
  10300. * Gets the trigger parameters
  10301. * @returns the trigger parameters
  10302. */
  10303. getTriggerParameter(): any;
  10304. /**
  10305. * Internal only - executes current action event
  10306. * @hidden
  10307. */
  10308. _executeCurrent(evt?: ActionEvent): void;
  10309. /**
  10310. * Execute placeholder for child classes
  10311. * @param evt optional action event
  10312. */
  10313. execute(evt?: ActionEvent): void;
  10314. /**
  10315. * Skips to next active action
  10316. */
  10317. skipToNextActiveAction(): void;
  10318. /**
  10319. * Adds action to chain of actions, may be a DoNothingAction
  10320. * @param action defines the next action to execute
  10321. * @returns The action passed in
  10322. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10323. */
  10324. then(action: Action): Action;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. _getProperty(propertyPath: string): string;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. _getEffectiveTarget(target: any, propertyPath: string): any;
  10335. /**
  10336. * Serialize placeholder for child classes
  10337. * @param parent of child
  10338. * @returns the serialized object
  10339. */
  10340. serialize(parent: any): any;
  10341. /**
  10342. * Internal only called by serialize
  10343. * @hidden
  10344. */
  10345. protected _serialize(serializedAction: any, parent?: any): any;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. static _SerializeValueAsString: (value: any) => string;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10356. name: string;
  10357. targetType: string;
  10358. value: string;
  10359. };
  10360. }
  10361. }
  10362. declare module "babylonjs/Actions/condition" {
  10363. import { ActionManager } from "babylonjs/Actions/actionManager";
  10364. /**
  10365. * A Condition applied to an Action
  10366. */
  10367. export class Condition {
  10368. /**
  10369. * Internal only - manager for action
  10370. * @hidden
  10371. */
  10372. _actionManager: ActionManager;
  10373. /**
  10374. * Internal only
  10375. * @hidden
  10376. */
  10377. _evaluationId: number;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. _currentResult: boolean;
  10383. /**
  10384. * Creates a new Condition
  10385. * @param actionManager the manager of the action the condition is applied to
  10386. */
  10387. constructor(actionManager: ActionManager);
  10388. /**
  10389. * Check if the current condition is valid
  10390. * @returns a boolean
  10391. */
  10392. isValid(): boolean;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. _getProperty(propertyPath: string): string;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. _getEffectiveTarget(target: any, propertyPath: string): any;
  10403. /**
  10404. * Serialize placeholder for child classes
  10405. * @returns the serialized object
  10406. */
  10407. serialize(): any;
  10408. /**
  10409. * Internal only
  10410. * @hidden
  10411. */
  10412. protected _serialize(serializedCondition: any): any;
  10413. }
  10414. /**
  10415. * Defines specific conditional operators as extensions of Condition
  10416. */
  10417. export class ValueCondition extends Condition {
  10418. /** path to specify the property of the target the conditional operator uses */
  10419. propertyPath: string;
  10420. /** the value compared by the conditional operator against the current value of the property */
  10421. value: any;
  10422. /** the conditional operator, default ValueCondition.IsEqual */
  10423. operator: number;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private static _IsEqual;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private static _IsDifferent;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. private static _IsGreater;
  10439. /**
  10440. * Internal only
  10441. * @hidden
  10442. */
  10443. private static _IsLesser;
  10444. /**
  10445. * returns the number for IsEqual
  10446. */
  10447. static readonly IsEqual: number;
  10448. /**
  10449. * Returns the number for IsDifferent
  10450. */
  10451. static readonly IsDifferent: number;
  10452. /**
  10453. * Returns the number for IsGreater
  10454. */
  10455. static readonly IsGreater: number;
  10456. /**
  10457. * Returns the number for IsLesser
  10458. */
  10459. static readonly IsLesser: number;
  10460. /**
  10461. * Internal only The action manager for the condition
  10462. * @hidden
  10463. */
  10464. _actionManager: ActionManager;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private _target;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. private _effectiveTarget;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. private _property;
  10480. /**
  10481. * Creates a new ValueCondition
  10482. * @param actionManager manager for the action the condition applies to
  10483. * @param target for the action
  10484. * @param propertyPath path to specify the property of the target the conditional operator uses
  10485. * @param value the value compared by the conditional operator against the current value of the property
  10486. * @param operator the conditional operator, default ValueCondition.IsEqual
  10487. */
  10488. constructor(actionManager: ActionManager, target: any,
  10489. /** path to specify the property of the target the conditional operator uses */
  10490. propertyPath: string,
  10491. /** the value compared by the conditional operator against the current value of the property */
  10492. value: any,
  10493. /** the conditional operator, default ValueCondition.IsEqual */
  10494. operator?: number);
  10495. /**
  10496. * Compares the given value with the property value for the specified conditional operator
  10497. * @returns the result of the comparison
  10498. */
  10499. isValid(): boolean;
  10500. /**
  10501. * Serialize the ValueCondition into a JSON compatible object
  10502. * @returns serialization object
  10503. */
  10504. serialize(): any;
  10505. /**
  10506. * Gets the name of the conditional operator for the ValueCondition
  10507. * @param operator the conditional operator
  10508. * @returns the name
  10509. */
  10510. static GetOperatorName(operator: number): string;
  10511. }
  10512. /**
  10513. * Defines a predicate condition as an extension of Condition
  10514. */
  10515. export class PredicateCondition extends Condition {
  10516. /** defines the predicate function used to validate the condition */
  10517. predicate: () => boolean;
  10518. /**
  10519. * Internal only - manager for action
  10520. * @hidden
  10521. */
  10522. _actionManager: ActionManager;
  10523. /**
  10524. * Creates a new PredicateCondition
  10525. * @param actionManager manager for the action the condition applies to
  10526. * @param predicate defines the predicate function used to validate the condition
  10527. */
  10528. constructor(actionManager: ActionManager,
  10529. /** defines the predicate function used to validate the condition */
  10530. predicate: () => boolean);
  10531. /**
  10532. * @returns the validity of the predicate condition
  10533. */
  10534. isValid(): boolean;
  10535. }
  10536. /**
  10537. * Defines a state condition as an extension of Condition
  10538. */
  10539. export class StateCondition extends Condition {
  10540. /** Value to compare with target state */
  10541. value: string;
  10542. /**
  10543. * Internal only - manager for action
  10544. * @hidden
  10545. */
  10546. _actionManager: ActionManager;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private _target;
  10552. /**
  10553. * Creates a new StateCondition
  10554. * @param actionManager manager for the action the condition applies to
  10555. * @param target of the condition
  10556. * @param value to compare with target state
  10557. */
  10558. constructor(actionManager: ActionManager, target: any,
  10559. /** Value to compare with target state */
  10560. value: string);
  10561. /**
  10562. * Gets a boolean indicating if the current condition is met
  10563. * @returns the validity of the state
  10564. */
  10565. isValid(): boolean;
  10566. /**
  10567. * Serialize the StateCondition into a JSON compatible object
  10568. * @returns serialization object
  10569. */
  10570. serialize(): any;
  10571. }
  10572. }
  10573. declare module "babylonjs/Actions/directActions" {
  10574. import { Action } from "babylonjs/Actions/action";
  10575. import { Condition } from "babylonjs/Actions/condition";
  10576. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10577. /**
  10578. * This defines an action responsible to toggle a boolean once triggered.
  10579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10580. */
  10581. export class SwitchBooleanAction extends Action {
  10582. /**
  10583. * The path to the boolean property in the target object
  10584. */
  10585. propertyPath: string;
  10586. private _target;
  10587. private _effectiveTarget;
  10588. private _property;
  10589. /**
  10590. * Instantiate the action
  10591. * @param triggerOptions defines the trigger options
  10592. * @param target defines the object containing the boolean
  10593. * @param propertyPath defines the path to the boolean property in the target object
  10594. * @param condition defines the trigger related conditions
  10595. */
  10596. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10597. /** @hidden */
  10598. _prepare(): void;
  10599. /**
  10600. * Execute the action toggle the boolean value.
  10601. */
  10602. execute(): void;
  10603. /**
  10604. * Serializes the actions and its related information.
  10605. * @param parent defines the object to serialize in
  10606. * @returns the serialized object
  10607. */
  10608. serialize(parent: any): any;
  10609. }
  10610. /**
  10611. * This defines an action responsible to set a the state field of the target
  10612. * to a desired value once triggered.
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10614. */
  10615. export class SetStateAction extends Action {
  10616. /**
  10617. * The value to store in the state field.
  10618. */
  10619. value: string;
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the object containing the state property
  10625. * @param value defines the value to store in the state field
  10626. * @param condition defines the trigger related conditions
  10627. */
  10628. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10629. /**
  10630. * Execute the action and store the value on the target state property.
  10631. */
  10632. execute(): void;
  10633. /**
  10634. * Serializes the actions and its related information.
  10635. * @param parent defines the object to serialize in
  10636. * @returns the serialized object
  10637. */
  10638. serialize(parent: any): any;
  10639. }
  10640. /**
  10641. * This defines an action responsible to set a property of the target
  10642. * to a desired value once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class SetValueAction extends Action {
  10646. /**
  10647. * The path of the property to set in the target.
  10648. */
  10649. propertyPath: string;
  10650. /**
  10651. * The value to set in the property
  10652. */
  10653. value: any;
  10654. private _target;
  10655. private _effectiveTarget;
  10656. private _property;
  10657. /**
  10658. * Instantiate the action
  10659. * @param triggerOptions defines the trigger options
  10660. * @param target defines the object containing the property
  10661. * @param propertyPath defines the path of the property to set in the target
  10662. * @param value defines the value to set in the property
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10666. /** @hidden */
  10667. _prepare(): void;
  10668. /**
  10669. * Execute the action and set the targetted property to the desired value.
  10670. */
  10671. execute(): void;
  10672. /**
  10673. * Serializes the actions and its related information.
  10674. * @param parent defines the object to serialize in
  10675. * @returns the serialized object
  10676. */
  10677. serialize(parent: any): any;
  10678. }
  10679. /**
  10680. * This defines an action responsible to increment the target value
  10681. * to a desired value once triggered.
  10682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10683. */
  10684. export class IncrementValueAction extends Action {
  10685. /**
  10686. * The path of the property to increment in the target.
  10687. */
  10688. propertyPath: string;
  10689. /**
  10690. * The value we should increment the property by.
  10691. */
  10692. value: any;
  10693. private _target;
  10694. private _effectiveTarget;
  10695. private _property;
  10696. /**
  10697. * Instantiate the action
  10698. * @param triggerOptions defines the trigger options
  10699. * @param target defines the object containing the property
  10700. * @param propertyPath defines the path of the property to increment in the target
  10701. * @param value defines the value value we should increment the property by
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action and increment the target of the value amount.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to start an animation once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class PlayAnimationAction extends Action {
  10723. /**
  10724. * Where the animation should start (animation frame)
  10725. */
  10726. from: number;
  10727. /**
  10728. * Where the animation should stop (animation frame)
  10729. */
  10730. to: number;
  10731. /**
  10732. * Define if the animation should loop or stop after the first play.
  10733. */
  10734. loop?: boolean;
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the target animation or animation name
  10740. * @param from defines from where the animation should start (animation frame)
  10741. * @param end defines where the animation should stop (animation frame)
  10742. * @param loop defines if the animation should loop or stop after the first play
  10743. * @param condition defines the trigger related conditions
  10744. */
  10745. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10746. /** @hidden */
  10747. _prepare(): void;
  10748. /**
  10749. * Execute the action and play the animation.
  10750. */
  10751. execute(): void;
  10752. /**
  10753. * Serializes the actions and its related information.
  10754. * @param parent defines the object to serialize in
  10755. * @returns the serialized object
  10756. */
  10757. serialize(parent: any): any;
  10758. }
  10759. /**
  10760. * This defines an action responsible to stop an animation once triggered.
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10762. */
  10763. export class StopAnimationAction extends Action {
  10764. private _target;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param target defines the target animation or animation name
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and stop the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible that does nothing once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class DoNothingAction extends Action {
  10790. /**
  10791. * Instantiate the action
  10792. * @param triggerOptions defines the trigger options
  10793. * @param condition defines the trigger related conditions
  10794. */
  10795. constructor(triggerOptions?: any, condition?: Condition);
  10796. /**
  10797. * Execute the action and do nothing.
  10798. */
  10799. execute(): void;
  10800. /**
  10801. * Serializes the actions and its related information.
  10802. * @param parent defines the object to serialize in
  10803. * @returns the serialized object
  10804. */
  10805. serialize(parent: any): any;
  10806. }
  10807. /**
  10808. * This defines an action responsible to trigger several actions once triggered.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class CombineAction extends Action {
  10812. /**
  10813. * The list of aggregated animations to run.
  10814. */
  10815. children: Action[];
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param children defines the list of aggregated animations to run
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and executes all the aggregated actions.
  10827. */
  10828. execute(evt: ActionEvent): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. /**
  10837. * This defines an action responsible to run code (external event) once triggered.
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10839. */
  10840. export class ExecuteCodeAction extends Action {
  10841. /**
  10842. * The callback function to run.
  10843. */
  10844. func: (evt: ActionEvent) => void;
  10845. /**
  10846. * Instantiate the action
  10847. * @param triggerOptions defines the trigger options
  10848. * @param func defines the callback function to run
  10849. * @param condition defines the trigger related conditions
  10850. */
  10851. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10852. /**
  10853. * Execute the action and run the attached code.
  10854. */
  10855. execute(evt: ActionEvent): void;
  10856. }
  10857. /**
  10858. * This defines an action responsible to set the parent property of the target once triggered.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class SetParentAction extends Action {
  10862. private _parent;
  10863. private _target;
  10864. /**
  10865. * Instantiate the action
  10866. * @param triggerOptions defines the trigger options
  10867. * @param target defines the target containing the parent property
  10868. * @param parent defines from where the animation should start (animation frame)
  10869. * @param condition defines the trigger related conditions
  10870. */
  10871. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10872. /** @hidden */
  10873. _prepare(): void;
  10874. /**
  10875. * Execute the action and set the parent property.
  10876. */
  10877. execute(): void;
  10878. /**
  10879. * Serializes the actions and its related information.
  10880. * @param parent defines the object to serialize in
  10881. * @returns the serialized object
  10882. */
  10883. serialize(parent: any): any;
  10884. }
  10885. }
  10886. declare module "babylonjs/Actions/actionManager" {
  10887. import { Nullable } from "babylonjs/types";
  10888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10889. import { Scene } from "babylonjs/scene";
  10890. import { IAction } from "babylonjs/Actions/action";
  10891. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10892. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10893. /**
  10894. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10895. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class ActionManager extends AbstractActionManager {
  10899. /**
  10900. * Nothing
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly NothingTrigger: number;
  10904. /**
  10905. * On pick
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnPickTrigger: number;
  10909. /**
  10910. * On left pick
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnLeftPickTrigger: number;
  10914. /**
  10915. * On right pick
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnRightPickTrigger: number;
  10919. /**
  10920. * On center pick
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnCenterPickTrigger: number;
  10924. /**
  10925. * On pick down
  10926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10927. */
  10928. static readonly OnPickDownTrigger: number;
  10929. /**
  10930. * On double pick
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10932. */
  10933. static readonly OnDoublePickTrigger: number;
  10934. /**
  10935. * On pick up
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10937. */
  10938. static readonly OnPickUpTrigger: number;
  10939. /**
  10940. * On pick out.
  10941. * This trigger will only be raised if you also declared a OnPickDown
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnPickOutTrigger: number;
  10945. /**
  10946. * On long press
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnLongPressTrigger: number;
  10950. /**
  10951. * On pointer over
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPointerOverTrigger: number;
  10955. /**
  10956. * On pointer out
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnPointerOutTrigger: number;
  10960. /**
  10961. * On every frame
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnEveryFrameTrigger: number;
  10965. /**
  10966. * On intersection enter
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10968. */
  10969. static readonly OnIntersectionEnterTrigger: number;
  10970. /**
  10971. * On intersection exit
  10972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10973. */
  10974. static readonly OnIntersectionExitTrigger: number;
  10975. /**
  10976. * On key down
  10977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10978. */
  10979. static readonly OnKeyDownTrigger: number;
  10980. /**
  10981. * On key up
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10983. */
  10984. static readonly OnKeyUpTrigger: number;
  10985. private _scene;
  10986. /**
  10987. * Creates a new action manager
  10988. * @param scene defines the hosting scene
  10989. */
  10990. constructor(scene: Scene);
  10991. /**
  10992. * Releases all associated resources
  10993. */
  10994. dispose(): void;
  10995. /**
  10996. * Gets hosting scene
  10997. * @returns the hosting scene
  10998. */
  10999. getScene(): Scene;
  11000. /**
  11001. * Does this action manager handles actions of any of the given triggers
  11002. * @param triggers defines the triggers to be tested
  11003. * @return a boolean indicating whether one (or more) of the triggers is handled
  11004. */
  11005. hasSpecificTriggers(triggers: number[]): boolean;
  11006. /**
  11007. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11008. * speed.
  11009. * @param triggerA defines the trigger to be tested
  11010. * @param triggerB defines the trigger to be tested
  11011. * @return a boolean indicating whether one (or more) of the triggers is handled
  11012. */
  11013. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11014. /**
  11015. * Does this action manager handles actions of a given trigger
  11016. * @param trigger defines the trigger to be tested
  11017. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11018. * @return whether the trigger is handled
  11019. */
  11020. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11021. /**
  11022. * Does this action manager has pointer triggers
  11023. */
  11024. readonly hasPointerTriggers: boolean;
  11025. /**
  11026. * Does this action manager has pick triggers
  11027. */
  11028. readonly hasPickTriggers: boolean;
  11029. /**
  11030. * Registers an action to this action manager
  11031. * @param action defines the action to be registered
  11032. * @return the action amended (prepared) after registration
  11033. */
  11034. registerAction(action: IAction): Nullable<IAction>;
  11035. /**
  11036. * Unregisters an action to this action manager
  11037. * @param action defines the action to be unregistered
  11038. * @return a boolean indicating whether the action has been unregistered
  11039. */
  11040. unregisterAction(action: IAction): Boolean;
  11041. /**
  11042. * Process a specific trigger
  11043. * @param trigger defines the trigger to process
  11044. * @param evt defines the event details to be processed
  11045. */
  11046. processTrigger(trigger: number, evt?: IActionEvent): void;
  11047. /** @hidden */
  11048. _getEffectiveTarget(target: any, propertyPath: string): any;
  11049. /** @hidden */
  11050. _getProperty(propertyPath: string): string;
  11051. /**
  11052. * Serialize this manager to a JSON object
  11053. * @param name defines the property name to store this manager
  11054. * @returns a JSON representation of this manager
  11055. */
  11056. serialize(name: string): any;
  11057. /**
  11058. * Creates a new ActionManager from a JSON data
  11059. * @param parsedActions defines the JSON data to read from
  11060. * @param object defines the hosting mesh
  11061. * @param scene defines the hosting scene
  11062. */
  11063. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11064. /**
  11065. * Get a trigger name by index
  11066. * @param trigger defines the trigger index
  11067. * @returns a trigger name
  11068. */
  11069. static GetTriggerName(trigger: number): string;
  11070. }
  11071. }
  11072. declare module "babylonjs/Culling/ray" {
  11073. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11074. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11076. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11077. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11078. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11079. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11080. import { Plane } from "babylonjs/Maths/math.plane";
  11081. /**
  11082. * Class representing a ray with position and direction
  11083. */
  11084. export class Ray {
  11085. /** origin point */
  11086. origin: Vector3;
  11087. /** direction */
  11088. direction: Vector3;
  11089. /** length of the ray */
  11090. length: number;
  11091. private static readonly TmpVector3;
  11092. private _tmpRay;
  11093. /**
  11094. * Creates a new ray
  11095. * @param origin origin point
  11096. * @param direction direction
  11097. * @param length length of the ray
  11098. */
  11099. constructor(
  11100. /** origin point */
  11101. origin: Vector3,
  11102. /** direction */
  11103. direction: Vector3,
  11104. /** length of the ray */
  11105. length?: number);
  11106. /**
  11107. * Checks if the ray intersects a box
  11108. * @param minimum bound of the box
  11109. * @param maximum bound of the box
  11110. * @param intersectionTreshold extra extend to be added to the box in all direction
  11111. * @returns if the box was hit
  11112. */
  11113. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11114. /**
  11115. * Checks if the ray intersects a box
  11116. * @param box the bounding box to check
  11117. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11118. * @returns if the box was hit
  11119. */
  11120. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11121. /**
  11122. * If the ray hits a sphere
  11123. * @param sphere the bounding sphere to check
  11124. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11125. * @returns true if it hits the sphere
  11126. */
  11127. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11128. /**
  11129. * If the ray hits a triange
  11130. * @param vertex0 triangle vertex
  11131. * @param vertex1 triangle vertex
  11132. * @param vertex2 triangle vertex
  11133. * @returns intersection information if hit
  11134. */
  11135. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11136. /**
  11137. * Checks if ray intersects a plane
  11138. * @param plane the plane to check
  11139. * @returns the distance away it was hit
  11140. */
  11141. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11142. /**
  11143. * Calculate the intercept of a ray on a given axis
  11144. * @param axis to check 'x' | 'y' | 'z'
  11145. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11146. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11147. */
  11148. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11149. /**
  11150. * Checks if ray intersects a mesh
  11151. * @param mesh the mesh to check
  11152. * @param fastCheck if only the bounding box should checked
  11153. * @returns picking info of the intersecton
  11154. */
  11155. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11156. /**
  11157. * Checks if ray intersects a mesh
  11158. * @param meshes the meshes to check
  11159. * @param fastCheck if only the bounding box should checked
  11160. * @param results array to store result in
  11161. * @returns Array of picking infos
  11162. */
  11163. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11164. private _comparePickingInfo;
  11165. private static smallnum;
  11166. private static rayl;
  11167. /**
  11168. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11169. * @param sega the first point of the segment to test the intersection against
  11170. * @param segb the second point of the segment to test the intersection against
  11171. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11172. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11173. */
  11174. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11175. /**
  11176. * Update the ray from viewport position
  11177. * @param x position
  11178. * @param y y position
  11179. * @param viewportWidth viewport width
  11180. * @param viewportHeight viewport height
  11181. * @param world world matrix
  11182. * @param view view matrix
  11183. * @param projection projection matrix
  11184. * @returns this ray updated
  11185. */
  11186. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11187. /**
  11188. * Creates a ray with origin and direction of 0,0,0
  11189. * @returns the new ray
  11190. */
  11191. static Zero(): Ray;
  11192. /**
  11193. * Creates a new ray from screen space and viewport
  11194. * @param x position
  11195. * @param y y position
  11196. * @param viewportWidth viewport width
  11197. * @param viewportHeight viewport height
  11198. * @param world world matrix
  11199. * @param view view matrix
  11200. * @param projection projection matrix
  11201. * @returns new ray
  11202. */
  11203. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11204. /**
  11205. * 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
  11206. * transformed to the given world matrix.
  11207. * @param origin The origin point
  11208. * @param end The end point
  11209. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11210. * @returns the new ray
  11211. */
  11212. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Transforms a ray by a matrix
  11215. * @param ray ray to transform
  11216. * @param matrix matrix to apply
  11217. * @returns the resulting new ray
  11218. */
  11219. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11220. /**
  11221. * Transforms a ray by a matrix
  11222. * @param ray ray to transform
  11223. * @param matrix matrix to apply
  11224. * @param result ray to store result in
  11225. */
  11226. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11227. /**
  11228. * Unproject a ray from screen space to object space
  11229. * @param sourceX defines the screen space x coordinate to use
  11230. * @param sourceY defines the screen space y coordinate to use
  11231. * @param viewportWidth defines the current width of the viewport
  11232. * @param viewportHeight defines the current height of the viewport
  11233. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11234. * @param view defines the view matrix to use
  11235. * @param projection defines the projection matrix to use
  11236. */
  11237. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11238. }
  11239. /**
  11240. * Type used to define predicate used to select faces when a mesh intersection is detected
  11241. */
  11242. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11243. module "babylonjs/scene" {
  11244. interface Scene {
  11245. /** @hidden */
  11246. _tempPickingRay: Nullable<Ray>;
  11247. /** @hidden */
  11248. _cachedRayForTransform: Ray;
  11249. /** @hidden */
  11250. _pickWithRayInverseMatrix: Matrix;
  11251. /** @hidden */
  11252. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11253. /** @hidden */
  11254. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11255. }
  11256. }
  11257. }
  11258. declare module "babylonjs/sceneComponent" {
  11259. import { Scene } from "babylonjs/scene";
  11260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11262. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11263. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11264. import { Nullable } from "babylonjs/types";
  11265. import { Camera } from "babylonjs/Cameras/camera";
  11266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11267. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11268. import { AbstractScene } from "babylonjs/abstractScene";
  11269. /**
  11270. * Groups all the scene component constants in one place to ease maintenance.
  11271. * @hidden
  11272. */
  11273. export class SceneComponentConstants {
  11274. static readonly NAME_EFFECTLAYER: string;
  11275. static readonly NAME_LAYER: string;
  11276. static readonly NAME_LENSFLARESYSTEM: string;
  11277. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11278. static readonly NAME_PARTICLESYSTEM: string;
  11279. static readonly NAME_GAMEPAD: string;
  11280. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11281. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11282. static readonly NAME_DEPTHRENDERER: string;
  11283. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11284. static readonly NAME_SPRITE: string;
  11285. static readonly NAME_OUTLINERENDERER: string;
  11286. static readonly NAME_PROCEDURALTEXTURE: string;
  11287. static readonly NAME_SHADOWGENERATOR: string;
  11288. static readonly NAME_OCTREE: string;
  11289. static readonly NAME_PHYSICSENGINE: string;
  11290. static readonly NAME_AUDIO: string;
  11291. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11292. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11293. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11294. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11295. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11296. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11297. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11298. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11299. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11300. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11301. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11302. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11303. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11304. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11305. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11306. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11307. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11308. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11309. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11310. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11311. static readonly STEP_AFTERRENDER_AUDIO: number;
  11312. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11313. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11314. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11315. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11316. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11317. static readonly STEP_POINTERMOVE_SPRITE: number;
  11318. static readonly STEP_POINTERDOWN_SPRITE: number;
  11319. static readonly STEP_POINTERUP_SPRITE: number;
  11320. }
  11321. /**
  11322. * This represents a scene component.
  11323. *
  11324. * This is used to decouple the dependency the scene is having on the different workloads like
  11325. * layers, post processes...
  11326. */
  11327. export interface ISceneComponent {
  11328. /**
  11329. * The name of the component. Each component must have a unique name.
  11330. */
  11331. name: string;
  11332. /**
  11333. * The scene the component belongs to.
  11334. */
  11335. scene: Scene;
  11336. /**
  11337. * Register the component to one instance of a scene.
  11338. */
  11339. register(): void;
  11340. /**
  11341. * Rebuilds the elements related to this component in case of
  11342. * context lost for instance.
  11343. */
  11344. rebuild(): void;
  11345. /**
  11346. * Disposes the component and the associated ressources.
  11347. */
  11348. dispose(): void;
  11349. }
  11350. /**
  11351. * This represents a SERIALIZABLE scene component.
  11352. *
  11353. * This extends Scene Component to add Serialization methods on top.
  11354. */
  11355. export interface ISceneSerializableComponent extends ISceneComponent {
  11356. /**
  11357. * Adds all the elements from the container to the scene
  11358. * @param container the container holding the elements
  11359. */
  11360. addFromContainer(container: AbstractScene): void;
  11361. /**
  11362. * Removes all the elements in the container from the scene
  11363. * @param container contains the elements to remove
  11364. * @param dispose if the removed element should be disposed (default: false)
  11365. */
  11366. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11367. /**
  11368. * Serializes the component data to the specified json object
  11369. * @param serializationObject The object to serialize to
  11370. */
  11371. serialize(serializationObject: any): void;
  11372. }
  11373. /**
  11374. * Strong typing of a Mesh related stage step action
  11375. */
  11376. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11377. /**
  11378. * Strong typing of a Evaluate Sub Mesh related stage step action
  11379. */
  11380. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11381. /**
  11382. * Strong typing of a Active Mesh related stage step action
  11383. */
  11384. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11385. /**
  11386. * Strong typing of a Camera related stage step action
  11387. */
  11388. export type CameraStageAction = (camera: Camera) => void;
  11389. /**
  11390. * Strong typing of a Camera Frame buffer related stage step action
  11391. */
  11392. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11393. /**
  11394. * Strong typing of a Render Target related stage step action
  11395. */
  11396. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11397. /**
  11398. * Strong typing of a RenderingGroup related stage step action
  11399. */
  11400. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11401. /**
  11402. * Strong typing of a Mesh Render related stage step action
  11403. */
  11404. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11405. /**
  11406. * Strong typing of a simple stage step action
  11407. */
  11408. export type SimpleStageAction = () => void;
  11409. /**
  11410. * Strong typing of a render target action.
  11411. */
  11412. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11413. /**
  11414. * Strong typing of a pointer move action.
  11415. */
  11416. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11417. /**
  11418. * Strong typing of a pointer up/down action.
  11419. */
  11420. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11421. /**
  11422. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11423. * @hidden
  11424. */
  11425. export class Stage<T extends Function> extends Array<{
  11426. index: number;
  11427. component: ISceneComponent;
  11428. action: T;
  11429. }> {
  11430. /**
  11431. * Hide ctor from the rest of the world.
  11432. * @param items The items to add.
  11433. */
  11434. private constructor();
  11435. /**
  11436. * Creates a new Stage.
  11437. * @returns A new instance of a Stage
  11438. */
  11439. static Create<T extends Function>(): Stage<T>;
  11440. /**
  11441. * Registers a step in an ordered way in the targeted stage.
  11442. * @param index Defines the position to register the step in
  11443. * @param component Defines the component attached to the step
  11444. * @param action Defines the action to launch during the step
  11445. */
  11446. registerStep(index: number, component: ISceneComponent, action: T): void;
  11447. /**
  11448. * Clears all the steps from the stage.
  11449. */
  11450. clear(): void;
  11451. }
  11452. }
  11453. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11454. import { Nullable } from "babylonjs/types";
  11455. import { Observable } from "babylonjs/Misc/observable";
  11456. import { Scene } from "babylonjs/scene";
  11457. import { Sprite } from "babylonjs/Sprites/sprite";
  11458. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11459. import { Ray } from "babylonjs/Culling/ray";
  11460. import { Camera } from "babylonjs/Cameras/camera";
  11461. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11462. import { ISceneComponent } from "babylonjs/sceneComponent";
  11463. module "babylonjs/scene" {
  11464. interface Scene {
  11465. /** @hidden */
  11466. _pointerOverSprite: Nullable<Sprite>;
  11467. /** @hidden */
  11468. _pickedDownSprite: Nullable<Sprite>;
  11469. /** @hidden */
  11470. _tempSpritePickingRay: Nullable<Ray>;
  11471. /**
  11472. * All of the sprite managers added to this scene
  11473. * @see http://doc.babylonjs.com/babylon101/sprites
  11474. */
  11475. spriteManagers: Array<ISpriteManager>;
  11476. /**
  11477. * An event triggered when sprites rendering is about to start
  11478. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11479. */
  11480. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11481. /**
  11482. * An event triggered when sprites rendering is done
  11483. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11484. */
  11485. onAfterSpritesRenderingObservable: Observable<Scene>;
  11486. /** @hidden */
  11487. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11488. /** Launch a ray to try to pick a sprite in the scene
  11489. * @param x position on screen
  11490. * @param y position on screen
  11491. * @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
  11492. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11493. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11494. * @returns a PickingInfo
  11495. */
  11496. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11497. /** Use the given ray to pick a sprite in the scene
  11498. * @param ray The ray (in world space) to use to pick meshes
  11499. * @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
  11500. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11501. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11502. * @returns a PickingInfo
  11503. */
  11504. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11505. /** @hidden */
  11506. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11507. /** Launch a ray to try to pick sprites in the scene
  11508. * @param x position on screen
  11509. * @param y position on screen
  11510. * @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
  11511. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11512. * @returns a PickingInfo array
  11513. */
  11514. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11515. /** Use the given ray to pick sprites in the scene
  11516. * @param ray The ray (in world space) to use to pick meshes
  11517. * @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
  11518. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11519. * @returns a PickingInfo array
  11520. */
  11521. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11522. /**
  11523. * Force the sprite under the pointer
  11524. * @param sprite defines the sprite to use
  11525. */
  11526. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11527. /**
  11528. * Gets the sprite under the pointer
  11529. * @returns a Sprite or null if no sprite is under the pointer
  11530. */
  11531. getPointerOverSprite(): Nullable<Sprite>;
  11532. }
  11533. }
  11534. /**
  11535. * Defines the sprite scene component responsible to manage sprites
  11536. * in a given scene.
  11537. */
  11538. export class SpriteSceneComponent implements ISceneComponent {
  11539. /**
  11540. * The component name helpfull to identify the component in the list of scene components.
  11541. */
  11542. readonly name: string;
  11543. /**
  11544. * The scene the component belongs to.
  11545. */
  11546. scene: Scene;
  11547. /** @hidden */
  11548. private _spritePredicate;
  11549. /**
  11550. * Creates a new instance of the component for the given scene
  11551. * @param scene Defines the scene to register the component in
  11552. */
  11553. constructor(scene: Scene);
  11554. /**
  11555. * Registers the component in a given scene
  11556. */
  11557. register(): void;
  11558. /**
  11559. * Rebuilds the elements related to this component in case of
  11560. * context lost for instance.
  11561. */
  11562. rebuild(): void;
  11563. /**
  11564. * Disposes the component and the associated ressources.
  11565. */
  11566. dispose(): void;
  11567. private _pickSpriteButKeepRay;
  11568. private _pointerMove;
  11569. private _pointerDown;
  11570. private _pointerUp;
  11571. }
  11572. }
  11573. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11574. /** @hidden */
  11575. export var fogFragmentDeclaration: {
  11576. name: string;
  11577. shader: string;
  11578. };
  11579. }
  11580. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11581. /** @hidden */
  11582. export var fogFragment: {
  11583. name: string;
  11584. shader: string;
  11585. };
  11586. }
  11587. declare module "babylonjs/Shaders/sprites.fragment" {
  11588. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11589. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11590. /** @hidden */
  11591. export var spritesPixelShader: {
  11592. name: string;
  11593. shader: string;
  11594. };
  11595. }
  11596. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11597. /** @hidden */
  11598. export var fogVertexDeclaration: {
  11599. name: string;
  11600. shader: string;
  11601. };
  11602. }
  11603. declare module "babylonjs/Shaders/sprites.vertex" {
  11604. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11605. /** @hidden */
  11606. export var spritesVertexShader: {
  11607. name: string;
  11608. shader: string;
  11609. };
  11610. }
  11611. declare module "babylonjs/Sprites/spriteManager" {
  11612. import { IDisposable, Scene } from "babylonjs/scene";
  11613. import { Nullable } from "babylonjs/types";
  11614. import { Observable } from "babylonjs/Misc/observable";
  11615. import { Sprite } from "babylonjs/Sprites/sprite";
  11616. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11617. import { Camera } from "babylonjs/Cameras/camera";
  11618. import { Texture } from "babylonjs/Materials/Textures/texture";
  11619. import "babylonjs/Shaders/sprites.fragment";
  11620. import "babylonjs/Shaders/sprites.vertex";
  11621. import { Ray } from "babylonjs/Culling/ray";
  11622. /**
  11623. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11624. */
  11625. export interface ISpriteManager extends IDisposable {
  11626. /**
  11627. * Restricts the camera to viewing objects with the same layerMask.
  11628. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11629. */
  11630. layerMask: number;
  11631. /**
  11632. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11633. */
  11634. isPickable: boolean;
  11635. /**
  11636. * Specifies the rendering group id for this mesh (0 by default)
  11637. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11638. */
  11639. renderingGroupId: number;
  11640. /**
  11641. * Defines the list of sprites managed by the manager.
  11642. */
  11643. sprites: Array<Sprite>;
  11644. /**
  11645. * Tests the intersection of a sprite with a specific ray.
  11646. * @param ray The ray we are sending to test the collision
  11647. * @param camera The camera space we are sending rays in
  11648. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11649. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11650. * @returns picking info or null.
  11651. */
  11652. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11653. /**
  11654. * Intersects the sprites with a ray
  11655. * @param ray defines the ray to intersect with
  11656. * @param camera defines the current active camera
  11657. * @param predicate defines a predicate used to select candidate sprites
  11658. * @returns null if no hit or a PickingInfo array
  11659. */
  11660. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11661. /**
  11662. * Renders the list of sprites on screen.
  11663. */
  11664. render(): void;
  11665. }
  11666. /**
  11667. * Class used to manage multiple sprites on the same spritesheet
  11668. * @see http://doc.babylonjs.com/babylon101/sprites
  11669. */
  11670. export class SpriteManager implements ISpriteManager {
  11671. /** defines the manager's name */
  11672. name: string;
  11673. /** Gets the list of sprites */
  11674. sprites: Sprite[];
  11675. /** Gets or sets the rendering group id (0 by default) */
  11676. renderingGroupId: number;
  11677. /** Gets or sets camera layer mask */
  11678. layerMask: number;
  11679. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11680. fogEnabled: boolean;
  11681. /** Gets or sets a boolean indicating if the sprites are pickable */
  11682. isPickable: boolean;
  11683. /** Defines the default width of a cell in the spritesheet */
  11684. cellWidth: number;
  11685. /** Defines the default height of a cell in the spritesheet */
  11686. cellHeight: number;
  11687. /** Associative array from JSON sprite data file */
  11688. private _cellData;
  11689. /** Array of sprite names from JSON sprite data file */
  11690. private _spriteMap;
  11691. /** True when packed cell data from JSON file is ready*/
  11692. private _packedAndReady;
  11693. /**
  11694. * An event triggered when the manager is disposed.
  11695. */
  11696. onDisposeObservable: Observable<SpriteManager>;
  11697. private _onDisposeObserver;
  11698. /**
  11699. * Callback called when the manager is disposed
  11700. */
  11701. onDispose: () => void;
  11702. private _capacity;
  11703. private _fromPacked;
  11704. private _spriteTexture;
  11705. private _epsilon;
  11706. private _scene;
  11707. private _vertexData;
  11708. private _buffer;
  11709. private _vertexBuffers;
  11710. private _indexBuffer;
  11711. private _effectBase;
  11712. private _effectFog;
  11713. /**
  11714. * Gets or sets the spritesheet texture
  11715. */
  11716. texture: Texture;
  11717. /**
  11718. * Creates a new sprite manager
  11719. * @param name defines the manager's name
  11720. * @param imgUrl defines the sprite sheet url
  11721. * @param capacity defines the maximum allowed number of sprites
  11722. * @param cellSize defines the size of a sprite cell
  11723. * @param scene defines the hosting scene
  11724. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11725. * @param samplingMode defines the smapling mode to use with spritesheet
  11726. * @param fromPacked set to false; do not alter
  11727. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11728. */
  11729. constructor(
  11730. /** defines the manager's name */
  11731. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11732. private _makePacked;
  11733. private _appendSpriteVertex;
  11734. /**
  11735. * Intersects the sprites with a ray
  11736. * @param ray defines the ray to intersect with
  11737. * @param camera defines the current active camera
  11738. * @param predicate defines a predicate used to select candidate sprites
  11739. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11740. * @returns null if no hit or a PickingInfo
  11741. */
  11742. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11743. /**
  11744. * Intersects the sprites with a ray
  11745. * @param ray defines the ray to intersect with
  11746. * @param camera defines the current active camera
  11747. * @param predicate defines a predicate used to select candidate sprites
  11748. * @returns null if no hit or a PickingInfo array
  11749. */
  11750. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11751. /**
  11752. * Render all child sprites
  11753. */
  11754. render(): void;
  11755. /**
  11756. * Release associated resources
  11757. */
  11758. dispose(): void;
  11759. }
  11760. }
  11761. declare module "babylonjs/Sprites/sprite" {
  11762. import { Vector3 } from "babylonjs/Maths/math.vector";
  11763. import { Nullable } from "babylonjs/types";
  11764. import { ActionManager } from "babylonjs/Actions/actionManager";
  11765. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11766. import { Color4 } from "babylonjs/Maths/math.color";
  11767. /**
  11768. * Class used to represent a sprite
  11769. * @see http://doc.babylonjs.com/babylon101/sprites
  11770. */
  11771. export class Sprite {
  11772. /** defines the name */
  11773. name: string;
  11774. /** Gets or sets the current world position */
  11775. position: Vector3;
  11776. /** Gets or sets the main color */
  11777. color: Color4;
  11778. /** Gets or sets the width */
  11779. width: number;
  11780. /** Gets or sets the height */
  11781. height: number;
  11782. /** Gets or sets rotation angle */
  11783. angle: number;
  11784. /** Gets or sets the cell index in the sprite sheet */
  11785. cellIndex: number;
  11786. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11787. cellRef: string;
  11788. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11789. invertU: number;
  11790. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11791. invertV: number;
  11792. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11793. disposeWhenFinishedAnimating: boolean;
  11794. /** Gets the list of attached animations */
  11795. animations: Animation[];
  11796. /** Gets or sets a boolean indicating if the sprite can be picked */
  11797. isPickable: boolean;
  11798. /**
  11799. * Gets or sets the associated action manager
  11800. */
  11801. actionManager: Nullable<ActionManager>;
  11802. private _animationStarted;
  11803. private _loopAnimation;
  11804. private _fromIndex;
  11805. private _toIndex;
  11806. private _delay;
  11807. private _direction;
  11808. private _manager;
  11809. private _time;
  11810. private _onAnimationEnd;
  11811. /**
  11812. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11813. */
  11814. isVisible: boolean;
  11815. /**
  11816. * Gets or sets the sprite size
  11817. */
  11818. size: number;
  11819. /**
  11820. * Creates a new Sprite
  11821. * @param name defines the name
  11822. * @param manager defines the manager
  11823. */
  11824. constructor(
  11825. /** defines the name */
  11826. name: string, manager: ISpriteManager);
  11827. /**
  11828. * Starts an animation
  11829. * @param from defines the initial key
  11830. * @param to defines the end key
  11831. * @param loop defines if the animation must loop
  11832. * @param delay defines the start delay (in ms)
  11833. * @param onAnimationEnd defines a callback to call when animation ends
  11834. */
  11835. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11836. /** Stops current animation (if any) */
  11837. stopAnimation(): void;
  11838. /** @hidden */
  11839. _animate(deltaTime: number): void;
  11840. /** Release associated resources */
  11841. dispose(): void;
  11842. }
  11843. }
  11844. declare module "babylonjs/Collisions/pickingInfo" {
  11845. import { Nullable } from "babylonjs/types";
  11846. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11848. import { Sprite } from "babylonjs/Sprites/sprite";
  11849. import { Ray } from "babylonjs/Culling/ray";
  11850. /**
  11851. * Information about the result of picking within a scene
  11852. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11853. */
  11854. export class PickingInfo {
  11855. /** @hidden */
  11856. _pickingUnavailable: boolean;
  11857. /**
  11858. * If the pick collided with an object
  11859. */
  11860. hit: boolean;
  11861. /**
  11862. * Distance away where the pick collided
  11863. */
  11864. distance: number;
  11865. /**
  11866. * The location of pick collision
  11867. */
  11868. pickedPoint: Nullable<Vector3>;
  11869. /**
  11870. * The mesh corresponding the the pick collision
  11871. */
  11872. pickedMesh: Nullable<AbstractMesh>;
  11873. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11874. bu: number;
  11875. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11876. bv: number;
  11877. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11878. faceId: number;
  11879. /** Id of the the submesh that was picked */
  11880. subMeshId: number;
  11881. /** If a sprite was picked, this will be the sprite the pick collided with */
  11882. pickedSprite: Nullable<Sprite>;
  11883. /**
  11884. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11885. */
  11886. originMesh: Nullable<AbstractMesh>;
  11887. /**
  11888. * The ray that was used to perform the picking.
  11889. */
  11890. ray: Nullable<Ray>;
  11891. /**
  11892. * Gets the normal correspodning to the face the pick collided with
  11893. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11894. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11895. * @returns The normal correspodning to the face the pick collided with
  11896. */
  11897. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11898. /**
  11899. * Gets the texture coordinates of where the pick occured
  11900. * @returns the vector containing the coordnates of the texture
  11901. */
  11902. getTextureCoordinates(): Nullable<Vector2>;
  11903. }
  11904. }
  11905. declare module "babylonjs/Events/pointerEvents" {
  11906. import { Nullable } from "babylonjs/types";
  11907. import { Vector2 } from "babylonjs/Maths/math.vector";
  11908. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11909. import { Ray } from "babylonjs/Culling/ray";
  11910. /**
  11911. * Gather the list of pointer event types as constants.
  11912. */
  11913. export class PointerEventTypes {
  11914. /**
  11915. * 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.
  11916. */
  11917. static readonly POINTERDOWN: number;
  11918. /**
  11919. * The pointerup event is fired when a pointer is no longer active.
  11920. */
  11921. static readonly POINTERUP: number;
  11922. /**
  11923. * The pointermove event is fired when a pointer changes coordinates.
  11924. */
  11925. static readonly POINTERMOVE: number;
  11926. /**
  11927. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11928. */
  11929. static readonly POINTERWHEEL: number;
  11930. /**
  11931. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11932. */
  11933. static readonly POINTERPICK: number;
  11934. /**
  11935. * The pointertap event is fired when a the object has been touched and released without drag.
  11936. */
  11937. static readonly POINTERTAP: number;
  11938. /**
  11939. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11940. */
  11941. static readonly POINTERDOUBLETAP: number;
  11942. }
  11943. /**
  11944. * Base class of pointer info types.
  11945. */
  11946. export class PointerInfoBase {
  11947. /**
  11948. * Defines the type of event (PointerEventTypes)
  11949. */
  11950. type: number;
  11951. /**
  11952. * Defines the related dom event
  11953. */
  11954. event: PointerEvent | MouseWheelEvent;
  11955. /**
  11956. * Instantiates the base class of pointers info.
  11957. * @param type Defines the type of event (PointerEventTypes)
  11958. * @param event Defines the related dom event
  11959. */
  11960. constructor(
  11961. /**
  11962. * Defines the type of event (PointerEventTypes)
  11963. */
  11964. type: number,
  11965. /**
  11966. * Defines the related dom event
  11967. */
  11968. event: PointerEvent | MouseWheelEvent);
  11969. }
  11970. /**
  11971. * This class is used to store pointer related info for the onPrePointerObservable event.
  11972. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11973. */
  11974. export class PointerInfoPre extends PointerInfoBase {
  11975. /**
  11976. * Ray from a pointer if availible (eg. 6dof controller)
  11977. */
  11978. ray: Nullable<Ray>;
  11979. /**
  11980. * Defines the local position of the pointer on the canvas.
  11981. */
  11982. localPosition: Vector2;
  11983. /**
  11984. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11985. */
  11986. skipOnPointerObservable: boolean;
  11987. /**
  11988. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11989. * @param type Defines the type of event (PointerEventTypes)
  11990. * @param event Defines the related dom event
  11991. * @param localX Defines the local x coordinates of the pointer when the event occured
  11992. * @param localY Defines the local y coordinates of the pointer when the event occured
  11993. */
  11994. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11995. }
  11996. /**
  11997. * This type contains all the data related to a pointer event in Babylon.js.
  11998. * 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.
  11999. */
  12000. export class PointerInfo extends PointerInfoBase {
  12001. /**
  12002. * Defines the picking info associated to the info (if any)\
  12003. */
  12004. pickInfo: Nullable<PickingInfo>;
  12005. /**
  12006. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12007. * @param type Defines the type of event (PointerEventTypes)
  12008. * @param event Defines the related dom event
  12009. * @param pickInfo Defines the picking info associated to the info (if any)\
  12010. */
  12011. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12012. /**
  12013. * Defines the picking info associated to the info (if any)\
  12014. */
  12015. pickInfo: Nullable<PickingInfo>);
  12016. }
  12017. /**
  12018. * Data relating to a touch event on the screen.
  12019. */
  12020. export interface PointerTouch {
  12021. /**
  12022. * X coordinate of touch.
  12023. */
  12024. x: number;
  12025. /**
  12026. * Y coordinate of touch.
  12027. */
  12028. y: number;
  12029. /**
  12030. * Id of touch. Unique for each finger.
  12031. */
  12032. pointerId: number;
  12033. /**
  12034. * Event type passed from DOM.
  12035. */
  12036. type: any;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12040. import { Observable } from "babylonjs/Misc/observable";
  12041. import { Nullable } from "babylonjs/types";
  12042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12043. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12044. /**
  12045. * Manage the mouse inputs to control the movement of a free camera.
  12046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12047. */
  12048. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12049. /**
  12050. * Define if touch is enabled in the mouse input
  12051. */
  12052. touchEnabled: boolean;
  12053. /**
  12054. * Defines the camera the input is attached to.
  12055. */
  12056. camera: FreeCamera;
  12057. /**
  12058. * Defines the buttons associated with the input to handle camera move.
  12059. */
  12060. buttons: number[];
  12061. /**
  12062. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12063. */
  12064. angularSensibility: number;
  12065. private _pointerInput;
  12066. private _onMouseMove;
  12067. private _observer;
  12068. private previousPosition;
  12069. /**
  12070. * Observable for when a pointer move event occurs containing the move offset
  12071. */
  12072. onPointerMovedObservable: Observable<{
  12073. offsetX: number;
  12074. offsetY: number;
  12075. }>;
  12076. /**
  12077. * @hidden
  12078. * If the camera should be rotated automatically based on pointer movement
  12079. */
  12080. _allowCameraRotation: boolean;
  12081. /**
  12082. * Manage the mouse inputs to control the movement of a free camera.
  12083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12084. * @param touchEnabled Defines if touch is enabled or not
  12085. */
  12086. constructor(
  12087. /**
  12088. * Define if touch is enabled in the mouse input
  12089. */
  12090. touchEnabled?: boolean);
  12091. /**
  12092. * Attach the input controls to a specific dom element to get the input from.
  12093. * @param element Defines the element the controls should be listened from
  12094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12095. */
  12096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12097. /**
  12098. * Called on JS contextmenu event.
  12099. * Override this method to provide functionality.
  12100. */
  12101. protected onContextMenu(evt: PointerEvent): void;
  12102. /**
  12103. * Detach the current controls from the specified dom element.
  12104. * @param element Defines the element to stop listening the inputs from
  12105. */
  12106. detachControl(element: Nullable<HTMLElement>): void;
  12107. /**
  12108. * Gets the class name of the current intput.
  12109. * @returns the class name
  12110. */
  12111. getClassName(): string;
  12112. /**
  12113. * Get the friendly name associated with the input class.
  12114. * @returns the input friendly name
  12115. */
  12116. getSimpleName(): string;
  12117. }
  12118. }
  12119. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12120. import { Nullable } from "babylonjs/types";
  12121. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12122. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12123. /**
  12124. * Manage the touch inputs to control the movement of a free camera.
  12125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12126. */
  12127. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12128. /**
  12129. * Defines the camera the input is attached to.
  12130. */
  12131. camera: FreeCamera;
  12132. /**
  12133. * Defines the touch sensibility for rotation.
  12134. * The higher the faster.
  12135. */
  12136. touchAngularSensibility: number;
  12137. /**
  12138. * Defines the touch sensibility for move.
  12139. * The higher the faster.
  12140. */
  12141. touchMoveSensibility: number;
  12142. private _offsetX;
  12143. private _offsetY;
  12144. private _pointerPressed;
  12145. private _pointerInput;
  12146. private _observer;
  12147. private _onLostFocus;
  12148. /**
  12149. * Attach the input controls to a specific dom element to get the input from.
  12150. * @param element Defines the element the controls should be listened from
  12151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12152. */
  12153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12154. /**
  12155. * Detach the current controls from the specified dom element.
  12156. * @param element Defines the element to stop listening the inputs from
  12157. */
  12158. detachControl(element: Nullable<HTMLElement>): void;
  12159. /**
  12160. * Update the current camera state depending on the inputs that have been used this frame.
  12161. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12162. */
  12163. checkInputs(): void;
  12164. /**
  12165. * Gets the class name of the current intput.
  12166. * @returns the class name
  12167. */
  12168. getClassName(): string;
  12169. /**
  12170. * Get the friendly name associated with the input class.
  12171. * @returns the input friendly name
  12172. */
  12173. getSimpleName(): string;
  12174. }
  12175. }
  12176. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12177. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12178. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12179. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12180. import { Nullable } from "babylonjs/types";
  12181. /**
  12182. * Default Inputs manager for the FreeCamera.
  12183. * It groups all the default supported inputs for ease of use.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12187. /**
  12188. * @hidden
  12189. */
  12190. _mouseInput: Nullable<FreeCameraMouseInput>;
  12191. /**
  12192. * Instantiates a new FreeCameraInputsManager.
  12193. * @param camera Defines the camera the inputs belong to
  12194. */
  12195. constructor(camera: FreeCamera);
  12196. /**
  12197. * Add keyboard input support to the input manager.
  12198. * @returns the current input manager
  12199. */
  12200. addKeyboard(): FreeCameraInputsManager;
  12201. /**
  12202. * Add mouse input support to the input manager.
  12203. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12204. * @returns the current input manager
  12205. */
  12206. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12207. /**
  12208. * Removes the mouse input support from the manager
  12209. * @returns the current input manager
  12210. */
  12211. removeMouse(): FreeCameraInputsManager;
  12212. /**
  12213. * Add touch input support to the input manager.
  12214. * @returns the current input manager
  12215. */
  12216. addTouch(): FreeCameraInputsManager;
  12217. /**
  12218. * Remove all attached input methods from a camera
  12219. */
  12220. clear(): void;
  12221. }
  12222. }
  12223. declare module "babylonjs/Cameras/freeCamera" {
  12224. import { Vector3 } from "babylonjs/Maths/math.vector";
  12225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12226. import { Scene } from "babylonjs/scene";
  12227. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12228. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12229. /**
  12230. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12231. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12232. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12233. */
  12234. export class FreeCamera extends TargetCamera {
  12235. /**
  12236. * Define the collision ellipsoid of the camera.
  12237. * This is helpful to simulate a camera body like the player body around the camera
  12238. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12239. */
  12240. ellipsoid: Vector3;
  12241. /**
  12242. * Define an offset for the position of the ellipsoid around the camera.
  12243. * This can be helpful to determine the center of the body near the gravity center of the body
  12244. * instead of its head.
  12245. */
  12246. ellipsoidOffset: Vector3;
  12247. /**
  12248. * Enable or disable collisions of the camera with the rest of the scene objects.
  12249. */
  12250. checkCollisions: boolean;
  12251. /**
  12252. * Enable or disable gravity on the camera.
  12253. */
  12254. applyGravity: boolean;
  12255. /**
  12256. * Define the input manager associated to the camera.
  12257. */
  12258. inputs: FreeCameraInputsManager;
  12259. /**
  12260. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12261. * Higher values reduce sensitivity.
  12262. */
  12263. /**
  12264. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12265. * Higher values reduce sensitivity.
  12266. */
  12267. angularSensibility: number;
  12268. /**
  12269. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12270. */
  12271. keysUp: number[];
  12272. /**
  12273. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12274. */
  12275. keysDown: number[];
  12276. /**
  12277. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12278. */
  12279. keysLeft: number[];
  12280. /**
  12281. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12282. */
  12283. keysRight: number[];
  12284. /**
  12285. * Event raised when the camera collide with a mesh in the scene.
  12286. */
  12287. onCollide: (collidedMesh: AbstractMesh) => void;
  12288. private _collider;
  12289. private _needMoveForGravity;
  12290. private _oldPosition;
  12291. private _diffPosition;
  12292. private _newPosition;
  12293. /** @hidden */
  12294. _localDirection: Vector3;
  12295. /** @hidden */
  12296. _transformedDirection: Vector3;
  12297. /**
  12298. * Instantiates a Free Camera.
  12299. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12300. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12302. * @param name Define the name of the camera in the scene
  12303. * @param position Define the start position of the camera in the scene
  12304. * @param scene Define the scene the camera belongs to
  12305. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12306. */
  12307. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12308. /**
  12309. * Attached controls to the current camera.
  12310. * @param element Defines the element the controls should be listened from
  12311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12312. */
  12313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12314. /**
  12315. * Detach the current controls from the camera.
  12316. * The camera will stop reacting to inputs.
  12317. * @param element Defines the element to stop listening the inputs from
  12318. */
  12319. detachControl(element: HTMLElement): void;
  12320. private _collisionMask;
  12321. /**
  12322. * Define a collision mask to limit the list of object the camera can collide with
  12323. */
  12324. collisionMask: number;
  12325. /** @hidden */
  12326. _collideWithWorld(displacement: Vector3): void;
  12327. private _onCollisionPositionChange;
  12328. /** @hidden */
  12329. _checkInputs(): void;
  12330. /** @hidden */
  12331. _decideIfNeedsToMove(): boolean;
  12332. /** @hidden */
  12333. _updatePosition(): void;
  12334. /**
  12335. * Destroy the camera and release the current resources hold by it.
  12336. */
  12337. dispose(): void;
  12338. /**
  12339. * Gets the current object class name.
  12340. * @return the class name
  12341. */
  12342. getClassName(): string;
  12343. }
  12344. }
  12345. declare module "babylonjs/Gamepads/gamepad" {
  12346. import { Observable } from "babylonjs/Misc/observable";
  12347. /**
  12348. * Represents a gamepad control stick position
  12349. */
  12350. export class StickValues {
  12351. /**
  12352. * The x component of the control stick
  12353. */
  12354. x: number;
  12355. /**
  12356. * The y component of the control stick
  12357. */
  12358. y: number;
  12359. /**
  12360. * Initializes the gamepad x and y control stick values
  12361. * @param x The x component of the gamepad control stick value
  12362. * @param y The y component of the gamepad control stick value
  12363. */
  12364. constructor(
  12365. /**
  12366. * The x component of the control stick
  12367. */
  12368. x: number,
  12369. /**
  12370. * The y component of the control stick
  12371. */
  12372. y: number);
  12373. }
  12374. /**
  12375. * An interface which manages callbacks for gamepad button changes
  12376. */
  12377. export interface GamepadButtonChanges {
  12378. /**
  12379. * Called when a gamepad has been changed
  12380. */
  12381. changed: boolean;
  12382. /**
  12383. * Called when a gamepad press event has been triggered
  12384. */
  12385. pressChanged: boolean;
  12386. /**
  12387. * Called when a touch event has been triggered
  12388. */
  12389. touchChanged: boolean;
  12390. /**
  12391. * Called when a value has changed
  12392. */
  12393. valueChanged: boolean;
  12394. }
  12395. /**
  12396. * Represents a gamepad
  12397. */
  12398. export class Gamepad {
  12399. /**
  12400. * The id of the gamepad
  12401. */
  12402. id: string;
  12403. /**
  12404. * The index of the gamepad
  12405. */
  12406. index: number;
  12407. /**
  12408. * The browser gamepad
  12409. */
  12410. browserGamepad: any;
  12411. /**
  12412. * Specifies what type of gamepad this represents
  12413. */
  12414. type: number;
  12415. private _leftStick;
  12416. private _rightStick;
  12417. /** @hidden */
  12418. _isConnected: boolean;
  12419. private _leftStickAxisX;
  12420. private _leftStickAxisY;
  12421. private _rightStickAxisX;
  12422. private _rightStickAxisY;
  12423. /**
  12424. * Triggered when the left control stick has been changed
  12425. */
  12426. private _onleftstickchanged;
  12427. /**
  12428. * Triggered when the right control stick has been changed
  12429. */
  12430. private _onrightstickchanged;
  12431. /**
  12432. * Represents a gamepad controller
  12433. */
  12434. static GAMEPAD: number;
  12435. /**
  12436. * Represents a generic controller
  12437. */
  12438. static GENERIC: number;
  12439. /**
  12440. * Represents an XBox controller
  12441. */
  12442. static XBOX: number;
  12443. /**
  12444. * Represents a pose-enabled controller
  12445. */
  12446. static POSE_ENABLED: number;
  12447. /**
  12448. * Represents an Dual Shock controller
  12449. */
  12450. static DUALSHOCK: number;
  12451. /**
  12452. * Specifies whether the left control stick should be Y-inverted
  12453. */
  12454. protected _invertLeftStickY: boolean;
  12455. /**
  12456. * Specifies if the gamepad has been connected
  12457. */
  12458. readonly isConnected: boolean;
  12459. /**
  12460. * Initializes the gamepad
  12461. * @param id The id of the gamepad
  12462. * @param index The index of the gamepad
  12463. * @param browserGamepad The browser gamepad
  12464. * @param leftStickX The x component of the left joystick
  12465. * @param leftStickY The y component of the left joystick
  12466. * @param rightStickX The x component of the right joystick
  12467. * @param rightStickY The y component of the right joystick
  12468. */
  12469. constructor(
  12470. /**
  12471. * The id of the gamepad
  12472. */
  12473. id: string,
  12474. /**
  12475. * The index of the gamepad
  12476. */
  12477. index: number,
  12478. /**
  12479. * The browser gamepad
  12480. */
  12481. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12482. /**
  12483. * Callback triggered when the left joystick has changed
  12484. * @param callback
  12485. */
  12486. onleftstickchanged(callback: (values: StickValues) => void): void;
  12487. /**
  12488. * Callback triggered when the right joystick has changed
  12489. * @param callback
  12490. */
  12491. onrightstickchanged(callback: (values: StickValues) => void): void;
  12492. /**
  12493. * Gets the left joystick
  12494. */
  12495. /**
  12496. * Sets the left joystick values
  12497. */
  12498. leftStick: StickValues;
  12499. /**
  12500. * Gets the right joystick
  12501. */
  12502. /**
  12503. * Sets the right joystick value
  12504. */
  12505. rightStick: StickValues;
  12506. /**
  12507. * Updates the gamepad joystick positions
  12508. */
  12509. update(): void;
  12510. /**
  12511. * Disposes the gamepad
  12512. */
  12513. dispose(): void;
  12514. }
  12515. /**
  12516. * Represents a generic gamepad
  12517. */
  12518. export class GenericPad extends Gamepad {
  12519. private _buttons;
  12520. private _onbuttondown;
  12521. private _onbuttonup;
  12522. /**
  12523. * Observable triggered when a button has been pressed
  12524. */
  12525. onButtonDownObservable: Observable<number>;
  12526. /**
  12527. * Observable triggered when a button has been released
  12528. */
  12529. onButtonUpObservable: Observable<number>;
  12530. /**
  12531. * Callback triggered when a button has been pressed
  12532. * @param callback Called when a button has been pressed
  12533. */
  12534. onbuttondown(callback: (buttonPressed: number) => void): void;
  12535. /**
  12536. * Callback triggered when a button has been released
  12537. * @param callback Called when a button has been released
  12538. */
  12539. onbuttonup(callback: (buttonReleased: number) => void): void;
  12540. /**
  12541. * Initializes the generic gamepad
  12542. * @param id The id of the generic gamepad
  12543. * @param index The index of the generic gamepad
  12544. * @param browserGamepad The browser gamepad
  12545. */
  12546. constructor(id: string, index: number, browserGamepad: any);
  12547. private _setButtonValue;
  12548. /**
  12549. * Updates the generic gamepad
  12550. */
  12551. update(): void;
  12552. /**
  12553. * Disposes the generic gamepad
  12554. */
  12555. dispose(): void;
  12556. }
  12557. }
  12558. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12559. import { Nullable } from "babylonjs/types";
  12560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12561. import { Scene } from "babylonjs/scene";
  12562. module "babylonjs/Engines/engine" {
  12563. interface Engine {
  12564. /**
  12565. * Creates a raw texture
  12566. * @param data defines the data to store in the texture
  12567. * @param width defines the width of the texture
  12568. * @param height defines the height of the texture
  12569. * @param format defines the format of the data
  12570. * @param generateMipMaps defines if the engine should generate the mip levels
  12571. * @param invertY defines if data must be stored with Y axis inverted
  12572. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12573. * @param compression defines the compression used (null by default)
  12574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12575. * @returns the raw texture inside an InternalTexture
  12576. */
  12577. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12578. /**
  12579. * Update a raw texture
  12580. * @param texture defines the texture to update
  12581. * @param data defines the data to store in the texture
  12582. * @param format defines the format of the data
  12583. * @param invertY defines if data must be stored with Y axis inverted
  12584. */
  12585. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12586. /**
  12587. * Update a raw texture
  12588. * @param texture defines the texture to update
  12589. * @param data defines the data to store in the texture
  12590. * @param format defines the format of the data
  12591. * @param invertY defines if data must be stored with Y axis inverted
  12592. * @param compression defines the compression used (null by default)
  12593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12594. */
  12595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12596. /**
  12597. * Creates a new raw cube texture
  12598. * @param data defines the array of data to use to create each face
  12599. * @param size defines the size of the textures
  12600. * @param format defines the format of the data
  12601. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12602. * @param generateMipMaps defines if the engine should generate the mip levels
  12603. * @param invertY defines if data must be stored with Y axis inverted
  12604. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12605. * @param compression defines the compression used (null by default)
  12606. * @returns the cube texture as an InternalTexture
  12607. */
  12608. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12609. /**
  12610. * Update a raw cube texture
  12611. * @param texture defines the texture to udpdate
  12612. * @param data defines the data to store
  12613. * @param format defines the data format
  12614. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12615. * @param invertY defines if data must be stored with Y axis inverted
  12616. */
  12617. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12618. /**
  12619. * Update a raw cube texture
  12620. * @param texture defines the texture to udpdate
  12621. * @param data defines the data to store
  12622. * @param format defines the data format
  12623. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12624. * @param invertY defines if data must be stored with Y axis inverted
  12625. * @param compression defines the compression used (null by default)
  12626. */
  12627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12628. /**
  12629. * Update a raw cube texture
  12630. * @param texture defines the texture to udpdate
  12631. * @param data defines the data to store
  12632. * @param format defines the data format
  12633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12634. * @param invertY defines if data must be stored with Y axis inverted
  12635. * @param compression defines the compression used (null by default)
  12636. * @param level defines which level of the texture to update
  12637. */
  12638. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12639. /**
  12640. * Creates a new raw cube texture from a specified url
  12641. * @param url defines the url where the data is located
  12642. * @param scene defines the current scene
  12643. * @param size defines the size of the textures
  12644. * @param format defines the format of the data
  12645. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12646. * @param noMipmap defines if the engine should avoid generating the mip levels
  12647. * @param callback defines a callback used to extract texture data from loaded data
  12648. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12649. * @param onLoad defines a callback called when texture is loaded
  12650. * @param onError defines a callback called if there is an error
  12651. * @returns the cube texture as an InternalTexture
  12652. */
  12653. 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;
  12654. /**
  12655. * Creates a new raw cube texture from a specified url
  12656. * @param url defines the url where the data is located
  12657. * @param scene defines the current scene
  12658. * @param size defines the size of the textures
  12659. * @param format defines the format of the data
  12660. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12661. * @param noMipmap defines if the engine should avoid generating the mip levels
  12662. * @param callback defines a callback used to extract texture data from loaded data
  12663. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12664. * @param onLoad defines a callback called when texture is loaded
  12665. * @param onError defines a callback called if there is an error
  12666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12667. * @param invertY defines if data must be stored with Y axis inverted
  12668. * @returns the cube texture as an InternalTexture
  12669. */
  12670. 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;
  12671. /**
  12672. * Creates a new raw 3D texture
  12673. * @param data defines the data used to create the texture
  12674. * @param width defines the width of the texture
  12675. * @param height defines the height of the texture
  12676. * @param depth defines the depth of the texture
  12677. * @param format defines the format of the texture
  12678. * @param generateMipMaps defines if the engine must generate mip levels
  12679. * @param invertY defines if data must be stored with Y axis inverted
  12680. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12681. * @param compression defines the compressed used (can be null)
  12682. * @param textureType defines the compressed used (can be null)
  12683. * @returns a new raw 3D texture (stored in an InternalTexture)
  12684. */
  12685. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12686. /**
  12687. * Update a raw 3D texture
  12688. * @param texture defines the texture to update
  12689. * @param data defines the data to store
  12690. * @param format defines the data format
  12691. * @param invertY defines if data must be stored with Y axis inverted
  12692. */
  12693. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12694. /**
  12695. * Update a raw 3D texture
  12696. * @param texture defines the texture to update
  12697. * @param data defines the data to store
  12698. * @param format defines the data format
  12699. * @param invertY defines if data must be stored with Y axis inverted
  12700. * @param compression defines the used compression (can be null)
  12701. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12702. */
  12703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12704. }
  12705. }
  12706. }
  12707. declare module "babylonjs/Materials/Textures/rawTexture" {
  12708. import { Scene } from "babylonjs/scene";
  12709. import { Texture } from "babylonjs/Materials/Textures/texture";
  12710. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12711. /**
  12712. * Raw texture can help creating a texture directly from an array of data.
  12713. * This can be super useful if you either get the data from an uncompressed source or
  12714. * if you wish to create your texture pixel by pixel.
  12715. */
  12716. export class RawTexture extends Texture {
  12717. /**
  12718. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12719. */
  12720. format: number;
  12721. private _engine;
  12722. /**
  12723. * Instantiates a new RawTexture.
  12724. * Raw texture can help creating a texture directly from an array of data.
  12725. * This can be super useful if you either get the data from an uncompressed source or
  12726. * if you wish to create your texture pixel by pixel.
  12727. * @param data define the array of data to use to create the texture
  12728. * @param width define the width of the texture
  12729. * @param height define the height of the texture
  12730. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12731. * @param scene define the scene the texture belongs to
  12732. * @param generateMipMaps define whether mip maps should be generated or not
  12733. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12734. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12735. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12736. */
  12737. constructor(data: ArrayBufferView, width: number, height: number,
  12738. /**
  12739. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12740. */
  12741. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12742. /**
  12743. * Updates the texture underlying data.
  12744. * @param data Define the new data of the texture
  12745. */
  12746. update(data: ArrayBufferView): void;
  12747. /**
  12748. * Creates a luminance texture from some data.
  12749. * @param data Define the texture data
  12750. * @param width Define the width of the texture
  12751. * @param height Define the height of the texture
  12752. * @param scene Define the scene the texture belongs to
  12753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12756. * @returns the luminance texture
  12757. */
  12758. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12759. /**
  12760. * Creates a luminance alpha texture from some data.
  12761. * @param data Define the texture data
  12762. * @param width Define the width of the texture
  12763. * @param height Define the height of the texture
  12764. * @param scene Define the scene the texture belongs to
  12765. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12766. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12767. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12768. * @returns the luminance alpha texture
  12769. */
  12770. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12771. /**
  12772. * Creates an alpha texture from some data.
  12773. * @param data Define the texture data
  12774. * @param width Define the width of the texture
  12775. * @param height Define the height of the texture
  12776. * @param scene Define the scene the texture belongs to
  12777. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12778. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12779. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12780. * @returns the alpha texture
  12781. */
  12782. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12783. /**
  12784. * Creates a RGB texture from some data.
  12785. * @param data Define the texture data
  12786. * @param width Define the width of the texture
  12787. * @param height Define the height of the texture
  12788. * @param scene Define the scene the texture belongs to
  12789. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12790. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12791. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12792. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12793. * @returns the RGB alpha texture
  12794. */
  12795. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12796. /**
  12797. * Creates a RGBA texture from some data.
  12798. * @param data Define the texture data
  12799. * @param width Define the width of the texture
  12800. * @param height Define the height of the texture
  12801. * @param scene Define the scene the texture belongs to
  12802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12805. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12806. * @returns the RGBA texture
  12807. */
  12808. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12809. /**
  12810. * Creates a R texture from some data.
  12811. * @param data Define the texture data
  12812. * @param width Define the width of the texture
  12813. * @param height Define the height of the texture
  12814. * @param scene Define the scene the texture belongs to
  12815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12818. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12819. * @returns the R texture
  12820. */
  12821. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12822. }
  12823. }
  12824. declare module "babylonjs/Maths/math.size" {
  12825. /**
  12826. * Interface for the size containing width and height
  12827. */
  12828. export interface ISize {
  12829. /**
  12830. * Width
  12831. */
  12832. width: number;
  12833. /**
  12834. * Heighht
  12835. */
  12836. height: number;
  12837. }
  12838. /**
  12839. * Size containing widht and height
  12840. */
  12841. export class Size implements ISize {
  12842. /**
  12843. * Width
  12844. */
  12845. width: number;
  12846. /**
  12847. * Height
  12848. */
  12849. height: number;
  12850. /**
  12851. * Creates a Size object from the given width and height (floats).
  12852. * @param width width of the new size
  12853. * @param height height of the new size
  12854. */
  12855. constructor(width: number, height: number);
  12856. /**
  12857. * Returns a string with the Size width and height
  12858. * @returns a string with the Size width and height
  12859. */
  12860. toString(): string;
  12861. /**
  12862. * "Size"
  12863. * @returns the string "Size"
  12864. */
  12865. getClassName(): string;
  12866. /**
  12867. * Returns the Size hash code.
  12868. * @returns a hash code for a unique width and height
  12869. */
  12870. getHashCode(): number;
  12871. /**
  12872. * Updates the current size from the given one.
  12873. * @param src the given size
  12874. */
  12875. copyFrom(src: Size): void;
  12876. /**
  12877. * Updates in place the current Size from the given floats.
  12878. * @param width width of the new size
  12879. * @param height height of the new size
  12880. * @returns the updated Size.
  12881. */
  12882. copyFromFloats(width: number, height: number): Size;
  12883. /**
  12884. * Updates in place the current Size from the given floats.
  12885. * @param width width to set
  12886. * @param height height to set
  12887. * @returns the updated Size.
  12888. */
  12889. set(width: number, height: number): Size;
  12890. /**
  12891. * Multiplies the width and height by numbers
  12892. * @param w factor to multiple the width by
  12893. * @param h factor to multiple the height by
  12894. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12895. */
  12896. multiplyByFloats(w: number, h: number): Size;
  12897. /**
  12898. * Clones the size
  12899. * @returns a new Size copied from the given one.
  12900. */
  12901. clone(): Size;
  12902. /**
  12903. * True if the current Size and the given one width and height are strictly equal.
  12904. * @param other the other size to compare against
  12905. * @returns True if the current Size and the given one width and height are strictly equal.
  12906. */
  12907. equals(other: Size): boolean;
  12908. /**
  12909. * The surface of the Size : width * height (float).
  12910. */
  12911. readonly surface: number;
  12912. /**
  12913. * Create a new size of zero
  12914. * @returns a new Size set to (0.0, 0.0)
  12915. */
  12916. static Zero(): Size;
  12917. /**
  12918. * Sums the width and height of two sizes
  12919. * @param otherSize size to add to this size
  12920. * @returns a new Size set as the addition result of the current Size and the given one.
  12921. */
  12922. add(otherSize: Size): Size;
  12923. /**
  12924. * Subtracts the width and height of two
  12925. * @param otherSize size to subtract to this size
  12926. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12927. */
  12928. subtract(otherSize: Size): Size;
  12929. /**
  12930. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12931. * @param start starting size to lerp between
  12932. * @param end end size to lerp between
  12933. * @param amount amount to lerp between the start and end values
  12934. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12935. */
  12936. static Lerp(start: Size, end: Size, amount: number): Size;
  12937. }
  12938. }
  12939. declare module "babylonjs/Animations/runtimeAnimation" {
  12940. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12941. import { Animatable } from "babylonjs/Animations/animatable";
  12942. import { Scene } from "babylonjs/scene";
  12943. /**
  12944. * Defines a runtime animation
  12945. */
  12946. export class RuntimeAnimation {
  12947. private _events;
  12948. /**
  12949. * The current frame of the runtime animation
  12950. */
  12951. private _currentFrame;
  12952. /**
  12953. * The animation used by the runtime animation
  12954. */
  12955. private _animation;
  12956. /**
  12957. * The target of the runtime animation
  12958. */
  12959. private _target;
  12960. /**
  12961. * The initiating animatable
  12962. */
  12963. private _host;
  12964. /**
  12965. * The original value of the runtime animation
  12966. */
  12967. private _originalValue;
  12968. /**
  12969. * The original blend value of the runtime animation
  12970. */
  12971. private _originalBlendValue;
  12972. /**
  12973. * The offsets cache of the runtime animation
  12974. */
  12975. private _offsetsCache;
  12976. /**
  12977. * The high limits cache of the runtime animation
  12978. */
  12979. private _highLimitsCache;
  12980. /**
  12981. * Specifies if the runtime animation has been stopped
  12982. */
  12983. private _stopped;
  12984. /**
  12985. * The blending factor of the runtime animation
  12986. */
  12987. private _blendingFactor;
  12988. /**
  12989. * The BabylonJS scene
  12990. */
  12991. private _scene;
  12992. /**
  12993. * The current value of the runtime animation
  12994. */
  12995. private _currentValue;
  12996. /** @hidden */
  12997. _animationState: _IAnimationState;
  12998. /**
  12999. * The active target of the runtime animation
  13000. */
  13001. private _activeTargets;
  13002. private _currentActiveTarget;
  13003. private _directTarget;
  13004. /**
  13005. * The target path of the runtime animation
  13006. */
  13007. private _targetPath;
  13008. /**
  13009. * The weight of the runtime animation
  13010. */
  13011. private _weight;
  13012. /**
  13013. * The ratio offset of the runtime animation
  13014. */
  13015. private _ratioOffset;
  13016. /**
  13017. * The previous delay of the runtime animation
  13018. */
  13019. private _previousDelay;
  13020. /**
  13021. * The previous ratio of the runtime animation
  13022. */
  13023. private _previousRatio;
  13024. private _enableBlending;
  13025. private _keys;
  13026. private _minFrame;
  13027. private _maxFrame;
  13028. private _minValue;
  13029. private _maxValue;
  13030. private _targetIsArray;
  13031. /**
  13032. * Gets the current frame of the runtime animation
  13033. */
  13034. readonly currentFrame: number;
  13035. /**
  13036. * Gets the weight of the runtime animation
  13037. */
  13038. readonly weight: number;
  13039. /**
  13040. * Gets the current value of the runtime animation
  13041. */
  13042. readonly currentValue: any;
  13043. /**
  13044. * Gets the target path of the runtime animation
  13045. */
  13046. readonly targetPath: string;
  13047. /**
  13048. * Gets the actual target of the runtime animation
  13049. */
  13050. readonly target: any;
  13051. /** @hidden */
  13052. _onLoop: () => void;
  13053. /**
  13054. * Create a new RuntimeAnimation object
  13055. * @param target defines the target of the animation
  13056. * @param animation defines the source animation object
  13057. * @param scene defines the hosting scene
  13058. * @param host defines the initiating Animatable
  13059. */
  13060. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13061. private _preparePath;
  13062. /**
  13063. * Gets the animation from the runtime animation
  13064. */
  13065. readonly animation: Animation;
  13066. /**
  13067. * Resets the runtime animation to the beginning
  13068. * @param restoreOriginal defines whether to restore the target property to the original value
  13069. */
  13070. reset(restoreOriginal?: boolean): void;
  13071. /**
  13072. * Specifies if the runtime animation is stopped
  13073. * @returns Boolean specifying if the runtime animation is stopped
  13074. */
  13075. isStopped(): boolean;
  13076. /**
  13077. * Disposes of the runtime animation
  13078. */
  13079. dispose(): void;
  13080. /**
  13081. * Apply the interpolated value to the target
  13082. * @param currentValue defines the value computed by the animation
  13083. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13084. */
  13085. setValue(currentValue: any, weight: number): void;
  13086. private _getOriginalValues;
  13087. private _setValue;
  13088. /**
  13089. * Gets the loop pmode of the runtime animation
  13090. * @returns Loop Mode
  13091. */
  13092. private _getCorrectLoopMode;
  13093. /**
  13094. * Move the current animation to a given frame
  13095. * @param frame defines the frame to move to
  13096. */
  13097. goToFrame(frame: number): void;
  13098. /**
  13099. * @hidden Internal use only
  13100. */
  13101. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13102. /**
  13103. * Execute the current animation
  13104. * @param delay defines the delay to add to the current frame
  13105. * @param from defines the lower bound of the animation range
  13106. * @param to defines the upper bound of the animation range
  13107. * @param loop defines if the current animation must loop
  13108. * @param speedRatio defines the current speed ratio
  13109. * @param weight defines the weight of the animation (default is -1 so no weight)
  13110. * @param onLoop optional callback called when animation loops
  13111. * @returns a boolean indicating if the animation is running
  13112. */
  13113. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13114. }
  13115. }
  13116. declare module "babylonjs/Animations/animatable" {
  13117. import { Animation } from "babylonjs/Animations/animation";
  13118. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13119. import { Nullable } from "babylonjs/types";
  13120. import { Observable } from "babylonjs/Misc/observable";
  13121. import { Scene } from "babylonjs/scene";
  13122. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13123. import { Node } from "babylonjs/node";
  13124. /**
  13125. * Class used to store an actual running animation
  13126. */
  13127. export class Animatable {
  13128. /** defines the target object */
  13129. target: any;
  13130. /** defines the starting frame number (default is 0) */
  13131. fromFrame: number;
  13132. /** defines the ending frame number (default is 100) */
  13133. toFrame: number;
  13134. /** defines if the animation must loop (default is false) */
  13135. loopAnimation: boolean;
  13136. /** defines a callback to call when animation ends if it is not looping */
  13137. onAnimationEnd?: (() => void) | null | undefined;
  13138. /** defines a callback to call when animation loops */
  13139. onAnimationLoop?: (() => void) | null | undefined;
  13140. private _localDelayOffset;
  13141. private _pausedDelay;
  13142. private _runtimeAnimations;
  13143. private _paused;
  13144. private _scene;
  13145. private _speedRatio;
  13146. private _weight;
  13147. private _syncRoot;
  13148. /**
  13149. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13150. * This will only apply for non looping animation (default is true)
  13151. */
  13152. disposeOnEnd: boolean;
  13153. /**
  13154. * Gets a boolean indicating if the animation has started
  13155. */
  13156. animationStarted: boolean;
  13157. /**
  13158. * Observer raised when the animation ends
  13159. */
  13160. onAnimationEndObservable: Observable<Animatable>;
  13161. /**
  13162. * Observer raised when the animation loops
  13163. */
  13164. onAnimationLoopObservable: Observable<Animatable>;
  13165. /**
  13166. * Gets the root Animatable used to synchronize and normalize animations
  13167. */
  13168. readonly syncRoot: Nullable<Animatable>;
  13169. /**
  13170. * Gets the current frame of the first RuntimeAnimation
  13171. * Used to synchronize Animatables
  13172. */
  13173. readonly masterFrame: number;
  13174. /**
  13175. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13176. */
  13177. weight: number;
  13178. /**
  13179. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13180. */
  13181. speedRatio: number;
  13182. /**
  13183. * Creates a new Animatable
  13184. * @param scene defines the hosting scene
  13185. * @param target defines the target object
  13186. * @param fromFrame defines the starting frame number (default is 0)
  13187. * @param toFrame defines the ending frame number (default is 100)
  13188. * @param loopAnimation defines if the animation must loop (default is false)
  13189. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13190. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13191. * @param animations defines a group of animation to add to the new Animatable
  13192. * @param onAnimationLoop defines a callback to call when animation loops
  13193. */
  13194. constructor(scene: Scene,
  13195. /** defines the target object */
  13196. target: any,
  13197. /** defines the starting frame number (default is 0) */
  13198. fromFrame?: number,
  13199. /** defines the ending frame number (default is 100) */
  13200. toFrame?: number,
  13201. /** defines if the animation must loop (default is false) */
  13202. loopAnimation?: boolean, speedRatio?: number,
  13203. /** defines a callback to call when animation ends if it is not looping */
  13204. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13205. /** defines a callback to call when animation loops */
  13206. onAnimationLoop?: (() => void) | null | undefined);
  13207. /**
  13208. * Synchronize and normalize current Animatable with a source Animatable
  13209. * This is useful when using animation weights and when animations are not of the same length
  13210. * @param root defines the root Animatable to synchronize with
  13211. * @returns the current Animatable
  13212. */
  13213. syncWith(root: Animatable): Animatable;
  13214. /**
  13215. * Gets the list of runtime animations
  13216. * @returns an array of RuntimeAnimation
  13217. */
  13218. getAnimations(): RuntimeAnimation[];
  13219. /**
  13220. * Adds more animations to the current animatable
  13221. * @param target defines the target of the animations
  13222. * @param animations defines the new animations to add
  13223. */
  13224. appendAnimations(target: any, animations: Animation[]): void;
  13225. /**
  13226. * Gets the source animation for a specific property
  13227. * @param property defines the propertyu to look for
  13228. * @returns null or the source animation for the given property
  13229. */
  13230. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13231. /**
  13232. * Gets the runtime animation for a specific property
  13233. * @param property defines the propertyu to look for
  13234. * @returns null or the runtime animation for the given property
  13235. */
  13236. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13237. /**
  13238. * Resets the animatable to its original state
  13239. */
  13240. reset(): void;
  13241. /**
  13242. * Allows the animatable to blend with current running animations
  13243. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13244. * @param blendingSpeed defines the blending speed to use
  13245. */
  13246. enableBlending(blendingSpeed: number): void;
  13247. /**
  13248. * Disable animation blending
  13249. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13250. */
  13251. disableBlending(): void;
  13252. /**
  13253. * Jump directly to a given frame
  13254. * @param frame defines the frame to jump to
  13255. */
  13256. goToFrame(frame: number): void;
  13257. /**
  13258. * Pause the animation
  13259. */
  13260. pause(): void;
  13261. /**
  13262. * Restart the animation
  13263. */
  13264. restart(): void;
  13265. private _raiseOnAnimationEnd;
  13266. /**
  13267. * Stop and delete the current animation
  13268. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13269. * @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)
  13270. */
  13271. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13272. /**
  13273. * Wait asynchronously for the animation to end
  13274. * @returns a promise which will be fullfilled when the animation ends
  13275. */
  13276. waitAsync(): Promise<Animatable>;
  13277. /** @hidden */
  13278. _animate(delay: number): boolean;
  13279. }
  13280. module "babylonjs/scene" {
  13281. interface Scene {
  13282. /** @hidden */
  13283. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13284. /** @hidden */
  13285. _processLateAnimationBindingsForMatrices(holder: {
  13286. totalWeight: number;
  13287. animations: RuntimeAnimation[];
  13288. originalValue: Matrix;
  13289. }): any;
  13290. /** @hidden */
  13291. _processLateAnimationBindingsForQuaternions(holder: {
  13292. totalWeight: number;
  13293. animations: RuntimeAnimation[];
  13294. originalValue: Quaternion;
  13295. }, refQuaternion: Quaternion): Quaternion;
  13296. /** @hidden */
  13297. _processLateAnimationBindings(): void;
  13298. /**
  13299. * Will start the animation sequence of a given target
  13300. * @param target defines the target
  13301. * @param from defines from which frame should animation start
  13302. * @param to defines until which frame should animation run.
  13303. * @param weight defines the weight to apply to the animation (1.0 by default)
  13304. * @param loop defines if the animation loops
  13305. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13306. * @param onAnimationEnd defines the function to be executed when the animation ends
  13307. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13308. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13309. * @param onAnimationLoop defines the callback to call when an animation loops
  13310. * @returns the animatable object created for this animation
  13311. */
  13312. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13313. /**
  13314. * Will start the animation sequence of a given target
  13315. * @param target defines the target
  13316. * @param from defines from which frame should animation start
  13317. * @param to defines until which frame should animation run.
  13318. * @param loop defines if the animation loops
  13319. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13320. * @param onAnimationEnd defines the function to be executed when the animation ends
  13321. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13322. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13323. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13324. * @param onAnimationLoop defines the callback to call when an animation loops
  13325. * @returns the animatable object created for this animation
  13326. */
  13327. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13328. /**
  13329. * Will start the animation sequence of a given target and its hierarchy
  13330. * @param target defines the target
  13331. * @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.
  13332. * @param from defines from which frame should animation start
  13333. * @param to defines until which frame should animation run.
  13334. * @param loop defines if the animation loops
  13335. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13336. * @param onAnimationEnd defines the function to be executed when the animation ends
  13337. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13338. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13339. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13340. * @param onAnimationLoop defines the callback to call when an animation loops
  13341. * @returns the list of created animatables
  13342. */
  13343. 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[];
  13344. /**
  13345. * Begin a new animation on a given node
  13346. * @param target defines the target where the animation will take place
  13347. * @param animations defines the list of animations to start
  13348. * @param from defines the initial value
  13349. * @param to defines the final value
  13350. * @param loop defines if you want animation to loop (off by default)
  13351. * @param speedRatio defines the speed ratio to apply to all animations
  13352. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13353. * @param onAnimationLoop defines the callback to call when an animation loops
  13354. * @returns the list of created animatables
  13355. */
  13356. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13357. /**
  13358. * Begin a new animation on a given node and its hierarchy
  13359. * @param target defines the root node where the animation will take place
  13360. * @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.
  13361. * @param animations defines the list of animations to start
  13362. * @param from defines the initial value
  13363. * @param to defines the final value
  13364. * @param loop defines if you want animation to loop (off by default)
  13365. * @param speedRatio defines the speed ratio to apply to all animations
  13366. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13367. * @param onAnimationLoop defines the callback to call when an animation loops
  13368. * @returns the list of animatables created for all nodes
  13369. */
  13370. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13371. /**
  13372. * Gets the animatable associated with a specific target
  13373. * @param target defines the target of the animatable
  13374. * @returns the required animatable if found
  13375. */
  13376. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13377. /**
  13378. * Gets all animatables associated with a given target
  13379. * @param target defines the target to look animatables for
  13380. * @returns an array of Animatables
  13381. */
  13382. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13383. /**
  13384. * Stops and removes all animations that have been applied to the scene
  13385. */
  13386. stopAllAnimations(): void;
  13387. /**
  13388. * Gets the current delta time used by animation engine
  13389. */
  13390. deltaTime: number;
  13391. }
  13392. }
  13393. module "babylonjs/Bones/bone" {
  13394. interface Bone {
  13395. /**
  13396. * Copy an animation range from another bone
  13397. * @param source defines the source bone
  13398. * @param rangeName defines the range name to copy
  13399. * @param frameOffset defines the frame offset
  13400. * @param rescaleAsRequired defines if rescaling must be applied if required
  13401. * @param skelDimensionsRatio defines the scaling ratio
  13402. * @returns true if operation was successful
  13403. */
  13404. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13405. }
  13406. }
  13407. }
  13408. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13409. /**
  13410. * Class used to override all child animations of a given target
  13411. */
  13412. export class AnimationPropertiesOverride {
  13413. /**
  13414. * Gets or sets a value indicating if animation blending must be used
  13415. */
  13416. enableBlending: boolean;
  13417. /**
  13418. * Gets or sets the blending speed to use when enableBlending is true
  13419. */
  13420. blendingSpeed: number;
  13421. /**
  13422. * Gets or sets the default loop mode to use
  13423. */
  13424. loopMode: number;
  13425. }
  13426. }
  13427. declare module "babylonjs/Bones/skeleton" {
  13428. import { Bone } from "babylonjs/Bones/bone";
  13429. import { Observable } from "babylonjs/Misc/observable";
  13430. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13431. import { Scene } from "babylonjs/scene";
  13432. import { Nullable } from "babylonjs/types";
  13433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13434. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13435. import { Animatable } from "babylonjs/Animations/animatable";
  13436. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13437. import { Animation } from "babylonjs/Animations/animation";
  13438. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13439. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13440. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13441. /**
  13442. * Class used to handle skinning animations
  13443. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13444. */
  13445. export class Skeleton implements IAnimatable {
  13446. /** defines the skeleton name */
  13447. name: string;
  13448. /** defines the skeleton Id */
  13449. id: string;
  13450. /**
  13451. * Defines the list of child bones
  13452. */
  13453. bones: Bone[];
  13454. /**
  13455. * Defines an estimate of the dimension of the skeleton at rest
  13456. */
  13457. dimensionsAtRest: Vector3;
  13458. /**
  13459. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13460. */
  13461. needInitialSkinMatrix: boolean;
  13462. /**
  13463. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13464. */
  13465. overrideMesh: Nullable<AbstractMesh>;
  13466. /**
  13467. * Gets the list of animations attached to this skeleton
  13468. */
  13469. animations: Array<Animation>;
  13470. private _scene;
  13471. private _isDirty;
  13472. private _transformMatrices;
  13473. private _transformMatrixTexture;
  13474. private _meshesWithPoseMatrix;
  13475. private _animatables;
  13476. private _identity;
  13477. private _synchronizedWithMesh;
  13478. private _ranges;
  13479. private _lastAbsoluteTransformsUpdateId;
  13480. private _canUseTextureForBones;
  13481. private _uniqueId;
  13482. /** @hidden */
  13483. _numBonesWithLinkedTransformNode: number;
  13484. /** @hidden */
  13485. _hasWaitingData: Nullable<boolean>;
  13486. /**
  13487. * Specifies if the skeleton should be serialized
  13488. */
  13489. doNotSerialize: boolean;
  13490. private _useTextureToStoreBoneMatrices;
  13491. /**
  13492. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13493. * Please note that this option is not available if the hardware does not support it
  13494. */
  13495. useTextureToStoreBoneMatrices: boolean;
  13496. private _animationPropertiesOverride;
  13497. /**
  13498. * Gets or sets the animation properties override
  13499. */
  13500. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13501. /**
  13502. * List of inspectable custom properties (used by the Inspector)
  13503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13504. */
  13505. inspectableCustomProperties: IInspectable[];
  13506. /**
  13507. * An observable triggered before computing the skeleton's matrices
  13508. */
  13509. onBeforeComputeObservable: Observable<Skeleton>;
  13510. /**
  13511. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13512. */
  13513. readonly isUsingTextureForMatrices: boolean;
  13514. /**
  13515. * Gets the unique ID of this skeleton
  13516. */
  13517. readonly uniqueId: number;
  13518. /**
  13519. * Creates a new skeleton
  13520. * @param name defines the skeleton name
  13521. * @param id defines the skeleton Id
  13522. * @param scene defines the hosting scene
  13523. */
  13524. constructor(
  13525. /** defines the skeleton name */
  13526. name: string,
  13527. /** defines the skeleton Id */
  13528. id: string, scene: Scene);
  13529. /**
  13530. * Gets the current object class name.
  13531. * @return the class name
  13532. */
  13533. getClassName(): string;
  13534. /**
  13535. * Returns an array containing the root bones
  13536. * @returns an array containing the root bones
  13537. */
  13538. getChildren(): Array<Bone>;
  13539. /**
  13540. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13541. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13542. * @returns a Float32Array containing matrices data
  13543. */
  13544. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13545. /**
  13546. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13547. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13548. * @returns a raw texture containing the data
  13549. */
  13550. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13551. /**
  13552. * Gets the current hosting scene
  13553. * @returns a scene object
  13554. */
  13555. getScene(): Scene;
  13556. /**
  13557. * Gets a string representing the current skeleton data
  13558. * @param fullDetails defines a boolean indicating if we want a verbose version
  13559. * @returns a string representing the current skeleton data
  13560. */
  13561. toString(fullDetails?: boolean): string;
  13562. /**
  13563. * Get bone's index searching by name
  13564. * @param name defines bone's name to search for
  13565. * @return the indice of the bone. Returns -1 if not found
  13566. */
  13567. getBoneIndexByName(name: string): number;
  13568. /**
  13569. * Creater a new animation range
  13570. * @param name defines the name of the range
  13571. * @param from defines the start key
  13572. * @param to defines the end key
  13573. */
  13574. createAnimationRange(name: string, from: number, to: number): void;
  13575. /**
  13576. * Delete a specific animation range
  13577. * @param name defines the name of the range
  13578. * @param deleteFrames defines if frames must be removed as well
  13579. */
  13580. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13581. /**
  13582. * Gets a specific animation range
  13583. * @param name defines the name of the range to look for
  13584. * @returns the requested animation range or null if not found
  13585. */
  13586. getAnimationRange(name: string): Nullable<AnimationRange>;
  13587. /**
  13588. * Gets the list of all animation ranges defined on this skeleton
  13589. * @returns an array
  13590. */
  13591. getAnimationRanges(): Nullable<AnimationRange>[];
  13592. /**
  13593. * Copy animation range from a source skeleton.
  13594. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13595. * @param source defines the source skeleton
  13596. * @param name defines the name of the range to copy
  13597. * @param rescaleAsRequired defines if rescaling must be applied if required
  13598. * @returns true if operation was successful
  13599. */
  13600. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13601. /**
  13602. * Forces the skeleton to go to rest pose
  13603. */
  13604. returnToRest(): void;
  13605. private _getHighestAnimationFrame;
  13606. /**
  13607. * Begin a specific animation range
  13608. * @param name defines the name of the range to start
  13609. * @param loop defines if looping must be turned on (false by default)
  13610. * @param speedRatio defines the speed ratio to apply (1 by default)
  13611. * @param onAnimationEnd defines a callback which will be called when animation will end
  13612. * @returns a new animatable
  13613. */
  13614. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13615. /** @hidden */
  13616. _markAsDirty(): void;
  13617. /** @hidden */
  13618. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13619. /** @hidden */
  13620. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13621. private _computeTransformMatrices;
  13622. /**
  13623. * Build all resources required to render a skeleton
  13624. */
  13625. prepare(): void;
  13626. /**
  13627. * Gets the list of animatables currently running for this skeleton
  13628. * @returns an array of animatables
  13629. */
  13630. getAnimatables(): IAnimatable[];
  13631. /**
  13632. * Clone the current skeleton
  13633. * @param name defines the name of the new skeleton
  13634. * @param id defines the id of the new skeleton
  13635. * @returns the new skeleton
  13636. */
  13637. clone(name: string, id: string): Skeleton;
  13638. /**
  13639. * Enable animation blending for this skeleton
  13640. * @param blendingSpeed defines the blending speed to apply
  13641. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13642. */
  13643. enableBlending(blendingSpeed?: number): void;
  13644. /**
  13645. * Releases all resources associated with the current skeleton
  13646. */
  13647. dispose(): void;
  13648. /**
  13649. * Serialize the skeleton in a JSON object
  13650. * @returns a JSON object
  13651. */
  13652. serialize(): any;
  13653. /**
  13654. * Creates a new skeleton from serialized data
  13655. * @param parsedSkeleton defines the serialized data
  13656. * @param scene defines the hosting scene
  13657. * @returns a new skeleton
  13658. */
  13659. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13660. /**
  13661. * Compute all node absolute transforms
  13662. * @param forceUpdate defines if computation must be done even if cache is up to date
  13663. */
  13664. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13665. /**
  13666. * Gets the root pose matrix
  13667. * @returns a matrix
  13668. */
  13669. getPoseMatrix(): Nullable<Matrix>;
  13670. /**
  13671. * Sorts bones per internal index
  13672. */
  13673. sortBones(): void;
  13674. private _sortBones;
  13675. }
  13676. }
  13677. declare module "babylonjs/Bones/bone" {
  13678. import { Skeleton } from "babylonjs/Bones/skeleton";
  13679. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13680. import { Nullable } from "babylonjs/types";
  13681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13682. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13683. import { Node } from "babylonjs/node";
  13684. import { Space } from "babylonjs/Maths/math.axis";
  13685. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13686. /**
  13687. * Class used to store bone information
  13688. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13689. */
  13690. export class Bone extends Node {
  13691. /**
  13692. * defines the bone name
  13693. */
  13694. name: string;
  13695. private static _tmpVecs;
  13696. private static _tmpQuat;
  13697. private static _tmpMats;
  13698. /**
  13699. * Gets the list of child bones
  13700. */
  13701. children: Bone[];
  13702. /** Gets the animations associated with this bone */
  13703. animations: import("babylonjs/Animations/animation").Animation[];
  13704. /**
  13705. * Gets or sets bone length
  13706. */
  13707. length: number;
  13708. /**
  13709. * @hidden Internal only
  13710. * Set this value to map this bone to a different index in the transform matrices
  13711. * Set this value to -1 to exclude the bone from the transform matrices
  13712. */
  13713. _index: Nullable<number>;
  13714. private _skeleton;
  13715. private _localMatrix;
  13716. private _restPose;
  13717. private _baseMatrix;
  13718. private _absoluteTransform;
  13719. private _invertedAbsoluteTransform;
  13720. private _parent;
  13721. private _scalingDeterminant;
  13722. private _worldTransform;
  13723. private _localScaling;
  13724. private _localRotation;
  13725. private _localPosition;
  13726. private _needToDecompose;
  13727. private _needToCompose;
  13728. /** @hidden */
  13729. _linkedTransformNode: Nullable<TransformNode>;
  13730. /** @hidden */
  13731. _waitingTransformNodeId: Nullable<string>;
  13732. /** @hidden */
  13733. /** @hidden */
  13734. _matrix: Matrix;
  13735. /**
  13736. * Create a new bone
  13737. * @param name defines the bone name
  13738. * @param skeleton defines the parent skeleton
  13739. * @param parentBone defines the parent (can be null if the bone is the root)
  13740. * @param localMatrix defines the local matrix
  13741. * @param restPose defines the rest pose matrix
  13742. * @param baseMatrix defines the base matrix
  13743. * @param index defines index of the bone in the hiearchy
  13744. */
  13745. constructor(
  13746. /**
  13747. * defines the bone name
  13748. */
  13749. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13750. /**
  13751. * Gets the current object class name.
  13752. * @return the class name
  13753. */
  13754. getClassName(): string;
  13755. /**
  13756. * Gets the parent skeleton
  13757. * @returns a skeleton
  13758. */
  13759. getSkeleton(): Skeleton;
  13760. /**
  13761. * Gets parent bone
  13762. * @returns a bone or null if the bone is the root of the bone hierarchy
  13763. */
  13764. getParent(): Nullable<Bone>;
  13765. /**
  13766. * Returns an array containing the root bones
  13767. * @returns an array containing the root bones
  13768. */
  13769. getChildren(): Array<Bone>;
  13770. /**
  13771. * Sets the parent bone
  13772. * @param parent defines the parent (can be null if the bone is the root)
  13773. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13774. */
  13775. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13776. /**
  13777. * Gets the local matrix
  13778. * @returns a matrix
  13779. */
  13780. getLocalMatrix(): Matrix;
  13781. /**
  13782. * Gets the base matrix (initial matrix which remains unchanged)
  13783. * @returns a matrix
  13784. */
  13785. getBaseMatrix(): Matrix;
  13786. /**
  13787. * Gets the rest pose matrix
  13788. * @returns a matrix
  13789. */
  13790. getRestPose(): Matrix;
  13791. /**
  13792. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13793. */
  13794. getWorldMatrix(): Matrix;
  13795. /**
  13796. * Sets the local matrix to rest pose matrix
  13797. */
  13798. returnToRest(): void;
  13799. /**
  13800. * Gets the inverse of the absolute transform matrix.
  13801. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13802. * @returns a matrix
  13803. */
  13804. getInvertedAbsoluteTransform(): Matrix;
  13805. /**
  13806. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13807. * @returns a matrix
  13808. */
  13809. getAbsoluteTransform(): Matrix;
  13810. /**
  13811. * Links with the given transform node.
  13812. * The local matrix of this bone is copied from the transform node every frame.
  13813. * @param transformNode defines the transform node to link to
  13814. */
  13815. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13816. /**
  13817. * Gets the node used to drive the bone's transformation
  13818. * @returns a transform node or null
  13819. */
  13820. getTransformNode(): Nullable<TransformNode>;
  13821. /** Gets or sets current position (in local space) */
  13822. position: Vector3;
  13823. /** Gets or sets current rotation (in local space) */
  13824. rotation: Vector3;
  13825. /** Gets or sets current rotation quaternion (in local space) */
  13826. rotationQuaternion: Quaternion;
  13827. /** Gets or sets current scaling (in local space) */
  13828. scaling: Vector3;
  13829. /**
  13830. * Gets the animation properties override
  13831. */
  13832. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13833. private _decompose;
  13834. private _compose;
  13835. /**
  13836. * Update the base and local matrices
  13837. * @param matrix defines the new base or local matrix
  13838. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13839. * @param updateLocalMatrix defines if the local matrix should be updated
  13840. */
  13841. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13842. /** @hidden */
  13843. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13844. /**
  13845. * Flag the bone as dirty (Forcing it to update everything)
  13846. */
  13847. markAsDirty(): void;
  13848. /** @hidden */
  13849. _markAsDirtyAndCompose(): void;
  13850. private _markAsDirtyAndDecompose;
  13851. /**
  13852. * Translate the bone in local or world space
  13853. * @param vec The amount to translate the bone
  13854. * @param space The space that the translation is in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. */
  13857. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13858. /**
  13859. * Set the postion of the bone in local or world space
  13860. * @param position The position to set the bone
  13861. * @param space The space that the position is in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. */
  13864. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13865. /**
  13866. * Set the absolute position of the bone (world space)
  13867. * @param position The position to set the bone
  13868. * @param mesh The mesh that this bone is attached to
  13869. */
  13870. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13871. /**
  13872. * Scale the bone on the x, y and z axes (in local space)
  13873. * @param x The amount to scale the bone on the x axis
  13874. * @param y The amount to scale the bone on the y axis
  13875. * @param z The amount to scale the bone on the z axis
  13876. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13877. */
  13878. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13879. /**
  13880. * Set the bone scaling in local space
  13881. * @param scale defines the scaling vector
  13882. */
  13883. setScale(scale: Vector3): void;
  13884. /**
  13885. * Gets the current scaling in local space
  13886. * @returns the current scaling vector
  13887. */
  13888. getScale(): Vector3;
  13889. /**
  13890. * Gets the current scaling in local space and stores it in a target vector
  13891. * @param result defines the target vector
  13892. */
  13893. getScaleToRef(result: Vector3): void;
  13894. /**
  13895. * Set the yaw, pitch, and roll of the bone in local or world space
  13896. * @param yaw The rotation of the bone on the y axis
  13897. * @param pitch The rotation of the bone on the x axis
  13898. * @param roll The rotation of the bone on the z axis
  13899. * @param space The space that the axes of rotation are in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. */
  13902. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13903. /**
  13904. * Add a rotation to the bone on an axis in local or world space
  13905. * @param axis The axis to rotate the bone on
  13906. * @param amount The amount to rotate the bone
  13907. * @param space The space that the axis is in
  13908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13909. */
  13910. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13911. /**
  13912. * Set the rotation of the bone to a particular axis angle in local or world space
  13913. * @param axis The axis to rotate the bone on
  13914. * @param angle The angle that the bone should be rotated to
  13915. * @param space The space that the axis is in
  13916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13917. */
  13918. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13919. /**
  13920. * Set the euler rotation of the bone in local of world space
  13921. * @param rotation The euler rotation that the bone should be set to
  13922. * @param space The space that the rotation is in
  13923. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13924. */
  13925. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13926. /**
  13927. * Set the quaternion rotation of the bone in local of world space
  13928. * @param quat The quaternion rotation that the bone should be set to
  13929. * @param space The space that the rotation is in
  13930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13931. */
  13932. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13933. /**
  13934. * Set the rotation matrix of the bone in local of world space
  13935. * @param rotMat The rotation matrix that the bone should be set to
  13936. * @param space The space that the rotation is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. */
  13939. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13940. private _rotateWithMatrix;
  13941. private _getNegativeRotationToRef;
  13942. /**
  13943. * Get the position of the bone in local or world space
  13944. * @param space The space that the returned position is in
  13945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13946. * @returns The position of the bone
  13947. */
  13948. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13949. /**
  13950. * Copy the position of the bone to a vector3 in local or world space
  13951. * @param space The space that the returned position is in
  13952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13953. * @param result The vector3 to copy the position to
  13954. */
  13955. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13956. /**
  13957. * Get the absolute position of the bone (world space)
  13958. * @param mesh The mesh that this bone is attached to
  13959. * @returns The absolute position of the bone
  13960. */
  13961. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13962. /**
  13963. * Copy the absolute position of the bone (world space) to the result param
  13964. * @param mesh The mesh that this bone is attached to
  13965. * @param result The vector3 to copy the absolute position to
  13966. */
  13967. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13968. /**
  13969. * Compute the absolute transforms of this bone and its children
  13970. */
  13971. computeAbsoluteTransforms(): void;
  13972. /**
  13973. * Get the world direction from an axis that is in the local space of the bone
  13974. * @param localAxis The local direction that is used to compute the world direction
  13975. * @param mesh The mesh that this bone is attached to
  13976. * @returns The world direction
  13977. */
  13978. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13979. /**
  13980. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13981. * @param localAxis The local direction that is used to compute the world direction
  13982. * @param mesh The mesh that this bone is attached to
  13983. * @param result The vector3 that the world direction will be copied to
  13984. */
  13985. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13986. /**
  13987. * Get the euler rotation of the bone in local or world space
  13988. * @param space The space that the rotation should be in
  13989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13990. * @returns The euler rotation
  13991. */
  13992. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13993. /**
  13994. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13995. * @param space The space that the rotation should be in
  13996. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13997. * @param result The vector3 that the rotation should be copied to
  13998. */
  13999. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14000. /**
  14001. * Get the quaternion rotation of the bone in either local or world space
  14002. * @param space The space that the rotation should be in
  14003. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14004. * @returns The quaternion rotation
  14005. */
  14006. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14007. /**
  14008. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14009. * @param space The space that the rotation should be in
  14010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14011. * @param result The quaternion that the rotation should be copied to
  14012. */
  14013. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14014. /**
  14015. * Get the rotation matrix of the bone in local or world space
  14016. * @param space The space that the rotation should be in
  14017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14018. * @returns The rotation matrix
  14019. */
  14020. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14021. /**
  14022. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14023. * @param space The space that the rotation should be in
  14024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14025. * @param result The quaternion that the rotation should be copied to
  14026. */
  14027. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14028. /**
  14029. * Get the world position of a point that is in the local space of the bone
  14030. * @param position The local position
  14031. * @param mesh The mesh that this bone is attached to
  14032. * @returns The world position
  14033. */
  14034. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14035. /**
  14036. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14037. * @param position The local position
  14038. * @param mesh The mesh that this bone is attached to
  14039. * @param result The vector3 that the world position should be copied to
  14040. */
  14041. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14042. /**
  14043. * Get the local position of a point that is in world space
  14044. * @param position The world position
  14045. * @param mesh The mesh that this bone is attached to
  14046. * @returns The local position
  14047. */
  14048. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14049. /**
  14050. * Get the local position of a point that is in world space and copy it to the result param
  14051. * @param position The world position
  14052. * @param mesh The mesh that this bone is attached to
  14053. * @param result The vector3 that the local position should be copied to
  14054. */
  14055. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14056. }
  14057. }
  14058. declare module "babylonjs/Meshes/transformNode" {
  14059. import { DeepImmutable } from "babylonjs/types";
  14060. import { Observable } from "babylonjs/Misc/observable";
  14061. import { Nullable } from "babylonjs/types";
  14062. import { Camera } from "babylonjs/Cameras/camera";
  14063. import { Scene } from "babylonjs/scene";
  14064. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14065. import { Node } from "babylonjs/node";
  14066. import { Bone } from "babylonjs/Bones/bone";
  14067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14068. import { Space } from "babylonjs/Maths/math.axis";
  14069. /**
  14070. * 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.
  14071. * @see https://doc.babylonjs.com/how_to/transformnode
  14072. */
  14073. export class TransformNode extends Node {
  14074. /**
  14075. * Object will not rotate to face the camera
  14076. */
  14077. static BILLBOARDMODE_NONE: number;
  14078. /**
  14079. * Object will rotate to face the camera but only on the x axis
  14080. */
  14081. static BILLBOARDMODE_X: number;
  14082. /**
  14083. * Object will rotate to face the camera but only on the y axis
  14084. */
  14085. static BILLBOARDMODE_Y: number;
  14086. /**
  14087. * Object will rotate to face the camera but only on the z axis
  14088. */
  14089. static BILLBOARDMODE_Z: number;
  14090. /**
  14091. * Object will rotate to face the camera
  14092. */
  14093. static BILLBOARDMODE_ALL: number;
  14094. /**
  14095. * Object will rotate to face the camera's position instead of orientation
  14096. */
  14097. static BILLBOARDMODE_USE_POSITION: number;
  14098. private _forward;
  14099. private _forwardInverted;
  14100. private _up;
  14101. private _right;
  14102. private _rightInverted;
  14103. private _position;
  14104. private _rotation;
  14105. private _rotationQuaternion;
  14106. protected _scaling: Vector3;
  14107. protected _isDirty: boolean;
  14108. private _transformToBoneReferal;
  14109. private _isAbsoluteSynced;
  14110. private _billboardMode;
  14111. /**
  14112. * Gets or sets the billboard mode. Default is 0.
  14113. *
  14114. * | Value | Type | Description |
  14115. * | --- | --- | --- |
  14116. * | 0 | BILLBOARDMODE_NONE | |
  14117. * | 1 | BILLBOARDMODE_X | |
  14118. * | 2 | BILLBOARDMODE_Y | |
  14119. * | 4 | BILLBOARDMODE_Z | |
  14120. * | 7 | BILLBOARDMODE_ALL | |
  14121. *
  14122. */
  14123. billboardMode: number;
  14124. private _preserveParentRotationForBillboard;
  14125. /**
  14126. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14127. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14128. */
  14129. preserveParentRotationForBillboard: boolean;
  14130. /**
  14131. * 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
  14132. */
  14133. scalingDeterminant: number;
  14134. private _infiniteDistance;
  14135. /**
  14136. * Gets or sets the distance of the object to max, often used by skybox
  14137. */
  14138. infiniteDistance: boolean;
  14139. /**
  14140. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14141. * By default the system will update normals to compensate
  14142. */
  14143. ignoreNonUniformScaling: boolean;
  14144. /**
  14145. * 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
  14146. */
  14147. reIntegrateRotationIntoRotationQuaternion: boolean;
  14148. /** @hidden */
  14149. _poseMatrix: Nullable<Matrix>;
  14150. /** @hidden */
  14151. _localMatrix: Matrix;
  14152. private _usePivotMatrix;
  14153. private _absolutePosition;
  14154. private _absoluteScaling;
  14155. private _absoluteRotationQuaternion;
  14156. private _pivotMatrix;
  14157. private _pivotMatrixInverse;
  14158. protected _postMultiplyPivotMatrix: boolean;
  14159. protected _isWorldMatrixFrozen: boolean;
  14160. /** @hidden */
  14161. _indexInSceneTransformNodesArray: number;
  14162. /**
  14163. * An event triggered after the world matrix is updated
  14164. */
  14165. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14166. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14167. /**
  14168. * Gets a string identifying the name of the class
  14169. * @returns "TransformNode" string
  14170. */
  14171. getClassName(): string;
  14172. /**
  14173. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14174. */
  14175. position: Vector3;
  14176. /**
  14177. * 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)).
  14178. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14179. */
  14180. rotation: Vector3;
  14181. /**
  14182. * 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)).
  14183. */
  14184. scaling: Vector3;
  14185. /**
  14186. * 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).
  14187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14188. */
  14189. rotationQuaternion: Nullable<Quaternion>;
  14190. /**
  14191. * The forward direction of that transform in world space.
  14192. */
  14193. readonly forward: Vector3;
  14194. /**
  14195. * The up direction of that transform in world space.
  14196. */
  14197. readonly up: Vector3;
  14198. /**
  14199. * The right direction of that transform in world space.
  14200. */
  14201. readonly right: Vector3;
  14202. /**
  14203. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14204. * @param matrix the matrix to copy the pose from
  14205. * @returns this TransformNode.
  14206. */
  14207. updatePoseMatrix(matrix: Matrix): TransformNode;
  14208. /**
  14209. * Returns the mesh Pose matrix.
  14210. * @returns the pose matrix
  14211. */
  14212. getPoseMatrix(): Matrix;
  14213. /** @hidden */
  14214. _isSynchronized(): boolean;
  14215. /** @hidden */
  14216. _initCache(): void;
  14217. /**
  14218. * Flag the transform node as dirty (Forcing it to update everything)
  14219. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14220. * @returns this transform node
  14221. */
  14222. markAsDirty(property: string): TransformNode;
  14223. /**
  14224. * Returns the current mesh absolute position.
  14225. * Returns a Vector3.
  14226. */
  14227. readonly absolutePosition: Vector3;
  14228. /**
  14229. * Returns the current mesh absolute scaling.
  14230. * Returns a Vector3.
  14231. */
  14232. readonly absoluteScaling: Vector3;
  14233. /**
  14234. * Returns the current mesh absolute rotation.
  14235. * Returns a Quaternion.
  14236. */
  14237. readonly absoluteRotationQuaternion: Quaternion;
  14238. /**
  14239. * Sets a new matrix to apply before all other transformation
  14240. * @param matrix defines the transform matrix
  14241. * @returns the current TransformNode
  14242. */
  14243. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14244. /**
  14245. * Sets a new pivot matrix to the current node
  14246. * @param matrix defines the new pivot matrix to use
  14247. * @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
  14248. * @returns the current TransformNode
  14249. */
  14250. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14251. /**
  14252. * Returns the mesh pivot matrix.
  14253. * Default : Identity.
  14254. * @returns the matrix
  14255. */
  14256. getPivotMatrix(): Matrix;
  14257. /**
  14258. * Instantiate (when possible) or clone that node with its hierarchy
  14259. * @param newParent defines the new parent to use for the instance (or clone)
  14260. * @returns an instance (or a clone) of the current node with its hiearchy
  14261. */
  14262. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14263. /**
  14264. * Prevents the World matrix to be computed any longer
  14265. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14266. * @returns the TransformNode.
  14267. */
  14268. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14269. /**
  14270. * Allows back the World matrix computation.
  14271. * @returns the TransformNode.
  14272. */
  14273. unfreezeWorldMatrix(): this;
  14274. /**
  14275. * True if the World matrix has been frozen.
  14276. */
  14277. readonly isWorldMatrixFrozen: boolean;
  14278. /**
  14279. * Retuns the mesh absolute position in the World.
  14280. * @returns a Vector3.
  14281. */
  14282. getAbsolutePosition(): Vector3;
  14283. /**
  14284. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14285. * @param absolutePosition the absolute position to set
  14286. * @returns the TransformNode.
  14287. */
  14288. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14289. /**
  14290. * Sets the mesh position in its local space.
  14291. * @param vector3 the position to set in localspace
  14292. * @returns the TransformNode.
  14293. */
  14294. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14295. /**
  14296. * Returns the mesh position in the local space from the current World matrix values.
  14297. * @returns a new Vector3.
  14298. */
  14299. getPositionExpressedInLocalSpace(): Vector3;
  14300. /**
  14301. * Translates the mesh along the passed Vector3 in its local space.
  14302. * @param vector3 the distance to translate in localspace
  14303. * @returns the TransformNode.
  14304. */
  14305. locallyTranslate(vector3: Vector3): TransformNode;
  14306. private static _lookAtVectorCache;
  14307. /**
  14308. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14309. * @param targetPoint the position (must be in same space as current mesh) to look at
  14310. * @param yawCor optional yaw (y-axis) correction in radians
  14311. * @param pitchCor optional pitch (x-axis) correction in radians
  14312. * @param rollCor optional roll (z-axis) correction in radians
  14313. * @param space the choosen space of the target
  14314. * @returns the TransformNode.
  14315. */
  14316. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14317. /**
  14318. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14319. * This Vector3 is expressed in the World space.
  14320. * @param localAxis axis to rotate
  14321. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14322. */
  14323. getDirection(localAxis: Vector3): Vector3;
  14324. /**
  14325. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14326. * localAxis is expressed in the mesh local space.
  14327. * result is computed in the Wordl space from the mesh World matrix.
  14328. * @param localAxis axis to rotate
  14329. * @param result the resulting transformnode
  14330. * @returns this TransformNode.
  14331. */
  14332. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14333. /**
  14334. * Sets this transform node rotation to the given local axis.
  14335. * @param localAxis the axis in local space
  14336. * @param yawCor optional yaw (y-axis) correction in radians
  14337. * @param pitchCor optional pitch (x-axis) correction in radians
  14338. * @param rollCor optional roll (z-axis) correction in radians
  14339. * @returns this TransformNode
  14340. */
  14341. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14342. /**
  14343. * Sets a new pivot point to the current node
  14344. * @param point defines the new pivot point to use
  14345. * @param space defines if the point is in world or local space (local by default)
  14346. * @returns the current TransformNode
  14347. */
  14348. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14349. /**
  14350. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14351. * @returns the pivot point
  14352. */
  14353. getPivotPoint(): Vector3;
  14354. /**
  14355. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14356. * @param result the vector3 to store the result
  14357. * @returns this TransformNode.
  14358. */
  14359. getPivotPointToRef(result: Vector3): TransformNode;
  14360. /**
  14361. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14362. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14363. */
  14364. getAbsolutePivotPoint(): Vector3;
  14365. /**
  14366. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14367. * @param result vector3 to store the result
  14368. * @returns this TransformNode.
  14369. */
  14370. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14371. /**
  14372. * Defines the passed node as the parent of the current node.
  14373. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14374. * @see https://doc.babylonjs.com/how_to/parenting
  14375. * @param node the node ot set as the parent
  14376. * @returns this TransformNode.
  14377. */
  14378. setParent(node: Nullable<Node>): TransformNode;
  14379. private _nonUniformScaling;
  14380. /**
  14381. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14382. */
  14383. readonly nonUniformScaling: boolean;
  14384. /** @hidden */
  14385. _updateNonUniformScalingState(value: boolean): boolean;
  14386. /**
  14387. * Attach the current TransformNode to another TransformNode associated with a bone
  14388. * @param bone Bone affecting the TransformNode
  14389. * @param affectedTransformNode TransformNode associated with the bone
  14390. * @returns this object
  14391. */
  14392. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14393. /**
  14394. * Detach the transform node if its associated with a bone
  14395. * @returns this object
  14396. */
  14397. detachFromBone(): TransformNode;
  14398. private static _rotationAxisCache;
  14399. /**
  14400. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14401. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14402. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14403. * The passed axis is also normalized.
  14404. * @param axis the axis to rotate around
  14405. * @param amount the amount to rotate in radians
  14406. * @param space Space to rotate in (Default: local)
  14407. * @returns the TransformNode.
  14408. */
  14409. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14410. /**
  14411. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14412. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14413. * The passed axis is also normalized. .
  14414. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14415. * @param point the point to rotate around
  14416. * @param axis the axis to rotate around
  14417. * @param amount the amount to rotate in radians
  14418. * @returns the TransformNode
  14419. */
  14420. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14421. /**
  14422. * Translates the mesh along the axis vector for the passed distance in the given space.
  14423. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14424. * @param axis the axis to translate in
  14425. * @param distance the distance to translate
  14426. * @param space Space to rotate in (Default: local)
  14427. * @returns the TransformNode.
  14428. */
  14429. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14430. /**
  14431. * Adds a rotation step to the mesh current rotation.
  14432. * x, y, z are Euler angles expressed in radians.
  14433. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14434. * This means this rotation is made in the mesh local space only.
  14435. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14436. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14437. * ```javascript
  14438. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14439. * ```
  14440. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14441. * 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.
  14442. * @param x Rotation to add
  14443. * @param y Rotation to add
  14444. * @param z Rotation to add
  14445. * @returns the TransformNode.
  14446. */
  14447. addRotation(x: number, y: number, z: number): TransformNode;
  14448. /**
  14449. * @hidden
  14450. */
  14451. protected _getEffectiveParent(): Nullable<Node>;
  14452. /**
  14453. * Computes the world matrix of the node
  14454. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14455. * @returns the world matrix
  14456. */
  14457. computeWorldMatrix(force?: boolean): Matrix;
  14458. protected _afterComputeWorldMatrix(): void;
  14459. /**
  14460. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14461. * @param func callback function to add
  14462. *
  14463. * @returns the TransformNode.
  14464. */
  14465. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14466. /**
  14467. * Removes a registered callback function.
  14468. * @param func callback function to remove
  14469. * @returns the TransformNode.
  14470. */
  14471. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14472. /**
  14473. * Gets the position of the current mesh in camera space
  14474. * @param camera defines the camera to use
  14475. * @returns a position
  14476. */
  14477. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14478. /**
  14479. * Returns the distance from the mesh to the active camera
  14480. * @param camera defines the camera to use
  14481. * @returns the distance
  14482. */
  14483. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14484. /**
  14485. * Clone the current transform node
  14486. * @param name Name of the new clone
  14487. * @param newParent New parent for the clone
  14488. * @param doNotCloneChildren Do not clone children hierarchy
  14489. * @returns the new transform node
  14490. */
  14491. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14492. /**
  14493. * Serializes the objects information.
  14494. * @param currentSerializationObject defines the object to serialize in
  14495. * @returns the serialized object
  14496. */
  14497. serialize(currentSerializationObject?: any): any;
  14498. /**
  14499. * Returns a new TransformNode object parsed from the source provided.
  14500. * @param parsedTransformNode is the source.
  14501. * @param scene the scne the object belongs to
  14502. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14503. * @returns a new TransformNode object parsed from the source provided.
  14504. */
  14505. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14506. /**
  14507. * Get all child-transformNodes of this node
  14508. * @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
  14509. * @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
  14510. * @returns an array of TransformNode
  14511. */
  14512. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14513. /**
  14514. * Releases resources associated with this transform node.
  14515. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14516. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14517. */
  14518. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14519. /**
  14520. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14521. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14522. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14523. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14524. * @returns the current mesh
  14525. */
  14526. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14527. private _syncAbsoluteScalingAndRotation;
  14528. }
  14529. }
  14530. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14531. import { Observable } from "babylonjs/Misc/observable";
  14532. import { Nullable } from "babylonjs/types";
  14533. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14536. import { Ray } from "babylonjs/Culling/ray";
  14537. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14538. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14539. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14540. /**
  14541. * Defines the types of pose enabled controllers that are supported
  14542. */
  14543. export enum PoseEnabledControllerType {
  14544. /**
  14545. * HTC Vive
  14546. */
  14547. VIVE = 0,
  14548. /**
  14549. * Oculus Rift
  14550. */
  14551. OCULUS = 1,
  14552. /**
  14553. * Windows mixed reality
  14554. */
  14555. WINDOWS = 2,
  14556. /**
  14557. * Samsung gear VR
  14558. */
  14559. GEAR_VR = 3,
  14560. /**
  14561. * Google Daydream
  14562. */
  14563. DAYDREAM = 4,
  14564. /**
  14565. * Generic
  14566. */
  14567. GENERIC = 5
  14568. }
  14569. /**
  14570. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14571. */
  14572. export interface MutableGamepadButton {
  14573. /**
  14574. * Value of the button/trigger
  14575. */
  14576. value: number;
  14577. /**
  14578. * If the button/trigger is currently touched
  14579. */
  14580. touched: boolean;
  14581. /**
  14582. * If the button/trigger is currently pressed
  14583. */
  14584. pressed: boolean;
  14585. }
  14586. /**
  14587. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14588. * @hidden
  14589. */
  14590. export interface ExtendedGamepadButton extends GamepadButton {
  14591. /**
  14592. * If the button/trigger is currently pressed
  14593. */
  14594. readonly pressed: boolean;
  14595. /**
  14596. * If the button/trigger is currently touched
  14597. */
  14598. readonly touched: boolean;
  14599. /**
  14600. * Value of the button/trigger
  14601. */
  14602. readonly value: number;
  14603. }
  14604. /** @hidden */
  14605. export interface _GamePadFactory {
  14606. /**
  14607. * Returns wether or not the current gamepad can be created for this type of controller.
  14608. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14609. * @returns true if it can be created, otherwise false
  14610. */
  14611. canCreate(gamepadInfo: any): boolean;
  14612. /**
  14613. * Creates a new instance of the Gamepad.
  14614. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14615. * @returns the new gamepad instance
  14616. */
  14617. create(gamepadInfo: any): Gamepad;
  14618. }
  14619. /**
  14620. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14621. */
  14622. export class PoseEnabledControllerHelper {
  14623. /** @hidden */
  14624. static _ControllerFactories: _GamePadFactory[];
  14625. /** @hidden */
  14626. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14627. /**
  14628. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14629. * @param vrGamepad the gamepad to initialized
  14630. * @returns a vr controller of the type the gamepad identified as
  14631. */
  14632. static InitiateController(vrGamepad: any): Gamepad;
  14633. }
  14634. /**
  14635. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14636. */
  14637. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14638. /**
  14639. * If the controller is used in a webXR session
  14640. */
  14641. isXR: boolean;
  14642. private _deviceRoomPosition;
  14643. private _deviceRoomRotationQuaternion;
  14644. /**
  14645. * The device position in babylon space
  14646. */
  14647. devicePosition: Vector3;
  14648. /**
  14649. * The device rotation in babylon space
  14650. */
  14651. deviceRotationQuaternion: Quaternion;
  14652. /**
  14653. * The scale factor of the device in babylon space
  14654. */
  14655. deviceScaleFactor: number;
  14656. /**
  14657. * (Likely devicePosition should be used instead) The device position in its room space
  14658. */
  14659. position: Vector3;
  14660. /**
  14661. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14662. */
  14663. rotationQuaternion: Quaternion;
  14664. /**
  14665. * The type of controller (Eg. Windows mixed reality)
  14666. */
  14667. controllerType: PoseEnabledControllerType;
  14668. protected _calculatedPosition: Vector3;
  14669. private _calculatedRotation;
  14670. /**
  14671. * The raw pose from the device
  14672. */
  14673. rawPose: DevicePose;
  14674. private _trackPosition;
  14675. private _maxRotationDistFromHeadset;
  14676. private _draggedRoomRotation;
  14677. /**
  14678. * @hidden
  14679. */
  14680. _disableTrackPosition(fixedPosition: Vector3): void;
  14681. /**
  14682. * Internal, the mesh attached to the controller
  14683. * @hidden
  14684. */
  14685. _mesh: Nullable<AbstractMesh>;
  14686. private _poseControlledCamera;
  14687. private _leftHandSystemQuaternion;
  14688. /**
  14689. * Internal, matrix used to convert room space to babylon space
  14690. * @hidden
  14691. */
  14692. _deviceToWorld: Matrix;
  14693. /**
  14694. * Node to be used when casting a ray from the controller
  14695. * @hidden
  14696. */
  14697. _pointingPoseNode: Nullable<TransformNode>;
  14698. /**
  14699. * Name of the child mesh that can be used to cast a ray from the controller
  14700. */
  14701. static readonly POINTING_POSE: string;
  14702. /**
  14703. * Creates a new PoseEnabledController from a gamepad
  14704. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14705. */
  14706. constructor(browserGamepad: any);
  14707. private _workingMatrix;
  14708. /**
  14709. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14710. */
  14711. update(): void;
  14712. /**
  14713. * Updates only the pose device and mesh without doing any button event checking
  14714. */
  14715. protected _updatePoseAndMesh(): void;
  14716. /**
  14717. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14718. * @param poseData raw pose fromthe device
  14719. */
  14720. updateFromDevice(poseData: DevicePose): void;
  14721. /**
  14722. * @hidden
  14723. */
  14724. _meshAttachedObservable: Observable<AbstractMesh>;
  14725. /**
  14726. * Attaches a mesh to the controller
  14727. * @param mesh the mesh to be attached
  14728. */
  14729. attachToMesh(mesh: AbstractMesh): void;
  14730. /**
  14731. * Attaches the controllers mesh to a camera
  14732. * @param camera the camera the mesh should be attached to
  14733. */
  14734. attachToPoseControlledCamera(camera: TargetCamera): void;
  14735. /**
  14736. * Disposes of the controller
  14737. */
  14738. dispose(): void;
  14739. /**
  14740. * The mesh that is attached to the controller
  14741. */
  14742. readonly mesh: Nullable<AbstractMesh>;
  14743. /**
  14744. * Gets the ray of the controller in the direction the controller is pointing
  14745. * @param length the length the resulting ray should be
  14746. * @returns a ray in the direction the controller is pointing
  14747. */
  14748. getForwardRay(length?: number): Ray;
  14749. }
  14750. }
  14751. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14752. import { Observable } from "babylonjs/Misc/observable";
  14753. import { Scene } from "babylonjs/scene";
  14754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14755. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14756. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14757. import { Nullable } from "babylonjs/types";
  14758. /**
  14759. * Defines the WebVRController object that represents controllers tracked in 3D space
  14760. */
  14761. export abstract class WebVRController extends PoseEnabledController {
  14762. /**
  14763. * Internal, the default controller model for the controller
  14764. */
  14765. protected _defaultModel: Nullable<AbstractMesh>;
  14766. /**
  14767. * Fired when the trigger state has changed
  14768. */
  14769. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14770. /**
  14771. * Fired when the main button state has changed
  14772. */
  14773. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14774. /**
  14775. * Fired when the secondary button state has changed
  14776. */
  14777. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14778. /**
  14779. * Fired when the pad state has changed
  14780. */
  14781. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14782. /**
  14783. * Fired when controllers stick values have changed
  14784. */
  14785. onPadValuesChangedObservable: Observable<StickValues>;
  14786. /**
  14787. * Array of button availible on the controller
  14788. */
  14789. protected _buttons: Array<MutableGamepadButton>;
  14790. private _onButtonStateChange;
  14791. /**
  14792. * Fired when a controller button's state has changed
  14793. * @param callback the callback containing the button that was modified
  14794. */
  14795. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14796. /**
  14797. * X and Y axis corresponding to the controllers joystick
  14798. */
  14799. pad: StickValues;
  14800. /**
  14801. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14802. */
  14803. hand: string;
  14804. /**
  14805. * The default controller model for the controller
  14806. */
  14807. readonly defaultModel: Nullable<AbstractMesh>;
  14808. /**
  14809. * Creates a new WebVRController from a gamepad
  14810. * @param vrGamepad the gamepad that the WebVRController should be created from
  14811. */
  14812. constructor(vrGamepad: any);
  14813. /**
  14814. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14815. */
  14816. update(): void;
  14817. /**
  14818. * Function to be called when a button is modified
  14819. */
  14820. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14821. /**
  14822. * Loads a mesh and attaches it to the controller
  14823. * @param scene the scene the mesh should be added to
  14824. * @param meshLoaded callback for when the mesh has been loaded
  14825. */
  14826. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14827. private _setButtonValue;
  14828. private _changes;
  14829. private _checkChanges;
  14830. /**
  14831. * Disposes of th webVRCOntroller
  14832. */
  14833. dispose(): void;
  14834. }
  14835. }
  14836. declare module "babylonjs/Lights/hemisphericLight" {
  14837. import { Nullable } from "babylonjs/types";
  14838. import { Scene } from "babylonjs/scene";
  14839. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14840. import { Color3 } from "babylonjs/Maths/math.color";
  14841. import { Effect } from "babylonjs/Materials/effect";
  14842. import { Light } from "babylonjs/Lights/light";
  14843. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14844. /**
  14845. * The HemisphericLight simulates the ambient environment light,
  14846. * so the passed direction is the light reflection direction, not the incoming direction.
  14847. */
  14848. export class HemisphericLight extends Light {
  14849. /**
  14850. * The groundColor is the light in the opposite direction to the one specified during creation.
  14851. * 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.
  14852. */
  14853. groundColor: Color3;
  14854. /**
  14855. * The light reflection direction, not the incoming direction.
  14856. */
  14857. direction: Vector3;
  14858. /**
  14859. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14860. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14861. * The HemisphericLight can't cast shadows.
  14862. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14863. * @param name The friendly name of the light
  14864. * @param direction The direction of the light reflection
  14865. * @param scene The scene the light belongs to
  14866. */
  14867. constructor(name: string, direction: Vector3, scene: Scene);
  14868. protected _buildUniformLayout(): void;
  14869. /**
  14870. * Returns the string "HemisphericLight".
  14871. * @return The class name
  14872. */
  14873. getClassName(): string;
  14874. /**
  14875. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14876. * Returns the updated direction.
  14877. * @param target The target the direction should point to
  14878. * @return The computed direction
  14879. */
  14880. setDirectionToTarget(target: Vector3): Vector3;
  14881. /**
  14882. * Returns the shadow generator associated to the light.
  14883. * @returns Always null for hemispheric lights because it does not support shadows.
  14884. */
  14885. getShadowGenerator(): Nullable<IShadowGenerator>;
  14886. /**
  14887. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14888. * @param effect The effect to update
  14889. * @param lightIndex The index of the light in the effect to update
  14890. * @returns The hemispheric light
  14891. */
  14892. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14893. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14894. /**
  14895. * Computes the world matrix of the node
  14896. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14897. * @param useWasUpdatedFlag defines a reserved property
  14898. * @returns the world matrix
  14899. */
  14900. computeWorldMatrix(): Matrix;
  14901. /**
  14902. * Returns the integer 3.
  14903. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14904. */
  14905. getTypeID(): number;
  14906. /**
  14907. * Prepares the list of defines specific to the light type.
  14908. * @param defines the list of defines
  14909. * @param lightIndex defines the index of the light for the effect
  14910. */
  14911. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14912. }
  14913. }
  14914. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14915. /** @hidden */
  14916. export var vrMultiviewToSingleviewPixelShader: {
  14917. name: string;
  14918. shader: string;
  14919. };
  14920. }
  14921. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14923. import { Scene } from "babylonjs/scene";
  14924. /**
  14925. * Renders to multiple views with a single draw call
  14926. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14927. */
  14928. export class MultiviewRenderTarget extends RenderTargetTexture {
  14929. /**
  14930. * Creates a multiview render target
  14931. * @param scene scene used with the render target
  14932. * @param size the size of the render target (used for each view)
  14933. */
  14934. constructor(scene: Scene, size?: number | {
  14935. width: number;
  14936. height: number;
  14937. } | {
  14938. ratio: number;
  14939. });
  14940. /**
  14941. * @hidden
  14942. * @param faceIndex the face index, if its a cube texture
  14943. */
  14944. _bindFrameBuffer(faceIndex?: number): void;
  14945. /**
  14946. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14947. * @returns the view count
  14948. */
  14949. getViewCount(): number;
  14950. }
  14951. }
  14952. declare module "babylonjs/Maths/math.frustum" {
  14953. import { Matrix } from "babylonjs/Maths/math.vector";
  14954. import { DeepImmutable } from "babylonjs/types";
  14955. import { Plane } from "babylonjs/Maths/math.plane";
  14956. /**
  14957. * Represents a camera frustum
  14958. */
  14959. export class Frustum {
  14960. /**
  14961. * Gets the planes representing the frustum
  14962. * @param transform matrix to be applied to the returned planes
  14963. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14964. */
  14965. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14966. /**
  14967. * Gets the near frustum plane transformed by the transform matrix
  14968. * @param transform transformation matrix to be applied to the resulting frustum plane
  14969. * @param frustumPlane the resuling frustum plane
  14970. */
  14971. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14972. /**
  14973. * Gets the far frustum plane transformed by the transform matrix
  14974. * @param transform transformation matrix to be applied to the resulting frustum plane
  14975. * @param frustumPlane the resuling frustum plane
  14976. */
  14977. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14978. /**
  14979. * Gets the left frustum plane transformed by the transform matrix
  14980. * @param transform transformation matrix to be applied to the resulting frustum plane
  14981. * @param frustumPlane the resuling frustum plane
  14982. */
  14983. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14984. /**
  14985. * Gets the right frustum plane transformed by the transform matrix
  14986. * @param transform transformation matrix to be applied to the resulting frustum plane
  14987. * @param frustumPlane the resuling frustum plane
  14988. */
  14989. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14990. /**
  14991. * Gets the top frustum plane transformed by the transform matrix
  14992. * @param transform transformation matrix to be applied to the resulting frustum plane
  14993. * @param frustumPlane the resuling frustum plane
  14994. */
  14995. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14996. /**
  14997. * Gets the bottom frustum plane transformed by the transform matrix
  14998. * @param transform transformation matrix to be applied to the resulting frustum plane
  14999. * @param frustumPlane the resuling frustum plane
  15000. */
  15001. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15002. /**
  15003. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15004. * @param transform transformation matrix to be applied to the resulting frustum planes
  15005. * @param frustumPlanes the resuling frustum planes
  15006. */
  15007. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15008. }
  15009. }
  15010. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15011. import { Camera } from "babylonjs/Cameras/camera";
  15012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15013. import { Nullable } from "babylonjs/types";
  15014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15015. import { Matrix } from "babylonjs/Maths/math.vector";
  15016. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15017. module "babylonjs/Engines/engine" {
  15018. interface Engine {
  15019. /**
  15020. * Creates a new multiview render target
  15021. * @param width defines the width of the texture
  15022. * @param height defines the height of the texture
  15023. * @returns the created multiview texture
  15024. */
  15025. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15026. /**
  15027. * Binds a multiview framebuffer to be drawn to
  15028. * @param multiviewTexture texture to bind
  15029. */
  15030. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15031. }
  15032. }
  15033. module "babylonjs/Cameras/camera" {
  15034. interface Camera {
  15035. /**
  15036. * @hidden
  15037. * 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)
  15038. */
  15039. _useMultiviewToSingleView: boolean;
  15040. /**
  15041. * @hidden
  15042. * 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)
  15043. */
  15044. _multiviewTexture: Nullable<RenderTargetTexture>;
  15045. /**
  15046. * @hidden
  15047. * ensures the multiview texture of the camera exists and has the specified width/height
  15048. * @param width height to set on the multiview texture
  15049. * @param height width to set on the multiview texture
  15050. */
  15051. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15052. }
  15053. }
  15054. module "babylonjs/scene" {
  15055. interface Scene {
  15056. /** @hidden */
  15057. _transformMatrixR: Matrix;
  15058. /** @hidden */
  15059. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15060. /** @hidden */
  15061. _createMultiviewUbo(): void;
  15062. /** @hidden */
  15063. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15064. /** @hidden */
  15065. _renderMultiviewToSingleView(camera: Camera): void;
  15066. }
  15067. }
  15068. }
  15069. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15070. import { Camera } from "babylonjs/Cameras/camera";
  15071. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15072. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15073. import "babylonjs/Engines/Extensions/engine.multiview";
  15074. /**
  15075. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15076. * This will not be used for webXR as it supports displaying texture arrays directly
  15077. */
  15078. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15079. /**
  15080. * Initializes a VRMultiviewToSingleview
  15081. * @param name name of the post process
  15082. * @param camera camera to be applied to
  15083. * @param scaleFactor scaling factor to the size of the output texture
  15084. */
  15085. constructor(name: string, camera: Camera, scaleFactor: number);
  15086. }
  15087. }
  15088. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15089. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15090. import { Nullable } from "babylonjs/types";
  15091. import { Size } from "babylonjs/Maths/math.size";
  15092. import { Observable } from "babylonjs/Misc/observable";
  15093. module "babylonjs/Engines/engine" {
  15094. interface Engine {
  15095. /** @hidden */
  15096. _vrDisplay: any;
  15097. /** @hidden */
  15098. _vrSupported: boolean;
  15099. /** @hidden */
  15100. _oldSize: Size;
  15101. /** @hidden */
  15102. _oldHardwareScaleFactor: number;
  15103. /** @hidden */
  15104. _vrExclusivePointerMode: boolean;
  15105. /** @hidden */
  15106. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15107. /** @hidden */
  15108. _onVRDisplayPointerRestricted: () => void;
  15109. /** @hidden */
  15110. _onVRDisplayPointerUnrestricted: () => void;
  15111. /** @hidden */
  15112. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15113. /** @hidden */
  15114. _onVrDisplayDisconnect: Nullable<() => void>;
  15115. /** @hidden */
  15116. _onVrDisplayPresentChange: Nullable<() => void>;
  15117. /**
  15118. * Observable signaled when VR display mode changes
  15119. */
  15120. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15121. /**
  15122. * Observable signaled when VR request present is complete
  15123. */
  15124. onVRRequestPresentComplete: Observable<boolean>;
  15125. /**
  15126. * Observable signaled when VR request present starts
  15127. */
  15128. onVRRequestPresentStart: Observable<Engine>;
  15129. /**
  15130. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15131. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15132. */
  15133. isInVRExclusivePointerMode: boolean;
  15134. /**
  15135. * Gets a boolean indicating if a webVR device was detected
  15136. * @returns true if a webVR device was detected
  15137. */
  15138. isVRDevicePresent(): boolean;
  15139. /**
  15140. * Gets the current webVR device
  15141. * @returns the current webVR device (or null)
  15142. */
  15143. getVRDevice(): any;
  15144. /**
  15145. * Initializes a webVR display and starts listening to display change events
  15146. * The onVRDisplayChangedObservable will be notified upon these changes
  15147. * @returns A promise containing a VRDisplay and if vr is supported
  15148. */
  15149. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15150. /** @hidden */
  15151. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15152. /**
  15153. * Call this function to switch to webVR mode
  15154. * Will do nothing if webVR is not supported or if there is no webVR device
  15155. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15156. */
  15157. enableVR(): void;
  15158. /** @hidden */
  15159. _onVRFullScreenTriggered(): void;
  15160. }
  15161. }
  15162. }
  15163. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15164. import { Nullable } from "babylonjs/types";
  15165. import { Observable } from "babylonjs/Misc/observable";
  15166. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15167. import { Scene } from "babylonjs/scene";
  15168. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15169. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15170. import { Node } from "babylonjs/node";
  15171. import { Ray } from "babylonjs/Culling/ray";
  15172. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15173. import "babylonjs/Engines/Extensions/engine.webVR";
  15174. /**
  15175. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15176. * IMPORTANT!! The data is right-hand data.
  15177. * @export
  15178. * @interface DevicePose
  15179. */
  15180. export interface DevicePose {
  15181. /**
  15182. * The position of the device, values in array are [x,y,z].
  15183. */
  15184. readonly position: Nullable<Float32Array>;
  15185. /**
  15186. * The linearVelocity of the device, values in array are [x,y,z].
  15187. */
  15188. readonly linearVelocity: Nullable<Float32Array>;
  15189. /**
  15190. * The linearAcceleration of the device, values in array are [x,y,z].
  15191. */
  15192. readonly linearAcceleration: Nullable<Float32Array>;
  15193. /**
  15194. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15195. */
  15196. readonly orientation: Nullable<Float32Array>;
  15197. /**
  15198. * The angularVelocity of the device, values in array are [x,y,z].
  15199. */
  15200. readonly angularVelocity: Nullable<Float32Array>;
  15201. /**
  15202. * The angularAcceleration of the device, values in array are [x,y,z].
  15203. */
  15204. readonly angularAcceleration: Nullable<Float32Array>;
  15205. }
  15206. /**
  15207. * Interface representing a pose controlled object in Babylon.
  15208. * A pose controlled object has both regular pose values as well as pose values
  15209. * from an external device such as a VR head mounted display
  15210. */
  15211. export interface PoseControlled {
  15212. /**
  15213. * The position of the object in babylon space.
  15214. */
  15215. position: Vector3;
  15216. /**
  15217. * The rotation quaternion of the object in babylon space.
  15218. */
  15219. rotationQuaternion: Quaternion;
  15220. /**
  15221. * The position of the device in babylon space.
  15222. */
  15223. devicePosition?: Vector3;
  15224. /**
  15225. * The rotation quaternion of the device in babylon space.
  15226. */
  15227. deviceRotationQuaternion: Quaternion;
  15228. /**
  15229. * The raw pose coming from the device.
  15230. */
  15231. rawPose: Nullable<DevicePose>;
  15232. /**
  15233. * The scale of the device to be used when translating from device space to babylon space.
  15234. */
  15235. deviceScaleFactor: number;
  15236. /**
  15237. * Updates the poseControlled values based on the input device pose.
  15238. * @param poseData the pose data to update the object with
  15239. */
  15240. updateFromDevice(poseData: DevicePose): void;
  15241. }
  15242. /**
  15243. * Set of options to customize the webVRCamera
  15244. */
  15245. export interface WebVROptions {
  15246. /**
  15247. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15248. */
  15249. trackPosition?: boolean;
  15250. /**
  15251. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15252. */
  15253. positionScale?: number;
  15254. /**
  15255. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15256. */
  15257. displayName?: string;
  15258. /**
  15259. * Should the native controller meshes be initialized. (default: true)
  15260. */
  15261. controllerMeshes?: boolean;
  15262. /**
  15263. * Creating a default HemiLight only on controllers. (default: true)
  15264. */
  15265. defaultLightingOnControllers?: boolean;
  15266. /**
  15267. * If you don't want to use the default VR button of the helper. (default: false)
  15268. */
  15269. useCustomVRButton?: boolean;
  15270. /**
  15271. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15272. */
  15273. customVRButton?: HTMLButtonElement;
  15274. /**
  15275. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15276. */
  15277. rayLength?: number;
  15278. /**
  15279. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15280. */
  15281. defaultHeight?: number;
  15282. /**
  15283. * If multiview should be used if availible (default: false)
  15284. */
  15285. useMultiview?: boolean;
  15286. }
  15287. /**
  15288. * This represents a WebVR camera.
  15289. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15290. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15291. */
  15292. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15293. private webVROptions;
  15294. /**
  15295. * @hidden
  15296. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15297. */
  15298. _vrDevice: any;
  15299. /**
  15300. * The rawPose of the vrDevice.
  15301. */
  15302. rawPose: Nullable<DevicePose>;
  15303. private _onVREnabled;
  15304. private _specsVersion;
  15305. private _attached;
  15306. private _frameData;
  15307. protected _descendants: Array<Node>;
  15308. private _deviceRoomPosition;
  15309. /** @hidden */
  15310. _deviceRoomRotationQuaternion: Quaternion;
  15311. private _standingMatrix;
  15312. /**
  15313. * Represents device position in babylon space.
  15314. */
  15315. devicePosition: Vector3;
  15316. /**
  15317. * Represents device rotation in babylon space.
  15318. */
  15319. deviceRotationQuaternion: Quaternion;
  15320. /**
  15321. * The scale of the device to be used when translating from device space to babylon space.
  15322. */
  15323. deviceScaleFactor: number;
  15324. private _deviceToWorld;
  15325. private _worldToDevice;
  15326. /**
  15327. * References to the webVR controllers for the vrDevice.
  15328. */
  15329. controllers: Array<WebVRController>;
  15330. /**
  15331. * Emits an event when a controller is attached.
  15332. */
  15333. onControllersAttachedObservable: Observable<WebVRController[]>;
  15334. /**
  15335. * Emits an event when a controller's mesh has been loaded;
  15336. */
  15337. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15338. /**
  15339. * Emits an event when the HMD's pose has been updated.
  15340. */
  15341. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15342. private _poseSet;
  15343. /**
  15344. * If the rig cameras be used as parent instead of this camera.
  15345. */
  15346. rigParenting: boolean;
  15347. private _lightOnControllers;
  15348. private _defaultHeight?;
  15349. /**
  15350. * Instantiates a WebVRFreeCamera.
  15351. * @param name The name of the WebVRFreeCamera
  15352. * @param position The starting anchor position for the camera
  15353. * @param scene The scene the camera belongs to
  15354. * @param webVROptions a set of customizable options for the webVRCamera
  15355. */
  15356. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15357. /**
  15358. * Gets the device distance from the ground in meters.
  15359. * @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.
  15360. */
  15361. deviceDistanceToRoomGround(): number;
  15362. /**
  15363. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15364. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15365. */
  15366. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15367. /**
  15368. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15369. * @returns A promise with a boolean set to if the standing matrix is supported.
  15370. */
  15371. useStandingMatrixAsync(): Promise<boolean>;
  15372. /**
  15373. * Disposes the camera
  15374. */
  15375. dispose(): void;
  15376. /**
  15377. * Gets a vrController by name.
  15378. * @param name The name of the controller to retreive
  15379. * @returns the controller matching the name specified or null if not found
  15380. */
  15381. getControllerByName(name: string): Nullable<WebVRController>;
  15382. private _leftController;
  15383. /**
  15384. * The controller corresponding to the users left hand.
  15385. */
  15386. readonly leftController: Nullable<WebVRController>;
  15387. private _rightController;
  15388. /**
  15389. * The controller corresponding to the users right hand.
  15390. */
  15391. readonly rightController: Nullable<WebVRController>;
  15392. /**
  15393. * Casts a ray forward from the vrCamera's gaze.
  15394. * @param length Length of the ray (default: 100)
  15395. * @returns the ray corresponding to the gaze
  15396. */
  15397. getForwardRay(length?: number): Ray;
  15398. /**
  15399. * @hidden
  15400. * Updates the camera based on device's frame data
  15401. */
  15402. _checkInputs(): void;
  15403. /**
  15404. * Updates the poseControlled values based on the input device pose.
  15405. * @param poseData Pose coming from the device
  15406. */
  15407. updateFromDevice(poseData: DevicePose): void;
  15408. private _htmlElementAttached;
  15409. private _detachIfAttached;
  15410. /**
  15411. * WebVR's attach control will start broadcasting frames to the device.
  15412. * Note that in certain browsers (chrome for example) this function must be called
  15413. * within a user-interaction callback. Example:
  15414. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15415. *
  15416. * @param element html element to attach the vrDevice to
  15417. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15418. */
  15419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15420. /**
  15421. * Detaches the camera from the html element and disables VR
  15422. *
  15423. * @param element html element to detach from
  15424. */
  15425. detachControl(element: HTMLElement): void;
  15426. /**
  15427. * @returns the name of this class
  15428. */
  15429. getClassName(): string;
  15430. /**
  15431. * Calls resetPose on the vrDisplay
  15432. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15433. */
  15434. resetToCurrentRotation(): void;
  15435. /**
  15436. * @hidden
  15437. * Updates the rig cameras (left and right eye)
  15438. */
  15439. _updateRigCameras(): void;
  15440. private _workingVector;
  15441. private _oneVector;
  15442. private _workingMatrix;
  15443. private updateCacheCalled;
  15444. private _correctPositionIfNotTrackPosition;
  15445. /**
  15446. * @hidden
  15447. * Updates the cached values of the camera
  15448. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15449. */
  15450. _updateCache(ignoreParentClass?: boolean): void;
  15451. /**
  15452. * @hidden
  15453. * Get current device position in babylon world
  15454. */
  15455. _computeDevicePosition(): void;
  15456. /**
  15457. * Updates the current device position and rotation in the babylon world
  15458. */
  15459. update(): void;
  15460. /**
  15461. * @hidden
  15462. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15463. * @returns an identity matrix
  15464. */
  15465. _getViewMatrix(): Matrix;
  15466. private _tmpMatrix;
  15467. /**
  15468. * This function is called by the two RIG cameras.
  15469. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15470. * @hidden
  15471. */
  15472. _getWebVRViewMatrix(): Matrix;
  15473. /** @hidden */
  15474. _getWebVRProjectionMatrix(): Matrix;
  15475. private _onGamepadConnectedObserver;
  15476. private _onGamepadDisconnectedObserver;
  15477. private _updateCacheWhenTrackingDisabledObserver;
  15478. /**
  15479. * Initializes the controllers and their meshes
  15480. */
  15481. initControllers(): void;
  15482. }
  15483. }
  15484. declare module "babylonjs/PostProcesses/postProcess" {
  15485. import { Nullable } from "babylonjs/types";
  15486. import { SmartArray } from "babylonjs/Misc/smartArray";
  15487. import { Observable } from "babylonjs/Misc/observable";
  15488. import { Vector2 } from "babylonjs/Maths/math.vector";
  15489. import { Camera } from "babylonjs/Cameras/camera";
  15490. import { Effect } from "babylonjs/Materials/effect";
  15491. import "babylonjs/Shaders/postprocess.vertex";
  15492. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15493. import { Engine } from "babylonjs/Engines/engine";
  15494. import { Color4 } from "babylonjs/Maths/math.color";
  15495. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15497. /**
  15498. * Size options for a post process
  15499. */
  15500. export type PostProcessOptions = {
  15501. width: number;
  15502. height: number;
  15503. };
  15504. /**
  15505. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15506. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15507. */
  15508. export class PostProcess {
  15509. /** Name of the PostProcess. */
  15510. name: string;
  15511. /**
  15512. * Gets or sets the unique id of the post process
  15513. */
  15514. uniqueId: number;
  15515. /**
  15516. * Width of the texture to apply the post process on
  15517. */
  15518. width: number;
  15519. /**
  15520. * Height of the texture to apply the post process on
  15521. */
  15522. height: number;
  15523. /**
  15524. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15525. * @hidden
  15526. */
  15527. _outputTexture: Nullable<InternalTexture>;
  15528. /**
  15529. * Sampling mode used by the shader
  15530. * See https://doc.babylonjs.com/classes/3.1/texture
  15531. */
  15532. renderTargetSamplingMode: number;
  15533. /**
  15534. * Clear color to use when screen clearing
  15535. */
  15536. clearColor: Color4;
  15537. /**
  15538. * If the buffer needs to be cleared before applying the post process. (default: true)
  15539. * Should be set to false if shader will overwrite all previous pixels.
  15540. */
  15541. autoClear: boolean;
  15542. /**
  15543. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15544. */
  15545. alphaMode: number;
  15546. /**
  15547. * Sets the setAlphaBlendConstants of the babylon engine
  15548. */
  15549. alphaConstants: Color4;
  15550. /**
  15551. * Animations to be used for the post processing
  15552. */
  15553. animations: import("babylonjs/Animations/animation").Animation[];
  15554. /**
  15555. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15556. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15557. */
  15558. enablePixelPerfectMode: boolean;
  15559. /**
  15560. * Force the postprocess to be applied without taking in account viewport
  15561. */
  15562. forceFullscreenViewport: boolean;
  15563. /**
  15564. * List of inspectable custom properties (used by the Inspector)
  15565. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15566. */
  15567. inspectableCustomProperties: IInspectable[];
  15568. /**
  15569. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15570. *
  15571. * | Value | Type | Description |
  15572. * | ----- | ----------------------------------- | ----------- |
  15573. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15574. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15575. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15576. *
  15577. */
  15578. scaleMode: number;
  15579. /**
  15580. * Force textures to be a power of two (default: false)
  15581. */
  15582. alwaysForcePOT: boolean;
  15583. private _samples;
  15584. /**
  15585. * Number of sample textures (default: 1)
  15586. */
  15587. samples: number;
  15588. /**
  15589. * Modify the scale of the post process to be the same as the viewport (default: false)
  15590. */
  15591. adaptScaleToCurrentViewport: boolean;
  15592. private _camera;
  15593. private _scene;
  15594. private _engine;
  15595. private _options;
  15596. private _reusable;
  15597. private _textureType;
  15598. /**
  15599. * Smart array of input and output textures for the post process.
  15600. * @hidden
  15601. */
  15602. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15603. /**
  15604. * The index in _textures that corresponds to the output texture.
  15605. * @hidden
  15606. */
  15607. _currentRenderTextureInd: number;
  15608. private _effect;
  15609. private _samplers;
  15610. private _fragmentUrl;
  15611. private _vertexUrl;
  15612. private _parameters;
  15613. private _scaleRatio;
  15614. protected _indexParameters: any;
  15615. private _shareOutputWithPostProcess;
  15616. private _texelSize;
  15617. private _forcedOutputTexture;
  15618. /**
  15619. * Returns the fragment url or shader name used in the post process.
  15620. * @returns the fragment url or name in the shader store.
  15621. */
  15622. getEffectName(): string;
  15623. /**
  15624. * An event triggered when the postprocess is activated.
  15625. */
  15626. onActivateObservable: Observable<Camera>;
  15627. private _onActivateObserver;
  15628. /**
  15629. * A function that is added to the onActivateObservable
  15630. */
  15631. onActivate: Nullable<(camera: Camera) => void>;
  15632. /**
  15633. * An event triggered when the postprocess changes its size.
  15634. */
  15635. onSizeChangedObservable: Observable<PostProcess>;
  15636. private _onSizeChangedObserver;
  15637. /**
  15638. * A function that is added to the onSizeChangedObservable
  15639. */
  15640. onSizeChanged: (postProcess: PostProcess) => void;
  15641. /**
  15642. * An event triggered when the postprocess applies its effect.
  15643. */
  15644. onApplyObservable: Observable<Effect>;
  15645. private _onApplyObserver;
  15646. /**
  15647. * A function that is added to the onApplyObservable
  15648. */
  15649. onApply: (effect: Effect) => void;
  15650. /**
  15651. * An event triggered before rendering the postprocess
  15652. */
  15653. onBeforeRenderObservable: Observable<Effect>;
  15654. private _onBeforeRenderObserver;
  15655. /**
  15656. * A function that is added to the onBeforeRenderObservable
  15657. */
  15658. onBeforeRender: (effect: Effect) => void;
  15659. /**
  15660. * An event triggered after rendering the postprocess
  15661. */
  15662. onAfterRenderObservable: Observable<Effect>;
  15663. private _onAfterRenderObserver;
  15664. /**
  15665. * A function that is added to the onAfterRenderObservable
  15666. */
  15667. onAfterRender: (efect: Effect) => void;
  15668. /**
  15669. * 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
  15670. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15671. */
  15672. inputTexture: InternalTexture;
  15673. /**
  15674. * Gets the camera which post process is applied to.
  15675. * @returns The camera the post process is applied to.
  15676. */
  15677. getCamera(): Camera;
  15678. /**
  15679. * Gets the texel size of the postprocess.
  15680. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15681. */
  15682. readonly texelSize: Vector2;
  15683. /**
  15684. * Creates a new instance PostProcess
  15685. * @param name The name of the PostProcess.
  15686. * @param fragmentUrl The url of the fragment shader to be used.
  15687. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15688. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15689. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15690. * @param camera The camera to apply the render pass to.
  15691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15692. * @param engine The engine which the post process will be applied. (default: current engine)
  15693. * @param reusable If the post process can be reused on the same frame. (default: false)
  15694. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15695. * @param textureType Type of textures used when performing the post process. (default: 0)
  15696. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15697. * @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
  15698. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15699. */
  15700. constructor(
  15701. /** Name of the PostProcess. */
  15702. 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);
  15703. /**
  15704. * Gets a string idenfifying the name of the class
  15705. * @returns "PostProcess" string
  15706. */
  15707. getClassName(): string;
  15708. /**
  15709. * Gets the engine which this post process belongs to.
  15710. * @returns The engine the post process was enabled with.
  15711. */
  15712. getEngine(): Engine;
  15713. /**
  15714. * The effect that is created when initializing the post process.
  15715. * @returns The created effect corresponding the the postprocess.
  15716. */
  15717. getEffect(): Effect;
  15718. /**
  15719. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15720. * @param postProcess The post process to share the output with.
  15721. * @returns This post process.
  15722. */
  15723. shareOutputWith(postProcess: PostProcess): PostProcess;
  15724. /**
  15725. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15726. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15727. */
  15728. useOwnOutput(): void;
  15729. /**
  15730. * Updates the effect with the current post process compile time values and recompiles the shader.
  15731. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15732. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15733. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15734. * @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
  15735. * @param onCompiled Called when the shader has been compiled.
  15736. * @param onError Called if there is an error when compiling a shader.
  15737. */
  15738. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15739. /**
  15740. * The post process is reusable if it can be used multiple times within one frame.
  15741. * @returns If the post process is reusable
  15742. */
  15743. isReusable(): boolean;
  15744. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15745. markTextureDirty(): void;
  15746. /**
  15747. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15748. * 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.
  15749. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15750. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15751. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15752. * @returns The target texture that was bound to be written to.
  15753. */
  15754. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15755. /**
  15756. * If the post process is supported.
  15757. */
  15758. readonly isSupported: boolean;
  15759. /**
  15760. * The aspect ratio of the output texture.
  15761. */
  15762. readonly aspectRatio: number;
  15763. /**
  15764. * Get a value indicating if the post-process is ready to be used
  15765. * @returns true if the post-process is ready (shader is compiled)
  15766. */
  15767. isReady(): boolean;
  15768. /**
  15769. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15770. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15771. */
  15772. apply(): Nullable<Effect>;
  15773. private _disposeTextures;
  15774. /**
  15775. * Disposes the post process.
  15776. * @param camera The camera to dispose the post process on.
  15777. */
  15778. dispose(camera?: Camera): void;
  15779. }
  15780. }
  15781. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15782. /** @hidden */
  15783. export var kernelBlurVaryingDeclaration: {
  15784. name: string;
  15785. shader: string;
  15786. };
  15787. }
  15788. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15789. /** @hidden */
  15790. export var kernelBlurFragment: {
  15791. name: string;
  15792. shader: string;
  15793. };
  15794. }
  15795. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15796. /** @hidden */
  15797. export var kernelBlurFragment2: {
  15798. name: string;
  15799. shader: string;
  15800. };
  15801. }
  15802. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15803. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15804. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15805. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15806. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15807. /** @hidden */
  15808. export var kernelBlurPixelShader: {
  15809. name: string;
  15810. shader: string;
  15811. };
  15812. }
  15813. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15814. /** @hidden */
  15815. export var kernelBlurVertex: {
  15816. name: string;
  15817. shader: string;
  15818. };
  15819. }
  15820. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15821. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15822. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15823. /** @hidden */
  15824. export var kernelBlurVertexShader: {
  15825. name: string;
  15826. shader: string;
  15827. };
  15828. }
  15829. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15830. import { Vector2 } from "babylonjs/Maths/math.vector";
  15831. import { Nullable } from "babylonjs/types";
  15832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15833. import { Camera } from "babylonjs/Cameras/camera";
  15834. import { Effect } from "babylonjs/Materials/effect";
  15835. import { Engine } from "babylonjs/Engines/engine";
  15836. import "babylonjs/Shaders/kernelBlur.fragment";
  15837. import "babylonjs/Shaders/kernelBlur.vertex";
  15838. /**
  15839. * The Blur Post Process which blurs an image based on a kernel and direction.
  15840. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15841. */
  15842. export class BlurPostProcess extends PostProcess {
  15843. /** The direction in which to blur the image. */
  15844. direction: Vector2;
  15845. private blockCompilation;
  15846. protected _kernel: number;
  15847. protected _idealKernel: number;
  15848. protected _packedFloat: boolean;
  15849. private _staticDefines;
  15850. /**
  15851. * Sets the length in pixels of the blur sample region
  15852. */
  15853. /**
  15854. * Gets the length in pixels of the blur sample region
  15855. */
  15856. kernel: number;
  15857. /**
  15858. * Sets wether or not the blur needs to unpack/repack floats
  15859. */
  15860. /**
  15861. * Gets wether or not the blur is unpacking/repacking floats
  15862. */
  15863. packedFloat: boolean;
  15864. /**
  15865. * Creates a new instance BlurPostProcess
  15866. * @param name The name of the effect.
  15867. * @param direction The direction in which to blur the image.
  15868. * @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.
  15869. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15870. * @param camera The camera to apply the render pass to.
  15871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15872. * @param engine The engine which the post process will be applied. (default: current engine)
  15873. * @param reusable If the post process can be reused on the same frame. (default: false)
  15874. * @param textureType Type of textures used when performing the post process. (default: 0)
  15875. * @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)
  15876. */
  15877. constructor(name: string,
  15878. /** The direction in which to blur the image. */
  15879. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15880. /**
  15881. * Updates the effect with the current post process compile time values and recompiles the shader.
  15882. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15883. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15884. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15885. * @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
  15886. * @param onCompiled Called when the shader has been compiled.
  15887. * @param onError Called if there is an error when compiling a shader.
  15888. */
  15889. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15890. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15891. /**
  15892. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15893. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15894. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15895. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15896. * The gaps between physical kernels are compensated for in the weighting of the samples
  15897. * @param idealKernel Ideal blur kernel.
  15898. * @return Nearest best kernel.
  15899. */
  15900. protected _nearestBestKernel(idealKernel: number): number;
  15901. /**
  15902. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15903. * @param x The point on the Gaussian distribution to sample.
  15904. * @return the value of the Gaussian function at x.
  15905. */
  15906. protected _gaussianWeight(x: number): number;
  15907. /**
  15908. * Generates a string that can be used as a floating point number in GLSL.
  15909. * @param x Value to print.
  15910. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15911. * @return GLSL float string.
  15912. */
  15913. protected _glslFloat(x: number, decimalFigures?: number): string;
  15914. }
  15915. }
  15916. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15917. import { Scene } from "babylonjs/scene";
  15918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15919. import { Plane } from "babylonjs/Maths/math.plane";
  15920. /**
  15921. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15922. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15923. * You can then easily use it as a reflectionTexture on a flat surface.
  15924. * In case the surface is not a plane, please consider relying on reflection probes.
  15925. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15926. */
  15927. export class MirrorTexture extends RenderTargetTexture {
  15928. private scene;
  15929. /**
  15930. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15931. * 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.
  15932. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15933. */
  15934. mirrorPlane: Plane;
  15935. /**
  15936. * Define the blur ratio used to blur the reflection if needed.
  15937. */
  15938. blurRatio: number;
  15939. /**
  15940. * Define the adaptive blur kernel used to blur the reflection if needed.
  15941. * This will autocompute the closest best match for the `blurKernel`
  15942. */
  15943. adaptiveBlurKernel: number;
  15944. /**
  15945. * Define the blur kernel used to blur the reflection if needed.
  15946. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15947. */
  15948. blurKernel: number;
  15949. /**
  15950. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15951. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15952. */
  15953. blurKernelX: number;
  15954. /**
  15955. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15956. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15957. */
  15958. blurKernelY: number;
  15959. private _autoComputeBlurKernel;
  15960. protected _onRatioRescale(): void;
  15961. private _updateGammaSpace;
  15962. private _imageProcessingConfigChangeObserver;
  15963. private _transformMatrix;
  15964. private _mirrorMatrix;
  15965. private _savedViewMatrix;
  15966. private _blurX;
  15967. private _blurY;
  15968. private _adaptiveBlurKernel;
  15969. private _blurKernelX;
  15970. private _blurKernelY;
  15971. private _blurRatio;
  15972. /**
  15973. * Instantiates a Mirror Texture.
  15974. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15975. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15976. * You can then easily use it as a reflectionTexture on a flat surface.
  15977. * In case the surface is not a plane, please consider relying on reflection probes.
  15978. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15979. * @param name
  15980. * @param size
  15981. * @param scene
  15982. * @param generateMipMaps
  15983. * @param type
  15984. * @param samplingMode
  15985. * @param generateDepthBuffer
  15986. */
  15987. constructor(name: string, size: number | {
  15988. width: number;
  15989. height: number;
  15990. } | {
  15991. ratio: number;
  15992. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15993. private _preparePostProcesses;
  15994. /**
  15995. * Clone the mirror texture.
  15996. * @returns the cloned texture
  15997. */
  15998. clone(): MirrorTexture;
  15999. /**
  16000. * Serialize the texture to a JSON representation you could use in Parse later on
  16001. * @returns the serialized JSON representation
  16002. */
  16003. serialize(): any;
  16004. /**
  16005. * Dispose the texture and release its associated resources.
  16006. */
  16007. dispose(): void;
  16008. }
  16009. }
  16010. declare module "babylonjs/Materials/Textures/texture" {
  16011. import { Observable } from "babylonjs/Misc/observable";
  16012. import { Nullable } from "babylonjs/types";
  16013. import { Matrix } from "babylonjs/Maths/math.vector";
  16014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16015. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16016. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16017. import { Scene } from "babylonjs/scene";
  16018. /**
  16019. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16020. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16021. */
  16022. export class Texture extends BaseTexture {
  16023. /**
  16024. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16025. */
  16026. static SerializeBuffers: boolean;
  16027. /** @hidden */
  16028. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16029. /** @hidden */
  16030. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16031. /** @hidden */
  16032. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16033. /** nearest is mag = nearest and min = nearest and mip = linear */
  16034. static readonly NEAREST_SAMPLINGMODE: number;
  16035. /** nearest is mag = nearest and min = nearest and mip = linear */
  16036. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16038. static readonly BILINEAR_SAMPLINGMODE: number;
  16039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16040. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16041. /** Trilinear is mag = linear and min = linear and mip = linear */
  16042. static readonly TRILINEAR_SAMPLINGMODE: number;
  16043. /** Trilinear is mag = linear and min = linear and mip = linear */
  16044. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16045. /** mag = nearest and min = nearest and mip = nearest */
  16046. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16047. /** mag = nearest and min = linear and mip = nearest */
  16048. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16049. /** mag = nearest and min = linear and mip = linear */
  16050. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16051. /** mag = nearest and min = linear and mip = none */
  16052. static readonly NEAREST_LINEAR: number;
  16053. /** mag = nearest and min = nearest and mip = none */
  16054. static readonly NEAREST_NEAREST: number;
  16055. /** mag = linear and min = nearest and mip = nearest */
  16056. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16057. /** mag = linear and min = nearest and mip = linear */
  16058. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16059. /** mag = linear and min = linear and mip = none */
  16060. static readonly LINEAR_LINEAR: number;
  16061. /** mag = linear and min = nearest and mip = none */
  16062. static readonly LINEAR_NEAREST: number;
  16063. /** Explicit coordinates mode */
  16064. static readonly EXPLICIT_MODE: number;
  16065. /** Spherical coordinates mode */
  16066. static readonly SPHERICAL_MODE: number;
  16067. /** Planar coordinates mode */
  16068. static readonly PLANAR_MODE: number;
  16069. /** Cubic coordinates mode */
  16070. static readonly CUBIC_MODE: number;
  16071. /** Projection coordinates mode */
  16072. static readonly PROJECTION_MODE: number;
  16073. /** Inverse Cubic coordinates mode */
  16074. static readonly SKYBOX_MODE: number;
  16075. /** Inverse Cubic coordinates mode */
  16076. static readonly INVCUBIC_MODE: number;
  16077. /** Equirectangular coordinates mode */
  16078. static readonly EQUIRECTANGULAR_MODE: number;
  16079. /** Equirectangular Fixed coordinates mode */
  16080. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16081. /** Equirectangular Fixed Mirrored coordinates mode */
  16082. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16083. /** Texture is not repeating outside of 0..1 UVs */
  16084. static readonly CLAMP_ADDRESSMODE: number;
  16085. /** Texture is repeating outside of 0..1 UVs */
  16086. static readonly WRAP_ADDRESSMODE: number;
  16087. /** Texture is repeating and mirrored */
  16088. static readonly MIRROR_ADDRESSMODE: number;
  16089. /**
  16090. * 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
  16091. */
  16092. static UseSerializedUrlIfAny: boolean;
  16093. /**
  16094. * Define the url of the texture.
  16095. */
  16096. url: Nullable<string>;
  16097. /**
  16098. * Define an offset on the texture to offset the u coordinates of the UVs
  16099. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16100. */
  16101. uOffset: number;
  16102. /**
  16103. * Define an offset on the texture to offset the v coordinates of the UVs
  16104. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16105. */
  16106. vOffset: number;
  16107. /**
  16108. * Define an offset on the texture to scale the u coordinates of the UVs
  16109. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16110. */
  16111. uScale: number;
  16112. /**
  16113. * Define an offset on the texture to scale the v coordinates of the UVs
  16114. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16115. */
  16116. vScale: number;
  16117. /**
  16118. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16119. * @see http://doc.babylonjs.com/how_to/more_materials
  16120. */
  16121. uAng: number;
  16122. /**
  16123. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16124. * @see http://doc.babylonjs.com/how_to/more_materials
  16125. */
  16126. vAng: number;
  16127. /**
  16128. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16129. * @see http://doc.babylonjs.com/how_to/more_materials
  16130. */
  16131. wAng: number;
  16132. /**
  16133. * Defines the center of rotation (U)
  16134. */
  16135. uRotationCenter: number;
  16136. /**
  16137. * Defines the center of rotation (V)
  16138. */
  16139. vRotationCenter: number;
  16140. /**
  16141. * Defines the center of rotation (W)
  16142. */
  16143. wRotationCenter: number;
  16144. /**
  16145. * Are mip maps generated for this texture or not.
  16146. */
  16147. readonly noMipmap: boolean;
  16148. /**
  16149. * List of inspectable custom properties (used by the Inspector)
  16150. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16151. */
  16152. inspectableCustomProperties: Nullable<IInspectable[]>;
  16153. private _noMipmap;
  16154. /** @hidden */
  16155. _invertY: boolean;
  16156. private _rowGenerationMatrix;
  16157. private _cachedTextureMatrix;
  16158. private _projectionModeMatrix;
  16159. private _t0;
  16160. private _t1;
  16161. private _t2;
  16162. private _cachedUOffset;
  16163. private _cachedVOffset;
  16164. private _cachedUScale;
  16165. private _cachedVScale;
  16166. private _cachedUAng;
  16167. private _cachedVAng;
  16168. private _cachedWAng;
  16169. private _cachedProjectionMatrixId;
  16170. private _cachedCoordinatesMode;
  16171. /** @hidden */
  16172. protected _initialSamplingMode: number;
  16173. /** @hidden */
  16174. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16175. private _deleteBuffer;
  16176. protected _format: Nullable<number>;
  16177. private _delayedOnLoad;
  16178. private _delayedOnError;
  16179. private _mimeType?;
  16180. /**
  16181. * Observable triggered once the texture has been loaded.
  16182. */
  16183. onLoadObservable: Observable<Texture>;
  16184. protected _isBlocking: boolean;
  16185. /**
  16186. * Is the texture preventing material to render while loading.
  16187. * If false, a default texture will be used instead of the loading one during the preparation step.
  16188. */
  16189. isBlocking: boolean;
  16190. /**
  16191. * Get the current sampling mode associated with the texture.
  16192. */
  16193. readonly samplingMode: number;
  16194. /**
  16195. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16196. */
  16197. readonly invertY: boolean;
  16198. /**
  16199. * Instantiates a new texture.
  16200. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16201. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16202. * @param url defines the url of the picture to load as a texture
  16203. * @param scene defines the scene or engine the texture will belong to
  16204. * @param noMipmap defines if the texture will require mip maps or not
  16205. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16206. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16207. * @param onLoad defines a callback triggered when the texture has been loaded
  16208. * @param onError defines a callback triggered when an error occurred during the loading session
  16209. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16210. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16211. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16212. * @param mimeType defines an optional mime type information
  16213. */
  16214. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16215. /**
  16216. * Update the url (and optional buffer) of this texture if url was null during construction.
  16217. * @param url the url of the texture
  16218. * @param buffer the buffer of the texture (defaults to null)
  16219. * @param onLoad callback called when the texture is loaded (defaults to null)
  16220. */
  16221. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16222. /**
  16223. * Finish the loading sequence of a texture flagged as delayed load.
  16224. * @hidden
  16225. */
  16226. delayLoad(): void;
  16227. private _prepareRowForTextureGeneration;
  16228. /**
  16229. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16230. * @returns the transform matrix of the texture.
  16231. */
  16232. getTextureMatrix(): Matrix;
  16233. /**
  16234. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16235. * @returns The reflection texture transform
  16236. */
  16237. getReflectionTextureMatrix(): Matrix;
  16238. /**
  16239. * Clones the texture.
  16240. * @returns the cloned texture
  16241. */
  16242. clone(): Texture;
  16243. /**
  16244. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16245. * @returns The JSON representation of the texture
  16246. */
  16247. serialize(): any;
  16248. /**
  16249. * Get the current class name of the texture useful for serialization or dynamic coding.
  16250. * @returns "Texture"
  16251. */
  16252. getClassName(): string;
  16253. /**
  16254. * Dispose the texture and release its associated resources.
  16255. */
  16256. dispose(): void;
  16257. /**
  16258. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16259. * @param parsedTexture Define the JSON representation of the texture
  16260. * @param scene Define the scene the parsed texture should be instantiated in
  16261. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16262. * @returns The parsed texture if successful
  16263. */
  16264. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16265. /**
  16266. * Creates a texture from its base 64 representation.
  16267. * @param data Define the base64 payload without the data: prefix
  16268. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16269. * @param scene Define the scene the texture should belong to
  16270. * @param noMipmap Forces the texture to not create mip map information if true
  16271. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16272. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16273. * @param onLoad define a callback triggered when the texture has been loaded
  16274. * @param onError define a callback triggered when an error occurred during the loading session
  16275. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16276. * @returns the created texture
  16277. */
  16278. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16279. /**
  16280. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16281. * @param data Define the base64 payload without the data: prefix
  16282. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16283. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16284. * @param scene Define the scene the texture should belong to
  16285. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16286. * @param noMipmap Forces the texture to not create mip map information if true
  16287. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16288. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16289. * @param onLoad define a callback triggered when the texture has been loaded
  16290. * @param onError define a callback triggered when an error occurred during the loading session
  16291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16292. * @returns the created texture
  16293. */
  16294. 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;
  16295. }
  16296. }
  16297. declare module "babylonjs/PostProcesses/postProcessManager" {
  16298. import { Nullable } from "babylonjs/types";
  16299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16300. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16301. import { Scene } from "babylonjs/scene";
  16302. /**
  16303. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16304. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16305. */
  16306. export class PostProcessManager {
  16307. private _scene;
  16308. private _indexBuffer;
  16309. private _vertexBuffers;
  16310. /**
  16311. * Creates a new instance PostProcess
  16312. * @param scene The scene that the post process is associated with.
  16313. */
  16314. constructor(scene: Scene);
  16315. private _prepareBuffers;
  16316. private _buildIndexBuffer;
  16317. /**
  16318. * Rebuilds the vertex buffers of the manager.
  16319. * @hidden
  16320. */
  16321. _rebuild(): void;
  16322. /**
  16323. * Prepares a frame to be run through a post process.
  16324. * @param sourceTexture The input texture to the post procesess. (default: null)
  16325. * @param postProcesses An array of post processes to be run. (default: null)
  16326. * @returns True if the post processes were able to be run.
  16327. * @hidden
  16328. */
  16329. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16330. /**
  16331. * Manually render a set of post processes to a texture.
  16332. * @param postProcesses An array of post processes to be run.
  16333. * @param targetTexture The target texture to render to.
  16334. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16335. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16336. * @param lodLevel defines which lod of the texture to render to
  16337. */
  16338. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16339. /**
  16340. * Finalize the result of the output of the postprocesses.
  16341. * @param doNotPresent If true the result will not be displayed to the screen.
  16342. * @param targetTexture The target texture to render to.
  16343. * @param faceIndex The index of the face to bind the target texture to.
  16344. * @param postProcesses The array of post processes to render.
  16345. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16346. * @hidden
  16347. */
  16348. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16349. /**
  16350. * Disposes of the post process manager.
  16351. */
  16352. dispose(): void;
  16353. }
  16354. }
  16355. declare module "babylonjs/Misc/gradients" {
  16356. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16357. /** Interface used by value gradients (color, factor, ...) */
  16358. export interface IValueGradient {
  16359. /**
  16360. * Gets or sets the gradient value (between 0 and 1)
  16361. */
  16362. gradient: number;
  16363. }
  16364. /** Class used to store color4 gradient */
  16365. export class ColorGradient implements IValueGradient {
  16366. /**
  16367. * Gets or sets the gradient value (between 0 and 1)
  16368. */
  16369. gradient: number;
  16370. /**
  16371. * Gets or sets first associated color
  16372. */
  16373. color1: Color4;
  16374. /**
  16375. * Gets or sets second associated color
  16376. */
  16377. color2?: Color4;
  16378. /**
  16379. * Will get a color picked randomly between color1 and color2.
  16380. * If color2 is undefined then color1 will be used
  16381. * @param result defines the target Color4 to store the result in
  16382. */
  16383. getColorToRef(result: Color4): void;
  16384. }
  16385. /** Class used to store color 3 gradient */
  16386. export class Color3Gradient implements IValueGradient {
  16387. /**
  16388. * Gets or sets the gradient value (between 0 and 1)
  16389. */
  16390. gradient: number;
  16391. /**
  16392. * Gets or sets the associated color
  16393. */
  16394. color: Color3;
  16395. }
  16396. /** Class used to store factor gradient */
  16397. export class FactorGradient implements IValueGradient {
  16398. /**
  16399. * Gets or sets the gradient value (between 0 and 1)
  16400. */
  16401. gradient: number;
  16402. /**
  16403. * Gets or sets first associated factor
  16404. */
  16405. factor1: number;
  16406. /**
  16407. * Gets or sets second associated factor
  16408. */
  16409. factor2?: number;
  16410. /**
  16411. * Will get a number picked randomly between factor1 and factor2.
  16412. * If factor2 is undefined then factor1 will be used
  16413. * @returns the picked number
  16414. */
  16415. getFactor(): number;
  16416. }
  16417. /**
  16418. * Helper used to simplify some generic gradient tasks
  16419. */
  16420. export class GradientHelper {
  16421. /**
  16422. * Gets the current gradient from an array of IValueGradient
  16423. * @param ratio defines the current ratio to get
  16424. * @param gradients defines the array of IValueGradient
  16425. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16426. */
  16427. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16428. }
  16429. }
  16430. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16432. import { Nullable } from "babylonjs/types";
  16433. module "babylonjs/Engines/thinEngine" {
  16434. interface ThinEngine {
  16435. /**
  16436. * Creates a dynamic texture
  16437. * @param width defines the width of the texture
  16438. * @param height defines the height of the texture
  16439. * @param generateMipMaps defines if the engine should generate the mip levels
  16440. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16441. * @returns the dynamic texture inside an InternalTexture
  16442. */
  16443. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16444. /**
  16445. * Update the content of a dynamic texture
  16446. * @param texture defines the texture to update
  16447. * @param canvas defines the canvas containing the source
  16448. * @param invertY defines if data must be stored with Y axis inverted
  16449. * @param premulAlpha defines if alpha is stored as premultiplied
  16450. * @param format defines the format of the data
  16451. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16452. */
  16453. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16454. }
  16455. }
  16456. }
  16457. declare module "babylonjs/Misc/canvasGenerator" {
  16458. /**
  16459. * Helper class used to generate a canvas to manipulate images
  16460. */
  16461. export class CanvasGenerator {
  16462. /**
  16463. * Create a new canvas (or offscreen canvas depending on the context)
  16464. * @param width defines the expected width
  16465. * @param height defines the expected height
  16466. * @return a new canvas or offscreen canvas
  16467. */
  16468. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16469. }
  16470. }
  16471. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16472. import { Scene } from "babylonjs/scene";
  16473. import { Texture } from "babylonjs/Materials/Textures/texture";
  16474. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16475. /**
  16476. * A class extending Texture allowing drawing on a texture
  16477. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16478. */
  16479. export class DynamicTexture extends Texture {
  16480. private _generateMipMaps;
  16481. private _canvas;
  16482. private _context;
  16483. private _engine;
  16484. /**
  16485. * Creates a DynamicTexture
  16486. * @param name defines the name of the texture
  16487. * @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
  16488. * @param scene defines the scene where you want the texture
  16489. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16490. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16491. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16492. */
  16493. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16494. /**
  16495. * Get the current class name of the texture useful for serialization or dynamic coding.
  16496. * @returns "DynamicTexture"
  16497. */
  16498. getClassName(): string;
  16499. /**
  16500. * Gets the current state of canRescale
  16501. */
  16502. readonly canRescale: boolean;
  16503. private _recreate;
  16504. /**
  16505. * Scales the texture
  16506. * @param ratio the scale factor to apply to both width and height
  16507. */
  16508. scale(ratio: number): void;
  16509. /**
  16510. * Resizes the texture
  16511. * @param width the new width
  16512. * @param height the new height
  16513. */
  16514. scaleTo(width: number, height: number): void;
  16515. /**
  16516. * Gets the context of the canvas used by the texture
  16517. * @returns the canvas context of the dynamic texture
  16518. */
  16519. getContext(): CanvasRenderingContext2D;
  16520. /**
  16521. * Clears the texture
  16522. */
  16523. clear(): void;
  16524. /**
  16525. * Updates the texture
  16526. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16527. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16528. */
  16529. update(invertY?: boolean, premulAlpha?: boolean): void;
  16530. /**
  16531. * Draws text onto the texture
  16532. * @param text defines the text to be drawn
  16533. * @param x defines the placement of the text from the left
  16534. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16535. * @param font defines the font to be used with font-style, font-size, font-name
  16536. * @param color defines the color used for the text
  16537. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16539. * @param update defines whether texture is immediately update (default is true)
  16540. */
  16541. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16542. /**
  16543. * Clones the texture
  16544. * @returns the clone of the texture.
  16545. */
  16546. clone(): DynamicTexture;
  16547. /**
  16548. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16549. * @returns a serialized dynamic texture object
  16550. */
  16551. serialize(): any;
  16552. /** @hidden */
  16553. _rebuild(): void;
  16554. }
  16555. }
  16556. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16557. import { Scene } from "babylonjs/scene";
  16558. import { ISceneComponent } from "babylonjs/sceneComponent";
  16559. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16560. module "babylonjs/abstractScene" {
  16561. interface AbstractScene {
  16562. /**
  16563. * The list of procedural textures added to the scene
  16564. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16565. */
  16566. proceduralTextures: Array<ProceduralTexture>;
  16567. }
  16568. }
  16569. /**
  16570. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16571. * in a given scene.
  16572. */
  16573. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16574. /**
  16575. * The component name helpfull to identify the component in the list of scene components.
  16576. */
  16577. readonly name: string;
  16578. /**
  16579. * The scene the component belongs to.
  16580. */
  16581. scene: Scene;
  16582. /**
  16583. * Creates a new instance of the component for the given scene
  16584. * @param scene Defines the scene to register the component in
  16585. */
  16586. constructor(scene: Scene);
  16587. /**
  16588. * Registers the component in a given scene
  16589. */
  16590. register(): void;
  16591. /**
  16592. * Rebuilds the elements related to this component in case of
  16593. * context lost for instance.
  16594. */
  16595. rebuild(): void;
  16596. /**
  16597. * Disposes the component and the associated ressources.
  16598. */
  16599. dispose(): void;
  16600. private _beforeClear;
  16601. }
  16602. }
  16603. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16605. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16606. module "babylonjs/Engines/thinEngine" {
  16607. interface ThinEngine {
  16608. /**
  16609. * Creates a new render target cube texture
  16610. * @param size defines the size of the texture
  16611. * @param options defines the options used to create the texture
  16612. * @returns a new render target cube texture stored in an InternalTexture
  16613. */
  16614. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16615. }
  16616. }
  16617. }
  16618. declare module "babylonjs/Shaders/procedural.vertex" {
  16619. /** @hidden */
  16620. export var proceduralVertexShader: {
  16621. name: string;
  16622. shader: string;
  16623. };
  16624. }
  16625. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16626. import { Observable } from "babylonjs/Misc/observable";
  16627. import { Nullable } from "babylonjs/types";
  16628. import { Scene } from "babylonjs/scene";
  16629. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16630. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16631. import { Effect } from "babylonjs/Materials/effect";
  16632. import { Texture } from "babylonjs/Materials/Textures/texture";
  16633. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16634. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16635. import "babylonjs/Shaders/procedural.vertex";
  16636. /**
  16637. * 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.
  16638. * This is the base class of any Procedural texture and contains most of the shareable code.
  16639. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16640. */
  16641. export class ProceduralTexture extends Texture {
  16642. isCube: boolean;
  16643. /**
  16644. * Define if the texture is enabled or not (disabled texture will not render)
  16645. */
  16646. isEnabled: boolean;
  16647. /**
  16648. * Define if the texture must be cleared before rendering (default is true)
  16649. */
  16650. autoClear: boolean;
  16651. /**
  16652. * Callback called when the texture is generated
  16653. */
  16654. onGenerated: () => void;
  16655. /**
  16656. * Event raised when the texture is generated
  16657. */
  16658. onGeneratedObservable: Observable<ProceduralTexture>;
  16659. /** @hidden */
  16660. _generateMipMaps: boolean;
  16661. /** @hidden **/
  16662. _effect: Effect;
  16663. /** @hidden */
  16664. _textures: {
  16665. [key: string]: Texture;
  16666. };
  16667. private _size;
  16668. private _currentRefreshId;
  16669. private _refreshRate;
  16670. private _vertexBuffers;
  16671. private _indexBuffer;
  16672. private _uniforms;
  16673. private _samplers;
  16674. private _fragment;
  16675. private _floats;
  16676. private _ints;
  16677. private _floatsArrays;
  16678. private _colors3;
  16679. private _colors4;
  16680. private _vectors2;
  16681. private _vectors3;
  16682. private _matrices;
  16683. private _fallbackTexture;
  16684. private _fallbackTextureUsed;
  16685. private _engine;
  16686. private _cachedDefines;
  16687. private _contentUpdateId;
  16688. private _contentData;
  16689. /**
  16690. * Instantiates a new procedural texture.
  16691. * 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.
  16692. * This is the base class of any Procedural texture and contains most of the shareable code.
  16693. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16694. * @param name Define the name of the texture
  16695. * @param size Define the size of the texture to create
  16696. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16697. * @param scene Define the scene the texture belongs to
  16698. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16699. * @param generateMipMaps Define if the texture should creates mip maps or not
  16700. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16701. */
  16702. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16703. /**
  16704. * The effect that is created when initializing the post process.
  16705. * @returns The created effect corresponding the the postprocess.
  16706. */
  16707. getEffect(): Effect;
  16708. /**
  16709. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16710. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16711. */
  16712. getContent(): Nullable<ArrayBufferView>;
  16713. private _createIndexBuffer;
  16714. /** @hidden */
  16715. _rebuild(): void;
  16716. /**
  16717. * Resets the texture in order to recreate its associated resources.
  16718. * This can be called in case of context loss
  16719. */
  16720. reset(): void;
  16721. protected _getDefines(): string;
  16722. /**
  16723. * Is the texture ready to be used ? (rendered at least once)
  16724. * @returns true if ready, otherwise, false.
  16725. */
  16726. isReady(): boolean;
  16727. /**
  16728. * Resets the refresh counter of the texture and start bak from scratch.
  16729. * Could be useful to regenerate the texture if it is setup to render only once.
  16730. */
  16731. resetRefreshCounter(): void;
  16732. /**
  16733. * Set the fragment shader to use in order to render the texture.
  16734. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16735. */
  16736. setFragment(fragment: any): void;
  16737. /**
  16738. * Define the refresh rate of the texture or the rendering frequency.
  16739. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16740. */
  16741. refreshRate: number;
  16742. /** @hidden */
  16743. _shouldRender(): boolean;
  16744. /**
  16745. * Get the size the texture is rendering at.
  16746. * @returns the size (texture is always squared)
  16747. */
  16748. getRenderSize(): number;
  16749. /**
  16750. * Resize the texture to new value.
  16751. * @param size Define the new size the texture should have
  16752. * @param generateMipMaps Define whether the new texture should create mip maps
  16753. */
  16754. resize(size: number, generateMipMaps: boolean): void;
  16755. private _checkUniform;
  16756. /**
  16757. * Set a texture in the shader program used to render.
  16758. * @param name Define the name of the uniform samplers as defined in the shader
  16759. * @param texture Define the texture to bind to this sampler
  16760. * @return the texture itself allowing "fluent" like uniform updates
  16761. */
  16762. setTexture(name: string, texture: Texture): ProceduralTexture;
  16763. /**
  16764. * Set a float in the shader.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the texture itself allowing "fluent" like uniform updates
  16768. */
  16769. setFloat(name: string, value: number): ProceduralTexture;
  16770. /**
  16771. * Set a int in the shader.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the texture itself allowing "fluent" like uniform updates
  16775. */
  16776. setInt(name: string, value: number): ProceduralTexture;
  16777. /**
  16778. * Set an array of floats in the shader.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the texture itself allowing "fluent" like uniform updates
  16782. */
  16783. setFloats(name: string, value: number[]): ProceduralTexture;
  16784. /**
  16785. * Set a vec3 in the shader from a Color3.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the texture itself allowing "fluent" like uniform updates
  16789. */
  16790. setColor3(name: string, value: Color3): ProceduralTexture;
  16791. /**
  16792. * Set a vec4 in the shader from a Color4.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the texture itself allowing "fluent" like uniform updates
  16796. */
  16797. setColor4(name: string, value: Color4): ProceduralTexture;
  16798. /**
  16799. * Set a vec2 in the shader from a Vector2.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the texture itself allowing "fluent" like uniform updates
  16803. */
  16804. setVector2(name: string, value: Vector2): ProceduralTexture;
  16805. /**
  16806. * Set a vec3 in the shader from a Vector3.
  16807. * @param name Define the name of the uniform as defined in the shader
  16808. * @param value Define the value to give to the uniform
  16809. * @return the texture itself allowing "fluent" like uniform updates
  16810. */
  16811. setVector3(name: string, value: Vector3): ProceduralTexture;
  16812. /**
  16813. * Set a mat4 in the shader from a MAtrix.
  16814. * @param name Define the name of the uniform as defined in the shader
  16815. * @param value Define the value to give to the uniform
  16816. * @return the texture itself allowing "fluent" like uniform updates
  16817. */
  16818. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16819. /**
  16820. * Render the texture to its associated render target.
  16821. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16822. */
  16823. render(useCameraPostProcess?: boolean): void;
  16824. /**
  16825. * Clone the texture.
  16826. * @returns the cloned texture
  16827. */
  16828. clone(): ProceduralTexture;
  16829. /**
  16830. * Dispose the texture and release its asoociated resources.
  16831. */
  16832. dispose(): void;
  16833. }
  16834. }
  16835. declare module "babylonjs/Particles/baseParticleSystem" {
  16836. import { Nullable } from "babylonjs/types";
  16837. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16839. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16840. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16841. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16842. import { Scene } from "babylonjs/scene";
  16843. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16844. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16845. import { Texture } from "babylonjs/Materials/Textures/texture";
  16846. import { Color4 } from "babylonjs/Maths/math.color";
  16847. import { Animation } from "babylonjs/Animations/animation";
  16848. /**
  16849. * This represents the base class for particle system in Babylon.
  16850. * 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.
  16851. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16852. * @example https://doc.babylonjs.com/babylon101/particles
  16853. */
  16854. export class BaseParticleSystem {
  16855. /**
  16856. * Source color is added to the destination color without alpha affecting the result
  16857. */
  16858. static BLENDMODE_ONEONE: number;
  16859. /**
  16860. * Blend current color and particle color using particle’s alpha
  16861. */
  16862. static BLENDMODE_STANDARD: number;
  16863. /**
  16864. * Add current color and particle color multiplied by particle’s alpha
  16865. */
  16866. static BLENDMODE_ADD: number;
  16867. /**
  16868. * Multiply current color with particle color
  16869. */
  16870. static BLENDMODE_MULTIPLY: number;
  16871. /**
  16872. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16873. */
  16874. static BLENDMODE_MULTIPLYADD: number;
  16875. /**
  16876. * List of animations used by the particle system.
  16877. */
  16878. animations: Animation[];
  16879. /**
  16880. * The id of the Particle system.
  16881. */
  16882. id: string;
  16883. /**
  16884. * The friendly name of the Particle system.
  16885. */
  16886. name: string;
  16887. /**
  16888. * The rendering group used by the Particle system to chose when to render.
  16889. */
  16890. renderingGroupId: number;
  16891. /**
  16892. * The emitter represents the Mesh or position we are attaching the particle system to.
  16893. */
  16894. emitter: Nullable<AbstractMesh | Vector3>;
  16895. /**
  16896. * The maximum number of particles to emit per frame
  16897. */
  16898. emitRate: number;
  16899. /**
  16900. * If you want to launch only a few particles at once, that can be done, as well.
  16901. */
  16902. manualEmitCount: number;
  16903. /**
  16904. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16905. */
  16906. updateSpeed: number;
  16907. /**
  16908. * The amount of time the particle system is running (depends of the overall update speed).
  16909. */
  16910. targetStopDuration: number;
  16911. /**
  16912. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16913. */
  16914. disposeOnStop: boolean;
  16915. /**
  16916. * Minimum power of emitting particles.
  16917. */
  16918. minEmitPower: number;
  16919. /**
  16920. * Maximum power of emitting particles.
  16921. */
  16922. maxEmitPower: number;
  16923. /**
  16924. * Minimum life time of emitting particles.
  16925. */
  16926. minLifeTime: number;
  16927. /**
  16928. * Maximum life time of emitting particles.
  16929. */
  16930. maxLifeTime: number;
  16931. /**
  16932. * Minimum Size of emitting particles.
  16933. */
  16934. minSize: number;
  16935. /**
  16936. * Maximum Size of emitting particles.
  16937. */
  16938. maxSize: number;
  16939. /**
  16940. * Minimum scale of emitting particles on X axis.
  16941. */
  16942. minScaleX: number;
  16943. /**
  16944. * Maximum scale of emitting particles on X axis.
  16945. */
  16946. maxScaleX: number;
  16947. /**
  16948. * Minimum scale of emitting particles on Y axis.
  16949. */
  16950. minScaleY: number;
  16951. /**
  16952. * Maximum scale of emitting particles on Y axis.
  16953. */
  16954. maxScaleY: number;
  16955. /**
  16956. * Gets or sets the minimal initial rotation in radians.
  16957. */
  16958. minInitialRotation: number;
  16959. /**
  16960. * Gets or sets the maximal initial rotation in radians.
  16961. */
  16962. maxInitialRotation: number;
  16963. /**
  16964. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16965. */
  16966. minAngularSpeed: number;
  16967. /**
  16968. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16969. */
  16970. maxAngularSpeed: number;
  16971. /**
  16972. * The texture used to render each particle. (this can be a spritesheet)
  16973. */
  16974. particleTexture: Nullable<Texture>;
  16975. /**
  16976. * The layer mask we are rendering the particles through.
  16977. */
  16978. layerMask: number;
  16979. /**
  16980. * This can help using your own shader to render the particle system.
  16981. * The according effect will be created
  16982. */
  16983. customShader: any;
  16984. /**
  16985. * By default particle system starts as soon as they are created. This prevents the
  16986. * automatic start to happen and let you decide when to start emitting particles.
  16987. */
  16988. preventAutoStart: boolean;
  16989. private _noiseTexture;
  16990. /**
  16991. * Gets or sets a texture used to add random noise to particle positions
  16992. */
  16993. noiseTexture: Nullable<ProceduralTexture>;
  16994. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16995. noiseStrength: Vector3;
  16996. /**
  16997. * Callback triggered when the particle animation is ending.
  16998. */
  16999. onAnimationEnd: Nullable<() => void>;
  17000. /**
  17001. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17002. */
  17003. blendMode: number;
  17004. /**
  17005. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17006. * to override the particles.
  17007. */
  17008. forceDepthWrite: boolean;
  17009. /** 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 */
  17010. preWarmCycles: number;
  17011. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17012. preWarmStepOffset: number;
  17013. /**
  17014. * 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)
  17015. */
  17016. spriteCellChangeSpeed: number;
  17017. /**
  17018. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17019. */
  17020. startSpriteCellID: number;
  17021. /**
  17022. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17023. */
  17024. endSpriteCellID: number;
  17025. /**
  17026. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17027. */
  17028. spriteCellWidth: number;
  17029. /**
  17030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17031. */
  17032. spriteCellHeight: number;
  17033. /**
  17034. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17035. */
  17036. spriteRandomStartCell: boolean;
  17037. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17038. translationPivot: Vector2;
  17039. /** @hidden */
  17040. protected _isAnimationSheetEnabled: boolean;
  17041. /**
  17042. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17043. */
  17044. beginAnimationOnStart: boolean;
  17045. /**
  17046. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17047. */
  17048. beginAnimationFrom: number;
  17049. /**
  17050. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17051. */
  17052. beginAnimationTo: number;
  17053. /**
  17054. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17055. */
  17056. beginAnimationLoop: boolean;
  17057. /**
  17058. * Gets or sets a world offset applied to all particles
  17059. */
  17060. worldOffset: Vector3;
  17061. /**
  17062. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17063. */
  17064. isAnimationSheetEnabled: boolean;
  17065. /**
  17066. * Get hosting scene
  17067. * @returns the scene
  17068. */
  17069. getScene(): Scene;
  17070. /**
  17071. * You can use gravity if you want to give an orientation to your particles.
  17072. */
  17073. gravity: Vector3;
  17074. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17075. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17076. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17077. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17078. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17079. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17080. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17081. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17082. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17083. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17084. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17085. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17086. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17087. /**
  17088. * Defines the delay in milliseconds before starting the system (0 by default)
  17089. */
  17090. startDelay: number;
  17091. /**
  17092. * Gets the current list of drag gradients.
  17093. * You must use addDragGradient and removeDragGradient to udpate this list
  17094. * @returns the list of drag gradients
  17095. */
  17096. getDragGradients(): Nullable<Array<FactorGradient>>;
  17097. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17098. limitVelocityDamping: number;
  17099. /**
  17100. * Gets the current list of limit velocity gradients.
  17101. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17102. * @returns the list of limit velocity gradients
  17103. */
  17104. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17105. /**
  17106. * Gets the current list of color gradients.
  17107. * You must use addColorGradient and removeColorGradient to udpate this list
  17108. * @returns the list of color gradients
  17109. */
  17110. getColorGradients(): Nullable<Array<ColorGradient>>;
  17111. /**
  17112. * Gets the current list of size gradients.
  17113. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17114. * @returns the list of size gradients
  17115. */
  17116. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17117. /**
  17118. * Gets the current list of color remap gradients.
  17119. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17120. * @returns the list of color remap gradients
  17121. */
  17122. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17123. /**
  17124. * Gets the current list of alpha remap gradients.
  17125. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17126. * @returns the list of alpha remap gradients
  17127. */
  17128. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17129. /**
  17130. * Gets the current list of life time gradients.
  17131. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17132. * @returns the list of life time gradients
  17133. */
  17134. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17135. /**
  17136. * Gets the current list of angular speed gradients.
  17137. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17138. * @returns the list of angular speed gradients
  17139. */
  17140. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17141. /**
  17142. * Gets the current list of velocity gradients.
  17143. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17144. * @returns the list of velocity gradients
  17145. */
  17146. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17147. /**
  17148. * Gets the current list of start size gradients.
  17149. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17150. * @returns the list of start size gradients
  17151. */
  17152. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17153. /**
  17154. * Gets the current list of emit rate gradients.
  17155. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17156. * @returns the list of emit rate gradients
  17157. */
  17158. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17159. /**
  17160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17161. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17162. */
  17163. direction1: Vector3;
  17164. /**
  17165. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17166. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17167. */
  17168. direction2: Vector3;
  17169. /**
  17170. * 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.
  17171. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17172. */
  17173. minEmitBox: Vector3;
  17174. /**
  17175. * 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.
  17176. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17177. */
  17178. maxEmitBox: Vector3;
  17179. /**
  17180. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17181. */
  17182. color1: Color4;
  17183. /**
  17184. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17185. */
  17186. color2: Color4;
  17187. /**
  17188. * Color the particle will have at the end of its lifetime
  17189. */
  17190. colorDead: Color4;
  17191. /**
  17192. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17193. */
  17194. textureMask: Color4;
  17195. /**
  17196. * The particle emitter type defines the emitter used by the particle system.
  17197. * It can be for example box, sphere, or cone...
  17198. */
  17199. particleEmitterType: IParticleEmitterType;
  17200. /** @hidden */
  17201. _isSubEmitter: boolean;
  17202. /**
  17203. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17204. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17205. */
  17206. billboardMode: number;
  17207. protected _isBillboardBased: boolean;
  17208. /**
  17209. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17210. */
  17211. isBillboardBased: boolean;
  17212. /**
  17213. * The scene the particle system belongs to.
  17214. */
  17215. protected _scene: Scene;
  17216. /**
  17217. * Local cache of defines for image processing.
  17218. */
  17219. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17220. /**
  17221. * Default configuration related to image processing available in the standard Material.
  17222. */
  17223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17224. /**
  17225. * Gets the image processing configuration used either in this material.
  17226. */
  17227. /**
  17228. * Sets the Default image processing configuration used either in the this material.
  17229. *
  17230. * If sets to null, the scene one is in use.
  17231. */
  17232. imageProcessingConfiguration: ImageProcessingConfiguration;
  17233. /**
  17234. * Attaches a new image processing configuration to the Standard Material.
  17235. * @param configuration
  17236. */
  17237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17238. /** @hidden */
  17239. protected _reset(): void;
  17240. /** @hidden */
  17241. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17242. /**
  17243. * Instantiates a particle system.
  17244. * 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.
  17245. * @param name The name of the particle system
  17246. */
  17247. constructor(name: string);
  17248. /**
  17249. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17250. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17251. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17252. * @returns the emitter
  17253. */
  17254. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17255. /**
  17256. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17257. * @param radius The radius of the hemisphere to emit from
  17258. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17259. * @returns the emitter
  17260. */
  17261. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17262. /**
  17263. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17264. * @param radius The radius of the sphere to emit from
  17265. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17266. * @returns the emitter
  17267. */
  17268. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17269. /**
  17270. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17271. * @param radius The radius of the sphere to emit from
  17272. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17273. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17274. * @returns the emitter
  17275. */
  17276. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17277. /**
  17278. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17279. * @param radius The radius of the emission cylinder
  17280. * @param height The height of the emission cylinder
  17281. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17282. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17283. * @returns the emitter
  17284. */
  17285. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17286. /**
  17287. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17288. * @param radius The radius of the cylinder to emit from
  17289. * @param height The height of the emission cylinder
  17290. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17293. * @returns the emitter
  17294. */
  17295. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17296. /**
  17297. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17298. * @param radius The radius of the cone to emit from
  17299. * @param angle The base angle of the cone
  17300. * @returns the emitter
  17301. */
  17302. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17303. /**
  17304. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17307. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17308. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17309. * @returns the emitter
  17310. */
  17311. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17312. }
  17313. }
  17314. declare module "babylonjs/Particles/subEmitter" {
  17315. import { Scene } from "babylonjs/scene";
  17316. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17317. /**
  17318. * Type of sub emitter
  17319. */
  17320. export enum SubEmitterType {
  17321. /**
  17322. * Attached to the particle over it's lifetime
  17323. */
  17324. ATTACHED = 0,
  17325. /**
  17326. * Created when the particle dies
  17327. */
  17328. END = 1
  17329. }
  17330. /**
  17331. * Sub emitter class used to emit particles from an existing particle
  17332. */
  17333. export class SubEmitter {
  17334. /**
  17335. * the particle system to be used by the sub emitter
  17336. */
  17337. particleSystem: ParticleSystem;
  17338. /**
  17339. * Type of the submitter (Default: END)
  17340. */
  17341. type: SubEmitterType;
  17342. /**
  17343. * 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)
  17344. * Note: This only is supported when using an emitter of type Mesh
  17345. */
  17346. inheritDirection: boolean;
  17347. /**
  17348. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17349. */
  17350. inheritedVelocityAmount: number;
  17351. /**
  17352. * Creates a sub emitter
  17353. * @param particleSystem the particle system to be used by the sub emitter
  17354. */
  17355. constructor(
  17356. /**
  17357. * the particle system to be used by the sub emitter
  17358. */
  17359. particleSystem: ParticleSystem);
  17360. /**
  17361. * Clones the sub emitter
  17362. * @returns the cloned sub emitter
  17363. */
  17364. clone(): SubEmitter;
  17365. /**
  17366. * Serialize current object to a JSON object
  17367. * @returns the serialized object
  17368. */
  17369. serialize(): any;
  17370. /** @hidden */
  17371. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17372. /**
  17373. * Creates a new SubEmitter from a serialized JSON version
  17374. * @param serializationObject defines the JSON object to read from
  17375. * @param scene defines the hosting scene
  17376. * @param rootUrl defines the rootUrl for data loading
  17377. * @returns a new SubEmitter
  17378. */
  17379. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17380. /** Release associated resources */
  17381. dispose(): void;
  17382. }
  17383. }
  17384. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17385. /** @hidden */
  17386. export var clipPlaneFragmentDeclaration: {
  17387. name: string;
  17388. shader: string;
  17389. };
  17390. }
  17391. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17392. /** @hidden */
  17393. export var imageProcessingDeclaration: {
  17394. name: string;
  17395. shader: string;
  17396. };
  17397. }
  17398. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17399. /** @hidden */
  17400. export var imageProcessingFunctions: {
  17401. name: string;
  17402. shader: string;
  17403. };
  17404. }
  17405. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17406. /** @hidden */
  17407. export var clipPlaneFragment: {
  17408. name: string;
  17409. shader: string;
  17410. };
  17411. }
  17412. declare module "babylonjs/Shaders/particles.fragment" {
  17413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17414. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17415. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17416. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17417. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17418. /** @hidden */
  17419. export var particlesPixelShader: {
  17420. name: string;
  17421. shader: string;
  17422. };
  17423. }
  17424. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17425. /** @hidden */
  17426. export var clipPlaneVertexDeclaration: {
  17427. name: string;
  17428. shader: string;
  17429. };
  17430. }
  17431. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17432. /** @hidden */
  17433. export var clipPlaneVertex: {
  17434. name: string;
  17435. shader: string;
  17436. };
  17437. }
  17438. declare module "babylonjs/Shaders/particles.vertex" {
  17439. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17440. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17441. /** @hidden */
  17442. export var particlesVertexShader: {
  17443. name: string;
  17444. shader: string;
  17445. };
  17446. }
  17447. declare module "babylonjs/Particles/particleSystem" {
  17448. import { Nullable } from "babylonjs/types";
  17449. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17450. import { Observable } from "babylonjs/Misc/observable";
  17451. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17452. import { Effect } from "babylonjs/Materials/effect";
  17453. import { Scene, IDisposable } from "babylonjs/scene";
  17454. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17455. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17456. import { Particle } from "babylonjs/Particles/particle";
  17457. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17458. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17459. import "babylonjs/Shaders/particles.fragment";
  17460. import "babylonjs/Shaders/particles.vertex";
  17461. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17462. /**
  17463. * This represents a particle system in Babylon.
  17464. * 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.
  17465. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17466. * @example https://doc.babylonjs.com/babylon101/particles
  17467. */
  17468. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17469. /**
  17470. * Billboard mode will only apply to Y axis
  17471. */
  17472. static readonly BILLBOARDMODE_Y: number;
  17473. /**
  17474. * Billboard mode will apply to all axes
  17475. */
  17476. static readonly BILLBOARDMODE_ALL: number;
  17477. /**
  17478. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17479. */
  17480. static readonly BILLBOARDMODE_STRETCHED: number;
  17481. /**
  17482. * This function can be defined to provide custom update for active particles.
  17483. * This function will be called instead of regular update (age, position, color, etc.).
  17484. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17485. */
  17486. updateFunction: (particles: Particle[]) => void;
  17487. private _emitterWorldMatrix;
  17488. /**
  17489. * This function can be defined to specify initial direction for every new particle.
  17490. * It by default use the emitterType defined function
  17491. */
  17492. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17493. /**
  17494. * This function can be defined to specify initial position for every new particle.
  17495. * It by default use the emitterType defined function
  17496. */
  17497. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17498. /**
  17499. * @hidden
  17500. */
  17501. _inheritedVelocityOffset: Vector3;
  17502. /**
  17503. * An event triggered when the system is disposed
  17504. */
  17505. onDisposeObservable: Observable<ParticleSystem>;
  17506. private _onDisposeObserver;
  17507. /**
  17508. * Sets a callback that will be triggered when the system is disposed
  17509. */
  17510. onDispose: () => void;
  17511. private _particles;
  17512. private _epsilon;
  17513. private _capacity;
  17514. private _stockParticles;
  17515. private _newPartsExcess;
  17516. private _vertexData;
  17517. private _vertexBuffer;
  17518. private _vertexBuffers;
  17519. private _spriteBuffer;
  17520. private _indexBuffer;
  17521. private _effect;
  17522. private _customEffect;
  17523. private _cachedDefines;
  17524. private _scaledColorStep;
  17525. private _colorDiff;
  17526. private _scaledDirection;
  17527. private _scaledGravity;
  17528. private _currentRenderId;
  17529. private _alive;
  17530. private _useInstancing;
  17531. private _started;
  17532. private _stopped;
  17533. private _actualFrame;
  17534. private _scaledUpdateSpeed;
  17535. private _vertexBufferSize;
  17536. /** @hidden */
  17537. _currentEmitRateGradient: Nullable<FactorGradient>;
  17538. /** @hidden */
  17539. _currentEmitRate1: number;
  17540. /** @hidden */
  17541. _currentEmitRate2: number;
  17542. /** @hidden */
  17543. _currentStartSizeGradient: Nullable<FactorGradient>;
  17544. /** @hidden */
  17545. _currentStartSize1: number;
  17546. /** @hidden */
  17547. _currentStartSize2: number;
  17548. private readonly _rawTextureWidth;
  17549. private _rampGradientsTexture;
  17550. private _useRampGradients;
  17551. /** Gets or sets a boolean indicating that ramp gradients must be used
  17552. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17553. */
  17554. useRampGradients: boolean;
  17555. /**
  17556. * 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.
  17557. * 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: [])
  17558. */
  17559. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17560. private _subEmitters;
  17561. /**
  17562. * @hidden
  17563. * If the particle systems emitter should be disposed when the particle system is disposed
  17564. */
  17565. _disposeEmitterOnDispose: boolean;
  17566. /**
  17567. * The current active Sub-systems, this property is used by the root particle system only.
  17568. */
  17569. activeSubSystems: Array<ParticleSystem>;
  17570. private _rootParticleSystem;
  17571. /**
  17572. * Gets the current list of active particles
  17573. */
  17574. readonly particles: Particle[];
  17575. /**
  17576. * Returns the string "ParticleSystem"
  17577. * @returns a string containing the class name
  17578. */
  17579. getClassName(): string;
  17580. /**
  17581. * Instantiates a particle system.
  17582. * 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.
  17583. * @param name The name of the particle system
  17584. * @param capacity The max number of particles alive at the same time
  17585. * @param scene The scene the particle system belongs to
  17586. * @param customEffect a custom effect used to change the way particles are rendered by default
  17587. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17588. * @param epsilon Offset used to render the particles
  17589. */
  17590. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17591. private _addFactorGradient;
  17592. private _removeFactorGradient;
  17593. /**
  17594. * Adds a new life time gradient
  17595. * @param gradient defines the gradient to use (between 0 and 1)
  17596. * @param factor defines the life time factor to affect to the specified gradient
  17597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17598. * @returns the current particle system
  17599. */
  17600. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17601. /**
  17602. * Remove a specific life time gradient
  17603. * @param gradient defines the gradient to remove
  17604. * @returns the current particle system
  17605. */
  17606. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17607. /**
  17608. * Adds a new size gradient
  17609. * @param gradient defines the gradient to use (between 0 and 1)
  17610. * @param factor defines the size factor to affect to the specified gradient
  17611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17612. * @returns the current particle system
  17613. */
  17614. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17615. /**
  17616. * Remove a specific size gradient
  17617. * @param gradient defines the gradient to remove
  17618. * @returns the current particle system
  17619. */
  17620. removeSizeGradient(gradient: number): IParticleSystem;
  17621. /**
  17622. * Adds a new color remap gradient
  17623. * @param gradient defines the gradient to use (between 0 and 1)
  17624. * @param min defines the color remap minimal range
  17625. * @param max defines the color remap maximal range
  17626. * @returns the current particle system
  17627. */
  17628. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17629. /**
  17630. * Remove a specific color remap gradient
  17631. * @param gradient defines the gradient to remove
  17632. * @returns the current particle system
  17633. */
  17634. removeColorRemapGradient(gradient: number): IParticleSystem;
  17635. /**
  17636. * Adds a new alpha remap gradient
  17637. * @param gradient defines the gradient to use (between 0 and 1)
  17638. * @param min defines the alpha remap minimal range
  17639. * @param max defines the alpha remap maximal range
  17640. * @returns the current particle system
  17641. */
  17642. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17643. /**
  17644. * Remove a specific alpha remap gradient
  17645. * @param gradient defines the gradient to remove
  17646. * @returns the current particle system
  17647. */
  17648. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17649. /**
  17650. * Adds a new angular speed gradient
  17651. * @param gradient defines the gradient to use (between 0 and 1)
  17652. * @param factor defines the angular speed to affect to the specified gradient
  17653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17654. * @returns the current particle system
  17655. */
  17656. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17657. /**
  17658. * Remove a specific angular speed gradient
  17659. * @param gradient defines the gradient to remove
  17660. * @returns the current particle system
  17661. */
  17662. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17663. /**
  17664. * Adds a new velocity gradient
  17665. * @param gradient defines the gradient to use (between 0 and 1)
  17666. * @param factor defines the velocity to affect to the specified gradient
  17667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17668. * @returns the current particle system
  17669. */
  17670. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17671. /**
  17672. * Remove a specific velocity gradient
  17673. * @param gradient defines the gradient to remove
  17674. * @returns the current particle system
  17675. */
  17676. removeVelocityGradient(gradient: number): IParticleSystem;
  17677. /**
  17678. * Adds a new limit velocity gradient
  17679. * @param gradient defines the gradient to use (between 0 and 1)
  17680. * @param factor defines the limit velocity value to affect to the specified gradient
  17681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17682. * @returns the current particle system
  17683. */
  17684. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17685. /**
  17686. * Remove a specific limit velocity gradient
  17687. * @param gradient defines the gradient to remove
  17688. * @returns the current particle system
  17689. */
  17690. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17691. /**
  17692. * Adds a new drag gradient
  17693. * @param gradient defines the gradient to use (between 0 and 1)
  17694. * @param factor defines the drag value to affect to the specified gradient
  17695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17696. * @returns the current particle system
  17697. */
  17698. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17699. /**
  17700. * Remove a specific drag gradient
  17701. * @param gradient defines the gradient to remove
  17702. * @returns the current particle system
  17703. */
  17704. removeDragGradient(gradient: number): IParticleSystem;
  17705. /**
  17706. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17707. * @param gradient defines the gradient to use (between 0 and 1)
  17708. * @param factor defines the emit rate value to affect to the specified gradient
  17709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17710. * @returns the current particle system
  17711. */
  17712. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17713. /**
  17714. * Remove a specific emit rate gradient
  17715. * @param gradient defines the gradient to remove
  17716. * @returns the current particle system
  17717. */
  17718. removeEmitRateGradient(gradient: number): IParticleSystem;
  17719. /**
  17720. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17721. * @param gradient defines the gradient to use (between 0 and 1)
  17722. * @param factor defines the start size value to affect to the specified gradient
  17723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17724. * @returns the current particle system
  17725. */
  17726. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17727. /**
  17728. * Remove a specific start size gradient
  17729. * @param gradient defines the gradient to remove
  17730. * @returns the current particle system
  17731. */
  17732. removeStartSizeGradient(gradient: number): IParticleSystem;
  17733. private _createRampGradientTexture;
  17734. /**
  17735. * Gets the current list of ramp gradients.
  17736. * You must use addRampGradient and removeRampGradient to udpate this list
  17737. * @returns the list of ramp gradients
  17738. */
  17739. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17740. /**
  17741. * Adds a new ramp gradient used to remap particle colors
  17742. * @param gradient defines the gradient to use (between 0 and 1)
  17743. * @param color defines the color to affect to the specified gradient
  17744. * @returns the current particle system
  17745. */
  17746. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17747. /**
  17748. * Remove a specific ramp gradient
  17749. * @param gradient defines the gradient to remove
  17750. * @returns the current particle system
  17751. */
  17752. removeRampGradient(gradient: number): ParticleSystem;
  17753. /**
  17754. * Adds a new color gradient
  17755. * @param gradient defines the gradient to use (between 0 and 1)
  17756. * @param color1 defines the color to affect to the specified gradient
  17757. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17758. * @returns this particle system
  17759. */
  17760. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17761. /**
  17762. * Remove a specific color gradient
  17763. * @param gradient defines the gradient to remove
  17764. * @returns this particle system
  17765. */
  17766. removeColorGradient(gradient: number): IParticleSystem;
  17767. private _fetchR;
  17768. protected _reset(): void;
  17769. private _resetEffect;
  17770. private _createVertexBuffers;
  17771. private _createIndexBuffer;
  17772. /**
  17773. * Gets the maximum number of particles active at the same time.
  17774. * @returns The max number of active particles.
  17775. */
  17776. getCapacity(): number;
  17777. /**
  17778. * Gets whether there are still active particles in the system.
  17779. * @returns True if it is alive, otherwise false.
  17780. */
  17781. isAlive(): boolean;
  17782. /**
  17783. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17784. * @returns True if it has been started, otherwise false.
  17785. */
  17786. isStarted(): boolean;
  17787. private _prepareSubEmitterInternalArray;
  17788. /**
  17789. * Starts the particle system and begins to emit
  17790. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17791. */
  17792. start(delay?: number): void;
  17793. /**
  17794. * Stops the particle system.
  17795. * @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.
  17796. */
  17797. stop(stopSubEmitters?: boolean): void;
  17798. /**
  17799. * Remove all active particles
  17800. */
  17801. reset(): void;
  17802. /**
  17803. * @hidden (for internal use only)
  17804. */
  17805. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17806. /**
  17807. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17808. * Its lifetime will start back at 0.
  17809. */
  17810. recycleParticle: (particle: Particle) => void;
  17811. private _stopSubEmitters;
  17812. private _createParticle;
  17813. private _removeFromRoot;
  17814. private _emitFromParticle;
  17815. private _update;
  17816. /** @hidden */
  17817. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17818. /** @hidden */
  17819. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17820. /** @hidden */
  17821. private _getEffect;
  17822. /**
  17823. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17824. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17825. */
  17826. animate(preWarmOnly?: boolean): void;
  17827. private _appendParticleVertices;
  17828. /**
  17829. * Rebuilds the particle system.
  17830. */
  17831. rebuild(): void;
  17832. /**
  17833. * Is this system ready to be used/rendered
  17834. * @return true if the system is ready
  17835. */
  17836. isReady(): boolean;
  17837. private _render;
  17838. /**
  17839. * Renders the particle system in its current state.
  17840. * @returns the current number of particles
  17841. */
  17842. render(): number;
  17843. /**
  17844. * Disposes the particle system and free the associated resources
  17845. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17846. */
  17847. dispose(disposeTexture?: boolean): void;
  17848. /**
  17849. * Clones the particle system.
  17850. * @param name The name of the cloned object
  17851. * @param newEmitter The new emitter to use
  17852. * @returns the cloned particle system
  17853. */
  17854. clone(name: string, newEmitter: any): ParticleSystem;
  17855. /**
  17856. * Serializes the particle system to a JSON object.
  17857. * @returns the JSON object
  17858. */
  17859. serialize(): any;
  17860. /** @hidden */
  17861. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17862. /** @hidden */
  17863. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17864. /**
  17865. * Parses a JSON object to create a particle system.
  17866. * @param parsedParticleSystem The JSON object to parse
  17867. * @param scene The scene to create the particle system in
  17868. * @param rootUrl The root url to use to load external dependencies like texture
  17869. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17870. * @returns the Parsed particle system
  17871. */
  17872. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17873. }
  17874. }
  17875. declare module "babylonjs/Particles/particle" {
  17876. import { Nullable } from "babylonjs/types";
  17877. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17878. import { Color4 } from "babylonjs/Maths/math.color";
  17879. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17880. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17881. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17882. /**
  17883. * A particle represents one of the element emitted by a particle system.
  17884. * This is mainly define by its coordinates, direction, velocity and age.
  17885. */
  17886. export class Particle {
  17887. /**
  17888. * The particle system the particle belongs to.
  17889. */
  17890. particleSystem: ParticleSystem;
  17891. private static _Count;
  17892. /**
  17893. * Unique ID of the particle
  17894. */
  17895. id: number;
  17896. /**
  17897. * The world position of the particle in the scene.
  17898. */
  17899. position: Vector3;
  17900. /**
  17901. * The world direction of the particle in the scene.
  17902. */
  17903. direction: Vector3;
  17904. /**
  17905. * The color of the particle.
  17906. */
  17907. color: Color4;
  17908. /**
  17909. * The color change of the particle per step.
  17910. */
  17911. colorStep: Color4;
  17912. /**
  17913. * Defines how long will the life of the particle be.
  17914. */
  17915. lifeTime: number;
  17916. /**
  17917. * The current age of the particle.
  17918. */
  17919. age: number;
  17920. /**
  17921. * The current size of the particle.
  17922. */
  17923. size: number;
  17924. /**
  17925. * The current scale of the particle.
  17926. */
  17927. scale: Vector2;
  17928. /**
  17929. * The current angle of the particle.
  17930. */
  17931. angle: number;
  17932. /**
  17933. * Defines how fast is the angle changing.
  17934. */
  17935. angularSpeed: number;
  17936. /**
  17937. * Defines the cell index used by the particle to be rendered from a sprite.
  17938. */
  17939. cellIndex: number;
  17940. /**
  17941. * The information required to support color remapping
  17942. */
  17943. remapData: Vector4;
  17944. /** @hidden */
  17945. _randomCellOffset?: number;
  17946. /** @hidden */
  17947. _initialDirection: Nullable<Vector3>;
  17948. /** @hidden */
  17949. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17950. /** @hidden */
  17951. _initialStartSpriteCellID: number;
  17952. /** @hidden */
  17953. _initialEndSpriteCellID: number;
  17954. /** @hidden */
  17955. _currentColorGradient: Nullable<ColorGradient>;
  17956. /** @hidden */
  17957. _currentColor1: Color4;
  17958. /** @hidden */
  17959. _currentColor2: Color4;
  17960. /** @hidden */
  17961. _currentSizeGradient: Nullable<FactorGradient>;
  17962. /** @hidden */
  17963. _currentSize1: number;
  17964. /** @hidden */
  17965. _currentSize2: number;
  17966. /** @hidden */
  17967. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17968. /** @hidden */
  17969. _currentAngularSpeed1: number;
  17970. /** @hidden */
  17971. _currentAngularSpeed2: number;
  17972. /** @hidden */
  17973. _currentVelocityGradient: Nullable<FactorGradient>;
  17974. /** @hidden */
  17975. _currentVelocity1: number;
  17976. /** @hidden */
  17977. _currentVelocity2: number;
  17978. /** @hidden */
  17979. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17980. /** @hidden */
  17981. _currentLimitVelocity1: number;
  17982. /** @hidden */
  17983. _currentLimitVelocity2: number;
  17984. /** @hidden */
  17985. _currentDragGradient: Nullable<FactorGradient>;
  17986. /** @hidden */
  17987. _currentDrag1: number;
  17988. /** @hidden */
  17989. _currentDrag2: number;
  17990. /** @hidden */
  17991. _randomNoiseCoordinates1: Vector3;
  17992. /** @hidden */
  17993. _randomNoiseCoordinates2: Vector3;
  17994. /**
  17995. * Creates a new instance Particle
  17996. * @param particleSystem the particle system the particle belongs to
  17997. */
  17998. constructor(
  17999. /**
  18000. * The particle system the particle belongs to.
  18001. */
  18002. particleSystem: ParticleSystem);
  18003. private updateCellInfoFromSystem;
  18004. /**
  18005. * Defines how the sprite cell index is updated for the particle
  18006. */
  18007. updateCellIndex(): void;
  18008. /** @hidden */
  18009. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18010. /** @hidden */
  18011. _inheritParticleInfoToSubEmitters(): void;
  18012. /** @hidden */
  18013. _reset(): void;
  18014. /**
  18015. * Copy the properties of particle to another one.
  18016. * @param other the particle to copy the information to.
  18017. */
  18018. copyTo(other: Particle): void;
  18019. }
  18020. }
  18021. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18023. import { Effect } from "babylonjs/Materials/effect";
  18024. import { Particle } from "babylonjs/Particles/particle";
  18025. /**
  18026. * Particle emitter represents a volume emitting particles.
  18027. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18028. */
  18029. export interface IParticleEmitterType {
  18030. /**
  18031. * Called by the particle System when the direction is computed for the created particle.
  18032. * @param worldMatrix is the world matrix of the particle system
  18033. * @param directionToUpdate is the direction vector to update with the result
  18034. * @param particle is the particle we are computed the direction for
  18035. */
  18036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18037. /**
  18038. * Called by the particle System when the position is computed for the created particle.
  18039. * @param worldMatrix is the world matrix of the particle system
  18040. * @param positionToUpdate is the position vector to update with the result
  18041. * @param particle is the particle we are computed the position for
  18042. */
  18043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18044. /**
  18045. * Clones the current emitter and returns a copy of it
  18046. * @returns the new emitter
  18047. */
  18048. clone(): IParticleEmitterType;
  18049. /**
  18050. * Called by the GPUParticleSystem to setup the update shader
  18051. * @param effect defines the update shader
  18052. */
  18053. applyToShader(effect: Effect): void;
  18054. /**
  18055. * Returns a string to use to update the GPU particles update shader
  18056. * @returns the effect defines string
  18057. */
  18058. getEffectDefines(): string;
  18059. /**
  18060. * Returns a string representing the class name
  18061. * @returns a string containing the class name
  18062. */
  18063. getClassName(): string;
  18064. /**
  18065. * Serializes the particle system to a JSON object.
  18066. * @returns the JSON object
  18067. */
  18068. serialize(): any;
  18069. /**
  18070. * Parse properties from a JSON object
  18071. * @param serializationObject defines the JSON object
  18072. */
  18073. parse(serializationObject: any): void;
  18074. }
  18075. }
  18076. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18077. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18078. import { Effect } from "babylonjs/Materials/effect";
  18079. import { Particle } from "babylonjs/Particles/particle";
  18080. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18081. /**
  18082. * Particle emitter emitting particles from the inside of a box.
  18083. * It emits the particles randomly between 2 given directions.
  18084. */
  18085. export class BoxParticleEmitter implements IParticleEmitterType {
  18086. /**
  18087. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18088. */
  18089. direction1: Vector3;
  18090. /**
  18091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18092. */
  18093. direction2: Vector3;
  18094. /**
  18095. * 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.
  18096. */
  18097. minEmitBox: Vector3;
  18098. /**
  18099. * 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.
  18100. */
  18101. maxEmitBox: Vector3;
  18102. /**
  18103. * Creates a new instance BoxParticleEmitter
  18104. */
  18105. constructor();
  18106. /**
  18107. * Called by the particle System when the direction is computed for the created particle.
  18108. * @param worldMatrix is the world matrix of the particle system
  18109. * @param directionToUpdate is the direction vector to update with the result
  18110. * @param particle is the particle we are computed the direction for
  18111. */
  18112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18113. /**
  18114. * Called by the particle System when the position is computed for the created particle.
  18115. * @param worldMatrix is the world matrix of the particle system
  18116. * @param positionToUpdate is the position vector to update with the result
  18117. * @param particle is the particle we are computed the position for
  18118. */
  18119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18120. /**
  18121. * Clones the current emitter and returns a copy of it
  18122. * @returns the new emitter
  18123. */
  18124. clone(): BoxParticleEmitter;
  18125. /**
  18126. * Called by the GPUParticleSystem to setup the update shader
  18127. * @param effect defines the update shader
  18128. */
  18129. applyToShader(effect: Effect): void;
  18130. /**
  18131. * Returns a string to use to update the GPU particles update shader
  18132. * @returns a string containng the defines string
  18133. */
  18134. getEffectDefines(): string;
  18135. /**
  18136. * Returns the string "BoxParticleEmitter"
  18137. * @returns a string containing the class name
  18138. */
  18139. getClassName(): string;
  18140. /**
  18141. * Serializes the particle system to a JSON object.
  18142. * @returns the JSON object
  18143. */
  18144. serialize(): any;
  18145. /**
  18146. * Parse properties from a JSON object
  18147. * @param serializationObject defines the JSON object
  18148. */
  18149. parse(serializationObject: any): void;
  18150. }
  18151. }
  18152. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18154. import { Effect } from "babylonjs/Materials/effect";
  18155. import { Particle } from "babylonjs/Particles/particle";
  18156. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18157. /**
  18158. * Particle emitter emitting particles from the inside of a cone.
  18159. * It emits the particles alongside the cone volume from the base to the particle.
  18160. * The emission direction might be randomized.
  18161. */
  18162. export class ConeParticleEmitter implements IParticleEmitterType {
  18163. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18164. directionRandomizer: number;
  18165. private _radius;
  18166. private _angle;
  18167. private _height;
  18168. /**
  18169. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18170. */
  18171. radiusRange: number;
  18172. /**
  18173. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18174. */
  18175. heightRange: number;
  18176. /**
  18177. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18178. */
  18179. emitFromSpawnPointOnly: boolean;
  18180. /**
  18181. * Gets or sets the radius of the emission cone
  18182. */
  18183. radius: number;
  18184. /**
  18185. * Gets or sets the angle of the emission cone
  18186. */
  18187. angle: number;
  18188. private _buildHeight;
  18189. /**
  18190. * Creates a new instance ConeParticleEmitter
  18191. * @param radius the radius of the emission cone (1 by default)
  18192. * @param angle the cone base angle (PI by default)
  18193. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18194. */
  18195. constructor(radius?: number, angle?: number,
  18196. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18197. directionRandomizer?: number);
  18198. /**
  18199. * Called by the particle System when the direction is computed for the created particle.
  18200. * @param worldMatrix is the world matrix of the particle system
  18201. * @param directionToUpdate is the direction vector to update with the result
  18202. * @param particle is the particle we are computed the direction for
  18203. */
  18204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18205. /**
  18206. * Called by the particle System when the position is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param positionToUpdate is the position vector to update with the result
  18209. * @param particle is the particle we are computed the position for
  18210. */
  18211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Clones the current emitter and returns a copy of it
  18214. * @returns the new emitter
  18215. */
  18216. clone(): ConeParticleEmitter;
  18217. /**
  18218. * Called by the GPUParticleSystem to setup the update shader
  18219. * @param effect defines the update shader
  18220. */
  18221. applyToShader(effect: Effect): void;
  18222. /**
  18223. * Returns a string to use to update the GPU particles update shader
  18224. * @returns a string containng the defines string
  18225. */
  18226. getEffectDefines(): string;
  18227. /**
  18228. * Returns the string "ConeParticleEmitter"
  18229. * @returns a string containing the class name
  18230. */
  18231. getClassName(): string;
  18232. /**
  18233. * Serializes the particle system to a JSON object.
  18234. * @returns the JSON object
  18235. */
  18236. serialize(): any;
  18237. /**
  18238. * Parse properties from a JSON object
  18239. * @param serializationObject defines the JSON object
  18240. */
  18241. parse(serializationObject: any): void;
  18242. }
  18243. }
  18244. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18245. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18246. import { Effect } from "babylonjs/Materials/effect";
  18247. import { Particle } from "babylonjs/Particles/particle";
  18248. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18249. /**
  18250. * Particle emitter emitting particles from the inside of a cylinder.
  18251. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18252. */
  18253. export class CylinderParticleEmitter implements IParticleEmitterType {
  18254. /**
  18255. * The radius of the emission cylinder.
  18256. */
  18257. radius: number;
  18258. /**
  18259. * The height of the emission cylinder.
  18260. */
  18261. height: number;
  18262. /**
  18263. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18264. */
  18265. radiusRange: number;
  18266. /**
  18267. * How much to randomize the particle direction [0-1].
  18268. */
  18269. directionRandomizer: number;
  18270. /**
  18271. * Creates a new instance CylinderParticleEmitter
  18272. * @param radius the radius of the emission cylinder (1 by default)
  18273. * @param height the height of the emission cylinder (1 by default)
  18274. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18275. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18276. */
  18277. constructor(
  18278. /**
  18279. * The radius of the emission cylinder.
  18280. */
  18281. radius?: number,
  18282. /**
  18283. * The height of the emission cylinder.
  18284. */
  18285. height?: number,
  18286. /**
  18287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18288. */
  18289. radiusRange?: number,
  18290. /**
  18291. * How much to randomize the particle direction [0-1].
  18292. */
  18293. directionRandomizer?: number);
  18294. /**
  18295. * Called by the particle System when the direction is computed for the created particle.
  18296. * @param worldMatrix is the world matrix of the particle system
  18297. * @param directionToUpdate is the direction vector to update with the result
  18298. * @param particle is the particle we are computed the direction for
  18299. */
  18300. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18301. /**
  18302. * Called by the particle System when the position is computed for the created particle.
  18303. * @param worldMatrix is the world matrix of the particle system
  18304. * @param positionToUpdate is the position vector to update with the result
  18305. * @param particle is the particle we are computed the position for
  18306. */
  18307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18308. /**
  18309. * Clones the current emitter and returns a copy of it
  18310. * @returns the new emitter
  18311. */
  18312. clone(): CylinderParticleEmitter;
  18313. /**
  18314. * Called by the GPUParticleSystem to setup the update shader
  18315. * @param effect defines the update shader
  18316. */
  18317. applyToShader(effect: Effect): void;
  18318. /**
  18319. * Returns a string to use to update the GPU particles update shader
  18320. * @returns a string containng the defines string
  18321. */
  18322. getEffectDefines(): string;
  18323. /**
  18324. * Returns the string "CylinderParticleEmitter"
  18325. * @returns a string containing the class name
  18326. */
  18327. getClassName(): string;
  18328. /**
  18329. * Serializes the particle system to a JSON object.
  18330. * @returns the JSON object
  18331. */
  18332. serialize(): any;
  18333. /**
  18334. * Parse properties from a JSON object
  18335. * @param serializationObject defines the JSON object
  18336. */
  18337. parse(serializationObject: any): void;
  18338. }
  18339. /**
  18340. * Particle emitter emitting particles from the inside of a cylinder.
  18341. * It emits the particles randomly between two vectors.
  18342. */
  18343. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18344. /**
  18345. * The min limit of the emission direction.
  18346. */
  18347. direction1: Vector3;
  18348. /**
  18349. * The max limit of the emission direction.
  18350. */
  18351. direction2: Vector3;
  18352. /**
  18353. * Creates a new instance CylinderDirectedParticleEmitter
  18354. * @param radius the radius of the emission cylinder (1 by default)
  18355. * @param height the height of the emission cylinder (1 by default)
  18356. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18357. * @param direction1 the min limit of the emission direction (up vector by default)
  18358. * @param direction2 the max limit of the emission direction (up vector by default)
  18359. */
  18360. constructor(radius?: number, height?: number, radiusRange?: number,
  18361. /**
  18362. * The min limit of the emission direction.
  18363. */
  18364. direction1?: Vector3,
  18365. /**
  18366. * The max limit of the emission direction.
  18367. */
  18368. direction2?: Vector3);
  18369. /**
  18370. * Called by the particle System when the direction is computed for the created particle.
  18371. * @param worldMatrix is the world matrix of the particle system
  18372. * @param directionToUpdate is the direction vector to update with the result
  18373. * @param particle is the particle we are computed the direction for
  18374. */
  18375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18376. /**
  18377. * Clones the current emitter and returns a copy of it
  18378. * @returns the new emitter
  18379. */
  18380. clone(): CylinderDirectedParticleEmitter;
  18381. /**
  18382. * Called by the GPUParticleSystem to setup the update shader
  18383. * @param effect defines the update shader
  18384. */
  18385. applyToShader(effect: Effect): void;
  18386. /**
  18387. * Returns a string to use to update the GPU particles update shader
  18388. * @returns a string containng the defines string
  18389. */
  18390. getEffectDefines(): string;
  18391. /**
  18392. * Returns the string "CylinderDirectedParticleEmitter"
  18393. * @returns a string containing the class name
  18394. */
  18395. getClassName(): string;
  18396. /**
  18397. * Serializes the particle system to a JSON object.
  18398. * @returns the JSON object
  18399. */
  18400. serialize(): any;
  18401. /**
  18402. * Parse properties from a JSON object
  18403. * @param serializationObject defines the JSON object
  18404. */
  18405. parse(serializationObject: any): void;
  18406. }
  18407. }
  18408. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18409. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18410. import { Effect } from "babylonjs/Materials/effect";
  18411. import { Particle } from "babylonjs/Particles/particle";
  18412. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18413. /**
  18414. * Particle emitter emitting particles from the inside of a hemisphere.
  18415. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18416. */
  18417. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18418. /**
  18419. * The radius of the emission hemisphere.
  18420. */
  18421. radius: number;
  18422. /**
  18423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18424. */
  18425. radiusRange: number;
  18426. /**
  18427. * How much to randomize the particle direction [0-1].
  18428. */
  18429. directionRandomizer: number;
  18430. /**
  18431. * Creates a new instance HemisphericParticleEmitter
  18432. * @param radius the radius of the emission hemisphere (1 by default)
  18433. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18434. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18435. */
  18436. constructor(
  18437. /**
  18438. * The radius of the emission hemisphere.
  18439. */
  18440. radius?: number,
  18441. /**
  18442. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18443. */
  18444. radiusRange?: number,
  18445. /**
  18446. * How much to randomize the particle direction [0-1].
  18447. */
  18448. directionRandomizer?: number);
  18449. /**
  18450. * Called by the particle System when the direction is computed for the created particle.
  18451. * @param worldMatrix is the world matrix of the particle system
  18452. * @param directionToUpdate is the direction vector to update with the result
  18453. * @param particle is the particle we are computed the direction for
  18454. */
  18455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18456. /**
  18457. * Called by the particle System when the position is computed for the created particle.
  18458. * @param worldMatrix is the world matrix of the particle system
  18459. * @param positionToUpdate is the position vector to update with the result
  18460. * @param particle is the particle we are computed the position for
  18461. */
  18462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18463. /**
  18464. * Clones the current emitter and returns a copy of it
  18465. * @returns the new emitter
  18466. */
  18467. clone(): HemisphericParticleEmitter;
  18468. /**
  18469. * Called by the GPUParticleSystem to setup the update shader
  18470. * @param effect defines the update shader
  18471. */
  18472. applyToShader(effect: Effect): void;
  18473. /**
  18474. * Returns a string to use to update the GPU particles update shader
  18475. * @returns a string containng the defines string
  18476. */
  18477. getEffectDefines(): string;
  18478. /**
  18479. * Returns the string "HemisphericParticleEmitter"
  18480. * @returns a string containing the class name
  18481. */
  18482. getClassName(): string;
  18483. /**
  18484. * Serializes the particle system to a JSON object.
  18485. * @returns the JSON object
  18486. */
  18487. serialize(): any;
  18488. /**
  18489. * Parse properties from a JSON object
  18490. * @param serializationObject defines the JSON object
  18491. */
  18492. parse(serializationObject: any): void;
  18493. }
  18494. }
  18495. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18496. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18497. import { Effect } from "babylonjs/Materials/effect";
  18498. import { Particle } from "babylonjs/Particles/particle";
  18499. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18500. /**
  18501. * Particle emitter emitting particles from a point.
  18502. * It emits the particles randomly between 2 given directions.
  18503. */
  18504. export class PointParticleEmitter implements IParticleEmitterType {
  18505. /**
  18506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18507. */
  18508. direction1: Vector3;
  18509. /**
  18510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18511. */
  18512. direction2: Vector3;
  18513. /**
  18514. * Creates a new instance PointParticleEmitter
  18515. */
  18516. constructor();
  18517. /**
  18518. * Called by the particle System when the direction is computed for the created particle.
  18519. * @param worldMatrix is the world matrix of the particle system
  18520. * @param directionToUpdate is the direction vector to update with the result
  18521. * @param particle is the particle we are computed the direction for
  18522. */
  18523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18524. /**
  18525. * Called by the particle System when the position is computed for the created particle.
  18526. * @param worldMatrix is the world matrix of the particle system
  18527. * @param positionToUpdate is the position vector to update with the result
  18528. * @param particle is the particle we are computed the position for
  18529. */
  18530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18531. /**
  18532. * Clones the current emitter and returns a copy of it
  18533. * @returns the new emitter
  18534. */
  18535. clone(): PointParticleEmitter;
  18536. /**
  18537. * Called by the GPUParticleSystem to setup the update shader
  18538. * @param effect defines the update shader
  18539. */
  18540. applyToShader(effect: Effect): void;
  18541. /**
  18542. * Returns a string to use to update the GPU particles update shader
  18543. * @returns a string containng the defines string
  18544. */
  18545. getEffectDefines(): string;
  18546. /**
  18547. * Returns the string "PointParticleEmitter"
  18548. * @returns a string containing the class name
  18549. */
  18550. getClassName(): string;
  18551. /**
  18552. * Serializes the particle system to a JSON object.
  18553. * @returns the JSON object
  18554. */
  18555. serialize(): any;
  18556. /**
  18557. * Parse properties from a JSON object
  18558. * @param serializationObject defines the JSON object
  18559. */
  18560. parse(serializationObject: any): void;
  18561. }
  18562. }
  18563. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18564. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18565. import { Effect } from "babylonjs/Materials/effect";
  18566. import { Particle } from "babylonjs/Particles/particle";
  18567. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18568. /**
  18569. * Particle emitter emitting particles from the inside of a sphere.
  18570. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18571. */
  18572. export class SphereParticleEmitter implements IParticleEmitterType {
  18573. /**
  18574. * The radius of the emission sphere.
  18575. */
  18576. radius: number;
  18577. /**
  18578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18579. */
  18580. radiusRange: number;
  18581. /**
  18582. * How much to randomize the particle direction [0-1].
  18583. */
  18584. directionRandomizer: number;
  18585. /**
  18586. * Creates a new instance SphereParticleEmitter
  18587. * @param radius the radius of the emission sphere (1 by default)
  18588. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18589. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18590. */
  18591. constructor(
  18592. /**
  18593. * The radius of the emission sphere.
  18594. */
  18595. radius?: number,
  18596. /**
  18597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18598. */
  18599. radiusRange?: number,
  18600. /**
  18601. * How much to randomize the particle direction [0-1].
  18602. */
  18603. directionRandomizer?: number);
  18604. /**
  18605. * Called by the particle System when the direction is computed for the created particle.
  18606. * @param worldMatrix is the world matrix of the particle system
  18607. * @param directionToUpdate is the direction vector to update with the result
  18608. * @param particle is the particle we are computed the direction for
  18609. */
  18610. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18611. /**
  18612. * Called by the particle System when the position is computed for the created particle.
  18613. * @param worldMatrix is the world matrix of the particle system
  18614. * @param positionToUpdate is the position vector to update with the result
  18615. * @param particle is the particle we are computed the position for
  18616. */
  18617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18618. /**
  18619. * Clones the current emitter and returns a copy of it
  18620. * @returns the new emitter
  18621. */
  18622. clone(): SphereParticleEmitter;
  18623. /**
  18624. * Called by the GPUParticleSystem to setup the update shader
  18625. * @param effect defines the update shader
  18626. */
  18627. applyToShader(effect: Effect): void;
  18628. /**
  18629. * Returns a string to use to update the GPU particles update shader
  18630. * @returns a string containng the defines string
  18631. */
  18632. getEffectDefines(): string;
  18633. /**
  18634. * Returns the string "SphereParticleEmitter"
  18635. * @returns a string containing the class name
  18636. */
  18637. getClassName(): string;
  18638. /**
  18639. * Serializes the particle system to a JSON object.
  18640. * @returns the JSON object
  18641. */
  18642. serialize(): any;
  18643. /**
  18644. * Parse properties from a JSON object
  18645. * @param serializationObject defines the JSON object
  18646. */
  18647. parse(serializationObject: any): void;
  18648. }
  18649. /**
  18650. * Particle emitter emitting particles from the inside of a sphere.
  18651. * It emits the particles randomly between two vectors.
  18652. */
  18653. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18654. /**
  18655. * The min limit of the emission direction.
  18656. */
  18657. direction1: Vector3;
  18658. /**
  18659. * The max limit of the emission direction.
  18660. */
  18661. direction2: Vector3;
  18662. /**
  18663. * Creates a new instance SphereDirectedParticleEmitter
  18664. * @param radius the radius of the emission sphere (1 by default)
  18665. * @param direction1 the min limit of the emission direction (up vector by default)
  18666. * @param direction2 the max limit of the emission direction (up vector by default)
  18667. */
  18668. constructor(radius?: number,
  18669. /**
  18670. * The min limit of the emission direction.
  18671. */
  18672. direction1?: Vector3,
  18673. /**
  18674. * The max limit of the emission direction.
  18675. */
  18676. direction2?: Vector3);
  18677. /**
  18678. * Called by the particle System when the direction is computed for the created particle.
  18679. * @param worldMatrix is the world matrix of the particle system
  18680. * @param directionToUpdate is the direction vector to update with the result
  18681. * @param particle is the particle we are computed the direction for
  18682. */
  18683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18684. /**
  18685. * Clones the current emitter and returns a copy of it
  18686. * @returns the new emitter
  18687. */
  18688. clone(): SphereDirectedParticleEmitter;
  18689. /**
  18690. * Called by the GPUParticleSystem to setup the update shader
  18691. * @param effect defines the update shader
  18692. */
  18693. applyToShader(effect: Effect): void;
  18694. /**
  18695. * Returns a string to use to update the GPU particles update shader
  18696. * @returns a string containng the defines string
  18697. */
  18698. getEffectDefines(): string;
  18699. /**
  18700. * Returns the string "SphereDirectedParticleEmitter"
  18701. * @returns a string containing the class name
  18702. */
  18703. getClassName(): string;
  18704. /**
  18705. * Serializes the particle system to a JSON object.
  18706. * @returns the JSON object
  18707. */
  18708. serialize(): any;
  18709. /**
  18710. * Parse properties from a JSON object
  18711. * @param serializationObject defines the JSON object
  18712. */
  18713. parse(serializationObject: any): void;
  18714. }
  18715. }
  18716. declare module "babylonjs/Particles/EmitterTypes/index" {
  18717. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18718. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18719. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18720. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18721. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18722. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18723. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18724. }
  18725. declare module "babylonjs/Particles/IParticleSystem" {
  18726. import { Nullable } from "babylonjs/types";
  18727. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18728. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18731. import { Texture } from "babylonjs/Materials/Textures/texture";
  18732. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18733. import { Scene } from "babylonjs/scene";
  18734. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18735. import { Animation } from "babylonjs/Animations/animation";
  18736. /**
  18737. * Interface representing a particle system in Babylon.js.
  18738. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18739. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18740. */
  18741. export interface IParticleSystem {
  18742. /**
  18743. * List of animations used by the particle system.
  18744. */
  18745. animations: Animation[];
  18746. /**
  18747. * The id of the Particle system.
  18748. */
  18749. id: string;
  18750. /**
  18751. * The name of the Particle system.
  18752. */
  18753. name: string;
  18754. /**
  18755. * The emitter represents the Mesh or position we are attaching the particle system to.
  18756. */
  18757. emitter: Nullable<AbstractMesh | Vector3>;
  18758. /**
  18759. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18760. */
  18761. isBillboardBased: boolean;
  18762. /**
  18763. * The rendering group used by the Particle system to chose when to render.
  18764. */
  18765. renderingGroupId: number;
  18766. /**
  18767. * The layer mask we are rendering the particles through.
  18768. */
  18769. layerMask: number;
  18770. /**
  18771. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18772. */
  18773. updateSpeed: number;
  18774. /**
  18775. * The amount of time the particle system is running (depends of the overall update speed).
  18776. */
  18777. targetStopDuration: number;
  18778. /**
  18779. * The texture used to render each particle. (this can be a spritesheet)
  18780. */
  18781. particleTexture: Nullable<Texture>;
  18782. /**
  18783. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18784. */
  18785. blendMode: number;
  18786. /**
  18787. * Minimum life time of emitting particles.
  18788. */
  18789. minLifeTime: number;
  18790. /**
  18791. * Maximum life time of emitting particles.
  18792. */
  18793. maxLifeTime: number;
  18794. /**
  18795. * Minimum Size of emitting particles.
  18796. */
  18797. minSize: number;
  18798. /**
  18799. * Maximum Size of emitting particles.
  18800. */
  18801. maxSize: number;
  18802. /**
  18803. * Minimum scale of emitting particles on X axis.
  18804. */
  18805. minScaleX: number;
  18806. /**
  18807. * Maximum scale of emitting particles on X axis.
  18808. */
  18809. maxScaleX: number;
  18810. /**
  18811. * Minimum scale of emitting particles on Y axis.
  18812. */
  18813. minScaleY: number;
  18814. /**
  18815. * Maximum scale of emitting particles on Y axis.
  18816. */
  18817. maxScaleY: number;
  18818. /**
  18819. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18820. */
  18821. color1: Color4;
  18822. /**
  18823. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18824. */
  18825. color2: Color4;
  18826. /**
  18827. * Color the particle will have at the end of its lifetime.
  18828. */
  18829. colorDead: Color4;
  18830. /**
  18831. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18832. */
  18833. emitRate: number;
  18834. /**
  18835. * You can use gravity if you want to give an orientation to your particles.
  18836. */
  18837. gravity: Vector3;
  18838. /**
  18839. * Minimum power of emitting particles.
  18840. */
  18841. minEmitPower: number;
  18842. /**
  18843. * Maximum power of emitting particles.
  18844. */
  18845. maxEmitPower: number;
  18846. /**
  18847. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18848. */
  18849. minAngularSpeed: number;
  18850. /**
  18851. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18852. */
  18853. maxAngularSpeed: number;
  18854. /**
  18855. * Gets or sets the minimal initial rotation in radians.
  18856. */
  18857. minInitialRotation: number;
  18858. /**
  18859. * Gets or sets the maximal initial rotation in radians.
  18860. */
  18861. maxInitialRotation: number;
  18862. /**
  18863. * The particle emitter type defines the emitter used by the particle system.
  18864. * It can be for example box, sphere, or cone...
  18865. */
  18866. particleEmitterType: Nullable<IParticleEmitterType>;
  18867. /**
  18868. * Defines the delay in milliseconds before starting the system (0 by default)
  18869. */
  18870. startDelay: number;
  18871. /**
  18872. * 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
  18873. */
  18874. preWarmCycles: number;
  18875. /**
  18876. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18877. */
  18878. preWarmStepOffset: number;
  18879. /**
  18880. * 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)
  18881. */
  18882. spriteCellChangeSpeed: number;
  18883. /**
  18884. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18885. */
  18886. startSpriteCellID: number;
  18887. /**
  18888. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18889. */
  18890. endSpriteCellID: number;
  18891. /**
  18892. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18893. */
  18894. spriteCellWidth: number;
  18895. /**
  18896. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18897. */
  18898. spriteCellHeight: number;
  18899. /**
  18900. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18901. */
  18902. spriteRandomStartCell: boolean;
  18903. /**
  18904. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18905. */
  18906. isAnimationSheetEnabled: boolean;
  18907. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18908. translationPivot: Vector2;
  18909. /**
  18910. * Gets or sets a texture used to add random noise to particle positions
  18911. */
  18912. noiseTexture: Nullable<BaseTexture>;
  18913. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18914. noiseStrength: Vector3;
  18915. /**
  18916. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18917. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18918. */
  18919. billboardMode: number;
  18920. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18921. limitVelocityDamping: number;
  18922. /**
  18923. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18924. */
  18925. beginAnimationOnStart: boolean;
  18926. /**
  18927. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18928. */
  18929. beginAnimationFrom: number;
  18930. /**
  18931. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18932. */
  18933. beginAnimationTo: number;
  18934. /**
  18935. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18936. */
  18937. beginAnimationLoop: boolean;
  18938. /**
  18939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18940. */
  18941. disposeOnStop: boolean;
  18942. /**
  18943. * Gets the maximum number of particles active at the same time.
  18944. * @returns The max number of active particles.
  18945. */
  18946. getCapacity(): number;
  18947. /**
  18948. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18949. * @returns True if it has been started, otherwise false.
  18950. */
  18951. isStarted(): boolean;
  18952. /**
  18953. * Animates the particle system for this frame.
  18954. */
  18955. animate(): void;
  18956. /**
  18957. * Renders the particle system in its current state.
  18958. * @returns the current number of particles
  18959. */
  18960. render(): number;
  18961. /**
  18962. * Dispose the particle system and frees its associated resources.
  18963. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18964. */
  18965. dispose(disposeTexture?: boolean): void;
  18966. /**
  18967. * Clones the particle system.
  18968. * @param name The name of the cloned object
  18969. * @param newEmitter The new emitter to use
  18970. * @returns the cloned particle system
  18971. */
  18972. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18973. /**
  18974. * Serializes the particle system to a JSON object.
  18975. * @returns the JSON object
  18976. */
  18977. serialize(): any;
  18978. /**
  18979. * Rebuild the particle system
  18980. */
  18981. rebuild(): void;
  18982. /**
  18983. * Starts the particle system and begins to emit
  18984. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18985. */
  18986. start(delay?: number): void;
  18987. /**
  18988. * Stops the particle system.
  18989. */
  18990. stop(): void;
  18991. /**
  18992. * Remove all active particles
  18993. */
  18994. reset(): void;
  18995. /**
  18996. * Is this system ready to be used/rendered
  18997. * @return true if the system is ready
  18998. */
  18999. isReady(): boolean;
  19000. /**
  19001. * Adds a new color gradient
  19002. * @param gradient defines the gradient to use (between 0 and 1)
  19003. * @param color1 defines the color to affect to the specified gradient
  19004. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19005. * @returns the current particle system
  19006. */
  19007. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19008. /**
  19009. * Remove a specific color gradient
  19010. * @param gradient defines the gradient to remove
  19011. * @returns the current particle system
  19012. */
  19013. removeColorGradient(gradient: number): IParticleSystem;
  19014. /**
  19015. * Adds a new size gradient
  19016. * @param gradient defines the gradient to use (between 0 and 1)
  19017. * @param factor defines the size factor to affect to the specified gradient
  19018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19019. * @returns the current particle system
  19020. */
  19021. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19022. /**
  19023. * Remove a specific size gradient
  19024. * @param gradient defines the gradient to remove
  19025. * @returns the current particle system
  19026. */
  19027. removeSizeGradient(gradient: number): IParticleSystem;
  19028. /**
  19029. * Gets the current list of color gradients.
  19030. * You must use addColorGradient and removeColorGradient to udpate this list
  19031. * @returns the list of color gradients
  19032. */
  19033. getColorGradients(): Nullable<Array<ColorGradient>>;
  19034. /**
  19035. * Gets the current list of size gradients.
  19036. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19037. * @returns the list of size gradients
  19038. */
  19039. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19040. /**
  19041. * Gets the current list of angular speed gradients.
  19042. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19043. * @returns the list of angular speed gradients
  19044. */
  19045. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19046. /**
  19047. * Adds a new angular speed gradient
  19048. * @param gradient defines the gradient to use (between 0 and 1)
  19049. * @param factor defines the angular speed to affect to the specified gradient
  19050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19051. * @returns the current particle system
  19052. */
  19053. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19054. /**
  19055. * Remove a specific angular speed gradient
  19056. * @param gradient defines the gradient to remove
  19057. * @returns the current particle system
  19058. */
  19059. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19060. /**
  19061. * Gets the current list of velocity gradients.
  19062. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19063. * @returns the list of velocity gradients
  19064. */
  19065. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19066. /**
  19067. * Adds a new velocity gradient
  19068. * @param gradient defines the gradient to use (between 0 and 1)
  19069. * @param factor defines the velocity to affect to the specified gradient
  19070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19071. * @returns the current particle system
  19072. */
  19073. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19074. /**
  19075. * Remove a specific velocity gradient
  19076. * @param gradient defines the gradient to remove
  19077. * @returns the current particle system
  19078. */
  19079. removeVelocityGradient(gradient: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of limit velocity gradients.
  19082. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19083. * @returns the list of limit velocity gradients
  19084. */
  19085. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Adds a new limit velocity gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param factor defines the limit velocity to affect to the specified gradient
  19090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19091. * @returns the current particle system
  19092. */
  19093. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19094. /**
  19095. * Remove a specific limit velocity gradient
  19096. * @param gradient defines the gradient to remove
  19097. * @returns the current particle system
  19098. */
  19099. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19100. /**
  19101. * Adds a new drag gradient
  19102. * @param gradient defines the gradient to use (between 0 and 1)
  19103. * @param factor defines the drag to affect to the specified gradient
  19104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19105. * @returns the current particle system
  19106. */
  19107. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19108. /**
  19109. * Remove a specific drag gradient
  19110. * @param gradient defines the gradient to remove
  19111. * @returns the current particle system
  19112. */
  19113. removeDragGradient(gradient: number): IParticleSystem;
  19114. /**
  19115. * Gets the current list of drag gradients.
  19116. * You must use addDragGradient and removeDragGradient to udpate this list
  19117. * @returns the list of drag gradients
  19118. */
  19119. getDragGradients(): Nullable<Array<FactorGradient>>;
  19120. /**
  19121. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19122. * @param gradient defines the gradient to use (between 0 and 1)
  19123. * @param factor defines the emit rate to affect to the specified gradient
  19124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19125. * @returns the current particle system
  19126. */
  19127. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19128. /**
  19129. * Remove a specific emit rate gradient
  19130. * @param gradient defines the gradient to remove
  19131. * @returns the current particle system
  19132. */
  19133. removeEmitRateGradient(gradient: number): IParticleSystem;
  19134. /**
  19135. * Gets the current list of emit rate gradients.
  19136. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19137. * @returns the list of emit rate gradients
  19138. */
  19139. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19140. /**
  19141. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19142. * @param gradient defines the gradient to use (between 0 and 1)
  19143. * @param factor defines the start size to affect to the specified gradient
  19144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19145. * @returns the current particle system
  19146. */
  19147. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19148. /**
  19149. * Remove a specific start size gradient
  19150. * @param gradient defines the gradient to remove
  19151. * @returns the current particle system
  19152. */
  19153. removeStartSizeGradient(gradient: number): IParticleSystem;
  19154. /**
  19155. * Gets the current list of start size gradients.
  19156. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19157. * @returns the list of start size gradients
  19158. */
  19159. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19160. /**
  19161. * Adds a new life time gradient
  19162. * @param gradient defines the gradient to use (between 0 and 1)
  19163. * @param factor defines the life time factor to affect to the specified gradient
  19164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19165. * @returns the current particle system
  19166. */
  19167. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19168. /**
  19169. * Remove a specific life time gradient
  19170. * @param gradient defines the gradient to remove
  19171. * @returns the current particle system
  19172. */
  19173. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19174. /**
  19175. * Gets the current list of life time gradients.
  19176. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19177. * @returns the list of life time gradients
  19178. */
  19179. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19180. /**
  19181. * Gets the current list of color gradients.
  19182. * You must use addColorGradient and removeColorGradient to udpate this list
  19183. * @returns the list of color gradients
  19184. */
  19185. getColorGradients(): Nullable<Array<ColorGradient>>;
  19186. /**
  19187. * Adds a new ramp gradient used to remap particle colors
  19188. * @param gradient defines the gradient to use (between 0 and 1)
  19189. * @param color defines the color to affect to the specified gradient
  19190. * @returns the current particle system
  19191. */
  19192. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19193. /**
  19194. * Gets the current list of ramp gradients.
  19195. * You must use addRampGradient and removeRampGradient to udpate this list
  19196. * @returns the list of ramp gradients
  19197. */
  19198. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19199. /** Gets or sets a boolean indicating that ramp gradients must be used
  19200. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19201. */
  19202. useRampGradients: boolean;
  19203. /**
  19204. * Adds a new color remap gradient
  19205. * @param gradient defines the gradient to use (between 0 and 1)
  19206. * @param min defines the color remap minimal range
  19207. * @param max defines the color remap maximal range
  19208. * @returns the current particle system
  19209. */
  19210. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19211. /**
  19212. * Gets the current list of color remap gradients.
  19213. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19214. * @returns the list of color remap gradients
  19215. */
  19216. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19217. /**
  19218. * Adds a new alpha remap gradient
  19219. * @param gradient defines the gradient to use (between 0 and 1)
  19220. * @param min defines the alpha remap minimal range
  19221. * @param max defines the alpha remap maximal range
  19222. * @returns the current particle system
  19223. */
  19224. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19225. /**
  19226. * Gets the current list of alpha remap gradients.
  19227. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19228. * @returns the list of alpha remap gradients
  19229. */
  19230. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19231. /**
  19232. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19233. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19234. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19235. * @returns the emitter
  19236. */
  19237. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19238. /**
  19239. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19240. * @param radius The radius of the hemisphere to emit from
  19241. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19242. * @returns the emitter
  19243. */
  19244. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19245. /**
  19246. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19247. * @param radius The radius of the sphere to emit from
  19248. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19249. * @returns the emitter
  19250. */
  19251. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19252. /**
  19253. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19254. * @param radius The radius of the sphere to emit from
  19255. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19256. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19257. * @returns the emitter
  19258. */
  19259. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19260. /**
  19261. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19262. * @param radius The radius of the emission cylinder
  19263. * @param height The height of the emission cylinder
  19264. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19265. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19266. * @returns the emitter
  19267. */
  19268. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19269. /**
  19270. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19271. * @param radius The radius of the cylinder to emit from
  19272. * @param height The height of the emission cylinder
  19273. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19274. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19275. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19276. * @returns the emitter
  19277. */
  19278. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19279. /**
  19280. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19281. * @param radius The radius of the cone to emit from
  19282. * @param angle The base angle of the cone
  19283. * @returns the emitter
  19284. */
  19285. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19286. /**
  19287. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19288. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19289. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19290. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19291. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19292. * @returns the emitter
  19293. */
  19294. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19295. /**
  19296. * Get hosting scene
  19297. * @returns the scene
  19298. */
  19299. getScene(): Scene;
  19300. }
  19301. }
  19302. declare module "babylonjs/Meshes/instancedMesh" {
  19303. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19304. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19305. import { Camera } from "babylonjs/Cameras/camera";
  19306. import { Node } from "babylonjs/node";
  19307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19308. import { Mesh } from "babylonjs/Meshes/mesh";
  19309. import { Material } from "babylonjs/Materials/material";
  19310. import { Skeleton } from "babylonjs/Bones/skeleton";
  19311. import { Light } from "babylonjs/Lights/light";
  19312. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19313. /**
  19314. * Creates an instance based on a source mesh.
  19315. */
  19316. export class InstancedMesh extends AbstractMesh {
  19317. private _sourceMesh;
  19318. private _currentLOD;
  19319. /** @hidden */
  19320. _indexInSourceMeshInstanceArray: number;
  19321. constructor(name: string, source: Mesh);
  19322. /**
  19323. * Returns the string "InstancedMesh".
  19324. */
  19325. getClassName(): string;
  19326. /** Gets the list of lights affecting that mesh */
  19327. readonly lightSources: Light[];
  19328. _resyncLightSources(): void;
  19329. _resyncLighSource(light: Light): void;
  19330. _removeLightSource(light: Light, dispose: boolean): void;
  19331. /**
  19332. * If the source mesh receives shadows
  19333. */
  19334. readonly receiveShadows: boolean;
  19335. /**
  19336. * The material of the source mesh
  19337. */
  19338. readonly material: Nullable<Material>;
  19339. /**
  19340. * Visibility of the source mesh
  19341. */
  19342. readonly visibility: number;
  19343. /**
  19344. * Skeleton of the source mesh
  19345. */
  19346. readonly skeleton: Nullable<Skeleton>;
  19347. /**
  19348. * Rendering ground id of the source mesh
  19349. */
  19350. renderingGroupId: number;
  19351. /**
  19352. * Returns the total number of vertices (integer).
  19353. */
  19354. getTotalVertices(): number;
  19355. /**
  19356. * Returns a positive integer : the total number of indices in this mesh geometry.
  19357. * @returns the numner of indices or zero if the mesh has no geometry.
  19358. */
  19359. getTotalIndices(): number;
  19360. /**
  19361. * The source mesh of the instance
  19362. */
  19363. readonly sourceMesh: Mesh;
  19364. /**
  19365. * Is this node ready to be used/rendered
  19366. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19367. * @return {boolean} is it ready
  19368. */
  19369. isReady(completeCheck?: boolean): boolean;
  19370. /**
  19371. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19372. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19373. * @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.
  19374. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19375. */
  19376. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19377. /**
  19378. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19379. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19380. * The `data` are either a numeric array either a Float32Array.
  19381. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19382. * 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).
  19383. * Note that a new underlying VertexBuffer object is created each call.
  19384. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19385. *
  19386. * Possible `kind` values :
  19387. * - VertexBuffer.PositionKind
  19388. * - VertexBuffer.UVKind
  19389. * - VertexBuffer.UV2Kind
  19390. * - VertexBuffer.UV3Kind
  19391. * - VertexBuffer.UV4Kind
  19392. * - VertexBuffer.UV5Kind
  19393. * - VertexBuffer.UV6Kind
  19394. * - VertexBuffer.ColorKind
  19395. * - VertexBuffer.MatricesIndicesKind
  19396. * - VertexBuffer.MatricesIndicesExtraKind
  19397. * - VertexBuffer.MatricesWeightsKind
  19398. * - VertexBuffer.MatricesWeightsExtraKind
  19399. *
  19400. * Returns the Mesh.
  19401. */
  19402. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19403. /**
  19404. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19405. * If the mesh has no geometry, it is simply returned as it is.
  19406. * The `data` are either a numeric array either a Float32Array.
  19407. * No new underlying VertexBuffer object is created.
  19408. * 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.
  19409. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19410. *
  19411. * Possible `kind` values :
  19412. * - VertexBuffer.PositionKind
  19413. * - VertexBuffer.UVKind
  19414. * - VertexBuffer.UV2Kind
  19415. * - VertexBuffer.UV3Kind
  19416. * - VertexBuffer.UV4Kind
  19417. * - VertexBuffer.UV5Kind
  19418. * - VertexBuffer.UV6Kind
  19419. * - VertexBuffer.ColorKind
  19420. * - VertexBuffer.MatricesIndicesKind
  19421. * - VertexBuffer.MatricesIndicesExtraKind
  19422. * - VertexBuffer.MatricesWeightsKind
  19423. * - VertexBuffer.MatricesWeightsExtraKind
  19424. *
  19425. * Returns the Mesh.
  19426. */
  19427. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19428. /**
  19429. * Sets the mesh indices.
  19430. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19431. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19432. * This method creates a new index buffer each call.
  19433. * Returns the Mesh.
  19434. */
  19435. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19436. /**
  19437. * Boolean : True if the mesh owns the requested kind of data.
  19438. */
  19439. isVerticesDataPresent(kind: string): boolean;
  19440. /**
  19441. * Returns an array of indices (IndicesArray).
  19442. */
  19443. getIndices(): Nullable<IndicesArray>;
  19444. readonly _positions: Nullable<Vector3[]>;
  19445. /**
  19446. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19447. * This means the mesh underlying bounding box and sphere are recomputed.
  19448. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19449. * @returns the current mesh
  19450. */
  19451. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19452. /** @hidden */
  19453. _preActivate(): InstancedMesh;
  19454. /** @hidden */
  19455. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19456. /** @hidden */
  19457. _postActivate(): void;
  19458. getWorldMatrix(): Matrix;
  19459. readonly isAnInstance: boolean;
  19460. /**
  19461. * Returns the current associated LOD AbstractMesh.
  19462. */
  19463. getLOD(camera: Camera): AbstractMesh;
  19464. /** @hidden */
  19465. _syncSubMeshes(): InstancedMesh;
  19466. /** @hidden */
  19467. _generatePointsArray(): boolean;
  19468. /**
  19469. * Creates a new InstancedMesh from the current mesh.
  19470. * - name (string) : the cloned mesh name
  19471. * - newParent (optional Node) : the optional Node to parent the clone to.
  19472. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19473. *
  19474. * Returns the clone.
  19475. */
  19476. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19477. /**
  19478. * Disposes the InstancedMesh.
  19479. * Returns nothing.
  19480. */
  19481. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19482. }
  19483. module "babylonjs/Meshes/mesh" {
  19484. interface Mesh {
  19485. /**
  19486. * Register a custom buffer that will be instanced
  19487. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19488. * @param kind defines the buffer kind
  19489. * @param stride defines the stride in floats
  19490. */
  19491. registerInstancedBuffer(kind: string, stride: number): void;
  19492. /** @hidden */
  19493. _userInstancedBuffersStorage: {
  19494. data: {
  19495. [key: string]: Float32Array;
  19496. };
  19497. sizes: {
  19498. [key: string]: number;
  19499. };
  19500. vertexBuffers: {
  19501. [key: string]: Nullable<VertexBuffer>;
  19502. };
  19503. strides: {
  19504. [key: string]: number;
  19505. };
  19506. };
  19507. }
  19508. }
  19509. module "babylonjs/Meshes/abstractMesh" {
  19510. interface AbstractMesh {
  19511. /**
  19512. * Object used to store instanced buffers defined by user
  19513. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19514. */
  19515. instancedBuffers: {
  19516. [key: string]: any;
  19517. };
  19518. }
  19519. }
  19520. }
  19521. declare module "babylonjs/Materials/shaderMaterial" {
  19522. import { Scene } from "babylonjs/scene";
  19523. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19525. import { Mesh } from "babylonjs/Meshes/mesh";
  19526. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19528. import { Texture } from "babylonjs/Materials/Textures/texture";
  19529. import { Material } from "babylonjs/Materials/material";
  19530. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19531. /**
  19532. * Defines the options associated with the creation of a shader material.
  19533. */
  19534. export interface IShaderMaterialOptions {
  19535. /**
  19536. * Does the material work in alpha blend mode
  19537. */
  19538. needAlphaBlending: boolean;
  19539. /**
  19540. * Does the material work in alpha test mode
  19541. */
  19542. needAlphaTesting: boolean;
  19543. /**
  19544. * The list of attribute names used in the shader
  19545. */
  19546. attributes: string[];
  19547. /**
  19548. * The list of unifrom names used in the shader
  19549. */
  19550. uniforms: string[];
  19551. /**
  19552. * The list of UBO names used in the shader
  19553. */
  19554. uniformBuffers: string[];
  19555. /**
  19556. * The list of sampler names used in the shader
  19557. */
  19558. samplers: string[];
  19559. /**
  19560. * The list of defines used in the shader
  19561. */
  19562. defines: string[];
  19563. }
  19564. /**
  19565. * 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.
  19566. *
  19567. * This returned material effects how the mesh will look based on the code in the shaders.
  19568. *
  19569. * @see http://doc.babylonjs.com/how_to/shader_material
  19570. */
  19571. export class ShaderMaterial extends Material {
  19572. private _shaderPath;
  19573. private _options;
  19574. private _textures;
  19575. private _textureArrays;
  19576. private _floats;
  19577. private _ints;
  19578. private _floatsArrays;
  19579. private _colors3;
  19580. private _colors3Arrays;
  19581. private _colors4;
  19582. private _colors4Arrays;
  19583. private _vectors2;
  19584. private _vectors3;
  19585. private _vectors4;
  19586. private _matrices;
  19587. private _matrices3x3;
  19588. private _matrices2x2;
  19589. private _vectors2Arrays;
  19590. private _vectors3Arrays;
  19591. private _vectors4Arrays;
  19592. private _cachedWorldViewMatrix;
  19593. private _cachedWorldViewProjectionMatrix;
  19594. private _renderId;
  19595. /**
  19596. * Instantiate a new shader material.
  19597. * 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.
  19598. * This returned material effects how the mesh will look based on the code in the shaders.
  19599. * @see http://doc.babylonjs.com/how_to/shader_material
  19600. * @param name Define the name of the material in the scene
  19601. * @param scene Define the scene the material belongs to
  19602. * @param shaderPath Defines the route to the shader code in one of three ways:
  19603. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19604. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19605. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19606. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19607. * @param options Define the options used to create the shader
  19608. */
  19609. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19610. /**
  19611. * Gets the options used to compile the shader.
  19612. * They can be modified to trigger a new compilation
  19613. */
  19614. readonly options: IShaderMaterialOptions;
  19615. /**
  19616. * Gets the current class name of the material e.g. "ShaderMaterial"
  19617. * Mainly use in serialization.
  19618. * @returns the class name
  19619. */
  19620. getClassName(): string;
  19621. /**
  19622. * Specifies if the material will require alpha blending
  19623. * @returns a boolean specifying if alpha blending is needed
  19624. */
  19625. needAlphaBlending(): boolean;
  19626. /**
  19627. * Specifies if this material should be rendered in alpha test mode
  19628. * @returns a boolean specifying if an alpha test is needed.
  19629. */
  19630. needAlphaTesting(): boolean;
  19631. private _checkUniform;
  19632. /**
  19633. * Set a texture in the shader.
  19634. * @param name Define the name of the uniform samplers as defined in the shader
  19635. * @param texture Define the texture to bind to this sampler
  19636. * @return the material itself allowing "fluent" like uniform updates
  19637. */
  19638. setTexture(name: string, texture: Texture): ShaderMaterial;
  19639. /**
  19640. * Set a texture array in the shader.
  19641. * @param name Define the name of the uniform sampler array as defined in the shader
  19642. * @param textures Define the list of textures to bind to this sampler
  19643. * @return the material itself allowing "fluent" like uniform updates
  19644. */
  19645. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19646. /**
  19647. * Set a float in the shader.
  19648. * @param name Define the name of the uniform as defined in the shader
  19649. * @param value Define the value to give to the uniform
  19650. * @return the material itself allowing "fluent" like uniform updates
  19651. */
  19652. setFloat(name: string, value: number): ShaderMaterial;
  19653. /**
  19654. * Set a int in the shader.
  19655. * @param name Define the name of the uniform as defined in the shader
  19656. * @param value Define the value to give to the uniform
  19657. * @return the material itself allowing "fluent" like uniform updates
  19658. */
  19659. setInt(name: string, value: number): ShaderMaterial;
  19660. /**
  19661. * Set an array of floats in the shader.
  19662. * @param name Define the name of the uniform as defined in the shader
  19663. * @param value Define the value to give to the uniform
  19664. * @return the material itself allowing "fluent" like uniform updates
  19665. */
  19666. setFloats(name: string, value: number[]): ShaderMaterial;
  19667. /**
  19668. * Set a vec3 in the shader from a Color3.
  19669. * @param name Define the name of the uniform as defined in the shader
  19670. * @param value Define the value to give to the uniform
  19671. * @return the material itself allowing "fluent" like uniform updates
  19672. */
  19673. setColor3(name: string, value: Color3): ShaderMaterial;
  19674. /**
  19675. * Set a vec3 array in the shader from a Color3 array.
  19676. * @param name Define the name of the uniform as defined in the shader
  19677. * @param value Define the value to give to the uniform
  19678. * @return the material itself allowing "fluent" like uniform updates
  19679. */
  19680. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19681. /**
  19682. * Set a vec4 in the shader from a Color4.
  19683. * @param name Define the name of the uniform as defined in the shader
  19684. * @param value Define the value to give to the uniform
  19685. * @return the material itself allowing "fluent" like uniform updates
  19686. */
  19687. setColor4(name: string, value: Color4): ShaderMaterial;
  19688. /**
  19689. * Set a vec4 array in the shader from a Color4 array.
  19690. * @param name Define the name of the uniform as defined in the shader
  19691. * @param value Define the value to give to the uniform
  19692. * @return the material itself allowing "fluent" like uniform updates
  19693. */
  19694. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19695. /**
  19696. * Set a vec2 in the shader from a Vector2.
  19697. * @param name Define the name of the uniform as defined in the shader
  19698. * @param value Define the value to give to the uniform
  19699. * @return the material itself allowing "fluent" like uniform updates
  19700. */
  19701. setVector2(name: string, value: Vector2): ShaderMaterial;
  19702. /**
  19703. * Set a vec3 in the shader from a Vector3.
  19704. * @param name Define the name of the uniform as defined in the shader
  19705. * @param value Define the value to give to the uniform
  19706. * @return the material itself allowing "fluent" like uniform updates
  19707. */
  19708. setVector3(name: string, value: Vector3): ShaderMaterial;
  19709. /**
  19710. * Set a vec4 in the shader from a Vector4.
  19711. * @param name Define the name of the uniform as defined in the shader
  19712. * @param value Define the value to give to the uniform
  19713. * @return the material itself allowing "fluent" like uniform updates
  19714. */
  19715. setVector4(name: string, value: Vector4): ShaderMaterial;
  19716. /**
  19717. * Set a mat4 in the shader from a Matrix.
  19718. * @param name Define the name of the uniform as defined in the shader
  19719. * @param value Define the value to give to the uniform
  19720. * @return the material itself allowing "fluent" like uniform updates
  19721. */
  19722. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19723. /**
  19724. * Set a mat3 in the shader from a Float32Array.
  19725. * @param name Define the name of the uniform as defined in the shader
  19726. * @param value Define the value to give to the uniform
  19727. * @return the material itself allowing "fluent" like uniform updates
  19728. */
  19729. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19730. /**
  19731. * Set a mat2 in the shader from a Float32Array.
  19732. * @param name Define the name of the uniform as defined in the shader
  19733. * @param value Define the value to give to the uniform
  19734. * @return the material itself allowing "fluent" like uniform updates
  19735. */
  19736. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19737. /**
  19738. * Set a vec2 array in the shader from a number array.
  19739. * @param name Define the name of the uniform as defined in the shader
  19740. * @param value Define the value to give to the uniform
  19741. * @return the material itself allowing "fluent" like uniform updates
  19742. */
  19743. setArray2(name: string, value: number[]): ShaderMaterial;
  19744. /**
  19745. * Set a vec3 array in the shader from a number array.
  19746. * @param name Define the name of the uniform as defined in the shader
  19747. * @param value Define the value to give to the uniform
  19748. * @return the material itself allowing "fluent" like uniform updates
  19749. */
  19750. setArray3(name: string, value: number[]): ShaderMaterial;
  19751. /**
  19752. * Set a vec4 array in the shader from a number array.
  19753. * @param name Define the name of the uniform as defined in the shader
  19754. * @param value Define the value to give to the uniform
  19755. * @return the material itself allowing "fluent" like uniform updates
  19756. */
  19757. setArray4(name: string, value: number[]): ShaderMaterial;
  19758. private _checkCache;
  19759. /**
  19760. * Specifies that the submesh is ready to be used
  19761. * @param mesh defines the mesh to check
  19762. * @param subMesh defines which submesh to check
  19763. * @param useInstances specifies that instances should be used
  19764. * @returns a boolean indicating that the submesh is ready or not
  19765. */
  19766. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19767. /**
  19768. * Checks if the material is ready to render the requested mesh
  19769. * @param mesh Define the mesh to render
  19770. * @param useInstances Define whether or not the material is used with instances
  19771. * @returns true if ready, otherwise false
  19772. */
  19773. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19774. /**
  19775. * Binds the world matrix to the material
  19776. * @param world defines the world transformation matrix
  19777. */
  19778. bindOnlyWorldMatrix(world: Matrix): void;
  19779. /**
  19780. * Binds the material to the mesh
  19781. * @param world defines the world transformation matrix
  19782. * @param mesh defines the mesh to bind the material to
  19783. */
  19784. bind(world: Matrix, mesh?: Mesh): void;
  19785. /**
  19786. * Gets the active textures from the material
  19787. * @returns an array of textures
  19788. */
  19789. getActiveTextures(): BaseTexture[];
  19790. /**
  19791. * Specifies if the material uses a texture
  19792. * @param texture defines the texture to check against the material
  19793. * @returns a boolean specifying if the material uses the texture
  19794. */
  19795. hasTexture(texture: BaseTexture): boolean;
  19796. /**
  19797. * Makes a duplicate of the material, and gives it a new name
  19798. * @param name defines the new name for the duplicated material
  19799. * @returns the cloned material
  19800. */
  19801. clone(name: string): ShaderMaterial;
  19802. /**
  19803. * Disposes the material
  19804. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19805. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19806. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19807. */
  19808. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19809. /**
  19810. * Serializes this material in a JSON representation
  19811. * @returns the serialized material object
  19812. */
  19813. serialize(): any;
  19814. /**
  19815. * Creates a shader material from parsed shader material data
  19816. * @param source defines the JSON represnetation of the material
  19817. * @param scene defines the hosting scene
  19818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19819. * @returns a new material
  19820. */
  19821. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19822. }
  19823. }
  19824. declare module "babylonjs/Shaders/color.fragment" {
  19825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19826. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19827. /** @hidden */
  19828. export var colorPixelShader: {
  19829. name: string;
  19830. shader: string;
  19831. };
  19832. }
  19833. declare module "babylonjs/Shaders/color.vertex" {
  19834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19835. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19837. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19838. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19839. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19840. /** @hidden */
  19841. export var colorVertexShader: {
  19842. name: string;
  19843. shader: string;
  19844. };
  19845. }
  19846. declare module "babylonjs/Meshes/linesMesh" {
  19847. import { Nullable } from "babylonjs/types";
  19848. import { Scene } from "babylonjs/scene";
  19849. import { Color3 } from "babylonjs/Maths/math.color";
  19850. import { Node } from "babylonjs/node";
  19851. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19852. import { Mesh } from "babylonjs/Meshes/mesh";
  19853. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19854. import { Effect } from "babylonjs/Materials/effect";
  19855. import { Material } from "babylonjs/Materials/material";
  19856. import "babylonjs/Shaders/color.fragment";
  19857. import "babylonjs/Shaders/color.vertex";
  19858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19859. /**
  19860. * Line mesh
  19861. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19862. */
  19863. export class LinesMesh extends Mesh {
  19864. /**
  19865. * If vertex color should be applied to the mesh
  19866. */
  19867. readonly useVertexColor?: boolean | undefined;
  19868. /**
  19869. * If vertex alpha should be applied to the mesh
  19870. */
  19871. readonly useVertexAlpha?: boolean | undefined;
  19872. /**
  19873. * Color of the line (Default: White)
  19874. */
  19875. color: Color3;
  19876. /**
  19877. * Alpha of the line (Default: 1)
  19878. */
  19879. alpha: number;
  19880. /**
  19881. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19882. * This margin is expressed in world space coordinates, so its value may vary.
  19883. * Default value is 0.1
  19884. */
  19885. intersectionThreshold: number;
  19886. private _colorShader;
  19887. private color4;
  19888. /**
  19889. * Creates a new LinesMesh
  19890. * @param name defines the name
  19891. * @param scene defines the hosting scene
  19892. * @param parent defines the parent mesh if any
  19893. * @param source defines the optional source LinesMesh used to clone data from
  19894. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19895. * When false, achieved by calling a clone(), also passing False.
  19896. * This will make creation of children, recursive.
  19897. * @param useVertexColor defines if this LinesMesh supports vertex color
  19898. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19899. */
  19900. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19901. /**
  19902. * If vertex color should be applied to the mesh
  19903. */
  19904. useVertexColor?: boolean | undefined,
  19905. /**
  19906. * If vertex alpha should be applied to the mesh
  19907. */
  19908. useVertexAlpha?: boolean | undefined);
  19909. private _addClipPlaneDefine;
  19910. private _removeClipPlaneDefine;
  19911. isReady(): boolean;
  19912. /**
  19913. * Returns the string "LineMesh"
  19914. */
  19915. getClassName(): string;
  19916. /**
  19917. * @hidden
  19918. */
  19919. /**
  19920. * @hidden
  19921. */
  19922. material: Material;
  19923. /**
  19924. * @hidden
  19925. */
  19926. readonly checkCollisions: boolean;
  19927. /** @hidden */
  19928. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19929. /** @hidden */
  19930. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19931. /**
  19932. * Disposes of the line mesh
  19933. * @param doNotRecurse If children should be disposed
  19934. */
  19935. dispose(doNotRecurse?: boolean): void;
  19936. /**
  19937. * Returns a new LineMesh object cloned from the current one.
  19938. */
  19939. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19940. /**
  19941. * Creates a new InstancedLinesMesh object from the mesh model.
  19942. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19943. * @param name defines the name of the new instance
  19944. * @returns a new InstancedLinesMesh
  19945. */
  19946. createInstance(name: string): InstancedLinesMesh;
  19947. }
  19948. /**
  19949. * Creates an instance based on a source LinesMesh
  19950. */
  19951. export class InstancedLinesMesh extends InstancedMesh {
  19952. /**
  19953. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19954. * This margin is expressed in world space coordinates, so its value may vary.
  19955. * Initilized with the intersectionThreshold value of the source LinesMesh
  19956. */
  19957. intersectionThreshold: number;
  19958. constructor(name: string, source: LinesMesh);
  19959. /**
  19960. * Returns the string "InstancedLinesMesh".
  19961. */
  19962. getClassName(): string;
  19963. }
  19964. }
  19965. declare module "babylonjs/Shaders/line.fragment" {
  19966. /** @hidden */
  19967. export var linePixelShader: {
  19968. name: string;
  19969. shader: string;
  19970. };
  19971. }
  19972. declare module "babylonjs/Shaders/line.vertex" {
  19973. /** @hidden */
  19974. export var lineVertexShader: {
  19975. name: string;
  19976. shader: string;
  19977. };
  19978. }
  19979. declare module "babylonjs/Rendering/edgesRenderer" {
  19980. import { Nullable } from "babylonjs/types";
  19981. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19983. import { Vector3 } from "babylonjs/Maths/math.vector";
  19984. import { IDisposable } from "babylonjs/scene";
  19985. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19986. import "babylonjs/Shaders/line.fragment";
  19987. import "babylonjs/Shaders/line.vertex";
  19988. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19989. module "babylonjs/Meshes/abstractMesh" {
  19990. interface AbstractMesh {
  19991. /**
  19992. * Gets the edgesRenderer associated with the mesh
  19993. */
  19994. edgesRenderer: Nullable<EdgesRenderer>;
  19995. }
  19996. }
  19997. module "babylonjs/Meshes/linesMesh" {
  19998. interface LinesMesh {
  19999. /**
  20000. * Enables the edge rendering mode on the mesh.
  20001. * This mode makes the mesh edges visible
  20002. * @param epsilon defines the maximal distance between two angles to detect a face
  20003. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20004. * @returns the currentAbstractMesh
  20005. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20006. */
  20007. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20008. }
  20009. }
  20010. module "babylonjs/Meshes/linesMesh" {
  20011. interface InstancedLinesMesh {
  20012. /**
  20013. * Enables the edge rendering mode on the mesh.
  20014. * This mode makes the mesh edges visible
  20015. * @param epsilon defines the maximal distance between two angles to detect a face
  20016. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20017. * @returns the current InstancedLinesMesh
  20018. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20019. */
  20020. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20021. }
  20022. }
  20023. /**
  20024. * Defines the minimum contract an Edges renderer should follow.
  20025. */
  20026. export interface IEdgesRenderer extends IDisposable {
  20027. /**
  20028. * Gets or sets a boolean indicating if the edgesRenderer is active
  20029. */
  20030. isEnabled: boolean;
  20031. /**
  20032. * Renders the edges of the attached mesh,
  20033. */
  20034. render(): void;
  20035. /**
  20036. * Checks wether or not the edges renderer is ready to render.
  20037. * @return true if ready, otherwise false.
  20038. */
  20039. isReady(): boolean;
  20040. }
  20041. /**
  20042. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20043. */
  20044. export class EdgesRenderer implements IEdgesRenderer {
  20045. /**
  20046. * Define the size of the edges with an orthographic camera
  20047. */
  20048. edgesWidthScalerForOrthographic: number;
  20049. /**
  20050. * Define the size of the edges with a perspective camera
  20051. */
  20052. edgesWidthScalerForPerspective: number;
  20053. protected _source: AbstractMesh;
  20054. protected _linesPositions: number[];
  20055. protected _linesNormals: number[];
  20056. protected _linesIndices: number[];
  20057. protected _epsilon: number;
  20058. protected _indicesCount: number;
  20059. protected _lineShader: ShaderMaterial;
  20060. protected _ib: DataBuffer;
  20061. protected _buffers: {
  20062. [key: string]: Nullable<VertexBuffer>;
  20063. };
  20064. protected _checkVerticesInsteadOfIndices: boolean;
  20065. private _meshRebuildObserver;
  20066. private _meshDisposeObserver;
  20067. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20068. isEnabled: boolean;
  20069. /**
  20070. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20071. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20072. * @param source Mesh used to create edges
  20073. * @param epsilon sum of angles in adjacency to check for edge
  20074. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20075. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20076. */
  20077. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20078. protected _prepareRessources(): void;
  20079. /** @hidden */
  20080. _rebuild(): void;
  20081. /**
  20082. * Releases the required resources for the edges renderer
  20083. */
  20084. dispose(): void;
  20085. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20086. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20087. /**
  20088. * Checks if the pair of p0 and p1 is en edge
  20089. * @param faceIndex
  20090. * @param edge
  20091. * @param faceNormals
  20092. * @param p0
  20093. * @param p1
  20094. * @private
  20095. */
  20096. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20097. /**
  20098. * push line into the position, normal and index buffer
  20099. * @protected
  20100. */
  20101. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20102. /**
  20103. * Generates lines edges from adjacencjes
  20104. * @private
  20105. */
  20106. _generateEdgesLines(): void;
  20107. /**
  20108. * Checks wether or not the edges renderer is ready to render.
  20109. * @return true if ready, otherwise false.
  20110. */
  20111. isReady(): boolean;
  20112. /**
  20113. * Renders the edges of the attached mesh,
  20114. */
  20115. render(): void;
  20116. }
  20117. /**
  20118. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20119. */
  20120. export class LineEdgesRenderer extends EdgesRenderer {
  20121. /**
  20122. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20123. * @param source LineMesh used to generate edges
  20124. * @param epsilon not important (specified angle for edge detection)
  20125. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20126. */
  20127. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20128. /**
  20129. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20130. */
  20131. _generateEdgesLines(): void;
  20132. }
  20133. }
  20134. declare module "babylonjs/Rendering/renderingGroup" {
  20135. import { SmartArray } from "babylonjs/Misc/smartArray";
  20136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20138. import { Nullable } from "babylonjs/types";
  20139. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20140. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20141. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20142. import { Material } from "babylonjs/Materials/material";
  20143. import { Scene } from "babylonjs/scene";
  20144. /**
  20145. * This represents the object necessary to create a rendering group.
  20146. * This is exclusively used and created by the rendering manager.
  20147. * To modify the behavior, you use the available helpers in your scene or meshes.
  20148. * @hidden
  20149. */
  20150. export class RenderingGroup {
  20151. index: number;
  20152. private static _zeroVector;
  20153. private _scene;
  20154. private _opaqueSubMeshes;
  20155. private _transparentSubMeshes;
  20156. private _alphaTestSubMeshes;
  20157. private _depthOnlySubMeshes;
  20158. private _particleSystems;
  20159. private _spriteManagers;
  20160. private _opaqueSortCompareFn;
  20161. private _alphaTestSortCompareFn;
  20162. private _transparentSortCompareFn;
  20163. private _renderOpaque;
  20164. private _renderAlphaTest;
  20165. private _renderTransparent;
  20166. /** @hidden */
  20167. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20168. onBeforeTransparentRendering: () => void;
  20169. /**
  20170. * Set the opaque sort comparison function.
  20171. * If null the sub meshes will be render in the order they were created
  20172. */
  20173. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20174. /**
  20175. * Set the alpha test sort comparison function.
  20176. * If null the sub meshes will be render in the order they were created
  20177. */
  20178. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20179. /**
  20180. * Set the transparent sort comparison function.
  20181. * If null the sub meshes will be render in the order they were created
  20182. */
  20183. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20184. /**
  20185. * Creates a new rendering group.
  20186. * @param index The rendering group index
  20187. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20188. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20189. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20190. */
  20191. 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>);
  20192. /**
  20193. * Render all the sub meshes contained in the group.
  20194. * @param customRenderFunction Used to override the default render behaviour of the group.
  20195. * @returns true if rendered some submeshes.
  20196. */
  20197. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20198. /**
  20199. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20200. * @param subMeshes The submeshes to render
  20201. */
  20202. private renderOpaqueSorted;
  20203. /**
  20204. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20205. * @param subMeshes The submeshes to render
  20206. */
  20207. private renderAlphaTestSorted;
  20208. /**
  20209. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20210. * @param subMeshes The submeshes to render
  20211. */
  20212. private renderTransparentSorted;
  20213. /**
  20214. * Renders the submeshes in a specified order.
  20215. * @param subMeshes The submeshes to sort before render
  20216. * @param sortCompareFn The comparison function use to sort
  20217. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20218. * @param transparent Specifies to activate blending if true
  20219. */
  20220. private static renderSorted;
  20221. /**
  20222. * Renders the submeshes in the order they were dispatched (no sort applied).
  20223. * @param subMeshes The submeshes to render
  20224. */
  20225. private static renderUnsorted;
  20226. /**
  20227. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20228. * are rendered back to front if in the same alpha index.
  20229. *
  20230. * @param a The first submesh
  20231. * @param b The second submesh
  20232. * @returns The result of the comparison
  20233. */
  20234. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20235. /**
  20236. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20237. * are rendered back to front.
  20238. *
  20239. * @param a The first submesh
  20240. * @param b The second submesh
  20241. * @returns The result of the comparison
  20242. */
  20243. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20244. /**
  20245. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20246. * are rendered front to back (prevent overdraw).
  20247. *
  20248. * @param a The first submesh
  20249. * @param b The second submesh
  20250. * @returns The result of the comparison
  20251. */
  20252. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20253. /**
  20254. * Resets the different lists of submeshes to prepare a new frame.
  20255. */
  20256. prepare(): void;
  20257. dispose(): void;
  20258. /**
  20259. * Inserts the submesh in its correct queue depending on its material.
  20260. * @param subMesh The submesh to dispatch
  20261. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20262. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20263. */
  20264. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20265. dispatchSprites(spriteManager: ISpriteManager): void;
  20266. dispatchParticles(particleSystem: IParticleSystem): void;
  20267. private _renderParticles;
  20268. private _renderSprites;
  20269. }
  20270. }
  20271. declare module "babylonjs/Rendering/renderingManager" {
  20272. import { Nullable } from "babylonjs/types";
  20273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20274. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20275. import { SmartArray } from "babylonjs/Misc/smartArray";
  20276. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20277. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20278. import { Material } from "babylonjs/Materials/material";
  20279. import { Scene } from "babylonjs/scene";
  20280. import { Camera } from "babylonjs/Cameras/camera";
  20281. /**
  20282. * Interface describing the different options available in the rendering manager
  20283. * regarding Auto Clear between groups.
  20284. */
  20285. export interface IRenderingManagerAutoClearSetup {
  20286. /**
  20287. * Defines whether or not autoclear is enable.
  20288. */
  20289. autoClear: boolean;
  20290. /**
  20291. * Defines whether or not to autoclear the depth buffer.
  20292. */
  20293. depth: boolean;
  20294. /**
  20295. * Defines whether or not to autoclear the stencil buffer.
  20296. */
  20297. stencil: boolean;
  20298. }
  20299. /**
  20300. * This class is used by the onRenderingGroupObservable
  20301. */
  20302. export class RenderingGroupInfo {
  20303. /**
  20304. * The Scene that being rendered
  20305. */
  20306. scene: Scene;
  20307. /**
  20308. * The camera currently used for the rendering pass
  20309. */
  20310. camera: Nullable<Camera>;
  20311. /**
  20312. * The ID of the renderingGroup being processed
  20313. */
  20314. renderingGroupId: number;
  20315. }
  20316. /**
  20317. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20318. * It is enable to manage the different groups as well as the different necessary sort functions.
  20319. * This should not be used directly aside of the few static configurations
  20320. */
  20321. export class RenderingManager {
  20322. /**
  20323. * The max id used for rendering groups (not included)
  20324. */
  20325. static MAX_RENDERINGGROUPS: number;
  20326. /**
  20327. * The min id used for rendering groups (included)
  20328. */
  20329. static MIN_RENDERINGGROUPS: number;
  20330. /**
  20331. * Used to globally prevent autoclearing scenes.
  20332. */
  20333. static AUTOCLEAR: boolean;
  20334. /**
  20335. * @hidden
  20336. */
  20337. _useSceneAutoClearSetup: boolean;
  20338. private _scene;
  20339. private _renderingGroups;
  20340. private _depthStencilBufferAlreadyCleaned;
  20341. private _autoClearDepthStencil;
  20342. private _customOpaqueSortCompareFn;
  20343. private _customAlphaTestSortCompareFn;
  20344. private _customTransparentSortCompareFn;
  20345. private _renderingGroupInfo;
  20346. /**
  20347. * Instantiates a new rendering group for a particular scene
  20348. * @param scene Defines the scene the groups belongs to
  20349. */
  20350. constructor(scene: Scene);
  20351. private _clearDepthStencilBuffer;
  20352. /**
  20353. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20354. * @hidden
  20355. */
  20356. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20357. /**
  20358. * Resets the different information of the group to prepare a new frame
  20359. * @hidden
  20360. */
  20361. reset(): void;
  20362. /**
  20363. * Dispose and release the group and its associated resources.
  20364. * @hidden
  20365. */
  20366. dispose(): void;
  20367. /**
  20368. * Clear the info related to rendering groups preventing retention points during dispose.
  20369. */
  20370. freeRenderingGroups(): void;
  20371. private _prepareRenderingGroup;
  20372. /**
  20373. * Add a sprite manager to the rendering manager in order to render it this frame.
  20374. * @param spriteManager Define the sprite manager to render
  20375. */
  20376. dispatchSprites(spriteManager: ISpriteManager): void;
  20377. /**
  20378. * Add a particle system to the rendering manager in order to render it this frame.
  20379. * @param particleSystem Define the particle system to render
  20380. */
  20381. dispatchParticles(particleSystem: IParticleSystem): void;
  20382. /**
  20383. * Add a submesh to the manager in order to render it this frame
  20384. * @param subMesh The submesh to dispatch
  20385. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20386. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20387. */
  20388. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20389. /**
  20390. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20391. * This allowed control for front to back rendering or reversly depending of the special needs.
  20392. *
  20393. * @param renderingGroupId The rendering group id corresponding to its index
  20394. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20395. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20396. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20397. */
  20398. 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;
  20399. /**
  20400. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20401. *
  20402. * @param renderingGroupId The rendering group id corresponding to its index
  20403. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20404. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20405. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20406. */
  20407. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20408. /**
  20409. * Gets the current auto clear configuration for one rendering group of the rendering
  20410. * manager.
  20411. * @param index the rendering group index to get the information for
  20412. * @returns The auto clear setup for the requested rendering group
  20413. */
  20414. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20415. }
  20416. }
  20417. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20418. import { Observable } from "babylonjs/Misc/observable";
  20419. import { SmartArray } from "babylonjs/Misc/smartArray";
  20420. import { Nullable } from "babylonjs/types";
  20421. import { Camera } from "babylonjs/Cameras/camera";
  20422. import { Scene } from "babylonjs/scene";
  20423. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20424. import { Color4 } from "babylonjs/Maths/math.color";
  20425. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20427. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20429. import { Texture } from "babylonjs/Materials/Textures/texture";
  20430. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20431. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20432. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20433. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20434. import { Engine } from "babylonjs/Engines/engine";
  20435. /**
  20436. * This Helps creating a texture that will be created from a camera in your scene.
  20437. * It is basically a dynamic texture that could be used to create special effects for instance.
  20438. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20439. */
  20440. export class RenderTargetTexture extends Texture {
  20441. isCube: boolean;
  20442. /**
  20443. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20444. */
  20445. static readonly REFRESHRATE_RENDER_ONCE: number;
  20446. /**
  20447. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20448. */
  20449. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20450. /**
  20451. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20452. * the central point of your effect and can save a lot of performances.
  20453. */
  20454. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20455. /**
  20456. * Use this predicate to dynamically define the list of mesh you want to render.
  20457. * If set, the renderList property will be overwritten.
  20458. */
  20459. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20460. private _renderList;
  20461. /**
  20462. * Use this list to define the list of mesh you want to render.
  20463. */
  20464. renderList: Nullable<Array<AbstractMesh>>;
  20465. private _hookArray;
  20466. /**
  20467. * Define if particles should be rendered in your texture.
  20468. */
  20469. renderParticles: boolean;
  20470. /**
  20471. * Define if sprites should be rendered in your texture.
  20472. */
  20473. renderSprites: boolean;
  20474. /**
  20475. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20476. */
  20477. coordinatesMode: number;
  20478. /**
  20479. * Define the camera used to render the texture.
  20480. */
  20481. activeCamera: Nullable<Camera>;
  20482. /**
  20483. * Override the render function of the texture with your own one.
  20484. */
  20485. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20486. /**
  20487. * Define if camera post processes should be use while rendering the texture.
  20488. */
  20489. useCameraPostProcesses: boolean;
  20490. /**
  20491. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20492. */
  20493. ignoreCameraViewport: boolean;
  20494. private _postProcessManager;
  20495. private _postProcesses;
  20496. private _resizeObserver;
  20497. /**
  20498. * An event triggered when the texture is unbind.
  20499. */
  20500. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20501. /**
  20502. * An event triggered when the texture is unbind.
  20503. */
  20504. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20505. private _onAfterUnbindObserver;
  20506. /**
  20507. * Set a after unbind callback in the texture.
  20508. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20509. */
  20510. onAfterUnbind: () => void;
  20511. /**
  20512. * An event triggered before rendering the texture
  20513. */
  20514. onBeforeRenderObservable: Observable<number>;
  20515. private _onBeforeRenderObserver;
  20516. /**
  20517. * Set a before render callback in the texture.
  20518. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20519. */
  20520. onBeforeRender: (faceIndex: number) => void;
  20521. /**
  20522. * An event triggered after rendering the texture
  20523. */
  20524. onAfterRenderObservable: Observable<number>;
  20525. private _onAfterRenderObserver;
  20526. /**
  20527. * Set a after render callback in the texture.
  20528. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20529. */
  20530. onAfterRender: (faceIndex: number) => void;
  20531. /**
  20532. * An event triggered after the texture clear
  20533. */
  20534. onClearObservable: Observable<Engine>;
  20535. private _onClearObserver;
  20536. /**
  20537. * Set a clear callback in the texture.
  20538. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20539. */
  20540. onClear: (Engine: Engine) => void;
  20541. /**
  20542. * An event triggered when the texture is resized.
  20543. */
  20544. onResizeObservable: Observable<RenderTargetTexture>;
  20545. /**
  20546. * Define the clear color of the Render Target if it should be different from the scene.
  20547. */
  20548. clearColor: Color4;
  20549. protected _size: number | {
  20550. width: number;
  20551. height: number;
  20552. };
  20553. protected _initialSizeParameter: number | {
  20554. width: number;
  20555. height: number;
  20556. } | {
  20557. ratio: number;
  20558. };
  20559. protected _sizeRatio: Nullable<number>;
  20560. /** @hidden */
  20561. _generateMipMaps: boolean;
  20562. protected _renderingManager: RenderingManager;
  20563. /** @hidden */
  20564. _waitingRenderList: string[];
  20565. protected _doNotChangeAspectRatio: boolean;
  20566. protected _currentRefreshId: number;
  20567. protected _refreshRate: number;
  20568. protected _textureMatrix: Matrix;
  20569. protected _samples: number;
  20570. protected _renderTargetOptions: RenderTargetCreationOptions;
  20571. /**
  20572. * Gets render target creation options that were used.
  20573. */
  20574. readonly renderTargetOptions: RenderTargetCreationOptions;
  20575. protected _engine: Engine;
  20576. protected _onRatioRescale(): void;
  20577. /**
  20578. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20579. * It must define where the camera used to render the texture is set
  20580. */
  20581. boundingBoxPosition: Vector3;
  20582. private _boundingBoxSize;
  20583. /**
  20584. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20585. * When defined, the cubemap will switch to local mode
  20586. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20587. * @example https://www.babylonjs-playground.com/#RNASML
  20588. */
  20589. boundingBoxSize: Vector3;
  20590. /**
  20591. * In case the RTT has been created with a depth texture, get the associated
  20592. * depth texture.
  20593. * Otherwise, return null.
  20594. */
  20595. depthStencilTexture: Nullable<InternalTexture>;
  20596. /**
  20597. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20598. * or used a shadow, depth texture...
  20599. * @param name The friendly name of the texture
  20600. * @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)
  20601. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20602. * @param generateMipMaps True if mip maps need to be generated after render.
  20603. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20604. * @param type The type of the buffer in the RTT (int, half float, float...)
  20605. * @param isCube True if a cube texture needs to be created
  20606. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20607. * @param generateDepthBuffer True to generate a depth buffer
  20608. * @param generateStencilBuffer True to generate a stencil buffer
  20609. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20610. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20611. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20612. */
  20613. constructor(name: string, size: number | {
  20614. width: number;
  20615. height: number;
  20616. } | {
  20617. ratio: number;
  20618. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20619. /**
  20620. * Creates a depth stencil texture.
  20621. * This is only available in WebGL 2 or with the depth texture extension available.
  20622. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20623. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20624. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20625. */
  20626. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20627. private _processSizeParameter;
  20628. /**
  20629. * Define the number of samples to use in case of MSAA.
  20630. * It defaults to one meaning no MSAA has been enabled.
  20631. */
  20632. samples: number;
  20633. /**
  20634. * Resets the refresh counter of the texture and start bak from scratch.
  20635. * Could be useful to regenerate the texture if it is setup to render only once.
  20636. */
  20637. resetRefreshCounter(): void;
  20638. /**
  20639. * Define the refresh rate of the texture or the rendering frequency.
  20640. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20641. */
  20642. refreshRate: number;
  20643. /**
  20644. * Adds a post process to the render target rendering passes.
  20645. * @param postProcess define the post process to add
  20646. */
  20647. addPostProcess(postProcess: PostProcess): void;
  20648. /**
  20649. * Clear all the post processes attached to the render target
  20650. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20651. */
  20652. clearPostProcesses(dispose?: boolean): void;
  20653. /**
  20654. * Remove one of the post process from the list of attached post processes to the texture
  20655. * @param postProcess define the post process to remove from the list
  20656. */
  20657. removePostProcess(postProcess: PostProcess): void;
  20658. /** @hidden */
  20659. _shouldRender(): boolean;
  20660. /**
  20661. * Gets the actual render size of the texture.
  20662. * @returns the width of the render size
  20663. */
  20664. getRenderSize(): number;
  20665. /**
  20666. * Gets the actual render width of the texture.
  20667. * @returns the width of the render size
  20668. */
  20669. getRenderWidth(): number;
  20670. /**
  20671. * Gets the actual render height of the texture.
  20672. * @returns the height of the render size
  20673. */
  20674. getRenderHeight(): number;
  20675. /**
  20676. * Get if the texture can be rescaled or not.
  20677. */
  20678. readonly canRescale: boolean;
  20679. /**
  20680. * Resize the texture using a ratio.
  20681. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20682. */
  20683. scale(ratio: number): void;
  20684. /**
  20685. * Get the texture reflection matrix used to rotate/transform the reflection.
  20686. * @returns the reflection matrix
  20687. */
  20688. getReflectionTextureMatrix(): Matrix;
  20689. /**
  20690. * Resize the texture to a new desired size.
  20691. * Be carrefull as it will recreate all the data in the new texture.
  20692. * @param size Define the new size. It can be:
  20693. * - a number for squared texture,
  20694. * - an object containing { width: number, height: number }
  20695. * - or an object containing a ratio { ratio: number }
  20696. */
  20697. resize(size: number | {
  20698. width: number;
  20699. height: number;
  20700. } | {
  20701. ratio: number;
  20702. }): void;
  20703. /**
  20704. * Renders all the objects from the render list into the texture.
  20705. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20706. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20707. */
  20708. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20709. private _bestReflectionRenderTargetDimension;
  20710. /**
  20711. * @hidden
  20712. * @param faceIndex face index to bind to if this is a cubetexture
  20713. */
  20714. _bindFrameBuffer(faceIndex?: number): void;
  20715. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20716. private renderToTarget;
  20717. /**
  20718. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20719. * This allowed control for front to back rendering or reversly depending of the special needs.
  20720. *
  20721. * @param renderingGroupId The rendering group id corresponding to its index
  20722. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20723. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20724. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20725. */
  20726. 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;
  20727. /**
  20728. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20729. *
  20730. * @param renderingGroupId The rendering group id corresponding to its index
  20731. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20732. */
  20733. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20734. /**
  20735. * Clones the texture.
  20736. * @returns the cloned texture
  20737. */
  20738. clone(): RenderTargetTexture;
  20739. /**
  20740. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20741. * @returns The JSON representation of the texture
  20742. */
  20743. serialize(): any;
  20744. /**
  20745. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20746. */
  20747. disposeFramebufferObjects(): void;
  20748. /**
  20749. * Dispose the texture and release its associated resources.
  20750. */
  20751. dispose(): void;
  20752. /** @hidden */
  20753. _rebuild(): void;
  20754. /**
  20755. * Clear the info related to rendering groups preventing retention point in material dispose.
  20756. */
  20757. freeRenderingGroups(): void;
  20758. /**
  20759. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20760. * @returns the view count
  20761. */
  20762. getViewCount(): number;
  20763. }
  20764. }
  20765. declare module "babylonjs/Materials/material" {
  20766. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20767. import { SmartArray } from "babylonjs/Misc/smartArray";
  20768. import { Observable } from "babylonjs/Misc/observable";
  20769. import { Nullable } from "babylonjs/types";
  20770. import { Scene } from "babylonjs/scene";
  20771. import { Matrix } from "babylonjs/Maths/math.vector";
  20772. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20774. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20775. import { Effect } from "babylonjs/Materials/effect";
  20776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20778. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20779. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20780. import { Mesh } from "babylonjs/Meshes/mesh";
  20781. import { Animation } from "babylonjs/Animations/animation";
  20782. /**
  20783. * Base class for the main features of a material in Babylon.js
  20784. */
  20785. export class Material implements IAnimatable {
  20786. /**
  20787. * Returns the triangle fill mode
  20788. */
  20789. static readonly TriangleFillMode: number;
  20790. /**
  20791. * Returns the wireframe mode
  20792. */
  20793. static readonly WireFrameFillMode: number;
  20794. /**
  20795. * Returns the point fill mode
  20796. */
  20797. static readonly PointFillMode: number;
  20798. /**
  20799. * Returns the point list draw mode
  20800. */
  20801. static readonly PointListDrawMode: number;
  20802. /**
  20803. * Returns the line list draw mode
  20804. */
  20805. static readonly LineListDrawMode: number;
  20806. /**
  20807. * Returns the line loop draw mode
  20808. */
  20809. static readonly LineLoopDrawMode: number;
  20810. /**
  20811. * Returns the line strip draw mode
  20812. */
  20813. static readonly LineStripDrawMode: number;
  20814. /**
  20815. * Returns the triangle strip draw mode
  20816. */
  20817. static readonly TriangleStripDrawMode: number;
  20818. /**
  20819. * Returns the triangle fan draw mode
  20820. */
  20821. static readonly TriangleFanDrawMode: number;
  20822. /**
  20823. * Stores the clock-wise side orientation
  20824. */
  20825. static readonly ClockWiseSideOrientation: number;
  20826. /**
  20827. * Stores the counter clock-wise side orientation
  20828. */
  20829. static readonly CounterClockWiseSideOrientation: number;
  20830. /**
  20831. * The dirty texture flag value
  20832. */
  20833. static readonly TextureDirtyFlag: number;
  20834. /**
  20835. * The dirty light flag value
  20836. */
  20837. static readonly LightDirtyFlag: number;
  20838. /**
  20839. * The dirty fresnel flag value
  20840. */
  20841. static readonly FresnelDirtyFlag: number;
  20842. /**
  20843. * The dirty attribute flag value
  20844. */
  20845. static readonly AttributesDirtyFlag: number;
  20846. /**
  20847. * The dirty misc flag value
  20848. */
  20849. static readonly MiscDirtyFlag: number;
  20850. /**
  20851. * The all dirty flag value
  20852. */
  20853. static readonly AllDirtyFlag: number;
  20854. /**
  20855. * The ID of the material
  20856. */
  20857. id: string;
  20858. /**
  20859. * Gets or sets the unique id of the material
  20860. */
  20861. uniqueId: number;
  20862. /**
  20863. * The name of the material
  20864. */
  20865. name: string;
  20866. /**
  20867. * Gets or sets user defined metadata
  20868. */
  20869. metadata: any;
  20870. /**
  20871. * For internal use only. Please do not use.
  20872. */
  20873. reservedDataStore: any;
  20874. /**
  20875. * Specifies if the ready state should be checked on each call
  20876. */
  20877. checkReadyOnEveryCall: boolean;
  20878. /**
  20879. * Specifies if the ready state should be checked once
  20880. */
  20881. checkReadyOnlyOnce: boolean;
  20882. /**
  20883. * The state of the material
  20884. */
  20885. state: string;
  20886. /**
  20887. * The alpha value of the material
  20888. */
  20889. protected _alpha: number;
  20890. /**
  20891. * List of inspectable custom properties (used by the Inspector)
  20892. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20893. */
  20894. inspectableCustomProperties: IInspectable[];
  20895. /**
  20896. * Sets the alpha value of the material
  20897. */
  20898. /**
  20899. * Gets the alpha value of the material
  20900. */
  20901. alpha: number;
  20902. /**
  20903. * Specifies if back face culling is enabled
  20904. */
  20905. protected _backFaceCulling: boolean;
  20906. /**
  20907. * Sets the back-face culling state
  20908. */
  20909. /**
  20910. * Gets the back-face culling state
  20911. */
  20912. backFaceCulling: boolean;
  20913. /**
  20914. * Stores the value for side orientation
  20915. */
  20916. sideOrientation: number;
  20917. /**
  20918. * Callback triggered when the material is compiled
  20919. */
  20920. onCompiled: Nullable<(effect: Effect) => void>;
  20921. /**
  20922. * Callback triggered when an error occurs
  20923. */
  20924. onError: Nullable<(effect: Effect, errors: string) => void>;
  20925. /**
  20926. * Callback triggered to get the render target textures
  20927. */
  20928. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20929. /**
  20930. * Gets a boolean indicating that current material needs to register RTT
  20931. */
  20932. readonly hasRenderTargetTextures: boolean;
  20933. /**
  20934. * Specifies if the material should be serialized
  20935. */
  20936. doNotSerialize: boolean;
  20937. /**
  20938. * @hidden
  20939. */
  20940. _storeEffectOnSubMeshes: boolean;
  20941. /**
  20942. * Stores the animations for the material
  20943. */
  20944. animations: Nullable<Array<Animation>>;
  20945. /**
  20946. * An event triggered when the material is disposed
  20947. */
  20948. onDisposeObservable: Observable<Material>;
  20949. /**
  20950. * An observer which watches for dispose events
  20951. */
  20952. private _onDisposeObserver;
  20953. private _onUnBindObservable;
  20954. /**
  20955. * Called during a dispose event
  20956. */
  20957. onDispose: () => void;
  20958. private _onBindObservable;
  20959. /**
  20960. * An event triggered when the material is bound
  20961. */
  20962. readonly onBindObservable: Observable<AbstractMesh>;
  20963. /**
  20964. * An observer which watches for bind events
  20965. */
  20966. private _onBindObserver;
  20967. /**
  20968. * Called during a bind event
  20969. */
  20970. onBind: (Mesh: AbstractMesh) => void;
  20971. /**
  20972. * An event triggered when the material is unbound
  20973. */
  20974. readonly onUnBindObservable: Observable<Material>;
  20975. /**
  20976. * Stores the value of the alpha mode
  20977. */
  20978. private _alphaMode;
  20979. /**
  20980. * Sets the value of the alpha mode.
  20981. *
  20982. * | Value | Type | Description |
  20983. * | --- | --- | --- |
  20984. * | 0 | ALPHA_DISABLE | |
  20985. * | 1 | ALPHA_ADD | |
  20986. * | 2 | ALPHA_COMBINE | |
  20987. * | 3 | ALPHA_SUBTRACT | |
  20988. * | 4 | ALPHA_MULTIPLY | |
  20989. * | 5 | ALPHA_MAXIMIZED | |
  20990. * | 6 | ALPHA_ONEONE | |
  20991. * | 7 | ALPHA_PREMULTIPLIED | |
  20992. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20993. * | 9 | ALPHA_INTERPOLATE | |
  20994. * | 10 | ALPHA_SCREENMODE | |
  20995. *
  20996. */
  20997. /**
  20998. * Gets the value of the alpha mode
  20999. */
  21000. alphaMode: number;
  21001. /**
  21002. * Stores the state of the need depth pre-pass value
  21003. */
  21004. private _needDepthPrePass;
  21005. /**
  21006. * Sets the need depth pre-pass value
  21007. */
  21008. /**
  21009. * Gets the depth pre-pass value
  21010. */
  21011. needDepthPrePass: boolean;
  21012. /**
  21013. * Specifies if depth writing should be disabled
  21014. */
  21015. disableDepthWrite: boolean;
  21016. /**
  21017. * Specifies if depth writing should be forced
  21018. */
  21019. forceDepthWrite: boolean;
  21020. /**
  21021. * Specifies if there should be a separate pass for culling
  21022. */
  21023. separateCullingPass: boolean;
  21024. /**
  21025. * Stores the state specifing if fog should be enabled
  21026. */
  21027. private _fogEnabled;
  21028. /**
  21029. * Sets the state for enabling fog
  21030. */
  21031. /**
  21032. * Gets the value of the fog enabled state
  21033. */
  21034. fogEnabled: boolean;
  21035. /**
  21036. * Stores the size of points
  21037. */
  21038. pointSize: number;
  21039. /**
  21040. * Stores the z offset value
  21041. */
  21042. zOffset: number;
  21043. /**
  21044. * Gets a value specifying if wireframe mode is enabled
  21045. */
  21046. /**
  21047. * Sets the state of wireframe mode
  21048. */
  21049. wireframe: boolean;
  21050. /**
  21051. * Gets the value specifying if point clouds are enabled
  21052. */
  21053. /**
  21054. * Sets the state of point cloud mode
  21055. */
  21056. pointsCloud: boolean;
  21057. /**
  21058. * Gets the material fill mode
  21059. */
  21060. /**
  21061. * Sets the material fill mode
  21062. */
  21063. fillMode: number;
  21064. /**
  21065. * @hidden
  21066. * Stores the effects for the material
  21067. */
  21068. _effect: Nullable<Effect>;
  21069. /**
  21070. * @hidden
  21071. * Specifies if the material was previously ready
  21072. */
  21073. _wasPreviouslyReady: boolean;
  21074. /**
  21075. * Specifies if uniform buffers should be used
  21076. */
  21077. private _useUBO;
  21078. /**
  21079. * Stores a reference to the scene
  21080. */
  21081. private _scene;
  21082. /**
  21083. * Stores the fill mode state
  21084. */
  21085. private _fillMode;
  21086. /**
  21087. * Specifies if the depth write state should be cached
  21088. */
  21089. private _cachedDepthWriteState;
  21090. /**
  21091. * Stores the uniform buffer
  21092. */
  21093. protected _uniformBuffer: UniformBuffer;
  21094. /** @hidden */
  21095. _indexInSceneMaterialArray: number;
  21096. /** @hidden */
  21097. meshMap: Nullable<{
  21098. [id: string]: AbstractMesh | undefined;
  21099. }>;
  21100. /**
  21101. * Creates a material instance
  21102. * @param name defines the name of the material
  21103. * @param scene defines the scene to reference
  21104. * @param doNotAdd specifies if the material should be added to the scene
  21105. */
  21106. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21107. /**
  21108. * Returns a string representation of the current material
  21109. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21110. * @returns a string with material information
  21111. */
  21112. toString(fullDetails?: boolean): string;
  21113. /**
  21114. * Gets the class name of the material
  21115. * @returns a string with the class name of the material
  21116. */
  21117. getClassName(): string;
  21118. /**
  21119. * Specifies if updates for the material been locked
  21120. */
  21121. readonly isFrozen: boolean;
  21122. /**
  21123. * Locks updates for the material
  21124. */
  21125. freeze(): void;
  21126. /**
  21127. * Unlocks updates for the material
  21128. */
  21129. unfreeze(): void;
  21130. /**
  21131. * Specifies if the material is ready to be used
  21132. * @param mesh defines the mesh to check
  21133. * @param useInstances specifies if instances should be used
  21134. * @returns a boolean indicating if the material is ready to be used
  21135. */
  21136. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21137. /**
  21138. * Specifies that the submesh is ready to be used
  21139. * @param mesh defines the mesh to check
  21140. * @param subMesh defines which submesh to check
  21141. * @param useInstances specifies that instances should be used
  21142. * @returns a boolean indicating that the submesh is ready or not
  21143. */
  21144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21145. /**
  21146. * Returns the material effect
  21147. * @returns the effect associated with the material
  21148. */
  21149. getEffect(): Nullable<Effect>;
  21150. /**
  21151. * Returns the current scene
  21152. * @returns a Scene
  21153. */
  21154. getScene(): Scene;
  21155. /**
  21156. * Specifies if the material will require alpha blending
  21157. * @returns a boolean specifying if alpha blending is needed
  21158. */
  21159. needAlphaBlending(): boolean;
  21160. /**
  21161. * Specifies if the mesh will require alpha blending
  21162. * @param mesh defines the mesh to check
  21163. * @returns a boolean specifying if alpha blending is needed for the mesh
  21164. */
  21165. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21166. /**
  21167. * Specifies if this material should be rendered in alpha test mode
  21168. * @returns a boolean specifying if an alpha test is needed.
  21169. */
  21170. needAlphaTesting(): boolean;
  21171. /**
  21172. * Gets the texture used for the alpha test
  21173. * @returns the texture to use for alpha testing
  21174. */
  21175. getAlphaTestTexture(): Nullable<BaseTexture>;
  21176. /**
  21177. * Marks the material to indicate that it needs to be re-calculated
  21178. */
  21179. markDirty(): void;
  21180. /** @hidden */
  21181. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21182. /**
  21183. * Binds the material to the mesh
  21184. * @param world defines the world transformation matrix
  21185. * @param mesh defines the mesh to bind the material to
  21186. */
  21187. bind(world: Matrix, mesh?: Mesh): void;
  21188. /**
  21189. * Binds the submesh to the material
  21190. * @param world defines the world transformation matrix
  21191. * @param mesh defines the mesh containing the submesh
  21192. * @param subMesh defines the submesh to bind the material to
  21193. */
  21194. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21195. /**
  21196. * Binds the world matrix to the material
  21197. * @param world defines the world transformation matrix
  21198. */
  21199. bindOnlyWorldMatrix(world: Matrix): void;
  21200. /**
  21201. * Binds the scene's uniform buffer to the effect.
  21202. * @param effect defines the effect to bind to the scene uniform buffer
  21203. * @param sceneUbo defines the uniform buffer storing scene data
  21204. */
  21205. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21206. /**
  21207. * Binds the view matrix to the effect
  21208. * @param effect defines the effect to bind the view matrix to
  21209. */
  21210. bindView(effect: Effect): void;
  21211. /**
  21212. * Binds the view projection matrix to the effect
  21213. * @param effect defines the effect to bind the view projection matrix to
  21214. */
  21215. bindViewProjection(effect: Effect): void;
  21216. /**
  21217. * Specifies if material alpha testing should be turned on for the mesh
  21218. * @param mesh defines the mesh to check
  21219. */
  21220. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21221. /**
  21222. * Processes to execute after binding the material to a mesh
  21223. * @param mesh defines the rendered mesh
  21224. */
  21225. protected _afterBind(mesh?: Mesh): void;
  21226. /**
  21227. * Unbinds the material from the mesh
  21228. */
  21229. unbind(): void;
  21230. /**
  21231. * Gets the active textures from the material
  21232. * @returns an array of textures
  21233. */
  21234. getActiveTextures(): BaseTexture[];
  21235. /**
  21236. * Specifies if the material uses a texture
  21237. * @param texture defines the texture to check against the material
  21238. * @returns a boolean specifying if the material uses the texture
  21239. */
  21240. hasTexture(texture: BaseTexture): boolean;
  21241. /**
  21242. * Makes a duplicate of the material, and gives it a new name
  21243. * @param name defines the new name for the duplicated material
  21244. * @returns the cloned material
  21245. */
  21246. clone(name: string): Nullable<Material>;
  21247. /**
  21248. * Gets the meshes bound to the material
  21249. * @returns an array of meshes bound to the material
  21250. */
  21251. getBindedMeshes(): AbstractMesh[];
  21252. /**
  21253. * Force shader compilation
  21254. * @param mesh defines the mesh associated with this material
  21255. * @param onCompiled defines a function to execute once the material is compiled
  21256. * @param options defines the options to configure the compilation
  21257. * @param onError defines a function to execute if the material fails compiling
  21258. */
  21259. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21260. clipPlane: boolean;
  21261. }>, onError?: (reason: string) => void): void;
  21262. /**
  21263. * Force shader compilation
  21264. * @param mesh defines the mesh that will use this material
  21265. * @param options defines additional options for compiling the shaders
  21266. * @returns a promise that resolves when the compilation completes
  21267. */
  21268. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21269. clipPlane: boolean;
  21270. }>): Promise<void>;
  21271. private static readonly _AllDirtyCallBack;
  21272. private static readonly _ImageProcessingDirtyCallBack;
  21273. private static readonly _TextureDirtyCallBack;
  21274. private static readonly _FresnelDirtyCallBack;
  21275. private static readonly _MiscDirtyCallBack;
  21276. private static readonly _LightsDirtyCallBack;
  21277. private static readonly _AttributeDirtyCallBack;
  21278. private static _FresnelAndMiscDirtyCallBack;
  21279. private static _TextureAndMiscDirtyCallBack;
  21280. private static readonly _DirtyCallbackArray;
  21281. private static readonly _RunDirtyCallBacks;
  21282. /**
  21283. * Marks a define in the material to indicate that it needs to be re-computed
  21284. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21285. */
  21286. markAsDirty(flag: number): void;
  21287. /**
  21288. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21289. * @param func defines a function which checks material defines against the submeshes
  21290. */
  21291. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21292. /**
  21293. * Indicates that we need to re-calculated for all submeshes
  21294. */
  21295. protected _markAllSubMeshesAsAllDirty(): void;
  21296. /**
  21297. * Indicates that image processing needs to be re-calculated for all submeshes
  21298. */
  21299. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21300. /**
  21301. * Indicates that textures need to be re-calculated for all submeshes
  21302. */
  21303. protected _markAllSubMeshesAsTexturesDirty(): void;
  21304. /**
  21305. * Indicates that fresnel needs to be re-calculated for all submeshes
  21306. */
  21307. protected _markAllSubMeshesAsFresnelDirty(): void;
  21308. /**
  21309. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21310. */
  21311. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21312. /**
  21313. * Indicates that lights need to be re-calculated for all submeshes
  21314. */
  21315. protected _markAllSubMeshesAsLightsDirty(): void;
  21316. /**
  21317. * Indicates that attributes need to be re-calculated for all submeshes
  21318. */
  21319. protected _markAllSubMeshesAsAttributesDirty(): void;
  21320. /**
  21321. * Indicates that misc needs to be re-calculated for all submeshes
  21322. */
  21323. protected _markAllSubMeshesAsMiscDirty(): void;
  21324. /**
  21325. * Indicates that textures and misc need to be re-calculated for all submeshes
  21326. */
  21327. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21328. /**
  21329. * Disposes the material
  21330. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21331. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21332. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21333. */
  21334. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21335. /** @hidden */
  21336. private releaseVertexArrayObject;
  21337. /**
  21338. * Serializes this material
  21339. * @returns the serialized material object
  21340. */
  21341. serialize(): any;
  21342. /**
  21343. * Creates a material from parsed material data
  21344. * @param parsedMaterial defines parsed material data
  21345. * @param scene defines the hosting scene
  21346. * @param rootUrl defines the root URL to use to load textures
  21347. * @returns a new material
  21348. */
  21349. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21350. }
  21351. }
  21352. declare module "babylonjs/Materials/multiMaterial" {
  21353. import { Nullable } from "babylonjs/types";
  21354. import { Scene } from "babylonjs/scene";
  21355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21356. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21358. import { Material } from "babylonjs/Materials/material";
  21359. /**
  21360. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21361. * separate meshes. This can be use to improve performances.
  21362. * @see http://doc.babylonjs.com/how_to/multi_materials
  21363. */
  21364. export class MultiMaterial extends Material {
  21365. private _subMaterials;
  21366. /**
  21367. * Gets or Sets the list of Materials used within the multi material.
  21368. * They need to be ordered according to the submeshes order in the associated mesh
  21369. */
  21370. subMaterials: Nullable<Material>[];
  21371. /**
  21372. * Function used to align with Node.getChildren()
  21373. * @returns the list of Materials used within the multi material
  21374. */
  21375. getChildren(): Nullable<Material>[];
  21376. /**
  21377. * Instantiates a new Multi Material
  21378. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21379. * separate meshes. This can be use to improve performances.
  21380. * @see http://doc.babylonjs.com/how_to/multi_materials
  21381. * @param name Define the name in the scene
  21382. * @param scene Define the scene the material belongs to
  21383. */
  21384. constructor(name: string, scene: Scene);
  21385. private _hookArray;
  21386. /**
  21387. * Get one of the submaterial by its index in the submaterials array
  21388. * @param index The index to look the sub material at
  21389. * @returns The Material if the index has been defined
  21390. */
  21391. getSubMaterial(index: number): Nullable<Material>;
  21392. /**
  21393. * Get the list of active textures for the whole sub materials list.
  21394. * @returns All the textures that will be used during the rendering
  21395. */
  21396. getActiveTextures(): BaseTexture[];
  21397. /**
  21398. * Gets the current class name of the material e.g. "MultiMaterial"
  21399. * Mainly use in serialization.
  21400. * @returns the class name
  21401. */
  21402. getClassName(): string;
  21403. /**
  21404. * Checks if the material is ready to render the requested sub mesh
  21405. * @param mesh Define the mesh the submesh belongs to
  21406. * @param subMesh Define the sub mesh to look readyness for
  21407. * @param useInstances Define whether or not the material is used with instances
  21408. * @returns true if ready, otherwise false
  21409. */
  21410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21411. /**
  21412. * Clones the current material and its related sub materials
  21413. * @param name Define the name of the newly cloned material
  21414. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21415. * @returns the cloned material
  21416. */
  21417. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21418. /**
  21419. * Serializes the materials into a JSON representation.
  21420. * @returns the JSON representation
  21421. */
  21422. serialize(): any;
  21423. /**
  21424. * Dispose the material and release its associated resources
  21425. * @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)
  21426. * @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)
  21427. * @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)
  21428. */
  21429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21430. /**
  21431. * Creates a MultiMaterial from parsed MultiMaterial data.
  21432. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21433. * @param scene defines the hosting scene
  21434. * @returns a new MultiMaterial
  21435. */
  21436. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21437. }
  21438. }
  21439. declare module "babylonjs/Meshes/subMesh" {
  21440. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21441. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21442. import { Engine } from "babylonjs/Engines/engine";
  21443. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21444. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21445. import { Effect } from "babylonjs/Materials/effect";
  21446. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21447. import { Plane } from "babylonjs/Maths/math.plane";
  21448. import { Collider } from "babylonjs/Collisions/collider";
  21449. import { Material } from "babylonjs/Materials/material";
  21450. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21452. import { Mesh } from "babylonjs/Meshes/mesh";
  21453. import { Ray } from "babylonjs/Culling/ray";
  21454. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21455. /**
  21456. * Base class for submeshes
  21457. */
  21458. export class BaseSubMesh {
  21459. /** @hidden */
  21460. _materialDefines: Nullable<MaterialDefines>;
  21461. /** @hidden */
  21462. _materialEffect: Nullable<Effect>;
  21463. /**
  21464. * Gets associated effect
  21465. */
  21466. readonly effect: Nullable<Effect>;
  21467. /**
  21468. * Sets associated effect (effect used to render this submesh)
  21469. * @param effect defines the effect to associate with
  21470. * @param defines defines the set of defines used to compile this effect
  21471. */
  21472. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21473. }
  21474. /**
  21475. * Defines a subdivision inside a mesh
  21476. */
  21477. export class SubMesh extends BaseSubMesh implements ICullable {
  21478. /** the material index to use */
  21479. materialIndex: number;
  21480. /** vertex index start */
  21481. verticesStart: number;
  21482. /** vertices count */
  21483. verticesCount: number;
  21484. /** index start */
  21485. indexStart: number;
  21486. /** indices count */
  21487. indexCount: number;
  21488. /** @hidden */
  21489. _linesIndexCount: number;
  21490. private _mesh;
  21491. private _renderingMesh;
  21492. private _boundingInfo;
  21493. private _linesIndexBuffer;
  21494. /** @hidden */
  21495. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21496. /** @hidden */
  21497. _trianglePlanes: Plane[];
  21498. /** @hidden */
  21499. _lastColliderTransformMatrix: Nullable<Matrix>;
  21500. /** @hidden */
  21501. _renderId: number;
  21502. /** @hidden */
  21503. _alphaIndex: number;
  21504. /** @hidden */
  21505. _distanceToCamera: number;
  21506. /** @hidden */
  21507. _id: number;
  21508. private _currentMaterial;
  21509. /**
  21510. * Add a new submesh to a mesh
  21511. * @param materialIndex defines the material index to use
  21512. * @param verticesStart defines vertex index start
  21513. * @param verticesCount defines vertices count
  21514. * @param indexStart defines index start
  21515. * @param indexCount defines indices count
  21516. * @param mesh defines the parent mesh
  21517. * @param renderingMesh defines an optional rendering mesh
  21518. * @param createBoundingBox defines if bounding box should be created for this submesh
  21519. * @returns the new submesh
  21520. */
  21521. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21522. /**
  21523. * Creates a new submesh
  21524. * @param materialIndex defines the material index to use
  21525. * @param verticesStart defines vertex index start
  21526. * @param verticesCount defines vertices count
  21527. * @param indexStart defines index start
  21528. * @param indexCount defines indices count
  21529. * @param mesh defines the parent mesh
  21530. * @param renderingMesh defines an optional rendering mesh
  21531. * @param createBoundingBox defines if bounding box should be created for this submesh
  21532. */
  21533. constructor(
  21534. /** the material index to use */
  21535. materialIndex: number,
  21536. /** vertex index start */
  21537. verticesStart: number,
  21538. /** vertices count */
  21539. verticesCount: number,
  21540. /** index start */
  21541. indexStart: number,
  21542. /** indices count */
  21543. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21544. /**
  21545. * Returns true if this submesh covers the entire parent mesh
  21546. * @ignorenaming
  21547. */
  21548. readonly IsGlobal: boolean;
  21549. /**
  21550. * Returns the submesh BoudingInfo object
  21551. * @returns current bounding info (or mesh's one if the submesh is global)
  21552. */
  21553. getBoundingInfo(): BoundingInfo;
  21554. /**
  21555. * Sets the submesh BoundingInfo
  21556. * @param boundingInfo defines the new bounding info to use
  21557. * @returns the SubMesh
  21558. */
  21559. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21560. /**
  21561. * Returns the mesh of the current submesh
  21562. * @return the parent mesh
  21563. */
  21564. getMesh(): AbstractMesh;
  21565. /**
  21566. * Returns the rendering mesh of the submesh
  21567. * @returns the rendering mesh (could be different from parent mesh)
  21568. */
  21569. getRenderingMesh(): Mesh;
  21570. /**
  21571. * Returns the submesh material
  21572. * @returns null or the current material
  21573. */
  21574. getMaterial(): Nullable<Material>;
  21575. /**
  21576. * Sets a new updated BoundingInfo object to the submesh
  21577. * @param data defines an optional position array to use to determine the bounding info
  21578. * @returns the SubMesh
  21579. */
  21580. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21581. /** @hidden */
  21582. _checkCollision(collider: Collider): boolean;
  21583. /**
  21584. * Updates the submesh BoundingInfo
  21585. * @param world defines the world matrix to use to update the bounding info
  21586. * @returns the submesh
  21587. */
  21588. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21589. /**
  21590. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21591. * @param frustumPlanes defines the frustum planes
  21592. * @returns true if the submesh is intersecting with the frustum
  21593. */
  21594. isInFrustum(frustumPlanes: Plane[]): boolean;
  21595. /**
  21596. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21597. * @param frustumPlanes defines the frustum planes
  21598. * @returns true if the submesh is inside the frustum
  21599. */
  21600. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21601. /**
  21602. * Renders the submesh
  21603. * @param enableAlphaMode defines if alpha needs to be used
  21604. * @returns the submesh
  21605. */
  21606. render(enableAlphaMode: boolean): SubMesh;
  21607. /**
  21608. * @hidden
  21609. */
  21610. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21611. /**
  21612. * Checks if the submesh intersects with a ray
  21613. * @param ray defines the ray to test
  21614. * @returns true is the passed ray intersects the submesh bounding box
  21615. */
  21616. canIntersects(ray: Ray): boolean;
  21617. /**
  21618. * Intersects current submesh with a ray
  21619. * @param ray defines the ray to test
  21620. * @param positions defines mesh's positions array
  21621. * @param indices defines mesh's indices array
  21622. * @param fastCheck defines if only bounding info should be used
  21623. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21624. * @returns intersection info or null if no intersection
  21625. */
  21626. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21627. /** @hidden */
  21628. private _intersectLines;
  21629. /** @hidden */
  21630. private _intersectUnIndexedLines;
  21631. /** @hidden */
  21632. private _intersectTriangles;
  21633. /** @hidden */
  21634. private _intersectUnIndexedTriangles;
  21635. /** @hidden */
  21636. _rebuild(): void;
  21637. /**
  21638. * Creates a new submesh from the passed mesh
  21639. * @param newMesh defines the new hosting mesh
  21640. * @param newRenderingMesh defines an optional rendering mesh
  21641. * @returns the new submesh
  21642. */
  21643. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21644. /**
  21645. * Release associated resources
  21646. */
  21647. dispose(): void;
  21648. /**
  21649. * Gets the class name
  21650. * @returns the string "SubMesh".
  21651. */
  21652. getClassName(): string;
  21653. /**
  21654. * Creates a new submesh from indices data
  21655. * @param materialIndex the index of the main mesh material
  21656. * @param startIndex the index where to start the copy in the mesh indices array
  21657. * @param indexCount the number of indices to copy then from the startIndex
  21658. * @param mesh the main mesh to create the submesh from
  21659. * @param renderingMesh the optional rendering mesh
  21660. * @returns a new submesh
  21661. */
  21662. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21663. }
  21664. }
  21665. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21666. /**
  21667. * Class used to represent data loading progression
  21668. */
  21669. export class SceneLoaderFlags {
  21670. private static _ForceFullSceneLoadingForIncremental;
  21671. private static _ShowLoadingScreen;
  21672. private static _CleanBoneMatrixWeights;
  21673. private static _loggingLevel;
  21674. /**
  21675. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21676. */
  21677. static ForceFullSceneLoadingForIncremental: boolean;
  21678. /**
  21679. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21680. */
  21681. static ShowLoadingScreen: boolean;
  21682. /**
  21683. * Defines the current logging level (while loading the scene)
  21684. * @ignorenaming
  21685. */
  21686. static loggingLevel: number;
  21687. /**
  21688. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21689. */
  21690. static CleanBoneMatrixWeights: boolean;
  21691. }
  21692. }
  21693. declare module "babylonjs/Meshes/geometry" {
  21694. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21695. import { Scene } from "babylonjs/scene";
  21696. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21697. import { Engine } from "babylonjs/Engines/engine";
  21698. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21699. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21700. import { Effect } from "babylonjs/Materials/effect";
  21701. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21702. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21703. import { Mesh } from "babylonjs/Meshes/mesh";
  21704. /**
  21705. * Class used to store geometry data (vertex buffers + index buffer)
  21706. */
  21707. export class Geometry implements IGetSetVerticesData {
  21708. /**
  21709. * Gets or sets the ID of the geometry
  21710. */
  21711. id: string;
  21712. /**
  21713. * Gets or sets the unique ID of the geometry
  21714. */
  21715. uniqueId: number;
  21716. /**
  21717. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21718. */
  21719. delayLoadState: number;
  21720. /**
  21721. * Gets the file containing the data to load when running in delay load state
  21722. */
  21723. delayLoadingFile: Nullable<string>;
  21724. /**
  21725. * Callback called when the geometry is updated
  21726. */
  21727. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21728. private _scene;
  21729. private _engine;
  21730. private _meshes;
  21731. private _totalVertices;
  21732. /** @hidden */
  21733. _indices: IndicesArray;
  21734. /** @hidden */
  21735. _vertexBuffers: {
  21736. [key: string]: VertexBuffer;
  21737. };
  21738. private _isDisposed;
  21739. private _extend;
  21740. private _boundingBias;
  21741. /** @hidden */
  21742. _delayInfo: Array<string>;
  21743. private _indexBuffer;
  21744. private _indexBufferIsUpdatable;
  21745. /** @hidden */
  21746. _boundingInfo: Nullable<BoundingInfo>;
  21747. /** @hidden */
  21748. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21749. /** @hidden */
  21750. _softwareSkinningFrameId: number;
  21751. private _vertexArrayObjects;
  21752. private _updatable;
  21753. /** @hidden */
  21754. _positions: Nullable<Vector3[]>;
  21755. /**
  21756. * 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
  21757. */
  21758. /**
  21759. * 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
  21760. */
  21761. boundingBias: Vector2;
  21762. /**
  21763. * Static function used to attach a new empty geometry to a mesh
  21764. * @param mesh defines the mesh to attach the geometry to
  21765. * @returns the new Geometry
  21766. */
  21767. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21768. /**
  21769. * Creates a new geometry
  21770. * @param id defines the unique ID
  21771. * @param scene defines the hosting scene
  21772. * @param vertexData defines the VertexData used to get geometry data
  21773. * @param updatable defines if geometry must be updatable (false by default)
  21774. * @param mesh defines the mesh that will be associated with the geometry
  21775. */
  21776. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21777. /**
  21778. * Gets the current extend of the geometry
  21779. */
  21780. readonly extend: {
  21781. minimum: Vector3;
  21782. maximum: Vector3;
  21783. };
  21784. /**
  21785. * Gets the hosting scene
  21786. * @returns the hosting Scene
  21787. */
  21788. getScene(): Scene;
  21789. /**
  21790. * Gets the hosting engine
  21791. * @returns the hosting Engine
  21792. */
  21793. getEngine(): Engine;
  21794. /**
  21795. * Defines if the geometry is ready to use
  21796. * @returns true if the geometry is ready to be used
  21797. */
  21798. isReady(): boolean;
  21799. /**
  21800. * Gets a value indicating that the geometry should not be serialized
  21801. */
  21802. readonly doNotSerialize: boolean;
  21803. /** @hidden */
  21804. _rebuild(): void;
  21805. /**
  21806. * Affects all geometry data in one call
  21807. * @param vertexData defines the geometry data
  21808. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21809. */
  21810. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21811. /**
  21812. * Set specific vertex data
  21813. * @param kind defines the data kind (Position, normal, etc...)
  21814. * @param data defines the vertex data to use
  21815. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21816. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21817. */
  21818. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21819. /**
  21820. * Removes a specific vertex data
  21821. * @param kind defines the data kind (Position, normal, etc...)
  21822. */
  21823. removeVerticesData(kind: string): void;
  21824. /**
  21825. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21826. * @param buffer defines the vertex buffer to use
  21827. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21828. */
  21829. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21830. /**
  21831. * Update a specific vertex buffer
  21832. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21833. * It will do nothing if the buffer is not updatable
  21834. * @param kind defines the data kind (Position, normal, etc...)
  21835. * @param data defines the data to use
  21836. * @param offset defines the offset in the target buffer where to store the data
  21837. * @param useBytes set to true if the offset is in bytes
  21838. */
  21839. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21840. /**
  21841. * Update a specific vertex buffer
  21842. * This function will create a new buffer if the current one is not updatable
  21843. * @param kind defines the data kind (Position, normal, etc...)
  21844. * @param data defines the data to use
  21845. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21846. */
  21847. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21848. private _updateBoundingInfo;
  21849. /** @hidden */
  21850. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21851. /**
  21852. * Gets total number of vertices
  21853. * @returns the total number of vertices
  21854. */
  21855. getTotalVertices(): number;
  21856. /**
  21857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21861. * @returns a float array containing vertex data
  21862. */
  21863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21864. /**
  21865. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21866. * @param kind defines the data kind (Position, normal, etc...)
  21867. * @returns true if the vertex buffer with the specified kind is updatable
  21868. */
  21869. isVertexBufferUpdatable(kind: string): boolean;
  21870. /**
  21871. * Gets a specific vertex buffer
  21872. * @param kind defines the data kind (Position, normal, etc...)
  21873. * @returns a VertexBuffer
  21874. */
  21875. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21876. /**
  21877. * Returns all vertex buffers
  21878. * @return an object holding all vertex buffers indexed by kind
  21879. */
  21880. getVertexBuffers(): Nullable<{
  21881. [key: string]: VertexBuffer;
  21882. }>;
  21883. /**
  21884. * Gets a boolean indicating if specific vertex buffer is present
  21885. * @param kind defines the data kind (Position, normal, etc...)
  21886. * @returns true if data is present
  21887. */
  21888. isVerticesDataPresent(kind: string): boolean;
  21889. /**
  21890. * Gets a list of all attached data kinds (Position, normal, etc...)
  21891. * @returns a list of string containing all kinds
  21892. */
  21893. getVerticesDataKinds(): string[];
  21894. /**
  21895. * Update index buffer
  21896. * @param indices defines the indices to store in the index buffer
  21897. * @param offset defines the offset in the target buffer where to store the data
  21898. * @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)
  21899. */
  21900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21901. /**
  21902. * Creates a new index buffer
  21903. * @param indices defines the indices to store in the index buffer
  21904. * @param totalVertices defines the total number of vertices (could be null)
  21905. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21906. */
  21907. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21908. /**
  21909. * Return the total number of indices
  21910. * @returns the total number of indices
  21911. */
  21912. getTotalIndices(): number;
  21913. /**
  21914. * Gets the index buffer array
  21915. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21917. * @returns the index buffer array
  21918. */
  21919. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21920. /**
  21921. * Gets the index buffer
  21922. * @return the index buffer
  21923. */
  21924. getIndexBuffer(): Nullable<DataBuffer>;
  21925. /** @hidden */
  21926. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21927. /**
  21928. * Release the associated resources for a specific mesh
  21929. * @param mesh defines the source mesh
  21930. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21931. */
  21932. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21933. /**
  21934. * Apply current geometry to a given mesh
  21935. * @param mesh defines the mesh to apply geometry to
  21936. */
  21937. applyToMesh(mesh: Mesh): void;
  21938. private _updateExtend;
  21939. private _applyToMesh;
  21940. private notifyUpdate;
  21941. /**
  21942. * Load the geometry if it was flagged as delay loaded
  21943. * @param scene defines the hosting scene
  21944. * @param onLoaded defines a callback called when the geometry is loaded
  21945. */
  21946. load(scene: Scene, onLoaded?: () => void): void;
  21947. private _queueLoad;
  21948. /**
  21949. * Invert the geometry to move from a right handed system to a left handed one.
  21950. */
  21951. toLeftHanded(): void;
  21952. /** @hidden */
  21953. _resetPointsArrayCache(): void;
  21954. /** @hidden */
  21955. _generatePointsArray(): boolean;
  21956. /**
  21957. * Gets a value indicating if the geometry is disposed
  21958. * @returns true if the geometry was disposed
  21959. */
  21960. isDisposed(): boolean;
  21961. private _disposeVertexArrayObjects;
  21962. /**
  21963. * Free all associated resources
  21964. */
  21965. dispose(): void;
  21966. /**
  21967. * Clone the current geometry into a new geometry
  21968. * @param id defines the unique ID of the new geometry
  21969. * @returns a new geometry object
  21970. */
  21971. copy(id: string): Geometry;
  21972. /**
  21973. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21974. * @return a JSON representation of the current geometry data (without the vertices data)
  21975. */
  21976. serialize(): any;
  21977. private toNumberArray;
  21978. /**
  21979. * Serialize all vertices data into a JSON oject
  21980. * @returns a JSON representation of the current geometry data
  21981. */
  21982. serializeVerticeData(): any;
  21983. /**
  21984. * Extracts a clone of a mesh geometry
  21985. * @param mesh defines the source mesh
  21986. * @param id defines the unique ID of the new geometry object
  21987. * @returns the new geometry object
  21988. */
  21989. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21990. /**
  21991. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21992. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21993. * Be aware Math.random() could cause collisions, but:
  21994. * "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"
  21995. * @returns a string containing a new GUID
  21996. */
  21997. static RandomId(): string;
  21998. /** @hidden */
  21999. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22000. private static _CleanMatricesWeights;
  22001. /**
  22002. * Create a new geometry from persisted data (Using .babylon file format)
  22003. * @param parsedVertexData defines the persisted data
  22004. * @param scene defines the hosting scene
  22005. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22006. * @returns the new geometry object
  22007. */
  22008. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22009. }
  22010. }
  22011. declare module "babylonjs/Meshes/mesh.vertexData" {
  22012. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22013. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22014. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22015. import { Geometry } from "babylonjs/Meshes/geometry";
  22016. import { Mesh } from "babylonjs/Meshes/mesh";
  22017. /**
  22018. * Define an interface for all classes that will get and set the data on vertices
  22019. */
  22020. export interface IGetSetVerticesData {
  22021. /**
  22022. * Gets a boolean indicating if specific vertex data is present
  22023. * @param kind defines the vertex data kind to use
  22024. * @returns true is data kind is present
  22025. */
  22026. isVerticesDataPresent(kind: string): boolean;
  22027. /**
  22028. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22029. * @param kind defines the data kind (Position, normal, etc...)
  22030. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22031. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22032. * @returns a float array containing vertex data
  22033. */
  22034. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22035. /**
  22036. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22037. * @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.
  22038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22039. * @returns the indices array or an empty array if the mesh has no geometry
  22040. */
  22041. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22042. /**
  22043. * Set specific vertex data
  22044. * @param kind defines the data kind (Position, normal, etc...)
  22045. * @param data defines the vertex data to use
  22046. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22047. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22048. */
  22049. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22050. /**
  22051. * Update a specific associated vertex buffer
  22052. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22053. * - VertexBuffer.PositionKind
  22054. * - VertexBuffer.UVKind
  22055. * - VertexBuffer.UV2Kind
  22056. * - VertexBuffer.UV3Kind
  22057. * - VertexBuffer.UV4Kind
  22058. * - VertexBuffer.UV5Kind
  22059. * - VertexBuffer.UV6Kind
  22060. * - VertexBuffer.ColorKind
  22061. * - VertexBuffer.MatricesIndicesKind
  22062. * - VertexBuffer.MatricesIndicesExtraKind
  22063. * - VertexBuffer.MatricesWeightsKind
  22064. * - VertexBuffer.MatricesWeightsExtraKind
  22065. * @param data defines the data source
  22066. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22067. * @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)
  22068. */
  22069. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22070. /**
  22071. * Creates a new index buffer
  22072. * @param indices defines the indices to store in the index buffer
  22073. * @param totalVertices defines the total number of vertices (could be null)
  22074. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22075. */
  22076. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22077. }
  22078. /**
  22079. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22080. */
  22081. export class VertexData {
  22082. /**
  22083. * Mesh side orientation : usually the external or front surface
  22084. */
  22085. static readonly FRONTSIDE: number;
  22086. /**
  22087. * Mesh side orientation : usually the internal or back surface
  22088. */
  22089. static readonly BACKSIDE: number;
  22090. /**
  22091. * Mesh side orientation : both internal and external or front and back surfaces
  22092. */
  22093. static readonly DOUBLESIDE: number;
  22094. /**
  22095. * Mesh side orientation : by default, `FRONTSIDE`
  22096. */
  22097. static readonly DEFAULTSIDE: number;
  22098. /**
  22099. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22100. */
  22101. positions: Nullable<FloatArray>;
  22102. /**
  22103. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22104. */
  22105. normals: Nullable<FloatArray>;
  22106. /**
  22107. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22108. */
  22109. tangents: Nullable<FloatArray>;
  22110. /**
  22111. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22112. */
  22113. uvs: Nullable<FloatArray>;
  22114. /**
  22115. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22116. */
  22117. uvs2: Nullable<FloatArray>;
  22118. /**
  22119. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22120. */
  22121. uvs3: Nullable<FloatArray>;
  22122. /**
  22123. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22124. */
  22125. uvs4: Nullable<FloatArray>;
  22126. /**
  22127. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22128. */
  22129. uvs5: Nullable<FloatArray>;
  22130. /**
  22131. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22132. */
  22133. uvs6: Nullable<FloatArray>;
  22134. /**
  22135. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22136. */
  22137. colors: Nullable<FloatArray>;
  22138. /**
  22139. * 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).
  22140. */
  22141. matricesIndices: Nullable<FloatArray>;
  22142. /**
  22143. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22144. */
  22145. matricesWeights: Nullable<FloatArray>;
  22146. /**
  22147. * An array extending the number of possible indices
  22148. */
  22149. matricesIndicesExtra: Nullable<FloatArray>;
  22150. /**
  22151. * An array extending the number of possible weights when the number of indices is extended
  22152. */
  22153. matricesWeightsExtra: Nullable<FloatArray>;
  22154. /**
  22155. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22156. */
  22157. indices: Nullable<IndicesArray>;
  22158. /**
  22159. * Uses the passed data array to set the set the values for the specified kind of data
  22160. * @param data a linear array of floating numbers
  22161. * @param kind the type of data that is being set, eg positions, colors etc
  22162. */
  22163. set(data: FloatArray, kind: string): void;
  22164. /**
  22165. * Associates the vertexData to the passed Mesh.
  22166. * Sets it as updatable or not (default `false`)
  22167. * @param mesh the mesh the vertexData is applied to
  22168. * @param updatable when used and having the value true allows new data to update the vertexData
  22169. * @returns the VertexData
  22170. */
  22171. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22172. /**
  22173. * Associates the vertexData to the passed Geometry.
  22174. * Sets it as updatable or not (default `false`)
  22175. * @param geometry the geometry the vertexData is applied to
  22176. * @param updatable when used and having the value true allows new data to update the vertexData
  22177. * @returns VertexData
  22178. */
  22179. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22180. /**
  22181. * Updates the associated mesh
  22182. * @param mesh the mesh to be updated
  22183. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22184. * @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
  22185. * @returns VertexData
  22186. */
  22187. updateMesh(mesh: Mesh): VertexData;
  22188. /**
  22189. * Updates the associated geometry
  22190. * @param geometry the geometry to be updated
  22191. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22192. * @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
  22193. * @returns VertexData.
  22194. */
  22195. updateGeometry(geometry: Geometry): VertexData;
  22196. private _applyTo;
  22197. private _update;
  22198. /**
  22199. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22200. * @param matrix the transforming matrix
  22201. * @returns the VertexData
  22202. */
  22203. transform(matrix: Matrix): VertexData;
  22204. /**
  22205. * Merges the passed VertexData into the current one
  22206. * @param other the VertexData to be merged into the current one
  22207. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22208. * @returns the modified VertexData
  22209. */
  22210. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22211. private _mergeElement;
  22212. private _validate;
  22213. /**
  22214. * Serializes the VertexData
  22215. * @returns a serialized object
  22216. */
  22217. serialize(): any;
  22218. /**
  22219. * Extracts the vertexData from a mesh
  22220. * @param mesh the mesh from which to extract the VertexData
  22221. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22222. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22223. * @returns the object VertexData associated to the passed mesh
  22224. */
  22225. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22226. /**
  22227. * Extracts the vertexData from the geometry
  22228. * @param geometry the geometry from which to extract the VertexData
  22229. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22230. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22231. * @returns the object VertexData associated to the passed mesh
  22232. */
  22233. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22234. private static _ExtractFrom;
  22235. /**
  22236. * Creates the VertexData for a Ribbon
  22237. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22238. * * pathArray array of paths, each of which an array of successive Vector3
  22239. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22240. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22241. * * 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
  22242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22243. * * 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)
  22244. * * 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)
  22245. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22246. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22247. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22248. * @returns the VertexData of the ribbon
  22249. */
  22250. static CreateRibbon(options: {
  22251. pathArray: Vector3[][];
  22252. closeArray?: boolean;
  22253. closePath?: boolean;
  22254. offset?: number;
  22255. sideOrientation?: number;
  22256. frontUVs?: Vector4;
  22257. backUVs?: Vector4;
  22258. invertUV?: boolean;
  22259. uvs?: Vector2[];
  22260. colors?: Color4[];
  22261. }): VertexData;
  22262. /**
  22263. * Creates the VertexData for a box
  22264. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22265. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22266. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22267. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22268. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22269. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22270. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22272. * * 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)
  22273. * * 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)
  22274. * @returns the VertexData of the box
  22275. */
  22276. static CreateBox(options: {
  22277. size?: number;
  22278. width?: number;
  22279. height?: number;
  22280. depth?: number;
  22281. faceUV?: Vector4[];
  22282. faceColors?: Color4[];
  22283. sideOrientation?: number;
  22284. frontUVs?: Vector4;
  22285. backUVs?: Vector4;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a tiled box
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22291. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22292. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22294. * @returns the VertexData of the box
  22295. */
  22296. static CreateTiledBox(options: {
  22297. pattern?: number;
  22298. width?: number;
  22299. height?: number;
  22300. depth?: number;
  22301. tileSize?: number;
  22302. tileWidth?: number;
  22303. tileHeight?: number;
  22304. alignHorizontal?: number;
  22305. alignVertical?: number;
  22306. faceUV?: Vector4[];
  22307. faceColors?: Color4[];
  22308. sideOrientation?: number;
  22309. }): VertexData;
  22310. /**
  22311. * Creates the VertexData for a tiled plane
  22312. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22313. * * pattern a limited pattern arrangement depending on the number
  22314. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22315. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22316. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22318. * * 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)
  22319. * * 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)
  22320. * @returns the VertexData of the tiled plane
  22321. */
  22322. static CreateTiledPlane(options: {
  22323. pattern?: number;
  22324. tileSize?: number;
  22325. tileWidth?: number;
  22326. tileHeight?: number;
  22327. size?: number;
  22328. width?: number;
  22329. height?: number;
  22330. alignHorizontal?: number;
  22331. alignVertical?: number;
  22332. sideOrientation?: number;
  22333. frontUVs?: Vector4;
  22334. backUVs?: Vector4;
  22335. }): VertexData;
  22336. /**
  22337. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22338. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22339. * * segments sets the number of horizontal strips optional, default 32
  22340. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22341. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22342. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22343. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22344. * * 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
  22345. * * 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
  22346. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22347. * * 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)
  22348. * * 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)
  22349. * @returns the VertexData of the ellipsoid
  22350. */
  22351. static CreateSphere(options: {
  22352. segments?: number;
  22353. diameter?: number;
  22354. diameterX?: number;
  22355. diameterY?: number;
  22356. diameterZ?: number;
  22357. arc?: number;
  22358. slice?: number;
  22359. sideOrientation?: number;
  22360. frontUVs?: Vector4;
  22361. backUVs?: Vector4;
  22362. }): VertexData;
  22363. /**
  22364. * Creates the VertexData for a cylinder, cone or prism
  22365. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22366. * * height sets the height (y direction) of the cylinder, optional, default 2
  22367. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22368. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22369. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22370. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22371. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22372. * * 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
  22373. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22374. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22375. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22376. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22378. * * 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)
  22379. * * 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)
  22380. * @returns the VertexData of the cylinder, cone or prism
  22381. */
  22382. static CreateCylinder(options: {
  22383. height?: number;
  22384. diameterTop?: number;
  22385. diameterBottom?: number;
  22386. diameter?: number;
  22387. tessellation?: number;
  22388. subdivisions?: number;
  22389. arc?: number;
  22390. faceColors?: Color4[];
  22391. faceUV?: Vector4[];
  22392. hasRings?: boolean;
  22393. enclose?: boolean;
  22394. sideOrientation?: number;
  22395. frontUVs?: Vector4;
  22396. backUVs?: Vector4;
  22397. }): VertexData;
  22398. /**
  22399. * Creates the VertexData for a torus
  22400. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22401. * * diameter the diameter of the torus, optional default 1
  22402. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22403. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22405. * * 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)
  22406. * * 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)
  22407. * @returns the VertexData of the torus
  22408. */
  22409. static CreateTorus(options: {
  22410. diameter?: number;
  22411. thickness?: number;
  22412. tessellation?: number;
  22413. sideOrientation?: number;
  22414. frontUVs?: Vector4;
  22415. backUVs?: Vector4;
  22416. }): VertexData;
  22417. /**
  22418. * Creates the VertexData of the LineSystem
  22419. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22420. * - lines an array of lines, each line being an array of successive Vector3
  22421. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22422. * @returns the VertexData of the LineSystem
  22423. */
  22424. static CreateLineSystem(options: {
  22425. lines: Vector3[][];
  22426. colors?: Nullable<Color4[][]>;
  22427. }): VertexData;
  22428. /**
  22429. * Create the VertexData for a DashedLines
  22430. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22431. * - points an array successive Vector3
  22432. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22433. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22434. * - dashNb the intended total number of dashes, optional, default 200
  22435. * @returns the VertexData for the DashedLines
  22436. */
  22437. static CreateDashedLines(options: {
  22438. points: Vector3[];
  22439. dashSize?: number;
  22440. gapSize?: number;
  22441. dashNb?: number;
  22442. }): VertexData;
  22443. /**
  22444. * Creates the VertexData for a Ground
  22445. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22446. * - width the width (x direction) of the ground, optional, default 1
  22447. * - height the height (z direction) of the ground, optional, default 1
  22448. * - subdivisions the number of subdivisions per side, optional, default 1
  22449. * @returns the VertexData of the Ground
  22450. */
  22451. static CreateGround(options: {
  22452. width?: number;
  22453. height?: number;
  22454. subdivisions?: number;
  22455. subdivisionsX?: number;
  22456. subdivisionsY?: number;
  22457. }): VertexData;
  22458. /**
  22459. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22460. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22461. * * xmin the ground minimum X coordinate, optional, default -1
  22462. * * zmin the ground minimum Z coordinate, optional, default -1
  22463. * * xmax the ground maximum X coordinate, optional, default 1
  22464. * * zmax the ground maximum Z coordinate, optional, default 1
  22465. * * 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}
  22466. * * 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}
  22467. * @returns the VertexData of the TiledGround
  22468. */
  22469. static CreateTiledGround(options: {
  22470. xmin: number;
  22471. zmin: number;
  22472. xmax: number;
  22473. zmax: number;
  22474. subdivisions?: {
  22475. w: number;
  22476. h: number;
  22477. };
  22478. precision?: {
  22479. w: number;
  22480. h: number;
  22481. };
  22482. }): VertexData;
  22483. /**
  22484. * Creates the VertexData of the Ground designed from a heightmap
  22485. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22486. * * width the width (x direction) of the ground
  22487. * * height the height (z direction) of the ground
  22488. * * subdivisions the number of subdivisions per side
  22489. * * minHeight the minimum altitude on the ground, optional, default 0
  22490. * * maxHeight the maximum altitude on the ground, optional default 1
  22491. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22492. * * buffer the array holding the image color data
  22493. * * bufferWidth the width of image
  22494. * * bufferHeight the height of image
  22495. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22496. * @returns the VertexData of the Ground designed from a heightmap
  22497. */
  22498. static CreateGroundFromHeightMap(options: {
  22499. width: number;
  22500. height: number;
  22501. subdivisions: number;
  22502. minHeight: number;
  22503. maxHeight: number;
  22504. colorFilter: Color3;
  22505. buffer: Uint8Array;
  22506. bufferWidth: number;
  22507. bufferHeight: number;
  22508. alphaFilter: number;
  22509. }): VertexData;
  22510. /**
  22511. * Creates the VertexData for a Plane
  22512. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22513. * * size sets the width and height of the plane to the value of size, optional default 1
  22514. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22515. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22517. * * 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)
  22518. * * 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)
  22519. * @returns the VertexData of the box
  22520. */
  22521. static CreatePlane(options: {
  22522. size?: number;
  22523. width?: number;
  22524. height?: number;
  22525. sideOrientation?: number;
  22526. frontUVs?: Vector4;
  22527. backUVs?: Vector4;
  22528. }): VertexData;
  22529. /**
  22530. * Creates the VertexData of the Disc or regular Polygon
  22531. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22532. * * radius the radius of the disc, optional default 0.5
  22533. * * tessellation the number of polygon sides, optional, default 64
  22534. * * 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
  22535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22536. * * 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)
  22537. * * 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)
  22538. * @returns the VertexData of the box
  22539. */
  22540. static CreateDisc(options: {
  22541. radius?: number;
  22542. tessellation?: number;
  22543. arc?: number;
  22544. sideOrientation?: number;
  22545. frontUVs?: Vector4;
  22546. backUVs?: Vector4;
  22547. }): VertexData;
  22548. /**
  22549. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22550. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22551. * @param polygon a mesh built from polygonTriangulation.build()
  22552. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22553. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22554. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22555. * @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)
  22556. * @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)
  22557. * @returns the VertexData of the Polygon
  22558. */
  22559. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22560. /**
  22561. * Creates the VertexData of the IcoSphere
  22562. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22563. * * radius the radius of the IcoSphere, optional default 1
  22564. * * radiusX allows stretching in the x direction, optional, default radius
  22565. * * radiusY allows stretching in the y direction, optional, default radius
  22566. * * radiusZ allows stretching in the z direction, optional, default radius
  22567. * * flat when true creates a flat shaded mesh, optional, default true
  22568. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22569. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22570. * * 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)
  22571. * * 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)
  22572. * @returns the VertexData of the IcoSphere
  22573. */
  22574. static CreateIcoSphere(options: {
  22575. radius?: number;
  22576. radiusX?: number;
  22577. radiusY?: number;
  22578. radiusZ?: number;
  22579. flat?: boolean;
  22580. subdivisions?: number;
  22581. sideOrientation?: number;
  22582. frontUVs?: Vector4;
  22583. backUVs?: Vector4;
  22584. }): VertexData;
  22585. /**
  22586. * Creates the VertexData for a Polyhedron
  22587. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22588. * * type provided types are:
  22589. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22590. * * 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)
  22591. * * size the size of the IcoSphere, optional default 1
  22592. * * sizeX allows stretching in the x direction, optional, default size
  22593. * * sizeY allows stretching in the y direction, optional, default size
  22594. * * sizeZ allows stretching in the z direction, optional, default size
  22595. * * 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
  22596. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22597. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22598. * * flat when true creates a flat shaded mesh, optional, default true
  22599. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22600. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22601. * * 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)
  22602. * * 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)
  22603. * @returns the VertexData of the Polyhedron
  22604. */
  22605. static CreatePolyhedron(options: {
  22606. type?: number;
  22607. size?: number;
  22608. sizeX?: number;
  22609. sizeY?: number;
  22610. sizeZ?: number;
  22611. custom?: any;
  22612. faceUV?: Vector4[];
  22613. faceColors?: Color4[];
  22614. flat?: boolean;
  22615. sideOrientation?: number;
  22616. frontUVs?: Vector4;
  22617. backUVs?: Vector4;
  22618. }): VertexData;
  22619. /**
  22620. * Creates the VertexData for a TorusKnot
  22621. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22622. * * radius the radius of the torus knot, optional, default 2
  22623. * * tube the thickness of the tube, optional, default 0.5
  22624. * * radialSegments the number of sides on each tube segments, optional, default 32
  22625. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22626. * * p the number of windings around the z axis, optional, default 2
  22627. * * q the number of windings around the x axis, optional, default 3
  22628. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22629. * * 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)
  22630. * * 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)
  22631. * @returns the VertexData of the Torus Knot
  22632. */
  22633. static CreateTorusKnot(options: {
  22634. radius?: number;
  22635. tube?: number;
  22636. radialSegments?: number;
  22637. tubularSegments?: number;
  22638. p?: number;
  22639. q?: number;
  22640. sideOrientation?: number;
  22641. frontUVs?: Vector4;
  22642. backUVs?: Vector4;
  22643. }): VertexData;
  22644. /**
  22645. * Compute normals for given positions and indices
  22646. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22647. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22648. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22649. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22650. * * facetNormals : optional array of facet normals (vector3)
  22651. * * facetPositions : optional array of facet positions (vector3)
  22652. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22653. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22654. * * bInfo : optional bounding info, required for facetPartitioning computation
  22655. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22656. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22657. * * useRightHandedSystem: optional boolean to for right handed system computation
  22658. * * depthSort : optional boolean to enable the facet depth sort computation
  22659. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22660. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22661. */
  22662. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22663. facetNormals?: any;
  22664. facetPositions?: any;
  22665. facetPartitioning?: any;
  22666. ratio?: number;
  22667. bInfo?: any;
  22668. bbSize?: Vector3;
  22669. subDiv?: any;
  22670. useRightHandedSystem?: boolean;
  22671. depthSort?: boolean;
  22672. distanceTo?: Vector3;
  22673. depthSortedFacets?: any;
  22674. }): void;
  22675. /** @hidden */
  22676. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22677. /**
  22678. * Applies VertexData created from the imported parameters to the geometry
  22679. * @param parsedVertexData the parsed data from an imported file
  22680. * @param geometry the geometry to apply the VertexData to
  22681. */
  22682. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22683. }
  22684. }
  22685. declare module "babylonjs/Morph/morphTarget" {
  22686. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22687. import { Observable } from "babylonjs/Misc/observable";
  22688. import { Nullable, FloatArray } from "babylonjs/types";
  22689. import { Scene } from "babylonjs/scene";
  22690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22691. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22692. /**
  22693. * Defines a target to use with MorphTargetManager
  22694. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22695. */
  22696. export class MorphTarget implements IAnimatable {
  22697. /** defines the name of the target */
  22698. name: string;
  22699. /**
  22700. * Gets or sets the list of animations
  22701. */
  22702. animations: import("babylonjs/Animations/animation").Animation[];
  22703. private _scene;
  22704. private _positions;
  22705. private _normals;
  22706. private _tangents;
  22707. private _uvs;
  22708. private _influence;
  22709. /**
  22710. * Observable raised when the influence changes
  22711. */
  22712. onInfluenceChanged: Observable<boolean>;
  22713. /** @hidden */
  22714. _onDataLayoutChanged: Observable<void>;
  22715. /**
  22716. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22717. */
  22718. influence: number;
  22719. /**
  22720. * Gets or sets the id of the morph Target
  22721. */
  22722. id: string;
  22723. private _animationPropertiesOverride;
  22724. /**
  22725. * Gets or sets the animation properties override
  22726. */
  22727. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22728. /**
  22729. * Creates a new MorphTarget
  22730. * @param name defines the name of the target
  22731. * @param influence defines the influence to use
  22732. * @param scene defines the scene the morphtarget belongs to
  22733. */
  22734. constructor(
  22735. /** defines the name of the target */
  22736. name: string, influence?: number, scene?: Nullable<Scene>);
  22737. /**
  22738. * Gets a boolean defining if the target contains position data
  22739. */
  22740. readonly hasPositions: boolean;
  22741. /**
  22742. * Gets a boolean defining if the target contains normal data
  22743. */
  22744. readonly hasNormals: boolean;
  22745. /**
  22746. * Gets a boolean defining if the target contains tangent data
  22747. */
  22748. readonly hasTangents: boolean;
  22749. /**
  22750. * Gets a boolean defining if the target contains texture coordinates data
  22751. */
  22752. readonly hasUVs: boolean;
  22753. /**
  22754. * Affects position data to this target
  22755. * @param data defines the position data to use
  22756. */
  22757. setPositions(data: Nullable<FloatArray>): void;
  22758. /**
  22759. * Gets the position data stored in this target
  22760. * @returns a FloatArray containing the position data (or null if not present)
  22761. */
  22762. getPositions(): Nullable<FloatArray>;
  22763. /**
  22764. * Affects normal data to this target
  22765. * @param data defines the normal data to use
  22766. */
  22767. setNormals(data: Nullable<FloatArray>): void;
  22768. /**
  22769. * Gets the normal data stored in this target
  22770. * @returns a FloatArray containing the normal data (or null if not present)
  22771. */
  22772. getNormals(): Nullable<FloatArray>;
  22773. /**
  22774. * Affects tangent data to this target
  22775. * @param data defines the tangent data to use
  22776. */
  22777. setTangents(data: Nullable<FloatArray>): void;
  22778. /**
  22779. * Gets the tangent data stored in this target
  22780. * @returns a FloatArray containing the tangent data (or null if not present)
  22781. */
  22782. getTangents(): Nullable<FloatArray>;
  22783. /**
  22784. * Affects texture coordinates data to this target
  22785. * @param data defines the texture coordinates data to use
  22786. */
  22787. setUVs(data: Nullable<FloatArray>): void;
  22788. /**
  22789. * Gets the texture coordinates data stored in this target
  22790. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22791. */
  22792. getUVs(): Nullable<FloatArray>;
  22793. /**
  22794. * Serializes the current target into a Serialization object
  22795. * @returns the serialized object
  22796. */
  22797. serialize(): any;
  22798. /**
  22799. * Returns the string "MorphTarget"
  22800. * @returns "MorphTarget"
  22801. */
  22802. getClassName(): string;
  22803. /**
  22804. * Creates a new target from serialized data
  22805. * @param serializationObject defines the serialized data to use
  22806. * @returns a new MorphTarget
  22807. */
  22808. static Parse(serializationObject: any): MorphTarget;
  22809. /**
  22810. * Creates a MorphTarget from mesh data
  22811. * @param mesh defines the source mesh
  22812. * @param name defines the name to use for the new target
  22813. * @param influence defines the influence to attach to the target
  22814. * @returns a new MorphTarget
  22815. */
  22816. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22817. }
  22818. }
  22819. declare module "babylonjs/Morph/morphTargetManager" {
  22820. import { Nullable } from "babylonjs/types";
  22821. import { Scene } from "babylonjs/scene";
  22822. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22823. /**
  22824. * This class is used to deform meshes using morphing between different targets
  22825. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22826. */
  22827. export class MorphTargetManager {
  22828. private _targets;
  22829. private _targetInfluenceChangedObservers;
  22830. private _targetDataLayoutChangedObservers;
  22831. private _activeTargets;
  22832. private _scene;
  22833. private _influences;
  22834. private _supportsNormals;
  22835. private _supportsTangents;
  22836. private _supportsUVs;
  22837. private _vertexCount;
  22838. private _uniqueId;
  22839. private _tempInfluences;
  22840. /**
  22841. * Gets or sets a boolean indicating if normals must be morphed
  22842. */
  22843. enableNormalMorphing: boolean;
  22844. /**
  22845. * Gets or sets a boolean indicating if tangents must be morphed
  22846. */
  22847. enableTangentMorphing: boolean;
  22848. /**
  22849. * Gets or sets a boolean indicating if UV must be morphed
  22850. */
  22851. enableUVMorphing: boolean;
  22852. /**
  22853. * Creates a new MorphTargetManager
  22854. * @param scene defines the current scene
  22855. */
  22856. constructor(scene?: Nullable<Scene>);
  22857. /**
  22858. * Gets the unique ID of this manager
  22859. */
  22860. readonly uniqueId: number;
  22861. /**
  22862. * Gets the number of vertices handled by this manager
  22863. */
  22864. readonly vertexCount: number;
  22865. /**
  22866. * Gets a boolean indicating if this manager supports morphing of normals
  22867. */
  22868. readonly supportsNormals: boolean;
  22869. /**
  22870. * Gets a boolean indicating if this manager supports morphing of tangents
  22871. */
  22872. readonly supportsTangents: boolean;
  22873. /**
  22874. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22875. */
  22876. readonly supportsUVs: boolean;
  22877. /**
  22878. * Gets the number of targets stored in this manager
  22879. */
  22880. readonly numTargets: number;
  22881. /**
  22882. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22883. */
  22884. readonly numInfluencers: number;
  22885. /**
  22886. * Gets the list of influences (one per target)
  22887. */
  22888. readonly influences: Float32Array;
  22889. /**
  22890. * Gets the active target at specified index. An active target is a target with an influence > 0
  22891. * @param index defines the index to check
  22892. * @returns the requested target
  22893. */
  22894. getActiveTarget(index: number): MorphTarget;
  22895. /**
  22896. * Gets the target at specified index
  22897. * @param index defines the index to check
  22898. * @returns the requested target
  22899. */
  22900. getTarget(index: number): MorphTarget;
  22901. /**
  22902. * Add a new target to this manager
  22903. * @param target defines the target to add
  22904. */
  22905. addTarget(target: MorphTarget): void;
  22906. /**
  22907. * Removes a target from the manager
  22908. * @param target defines the target to remove
  22909. */
  22910. removeTarget(target: MorphTarget): void;
  22911. /**
  22912. * Serializes the current manager into a Serialization object
  22913. * @returns the serialized object
  22914. */
  22915. serialize(): any;
  22916. private _syncActiveTargets;
  22917. /**
  22918. * Syncrhonize the targets with all the meshes using this morph target manager
  22919. */
  22920. synchronize(): void;
  22921. /**
  22922. * Creates a new MorphTargetManager from serialized data
  22923. * @param serializationObject defines the serialized data
  22924. * @param scene defines the hosting scene
  22925. * @returns the new MorphTargetManager
  22926. */
  22927. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22928. }
  22929. }
  22930. declare module "babylonjs/Meshes/meshLODLevel" {
  22931. import { Mesh } from "babylonjs/Meshes/mesh";
  22932. import { Nullable } from "babylonjs/types";
  22933. /**
  22934. * Class used to represent a specific level of detail of a mesh
  22935. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22936. */
  22937. export class MeshLODLevel {
  22938. /** Defines the distance where this level should start being displayed */
  22939. distance: number;
  22940. /** Defines the mesh to use to render this level */
  22941. mesh: Nullable<Mesh>;
  22942. /**
  22943. * Creates a new LOD level
  22944. * @param distance defines the distance where this level should star being displayed
  22945. * @param mesh defines the mesh to use to render this level
  22946. */
  22947. constructor(
  22948. /** Defines the distance where this level should start being displayed */
  22949. distance: number,
  22950. /** Defines the mesh to use to render this level */
  22951. mesh: Nullable<Mesh>);
  22952. }
  22953. }
  22954. declare module "babylonjs/Meshes/groundMesh" {
  22955. import { Scene } from "babylonjs/scene";
  22956. import { Vector3 } from "babylonjs/Maths/math.vector";
  22957. import { Mesh } from "babylonjs/Meshes/mesh";
  22958. /**
  22959. * Mesh representing the gorund
  22960. */
  22961. export class GroundMesh extends Mesh {
  22962. /** If octree should be generated */
  22963. generateOctree: boolean;
  22964. private _heightQuads;
  22965. /** @hidden */
  22966. _subdivisionsX: number;
  22967. /** @hidden */
  22968. _subdivisionsY: number;
  22969. /** @hidden */
  22970. _width: number;
  22971. /** @hidden */
  22972. _height: number;
  22973. /** @hidden */
  22974. _minX: number;
  22975. /** @hidden */
  22976. _maxX: number;
  22977. /** @hidden */
  22978. _minZ: number;
  22979. /** @hidden */
  22980. _maxZ: number;
  22981. constructor(name: string, scene: Scene);
  22982. /**
  22983. * "GroundMesh"
  22984. * @returns "GroundMesh"
  22985. */
  22986. getClassName(): string;
  22987. /**
  22988. * The minimum of x and y subdivisions
  22989. */
  22990. readonly subdivisions: number;
  22991. /**
  22992. * X subdivisions
  22993. */
  22994. readonly subdivisionsX: number;
  22995. /**
  22996. * Y subdivisions
  22997. */
  22998. readonly subdivisionsY: number;
  22999. /**
  23000. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23001. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23002. * @param chunksCount the number of subdivisions for x and y
  23003. * @param octreeBlocksSize (Default: 32)
  23004. */
  23005. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23006. /**
  23007. * Returns a height (y) value in the Worl system :
  23008. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23009. * @param x x coordinate
  23010. * @param z z coordinate
  23011. * @returns the ground y position if (x, z) are outside the ground surface.
  23012. */
  23013. getHeightAtCoordinates(x: number, z: number): number;
  23014. /**
  23015. * Returns a normalized vector (Vector3) orthogonal to the ground
  23016. * at the ground coordinates (x, z) expressed in the World system.
  23017. * @param x x coordinate
  23018. * @param z z coordinate
  23019. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23020. */
  23021. getNormalAtCoordinates(x: number, z: number): Vector3;
  23022. /**
  23023. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23024. * at the ground coordinates (x, z) expressed in the World system.
  23025. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23026. * @param x x coordinate
  23027. * @param z z coordinate
  23028. * @param ref vector to store the result
  23029. * @returns the GroundMesh.
  23030. */
  23031. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23032. /**
  23033. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23034. * if the ground has been updated.
  23035. * This can be used in the render loop.
  23036. * @returns the GroundMesh.
  23037. */
  23038. updateCoordinateHeights(): GroundMesh;
  23039. private _getFacetAt;
  23040. private _initHeightQuads;
  23041. private _computeHeightQuads;
  23042. /**
  23043. * Serializes this ground mesh
  23044. * @param serializationObject object to write serialization to
  23045. */
  23046. serialize(serializationObject: any): void;
  23047. /**
  23048. * Parses a serialized ground mesh
  23049. * @param parsedMesh the serialized mesh
  23050. * @param scene the scene to create the ground mesh in
  23051. * @returns the created ground mesh
  23052. */
  23053. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23054. }
  23055. }
  23056. declare module "babylonjs/Physics/physicsJoint" {
  23057. import { Vector3 } from "babylonjs/Maths/math.vector";
  23058. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23059. /**
  23060. * Interface for Physics-Joint data
  23061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23062. */
  23063. export interface PhysicsJointData {
  23064. /**
  23065. * The main pivot of the joint
  23066. */
  23067. mainPivot?: Vector3;
  23068. /**
  23069. * The connected pivot of the joint
  23070. */
  23071. connectedPivot?: Vector3;
  23072. /**
  23073. * The main axis of the joint
  23074. */
  23075. mainAxis?: Vector3;
  23076. /**
  23077. * The connected axis of the joint
  23078. */
  23079. connectedAxis?: Vector3;
  23080. /**
  23081. * The collision of the joint
  23082. */
  23083. collision?: boolean;
  23084. /**
  23085. * Native Oimo/Cannon/Energy data
  23086. */
  23087. nativeParams?: any;
  23088. }
  23089. /**
  23090. * This is a holder class for the physics joint created by the physics plugin
  23091. * It holds a set of functions to control the underlying joint
  23092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23093. */
  23094. export class PhysicsJoint {
  23095. /**
  23096. * The type of the physics joint
  23097. */
  23098. type: number;
  23099. /**
  23100. * The data for the physics joint
  23101. */
  23102. jointData: PhysicsJointData;
  23103. private _physicsJoint;
  23104. protected _physicsPlugin: IPhysicsEnginePlugin;
  23105. /**
  23106. * Initializes the physics joint
  23107. * @param type The type of the physics joint
  23108. * @param jointData The data for the physics joint
  23109. */
  23110. constructor(
  23111. /**
  23112. * The type of the physics joint
  23113. */
  23114. type: number,
  23115. /**
  23116. * The data for the physics joint
  23117. */
  23118. jointData: PhysicsJointData);
  23119. /**
  23120. * Gets the physics joint
  23121. */
  23122. /**
  23123. * Sets the physics joint
  23124. */
  23125. physicsJoint: any;
  23126. /**
  23127. * Sets the physics plugin
  23128. */
  23129. physicsPlugin: IPhysicsEnginePlugin;
  23130. /**
  23131. * Execute a function that is physics-plugin specific.
  23132. * @param {Function} func the function that will be executed.
  23133. * It accepts two parameters: the physics world and the physics joint
  23134. */
  23135. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23136. /**
  23137. * Distance-Joint type
  23138. */
  23139. static DistanceJoint: number;
  23140. /**
  23141. * Hinge-Joint type
  23142. */
  23143. static HingeJoint: number;
  23144. /**
  23145. * Ball-and-Socket joint type
  23146. */
  23147. static BallAndSocketJoint: number;
  23148. /**
  23149. * Wheel-Joint type
  23150. */
  23151. static WheelJoint: number;
  23152. /**
  23153. * Slider-Joint type
  23154. */
  23155. static SliderJoint: number;
  23156. /**
  23157. * Prismatic-Joint type
  23158. */
  23159. static PrismaticJoint: number;
  23160. /**
  23161. * Universal-Joint type
  23162. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23163. */
  23164. static UniversalJoint: number;
  23165. /**
  23166. * Hinge-Joint 2 type
  23167. */
  23168. static Hinge2Joint: number;
  23169. /**
  23170. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23171. */
  23172. static PointToPointJoint: number;
  23173. /**
  23174. * Spring-Joint type
  23175. */
  23176. static SpringJoint: number;
  23177. /**
  23178. * Lock-Joint type
  23179. */
  23180. static LockJoint: number;
  23181. }
  23182. /**
  23183. * A class representing a physics distance joint
  23184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23185. */
  23186. export class DistanceJoint extends PhysicsJoint {
  23187. /**
  23188. *
  23189. * @param jointData The data for the Distance-Joint
  23190. */
  23191. constructor(jointData: DistanceJointData);
  23192. /**
  23193. * Update the predefined distance.
  23194. * @param maxDistance The maximum preferred distance
  23195. * @param minDistance The minimum preferred distance
  23196. */
  23197. updateDistance(maxDistance: number, minDistance?: number): void;
  23198. }
  23199. /**
  23200. * Represents a Motor-Enabled Joint
  23201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23202. */
  23203. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23204. /**
  23205. * Initializes the Motor-Enabled Joint
  23206. * @param type The type of the joint
  23207. * @param jointData The physica joint data for the joint
  23208. */
  23209. constructor(type: number, jointData: PhysicsJointData);
  23210. /**
  23211. * Set the motor values.
  23212. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23213. * @param force the force to apply
  23214. * @param maxForce max force for this motor.
  23215. */
  23216. setMotor(force?: number, maxForce?: number): void;
  23217. /**
  23218. * Set the motor's limits.
  23219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23220. * @param upperLimit The upper limit of the motor
  23221. * @param lowerLimit The lower limit of the motor
  23222. */
  23223. setLimit(upperLimit: number, lowerLimit?: number): void;
  23224. }
  23225. /**
  23226. * This class represents a single physics Hinge-Joint
  23227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23228. */
  23229. export class HingeJoint extends MotorEnabledJoint {
  23230. /**
  23231. * Initializes the Hinge-Joint
  23232. * @param jointData The joint data for the Hinge-Joint
  23233. */
  23234. constructor(jointData: PhysicsJointData);
  23235. /**
  23236. * Set the motor values.
  23237. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23238. * @param {number} force the force to apply
  23239. * @param {number} maxForce max force for this motor.
  23240. */
  23241. setMotor(force?: number, maxForce?: number): void;
  23242. /**
  23243. * Set the motor's limits.
  23244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23245. * @param upperLimit The upper limit of the motor
  23246. * @param lowerLimit The lower limit of the motor
  23247. */
  23248. setLimit(upperLimit: number, lowerLimit?: number): void;
  23249. }
  23250. /**
  23251. * This class represents a dual hinge physics joint (same as wheel joint)
  23252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23253. */
  23254. export class Hinge2Joint extends MotorEnabledJoint {
  23255. /**
  23256. * Initializes the Hinge2-Joint
  23257. * @param jointData The joint data for the Hinge2-Joint
  23258. */
  23259. constructor(jointData: PhysicsJointData);
  23260. /**
  23261. * Set the motor values.
  23262. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23263. * @param {number} targetSpeed the speed the motor is to reach
  23264. * @param {number} maxForce max force for this motor.
  23265. * @param {motorIndex} the motor's index, 0 or 1.
  23266. */
  23267. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23268. /**
  23269. * Set the motor limits.
  23270. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23271. * @param {number} upperLimit the upper limit
  23272. * @param {number} lowerLimit lower limit
  23273. * @param {motorIndex} the motor's index, 0 or 1.
  23274. */
  23275. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23276. }
  23277. /**
  23278. * Interface for a motor enabled joint
  23279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23280. */
  23281. export interface IMotorEnabledJoint {
  23282. /**
  23283. * Physics joint
  23284. */
  23285. physicsJoint: any;
  23286. /**
  23287. * Sets the motor of the motor-enabled joint
  23288. * @param force The force of the motor
  23289. * @param maxForce The maximum force of the motor
  23290. * @param motorIndex The index of the motor
  23291. */
  23292. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23293. /**
  23294. * Sets the limit of the motor
  23295. * @param upperLimit The upper limit of the motor
  23296. * @param lowerLimit The lower limit of the motor
  23297. * @param motorIndex The index of the motor
  23298. */
  23299. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23300. }
  23301. /**
  23302. * Joint data for a Distance-Joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface DistanceJointData extends PhysicsJointData {
  23306. /**
  23307. * Max distance the 2 joint objects can be apart
  23308. */
  23309. maxDistance: number;
  23310. }
  23311. /**
  23312. * Joint data from a spring joint
  23313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23314. */
  23315. export interface SpringJointData extends PhysicsJointData {
  23316. /**
  23317. * Length of the spring
  23318. */
  23319. length: number;
  23320. /**
  23321. * Stiffness of the spring
  23322. */
  23323. stiffness: number;
  23324. /**
  23325. * Damping of the spring
  23326. */
  23327. damping: number;
  23328. /** this callback will be called when applying the force to the impostors. */
  23329. forceApplicationCallback: () => void;
  23330. }
  23331. }
  23332. declare module "babylonjs/Physics/physicsRaycastResult" {
  23333. import { Vector3 } from "babylonjs/Maths/math.vector";
  23334. /**
  23335. * Holds the data for the raycast result
  23336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23337. */
  23338. export class PhysicsRaycastResult {
  23339. private _hasHit;
  23340. private _hitDistance;
  23341. private _hitNormalWorld;
  23342. private _hitPointWorld;
  23343. private _rayFromWorld;
  23344. private _rayToWorld;
  23345. /**
  23346. * Gets if there was a hit
  23347. */
  23348. readonly hasHit: boolean;
  23349. /**
  23350. * Gets the distance from the hit
  23351. */
  23352. readonly hitDistance: number;
  23353. /**
  23354. * Gets the hit normal/direction in the world
  23355. */
  23356. readonly hitNormalWorld: Vector3;
  23357. /**
  23358. * Gets the hit point in the world
  23359. */
  23360. readonly hitPointWorld: Vector3;
  23361. /**
  23362. * Gets the ray "start point" of the ray in the world
  23363. */
  23364. readonly rayFromWorld: Vector3;
  23365. /**
  23366. * Gets the ray "end point" of the ray in the world
  23367. */
  23368. readonly rayToWorld: Vector3;
  23369. /**
  23370. * Sets the hit data (normal & point in world space)
  23371. * @param hitNormalWorld defines the normal in world space
  23372. * @param hitPointWorld defines the point in world space
  23373. */
  23374. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23375. /**
  23376. * Sets the distance from the start point to the hit point
  23377. * @param distance
  23378. */
  23379. setHitDistance(distance: number): void;
  23380. /**
  23381. * Calculates the distance manually
  23382. */
  23383. calculateHitDistance(): void;
  23384. /**
  23385. * Resets all the values to default
  23386. * @param from The from point on world space
  23387. * @param to The to point on world space
  23388. */
  23389. reset(from?: Vector3, to?: Vector3): void;
  23390. }
  23391. /**
  23392. * Interface for the size containing width and height
  23393. */
  23394. interface IXYZ {
  23395. /**
  23396. * X
  23397. */
  23398. x: number;
  23399. /**
  23400. * Y
  23401. */
  23402. y: number;
  23403. /**
  23404. * Z
  23405. */
  23406. z: number;
  23407. }
  23408. }
  23409. declare module "babylonjs/Physics/IPhysicsEngine" {
  23410. import { Nullable } from "babylonjs/types";
  23411. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23413. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23414. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23415. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23416. /**
  23417. * Interface used to describe a physics joint
  23418. */
  23419. export interface PhysicsImpostorJoint {
  23420. /** Defines the main impostor to which the joint is linked */
  23421. mainImpostor: PhysicsImpostor;
  23422. /** Defines the impostor that is connected to the main impostor using this joint */
  23423. connectedImpostor: PhysicsImpostor;
  23424. /** Defines the joint itself */
  23425. joint: PhysicsJoint;
  23426. }
  23427. /** @hidden */
  23428. export interface IPhysicsEnginePlugin {
  23429. world: any;
  23430. name: string;
  23431. setGravity(gravity: Vector3): void;
  23432. setTimeStep(timeStep: number): void;
  23433. getTimeStep(): number;
  23434. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23435. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23436. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23437. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23438. removePhysicsBody(impostor: PhysicsImpostor): void;
  23439. generateJoint(joint: PhysicsImpostorJoint): void;
  23440. removeJoint(joint: PhysicsImpostorJoint): void;
  23441. isSupported(): boolean;
  23442. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23443. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23444. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23445. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23446. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23447. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23448. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23449. getBodyMass(impostor: PhysicsImpostor): number;
  23450. getBodyFriction(impostor: PhysicsImpostor): number;
  23451. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23452. getBodyRestitution(impostor: PhysicsImpostor): number;
  23453. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23454. getBodyPressure?(impostor: PhysicsImpostor): number;
  23455. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23456. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23457. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23458. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23459. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23460. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23461. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23462. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23463. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23464. sleepBody(impostor: PhysicsImpostor): void;
  23465. wakeUpBody(impostor: PhysicsImpostor): void;
  23466. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23468. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23470. getRadius(impostor: PhysicsImpostor): number;
  23471. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23472. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23473. dispose(): void;
  23474. }
  23475. /**
  23476. * Interface used to define a physics engine
  23477. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23478. */
  23479. export interface IPhysicsEngine {
  23480. /**
  23481. * Gets the gravity vector used by the simulation
  23482. */
  23483. gravity: Vector3;
  23484. /**
  23485. * Sets the gravity vector used by the simulation
  23486. * @param gravity defines the gravity vector to use
  23487. */
  23488. setGravity(gravity: Vector3): void;
  23489. /**
  23490. * Set the time step of the physics engine.
  23491. * Default is 1/60.
  23492. * To slow it down, enter 1/600 for example.
  23493. * To speed it up, 1/30
  23494. * @param newTimeStep the new timestep to apply to this world.
  23495. */
  23496. setTimeStep(newTimeStep: number): void;
  23497. /**
  23498. * Get the time step of the physics engine.
  23499. * @returns the current time step
  23500. */
  23501. getTimeStep(): number;
  23502. /**
  23503. * Release all resources
  23504. */
  23505. dispose(): void;
  23506. /**
  23507. * Gets the name of the current physics plugin
  23508. * @returns the name of the plugin
  23509. */
  23510. getPhysicsPluginName(): string;
  23511. /**
  23512. * Adding a new impostor for the impostor tracking.
  23513. * This will be done by the impostor itself.
  23514. * @param impostor the impostor to add
  23515. */
  23516. addImpostor(impostor: PhysicsImpostor): void;
  23517. /**
  23518. * Remove an impostor from the engine.
  23519. * This impostor and its mesh will not longer be updated by the physics engine.
  23520. * @param impostor the impostor to remove
  23521. */
  23522. removeImpostor(impostor: PhysicsImpostor): void;
  23523. /**
  23524. * Add a joint to the physics engine
  23525. * @param mainImpostor defines the main impostor to which the joint is added.
  23526. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23527. * @param joint defines the joint that will connect both impostors.
  23528. */
  23529. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23530. /**
  23531. * Removes a joint from the simulation
  23532. * @param mainImpostor defines the impostor used with the joint
  23533. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23534. * @param joint defines the joint to remove
  23535. */
  23536. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23537. /**
  23538. * Gets the current plugin used to run the simulation
  23539. * @returns current plugin
  23540. */
  23541. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23542. /**
  23543. * Gets the list of physic impostors
  23544. * @returns an array of PhysicsImpostor
  23545. */
  23546. getImpostors(): Array<PhysicsImpostor>;
  23547. /**
  23548. * Gets the impostor for a physics enabled object
  23549. * @param object defines the object impersonated by the impostor
  23550. * @returns the PhysicsImpostor or null if not found
  23551. */
  23552. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23553. /**
  23554. * Gets the impostor for a physics body object
  23555. * @param body defines physics body used by the impostor
  23556. * @returns the PhysicsImpostor or null if not found
  23557. */
  23558. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23559. /**
  23560. * Does a raycast in the physics world
  23561. * @param from when should the ray start?
  23562. * @param to when should the ray end?
  23563. * @returns PhysicsRaycastResult
  23564. */
  23565. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23566. /**
  23567. * Called by the scene. No need to call it.
  23568. * @param delta defines the timespam between frames
  23569. */
  23570. _step(delta: number): void;
  23571. }
  23572. }
  23573. declare module "babylonjs/Physics/physicsImpostor" {
  23574. import { Nullable, IndicesArray } from "babylonjs/types";
  23575. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23576. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23578. import { Scene } from "babylonjs/scene";
  23579. import { Bone } from "babylonjs/Bones/bone";
  23580. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23581. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23582. import { Space } from "babylonjs/Maths/math.axis";
  23583. /**
  23584. * The interface for the physics imposter parameters
  23585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23586. */
  23587. export interface PhysicsImpostorParameters {
  23588. /**
  23589. * The mass of the physics imposter
  23590. */
  23591. mass: number;
  23592. /**
  23593. * The friction of the physics imposter
  23594. */
  23595. friction?: number;
  23596. /**
  23597. * The coefficient of restitution of the physics imposter
  23598. */
  23599. restitution?: number;
  23600. /**
  23601. * The native options of the physics imposter
  23602. */
  23603. nativeOptions?: any;
  23604. /**
  23605. * Specifies if the parent should be ignored
  23606. */
  23607. ignoreParent?: boolean;
  23608. /**
  23609. * Specifies if bi-directional transformations should be disabled
  23610. */
  23611. disableBidirectionalTransformation?: boolean;
  23612. /**
  23613. * The pressure inside the physics imposter, soft object only
  23614. */
  23615. pressure?: number;
  23616. /**
  23617. * The stiffness the physics imposter, soft object only
  23618. */
  23619. stiffness?: number;
  23620. /**
  23621. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23622. */
  23623. velocityIterations?: number;
  23624. /**
  23625. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23626. */
  23627. positionIterations?: number;
  23628. /**
  23629. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23630. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23631. * Add to fix multiple points
  23632. */
  23633. fixedPoints?: number;
  23634. /**
  23635. * The collision margin around a soft object
  23636. */
  23637. margin?: number;
  23638. /**
  23639. * The collision margin around a soft object
  23640. */
  23641. damping?: number;
  23642. /**
  23643. * The path for a rope based on an extrusion
  23644. */
  23645. path?: any;
  23646. /**
  23647. * The shape of an extrusion used for a rope based on an extrusion
  23648. */
  23649. shape?: any;
  23650. }
  23651. /**
  23652. * Interface for a physics-enabled object
  23653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23654. */
  23655. export interface IPhysicsEnabledObject {
  23656. /**
  23657. * The position of the physics-enabled object
  23658. */
  23659. position: Vector3;
  23660. /**
  23661. * The rotation of the physics-enabled object
  23662. */
  23663. rotationQuaternion: Nullable<Quaternion>;
  23664. /**
  23665. * The scale of the physics-enabled object
  23666. */
  23667. scaling: Vector3;
  23668. /**
  23669. * The rotation of the physics-enabled object
  23670. */
  23671. rotation?: Vector3;
  23672. /**
  23673. * The parent of the physics-enabled object
  23674. */
  23675. parent?: any;
  23676. /**
  23677. * The bounding info of the physics-enabled object
  23678. * @returns The bounding info of the physics-enabled object
  23679. */
  23680. getBoundingInfo(): BoundingInfo;
  23681. /**
  23682. * Computes the world matrix
  23683. * @param force Specifies if the world matrix should be computed by force
  23684. * @returns A world matrix
  23685. */
  23686. computeWorldMatrix(force: boolean): Matrix;
  23687. /**
  23688. * Gets the world matrix
  23689. * @returns A world matrix
  23690. */
  23691. getWorldMatrix?(): Matrix;
  23692. /**
  23693. * Gets the child meshes
  23694. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23695. * @returns An array of abstract meshes
  23696. */
  23697. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23698. /**
  23699. * Gets the vertex data
  23700. * @param kind The type of vertex data
  23701. * @returns A nullable array of numbers, or a float32 array
  23702. */
  23703. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23704. /**
  23705. * Gets the indices from the mesh
  23706. * @returns A nullable array of index arrays
  23707. */
  23708. getIndices?(): Nullable<IndicesArray>;
  23709. /**
  23710. * Gets the scene from the mesh
  23711. * @returns the indices array or null
  23712. */
  23713. getScene?(): Scene;
  23714. /**
  23715. * Gets the absolute position from the mesh
  23716. * @returns the absolute position
  23717. */
  23718. getAbsolutePosition(): Vector3;
  23719. /**
  23720. * Gets the absolute pivot point from the mesh
  23721. * @returns the absolute pivot point
  23722. */
  23723. getAbsolutePivotPoint(): Vector3;
  23724. /**
  23725. * Rotates the mesh
  23726. * @param axis The axis of rotation
  23727. * @param amount The amount of rotation
  23728. * @param space The space of the rotation
  23729. * @returns The rotation transform node
  23730. */
  23731. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23732. /**
  23733. * Translates the mesh
  23734. * @param axis The axis of translation
  23735. * @param distance The distance of translation
  23736. * @param space The space of the translation
  23737. * @returns The transform node
  23738. */
  23739. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23740. /**
  23741. * Sets the absolute position of the mesh
  23742. * @param absolutePosition The absolute position of the mesh
  23743. * @returns The transform node
  23744. */
  23745. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23746. /**
  23747. * Gets the class name of the mesh
  23748. * @returns The class name
  23749. */
  23750. getClassName(): string;
  23751. }
  23752. /**
  23753. * Represents a physics imposter
  23754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23755. */
  23756. export class PhysicsImpostor {
  23757. /**
  23758. * The physics-enabled object used as the physics imposter
  23759. */
  23760. object: IPhysicsEnabledObject;
  23761. /**
  23762. * The type of the physics imposter
  23763. */
  23764. type: number;
  23765. private _options;
  23766. private _scene?;
  23767. /**
  23768. * The default object size of the imposter
  23769. */
  23770. static DEFAULT_OBJECT_SIZE: Vector3;
  23771. /**
  23772. * The identity quaternion of the imposter
  23773. */
  23774. static IDENTITY_QUATERNION: Quaternion;
  23775. /** @hidden */
  23776. _pluginData: any;
  23777. private _physicsEngine;
  23778. private _physicsBody;
  23779. private _bodyUpdateRequired;
  23780. private _onBeforePhysicsStepCallbacks;
  23781. private _onAfterPhysicsStepCallbacks;
  23782. /** @hidden */
  23783. _onPhysicsCollideCallbacks: Array<{
  23784. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23785. otherImpostors: Array<PhysicsImpostor>;
  23786. }>;
  23787. private _deltaPosition;
  23788. private _deltaRotation;
  23789. private _deltaRotationConjugated;
  23790. /** @hidden */
  23791. _isFromLine: boolean;
  23792. private _parent;
  23793. private _isDisposed;
  23794. private static _tmpVecs;
  23795. private static _tmpQuat;
  23796. /**
  23797. * Specifies if the physics imposter is disposed
  23798. */
  23799. readonly isDisposed: boolean;
  23800. /**
  23801. * Gets the mass of the physics imposter
  23802. */
  23803. mass: number;
  23804. /**
  23805. * Gets the coefficient of friction
  23806. */
  23807. /**
  23808. * Sets the coefficient of friction
  23809. */
  23810. friction: number;
  23811. /**
  23812. * Gets the coefficient of restitution
  23813. */
  23814. /**
  23815. * Sets the coefficient of restitution
  23816. */
  23817. restitution: number;
  23818. /**
  23819. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23820. */
  23821. /**
  23822. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23823. */
  23824. pressure: number;
  23825. /**
  23826. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23827. */
  23828. /**
  23829. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23830. */
  23831. stiffness: number;
  23832. /**
  23833. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23834. */
  23835. /**
  23836. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23837. */
  23838. velocityIterations: number;
  23839. /**
  23840. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23841. */
  23842. /**
  23843. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23844. */
  23845. positionIterations: number;
  23846. /**
  23847. * The unique id of the physics imposter
  23848. * set by the physics engine when adding this impostor to the array
  23849. */
  23850. uniqueId: number;
  23851. /**
  23852. * @hidden
  23853. */
  23854. soft: boolean;
  23855. /**
  23856. * @hidden
  23857. */
  23858. segments: number;
  23859. private _joints;
  23860. /**
  23861. * Initializes the physics imposter
  23862. * @param object The physics-enabled object used as the physics imposter
  23863. * @param type The type of the physics imposter
  23864. * @param _options The options for the physics imposter
  23865. * @param _scene The Babylon scene
  23866. */
  23867. constructor(
  23868. /**
  23869. * The physics-enabled object used as the physics imposter
  23870. */
  23871. object: IPhysicsEnabledObject,
  23872. /**
  23873. * The type of the physics imposter
  23874. */
  23875. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23876. /**
  23877. * This function will completly initialize this impostor.
  23878. * It will create a new body - but only if this mesh has no parent.
  23879. * If it has, this impostor will not be used other than to define the impostor
  23880. * of the child mesh.
  23881. * @hidden
  23882. */
  23883. _init(): void;
  23884. private _getPhysicsParent;
  23885. /**
  23886. * Should a new body be generated.
  23887. * @returns boolean specifying if body initialization is required
  23888. */
  23889. isBodyInitRequired(): boolean;
  23890. /**
  23891. * Sets the updated scaling
  23892. * @param updated Specifies if the scaling is updated
  23893. */
  23894. setScalingUpdated(): void;
  23895. /**
  23896. * Force a regeneration of this or the parent's impostor's body.
  23897. * Use under cautious - This will remove all joints already implemented.
  23898. */
  23899. forceUpdate(): void;
  23900. /**
  23901. * Gets the body that holds this impostor. Either its own, or its parent.
  23902. */
  23903. /**
  23904. * Set the physics body. Used mainly by the physics engine/plugin
  23905. */
  23906. physicsBody: any;
  23907. /**
  23908. * Get the parent of the physics imposter
  23909. * @returns Physics imposter or null
  23910. */
  23911. /**
  23912. * Sets the parent of the physics imposter
  23913. */
  23914. parent: Nullable<PhysicsImpostor>;
  23915. /**
  23916. * Resets the update flags
  23917. */
  23918. resetUpdateFlags(): void;
  23919. /**
  23920. * Gets the object extend size
  23921. * @returns the object extend size
  23922. */
  23923. getObjectExtendSize(): Vector3;
  23924. /**
  23925. * Gets the object center
  23926. * @returns The object center
  23927. */
  23928. getObjectCenter(): Vector3;
  23929. /**
  23930. * Get a specific parametes from the options parameter
  23931. * @param paramName The object parameter name
  23932. * @returns The object parameter
  23933. */
  23934. getParam(paramName: string): any;
  23935. /**
  23936. * Sets a specific parameter in the options given to the physics plugin
  23937. * @param paramName The parameter name
  23938. * @param value The value of the parameter
  23939. */
  23940. setParam(paramName: string, value: number): void;
  23941. /**
  23942. * Specifically change the body's mass option. Won't recreate the physics body object
  23943. * @param mass The mass of the physics imposter
  23944. */
  23945. setMass(mass: number): void;
  23946. /**
  23947. * Gets the linear velocity
  23948. * @returns linear velocity or null
  23949. */
  23950. getLinearVelocity(): Nullable<Vector3>;
  23951. /**
  23952. * Sets the linear velocity
  23953. * @param velocity linear velocity or null
  23954. */
  23955. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23956. /**
  23957. * Gets the angular velocity
  23958. * @returns angular velocity or null
  23959. */
  23960. getAngularVelocity(): Nullable<Vector3>;
  23961. /**
  23962. * Sets the angular velocity
  23963. * @param velocity The velocity or null
  23964. */
  23965. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23966. /**
  23967. * Execute a function with the physics plugin native code
  23968. * Provide a function the will have two variables - the world object and the physics body object
  23969. * @param func The function to execute with the physics plugin native code
  23970. */
  23971. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23972. /**
  23973. * Register a function that will be executed before the physics world is stepping forward
  23974. * @param func The function to execute before the physics world is stepped forward
  23975. */
  23976. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23977. /**
  23978. * Unregister a function that will be executed before the physics world is stepping forward
  23979. * @param func The function to execute before the physics world is stepped forward
  23980. */
  23981. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23982. /**
  23983. * Register a function that will be executed after the physics step
  23984. * @param func The function to execute after physics step
  23985. */
  23986. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23987. /**
  23988. * Unregisters a function that will be executed after the physics step
  23989. * @param func The function to execute after physics step
  23990. */
  23991. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23992. /**
  23993. * register a function that will be executed when this impostor collides against a different body
  23994. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23995. * @param func Callback that is executed on collision
  23996. */
  23997. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23998. /**
  23999. * Unregisters the physics imposter on contact
  24000. * @param collideAgainst The physics object to collide against
  24001. * @param func Callback to execute on collision
  24002. */
  24003. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24004. private _tmpQuat;
  24005. private _tmpQuat2;
  24006. /**
  24007. * Get the parent rotation
  24008. * @returns The parent rotation
  24009. */
  24010. getParentsRotation(): Quaternion;
  24011. /**
  24012. * this function is executed by the physics engine.
  24013. */
  24014. beforeStep: () => void;
  24015. /**
  24016. * this function is executed by the physics engine
  24017. */
  24018. afterStep: () => void;
  24019. /**
  24020. * Legacy collision detection event support
  24021. */
  24022. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24023. /**
  24024. * event and body object due to cannon's event-based architecture.
  24025. */
  24026. onCollide: (e: {
  24027. body: any;
  24028. }) => void;
  24029. /**
  24030. * Apply a force
  24031. * @param force The force to apply
  24032. * @param contactPoint The contact point for the force
  24033. * @returns The physics imposter
  24034. */
  24035. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24036. /**
  24037. * Apply an impulse
  24038. * @param force The impulse force
  24039. * @param contactPoint The contact point for the impulse force
  24040. * @returns The physics imposter
  24041. */
  24042. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24043. /**
  24044. * A help function to create a joint
  24045. * @param otherImpostor A physics imposter used to create a joint
  24046. * @param jointType The type of joint
  24047. * @param jointData The data for the joint
  24048. * @returns The physics imposter
  24049. */
  24050. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24051. /**
  24052. * Add a joint to this impostor with a different impostor
  24053. * @param otherImpostor A physics imposter used to add a joint
  24054. * @param joint The joint to add
  24055. * @returns The physics imposter
  24056. */
  24057. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24058. /**
  24059. * Add an anchor to a cloth impostor
  24060. * @param otherImpostor rigid impostor to anchor to
  24061. * @param width ratio across width from 0 to 1
  24062. * @param height ratio up height from 0 to 1
  24063. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24064. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24065. * @returns impostor the soft imposter
  24066. */
  24067. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24068. /**
  24069. * Add a hook to a rope impostor
  24070. * @param otherImpostor rigid impostor to anchor to
  24071. * @param length ratio across rope from 0 to 1
  24072. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24073. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24074. * @returns impostor the rope imposter
  24075. */
  24076. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24077. /**
  24078. * Will keep this body still, in a sleep mode.
  24079. * @returns the physics imposter
  24080. */
  24081. sleep(): PhysicsImpostor;
  24082. /**
  24083. * Wake the body up.
  24084. * @returns The physics imposter
  24085. */
  24086. wakeUp(): PhysicsImpostor;
  24087. /**
  24088. * Clones the physics imposter
  24089. * @param newObject The physics imposter clones to this physics-enabled object
  24090. * @returns A nullable physics imposter
  24091. */
  24092. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24093. /**
  24094. * Disposes the physics imposter
  24095. */
  24096. dispose(): void;
  24097. /**
  24098. * Sets the delta position
  24099. * @param position The delta position amount
  24100. */
  24101. setDeltaPosition(position: Vector3): void;
  24102. /**
  24103. * Sets the delta rotation
  24104. * @param rotation The delta rotation amount
  24105. */
  24106. setDeltaRotation(rotation: Quaternion): void;
  24107. /**
  24108. * Gets the box size of the physics imposter and stores the result in the input parameter
  24109. * @param result Stores the box size
  24110. * @returns The physics imposter
  24111. */
  24112. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24113. /**
  24114. * Gets the radius of the physics imposter
  24115. * @returns Radius of the physics imposter
  24116. */
  24117. getRadius(): number;
  24118. /**
  24119. * Sync a bone with this impostor
  24120. * @param bone The bone to sync to the impostor.
  24121. * @param boneMesh The mesh that the bone is influencing.
  24122. * @param jointPivot The pivot of the joint / bone in local space.
  24123. * @param distToJoint Optional distance from the impostor to the joint.
  24124. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24125. */
  24126. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24127. /**
  24128. * Sync impostor to a bone
  24129. * @param bone The bone that the impostor will be synced to.
  24130. * @param boneMesh The mesh that the bone is influencing.
  24131. * @param jointPivot The pivot of the joint / bone in local space.
  24132. * @param distToJoint Optional distance from the impostor to the joint.
  24133. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24134. * @param boneAxis Optional vector3 axis the bone is aligned with
  24135. */
  24136. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24137. /**
  24138. * No-Imposter type
  24139. */
  24140. static NoImpostor: number;
  24141. /**
  24142. * Sphere-Imposter type
  24143. */
  24144. static SphereImpostor: number;
  24145. /**
  24146. * Box-Imposter type
  24147. */
  24148. static BoxImpostor: number;
  24149. /**
  24150. * Plane-Imposter type
  24151. */
  24152. static PlaneImpostor: number;
  24153. /**
  24154. * Mesh-imposter type
  24155. */
  24156. static MeshImpostor: number;
  24157. /**
  24158. * Capsule-Impostor type (Ammo.js plugin only)
  24159. */
  24160. static CapsuleImpostor: number;
  24161. /**
  24162. * Cylinder-Imposter type
  24163. */
  24164. static CylinderImpostor: number;
  24165. /**
  24166. * Particle-Imposter type
  24167. */
  24168. static ParticleImpostor: number;
  24169. /**
  24170. * Heightmap-Imposter type
  24171. */
  24172. static HeightmapImpostor: number;
  24173. /**
  24174. * ConvexHull-Impostor type (Ammo.js plugin only)
  24175. */
  24176. static ConvexHullImpostor: number;
  24177. /**
  24178. * Rope-Imposter type
  24179. */
  24180. static RopeImpostor: number;
  24181. /**
  24182. * Cloth-Imposter type
  24183. */
  24184. static ClothImpostor: number;
  24185. /**
  24186. * Softbody-Imposter type
  24187. */
  24188. static SoftbodyImpostor: number;
  24189. }
  24190. }
  24191. declare module "babylonjs/Meshes/mesh" {
  24192. import { Observable } from "babylonjs/Misc/observable";
  24193. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24194. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24195. import { Camera } from "babylonjs/Cameras/camera";
  24196. import { Scene } from "babylonjs/scene";
  24197. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24198. import { Color4 } from "babylonjs/Maths/math.color";
  24199. import { Engine } from "babylonjs/Engines/engine";
  24200. import { Node } from "babylonjs/node";
  24201. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24202. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24203. import { Buffer } from "babylonjs/Meshes/buffer";
  24204. import { Geometry } from "babylonjs/Meshes/geometry";
  24205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24206. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24207. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24208. import { Effect } from "babylonjs/Materials/effect";
  24209. import { Material } from "babylonjs/Materials/material";
  24210. import { Skeleton } from "babylonjs/Bones/skeleton";
  24211. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24212. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24213. import { Path3D } from "babylonjs/Maths/math.path";
  24214. import { Plane } from "babylonjs/Maths/math.plane";
  24215. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24216. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24217. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24218. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24219. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24220. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24221. /**
  24222. * @hidden
  24223. **/
  24224. export class _CreationDataStorage {
  24225. closePath?: boolean;
  24226. closeArray?: boolean;
  24227. idx: number[];
  24228. dashSize: number;
  24229. gapSize: number;
  24230. path3D: Path3D;
  24231. pathArray: Vector3[][];
  24232. arc: number;
  24233. radius: number;
  24234. cap: number;
  24235. tessellation: number;
  24236. }
  24237. /**
  24238. * @hidden
  24239. **/
  24240. class _InstanceDataStorage {
  24241. visibleInstances: any;
  24242. batchCache: _InstancesBatch;
  24243. instancesBufferSize: number;
  24244. instancesBuffer: Nullable<Buffer>;
  24245. instancesData: Float32Array;
  24246. overridenInstanceCount: number;
  24247. isFrozen: boolean;
  24248. previousBatch: Nullable<_InstancesBatch>;
  24249. hardwareInstancedRendering: boolean;
  24250. sideOrientation: number;
  24251. }
  24252. /**
  24253. * @hidden
  24254. **/
  24255. export class _InstancesBatch {
  24256. mustReturn: boolean;
  24257. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24258. renderSelf: boolean[];
  24259. hardwareInstancedRendering: boolean[];
  24260. }
  24261. /**
  24262. * Class used to represent renderable models
  24263. */
  24264. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24265. /**
  24266. * Mesh side orientation : usually the external or front surface
  24267. */
  24268. static readonly FRONTSIDE: number;
  24269. /**
  24270. * Mesh side orientation : usually the internal or back surface
  24271. */
  24272. static readonly BACKSIDE: number;
  24273. /**
  24274. * Mesh side orientation : both internal and external or front and back surfaces
  24275. */
  24276. static readonly DOUBLESIDE: number;
  24277. /**
  24278. * Mesh side orientation : by default, `FRONTSIDE`
  24279. */
  24280. static readonly DEFAULTSIDE: number;
  24281. /**
  24282. * Mesh cap setting : no cap
  24283. */
  24284. static readonly NO_CAP: number;
  24285. /**
  24286. * Mesh cap setting : one cap at the beginning of the mesh
  24287. */
  24288. static readonly CAP_START: number;
  24289. /**
  24290. * Mesh cap setting : one cap at the end of the mesh
  24291. */
  24292. static readonly CAP_END: number;
  24293. /**
  24294. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24295. */
  24296. static readonly CAP_ALL: number;
  24297. /**
  24298. * Mesh pattern setting : no flip or rotate
  24299. */
  24300. static readonly NO_FLIP: number;
  24301. /**
  24302. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24303. */
  24304. static readonly FLIP_TILE: number;
  24305. /**
  24306. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24307. */
  24308. static readonly ROTATE_TILE: number;
  24309. /**
  24310. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24311. */
  24312. static readonly FLIP_ROW: number;
  24313. /**
  24314. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24315. */
  24316. static readonly ROTATE_ROW: number;
  24317. /**
  24318. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24319. */
  24320. static readonly FLIP_N_ROTATE_TILE: number;
  24321. /**
  24322. * Mesh pattern setting : rotate pattern and rotate
  24323. */
  24324. static readonly FLIP_N_ROTATE_ROW: number;
  24325. /**
  24326. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24327. */
  24328. static readonly CENTER: number;
  24329. /**
  24330. * Mesh tile positioning : part tiles on left
  24331. */
  24332. static readonly LEFT: number;
  24333. /**
  24334. * Mesh tile positioning : part tiles on right
  24335. */
  24336. static readonly RIGHT: number;
  24337. /**
  24338. * Mesh tile positioning : part tiles on top
  24339. */
  24340. static readonly TOP: number;
  24341. /**
  24342. * Mesh tile positioning : part tiles on bottom
  24343. */
  24344. static readonly BOTTOM: number;
  24345. /**
  24346. * Gets the default side orientation.
  24347. * @param orientation the orientation to value to attempt to get
  24348. * @returns the default orientation
  24349. * @hidden
  24350. */
  24351. static _GetDefaultSideOrientation(orientation?: number): number;
  24352. private _internalMeshDataInfo;
  24353. /**
  24354. * An event triggered before rendering the mesh
  24355. */
  24356. readonly onBeforeRenderObservable: Observable<Mesh>;
  24357. /**
  24358. * An event triggered before binding the mesh
  24359. */
  24360. readonly onBeforeBindObservable: Observable<Mesh>;
  24361. /**
  24362. * An event triggered after rendering the mesh
  24363. */
  24364. readonly onAfterRenderObservable: Observable<Mesh>;
  24365. /**
  24366. * An event triggered before drawing the mesh
  24367. */
  24368. readonly onBeforeDrawObservable: Observable<Mesh>;
  24369. private _onBeforeDrawObserver;
  24370. /**
  24371. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24372. */
  24373. onBeforeDraw: () => void;
  24374. readonly hasInstances: boolean;
  24375. /**
  24376. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24377. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24378. */
  24379. delayLoadState: number;
  24380. /**
  24381. * Gets the list of instances created from this mesh
  24382. * it is not supposed to be modified manually.
  24383. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24384. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24385. */
  24386. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24387. /**
  24388. * Gets the file containing delay loading data for this mesh
  24389. */
  24390. delayLoadingFile: string;
  24391. /** @hidden */
  24392. _binaryInfo: any;
  24393. /**
  24394. * User defined function used to change how LOD level selection is done
  24395. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24396. */
  24397. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24398. /**
  24399. * Gets or sets the morph target manager
  24400. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24401. */
  24402. morphTargetManager: Nullable<MorphTargetManager>;
  24403. /** @hidden */
  24404. _creationDataStorage: Nullable<_CreationDataStorage>;
  24405. /** @hidden */
  24406. _geometry: Nullable<Geometry>;
  24407. /** @hidden */
  24408. _delayInfo: Array<string>;
  24409. /** @hidden */
  24410. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24411. /** @hidden */
  24412. _instanceDataStorage: _InstanceDataStorage;
  24413. private _effectiveMaterial;
  24414. /** @hidden */
  24415. _shouldGenerateFlatShading: boolean;
  24416. /** @hidden */
  24417. _originalBuilderSideOrientation: number;
  24418. /**
  24419. * Use this property to change the original side orientation defined at construction time
  24420. */
  24421. overrideMaterialSideOrientation: Nullable<number>;
  24422. /**
  24423. * Gets the source mesh (the one used to clone this one from)
  24424. */
  24425. readonly source: Nullable<Mesh>;
  24426. /**
  24427. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24428. */
  24429. isUnIndexed: boolean;
  24430. /**
  24431. * @constructor
  24432. * @param name The value used by scene.getMeshByName() to do a lookup.
  24433. * @param scene The scene to add this mesh to.
  24434. * @param parent The parent of this mesh, if it has one
  24435. * @param source An optional Mesh from which geometry is shared, cloned.
  24436. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24437. * When false, achieved by calling a clone(), also passing False.
  24438. * This will make creation of children, recursive.
  24439. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24440. */
  24441. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24442. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24443. /**
  24444. * Gets the class name
  24445. * @returns the string "Mesh".
  24446. */
  24447. getClassName(): string;
  24448. /** @hidden */
  24449. readonly _isMesh: boolean;
  24450. /**
  24451. * Returns a description of this mesh
  24452. * @param fullDetails define if full details about this mesh must be used
  24453. * @returns a descriptive string representing this mesh
  24454. */
  24455. toString(fullDetails?: boolean): string;
  24456. /** @hidden */
  24457. _unBindEffect(): void;
  24458. /**
  24459. * Gets a boolean indicating if this mesh has LOD
  24460. */
  24461. readonly hasLODLevels: boolean;
  24462. /**
  24463. * Gets the list of MeshLODLevel associated with the current mesh
  24464. * @returns an array of MeshLODLevel
  24465. */
  24466. getLODLevels(): MeshLODLevel[];
  24467. private _sortLODLevels;
  24468. /**
  24469. * Add a mesh as LOD level triggered at the given distance.
  24470. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24471. * @param distance The distance from the center of the object to show this level
  24472. * @param mesh The mesh to be added as LOD level (can be null)
  24473. * @return This mesh (for chaining)
  24474. */
  24475. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24476. /**
  24477. * Returns the LOD level mesh at the passed distance or null if not found.
  24478. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24479. * @param distance The distance from the center of the object to show this level
  24480. * @returns a Mesh or `null`
  24481. */
  24482. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24483. /**
  24484. * Remove a mesh from the LOD array
  24485. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24486. * @param mesh defines the mesh to be removed
  24487. * @return This mesh (for chaining)
  24488. */
  24489. removeLODLevel(mesh: Mesh): Mesh;
  24490. /**
  24491. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24492. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24493. * @param camera defines the camera to use to compute distance
  24494. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24495. * @return This mesh (for chaining)
  24496. */
  24497. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24498. /**
  24499. * Gets the mesh internal Geometry object
  24500. */
  24501. readonly geometry: Nullable<Geometry>;
  24502. /**
  24503. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24504. * @returns the total number of vertices
  24505. */
  24506. getTotalVertices(): number;
  24507. /**
  24508. * Returns the content of an associated vertex buffer
  24509. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24510. * - VertexBuffer.PositionKind
  24511. * - VertexBuffer.UVKind
  24512. * - VertexBuffer.UV2Kind
  24513. * - VertexBuffer.UV3Kind
  24514. * - VertexBuffer.UV4Kind
  24515. * - VertexBuffer.UV5Kind
  24516. * - VertexBuffer.UV6Kind
  24517. * - VertexBuffer.ColorKind
  24518. * - VertexBuffer.MatricesIndicesKind
  24519. * - VertexBuffer.MatricesIndicesExtraKind
  24520. * - VertexBuffer.MatricesWeightsKind
  24521. * - VertexBuffer.MatricesWeightsExtraKind
  24522. * @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
  24523. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24524. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24525. */
  24526. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24527. /**
  24528. * Returns the mesh VertexBuffer object from the requested `kind`
  24529. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24530. * - VertexBuffer.PositionKind
  24531. * - VertexBuffer.NormalKind
  24532. * - VertexBuffer.UVKind
  24533. * - VertexBuffer.UV2Kind
  24534. * - VertexBuffer.UV3Kind
  24535. * - VertexBuffer.UV4Kind
  24536. * - VertexBuffer.UV5Kind
  24537. * - VertexBuffer.UV6Kind
  24538. * - VertexBuffer.ColorKind
  24539. * - VertexBuffer.MatricesIndicesKind
  24540. * - VertexBuffer.MatricesIndicesExtraKind
  24541. * - VertexBuffer.MatricesWeightsKind
  24542. * - VertexBuffer.MatricesWeightsExtraKind
  24543. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24544. */
  24545. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24546. /**
  24547. * Tests if a specific vertex buffer is associated with this mesh
  24548. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24549. * - VertexBuffer.PositionKind
  24550. * - VertexBuffer.NormalKind
  24551. * - VertexBuffer.UVKind
  24552. * - VertexBuffer.UV2Kind
  24553. * - VertexBuffer.UV3Kind
  24554. * - VertexBuffer.UV4Kind
  24555. * - VertexBuffer.UV5Kind
  24556. * - VertexBuffer.UV6Kind
  24557. * - VertexBuffer.ColorKind
  24558. * - VertexBuffer.MatricesIndicesKind
  24559. * - VertexBuffer.MatricesIndicesExtraKind
  24560. * - VertexBuffer.MatricesWeightsKind
  24561. * - VertexBuffer.MatricesWeightsExtraKind
  24562. * @returns a boolean
  24563. */
  24564. isVerticesDataPresent(kind: string): boolean;
  24565. /**
  24566. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24567. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24568. * - VertexBuffer.PositionKind
  24569. * - VertexBuffer.UVKind
  24570. * - VertexBuffer.UV2Kind
  24571. * - VertexBuffer.UV3Kind
  24572. * - VertexBuffer.UV4Kind
  24573. * - VertexBuffer.UV5Kind
  24574. * - VertexBuffer.UV6Kind
  24575. * - VertexBuffer.ColorKind
  24576. * - VertexBuffer.MatricesIndicesKind
  24577. * - VertexBuffer.MatricesIndicesExtraKind
  24578. * - VertexBuffer.MatricesWeightsKind
  24579. * - VertexBuffer.MatricesWeightsExtraKind
  24580. * @returns a boolean
  24581. */
  24582. isVertexBufferUpdatable(kind: string): boolean;
  24583. /**
  24584. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24585. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24586. * - VertexBuffer.PositionKind
  24587. * - VertexBuffer.NormalKind
  24588. * - VertexBuffer.UVKind
  24589. * - VertexBuffer.UV2Kind
  24590. * - VertexBuffer.UV3Kind
  24591. * - VertexBuffer.UV4Kind
  24592. * - VertexBuffer.UV5Kind
  24593. * - VertexBuffer.UV6Kind
  24594. * - VertexBuffer.ColorKind
  24595. * - VertexBuffer.MatricesIndicesKind
  24596. * - VertexBuffer.MatricesIndicesExtraKind
  24597. * - VertexBuffer.MatricesWeightsKind
  24598. * - VertexBuffer.MatricesWeightsExtraKind
  24599. * @returns an array of strings
  24600. */
  24601. getVerticesDataKinds(): string[];
  24602. /**
  24603. * Returns a positive integer : the total number of indices in this mesh geometry.
  24604. * @returns the numner of indices or zero if the mesh has no geometry.
  24605. */
  24606. getTotalIndices(): number;
  24607. /**
  24608. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24609. * @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.
  24610. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24611. * @returns the indices array or an empty array if the mesh has no geometry
  24612. */
  24613. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24614. readonly isBlocked: boolean;
  24615. /**
  24616. * Determine if the current mesh is ready to be rendered
  24617. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24618. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24619. * @returns true if all associated assets are ready (material, textures, shaders)
  24620. */
  24621. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24622. /**
  24623. * 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.
  24624. */
  24625. readonly areNormalsFrozen: boolean;
  24626. /**
  24627. * 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.
  24628. * @returns the current mesh
  24629. */
  24630. freezeNormals(): Mesh;
  24631. /**
  24632. * 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
  24633. * @returns the current mesh
  24634. */
  24635. unfreezeNormals(): Mesh;
  24636. /**
  24637. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24638. */
  24639. overridenInstanceCount: number;
  24640. /** @hidden */
  24641. _preActivate(): Mesh;
  24642. /** @hidden */
  24643. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24644. /** @hidden */
  24645. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24646. /**
  24647. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24648. * This means the mesh underlying bounding box and sphere are recomputed.
  24649. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24650. * @returns the current mesh
  24651. */
  24652. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24653. /** @hidden */
  24654. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24655. /**
  24656. * This function will subdivide the mesh into multiple submeshes
  24657. * @param count defines the expected number of submeshes
  24658. */
  24659. subdivide(count: number): void;
  24660. /**
  24661. * Copy a FloatArray into a specific associated vertex buffer
  24662. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24663. * - VertexBuffer.PositionKind
  24664. * - VertexBuffer.UVKind
  24665. * - VertexBuffer.UV2Kind
  24666. * - VertexBuffer.UV3Kind
  24667. * - VertexBuffer.UV4Kind
  24668. * - VertexBuffer.UV5Kind
  24669. * - VertexBuffer.UV6Kind
  24670. * - VertexBuffer.ColorKind
  24671. * - VertexBuffer.MatricesIndicesKind
  24672. * - VertexBuffer.MatricesIndicesExtraKind
  24673. * - VertexBuffer.MatricesWeightsKind
  24674. * - VertexBuffer.MatricesWeightsExtraKind
  24675. * @param data defines the data source
  24676. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24677. * @param stride defines the data stride size (can be null)
  24678. * @returns the current mesh
  24679. */
  24680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24681. /**
  24682. * Delete a vertex buffer associated with this mesh
  24683. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24684. * - VertexBuffer.PositionKind
  24685. * - VertexBuffer.UVKind
  24686. * - VertexBuffer.UV2Kind
  24687. * - VertexBuffer.UV3Kind
  24688. * - VertexBuffer.UV4Kind
  24689. * - VertexBuffer.UV5Kind
  24690. * - VertexBuffer.UV6Kind
  24691. * - VertexBuffer.ColorKind
  24692. * - VertexBuffer.MatricesIndicesKind
  24693. * - VertexBuffer.MatricesIndicesExtraKind
  24694. * - VertexBuffer.MatricesWeightsKind
  24695. * - VertexBuffer.MatricesWeightsExtraKind
  24696. */
  24697. removeVerticesData(kind: string): void;
  24698. /**
  24699. * Flags an associated vertex buffer as updatable
  24700. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24701. * - VertexBuffer.PositionKind
  24702. * - VertexBuffer.UVKind
  24703. * - VertexBuffer.UV2Kind
  24704. * - VertexBuffer.UV3Kind
  24705. * - VertexBuffer.UV4Kind
  24706. * - VertexBuffer.UV5Kind
  24707. * - VertexBuffer.UV6Kind
  24708. * - VertexBuffer.ColorKind
  24709. * - VertexBuffer.MatricesIndicesKind
  24710. * - VertexBuffer.MatricesIndicesExtraKind
  24711. * - VertexBuffer.MatricesWeightsKind
  24712. * - VertexBuffer.MatricesWeightsExtraKind
  24713. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24714. */
  24715. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24716. /**
  24717. * Sets the mesh global Vertex Buffer
  24718. * @param buffer defines the buffer to use
  24719. * @returns the current mesh
  24720. */
  24721. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24722. /**
  24723. * Update a specific associated vertex buffer
  24724. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24725. * - VertexBuffer.PositionKind
  24726. * - VertexBuffer.UVKind
  24727. * - VertexBuffer.UV2Kind
  24728. * - VertexBuffer.UV3Kind
  24729. * - VertexBuffer.UV4Kind
  24730. * - VertexBuffer.UV5Kind
  24731. * - VertexBuffer.UV6Kind
  24732. * - VertexBuffer.ColorKind
  24733. * - VertexBuffer.MatricesIndicesKind
  24734. * - VertexBuffer.MatricesIndicesExtraKind
  24735. * - VertexBuffer.MatricesWeightsKind
  24736. * - VertexBuffer.MatricesWeightsExtraKind
  24737. * @param data defines the data source
  24738. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24739. * @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)
  24740. * @returns the current mesh
  24741. */
  24742. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24743. /**
  24744. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24745. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24746. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24747. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24748. * @returns the current mesh
  24749. */
  24750. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24751. /**
  24752. * Creates a un-shared specific occurence of the geometry for the mesh.
  24753. * @returns the current mesh
  24754. */
  24755. makeGeometryUnique(): Mesh;
  24756. /**
  24757. * Set the index buffer of this mesh
  24758. * @param indices defines the source data
  24759. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24760. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24761. * @returns the current mesh
  24762. */
  24763. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24764. /**
  24765. * Update the current index buffer
  24766. * @param indices defines the source data
  24767. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24768. * @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)
  24769. * @returns the current mesh
  24770. */
  24771. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24772. /**
  24773. * Invert the geometry to move from a right handed system to a left handed one.
  24774. * @returns the current mesh
  24775. */
  24776. toLeftHanded(): Mesh;
  24777. /** @hidden */
  24778. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24779. /** @hidden */
  24780. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24781. /**
  24782. * Registers for this mesh a javascript function called just before the rendering process
  24783. * @param func defines the function to call before rendering this mesh
  24784. * @returns the current mesh
  24785. */
  24786. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24787. /**
  24788. * Disposes a previously registered javascript function called before the rendering
  24789. * @param func defines the function to remove
  24790. * @returns the current mesh
  24791. */
  24792. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24793. /**
  24794. * Registers for this mesh a javascript function called just after the rendering is complete
  24795. * @param func defines the function to call after rendering this mesh
  24796. * @returns the current mesh
  24797. */
  24798. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24799. /**
  24800. * Disposes a previously registered javascript function called after the rendering.
  24801. * @param func defines the function to remove
  24802. * @returns the current mesh
  24803. */
  24804. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24805. /** @hidden */
  24806. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24807. /** @hidden */
  24808. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24809. /** @hidden */
  24810. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24811. /** @hidden */
  24812. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24813. /** @hidden */
  24814. _rebuild(): void;
  24815. /** @hidden */
  24816. _freeze(): void;
  24817. /** @hidden */
  24818. _unFreeze(): void;
  24819. /**
  24820. * 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
  24821. * @param subMesh defines the subMesh to render
  24822. * @param enableAlphaMode defines if alpha mode can be changed
  24823. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24824. * @returns the current mesh
  24825. */
  24826. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24827. private _onBeforeDraw;
  24828. /**
  24829. * Renormalize the mesh and patch it up if there are no weights
  24830. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24831. * However in the case of zero weights then we set just a single influence to 1.
  24832. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24833. */
  24834. cleanMatrixWeights(): void;
  24835. private normalizeSkinFourWeights;
  24836. private normalizeSkinWeightsAndExtra;
  24837. /**
  24838. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24839. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24840. * the user know there was an issue with importing the mesh
  24841. * @returns a validation object with skinned, valid and report string
  24842. */
  24843. validateSkinning(): {
  24844. skinned: boolean;
  24845. valid: boolean;
  24846. report: string;
  24847. };
  24848. /** @hidden */
  24849. _checkDelayState(): Mesh;
  24850. private _queueLoad;
  24851. /**
  24852. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24853. * A mesh is in the frustum if its bounding box intersects the frustum
  24854. * @param frustumPlanes defines the frustum to test
  24855. * @returns true if the mesh is in the frustum planes
  24856. */
  24857. isInFrustum(frustumPlanes: Plane[]): boolean;
  24858. /**
  24859. * Sets the mesh material by the material or multiMaterial `id` property
  24860. * @param id is a string identifying the material or the multiMaterial
  24861. * @returns the current mesh
  24862. */
  24863. setMaterialByID(id: string): Mesh;
  24864. /**
  24865. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24866. * @returns an array of IAnimatable
  24867. */
  24868. getAnimatables(): IAnimatable[];
  24869. /**
  24870. * Modifies the mesh geometry according to the passed transformation matrix.
  24871. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24872. * The mesh normals are modified using the same transformation.
  24873. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24874. * @param transform defines the transform matrix to use
  24875. * @see http://doc.babylonjs.com/resources/baking_transformations
  24876. * @returns the current mesh
  24877. */
  24878. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24879. /**
  24880. * Modifies the mesh geometry according to its own current World Matrix.
  24881. * The mesh World Matrix is then reset.
  24882. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24883. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24884. * @see http://doc.babylonjs.com/resources/baking_transformations
  24885. * @returns the current mesh
  24886. */
  24887. bakeCurrentTransformIntoVertices(): Mesh;
  24888. /** @hidden */
  24889. readonly _positions: Nullable<Vector3[]>;
  24890. /** @hidden */
  24891. _resetPointsArrayCache(): Mesh;
  24892. /** @hidden */
  24893. _generatePointsArray(): boolean;
  24894. /**
  24895. * Returns a new Mesh object generated from the current mesh properties.
  24896. * This method must not get confused with createInstance()
  24897. * @param name is a string, the name given to the new mesh
  24898. * @param newParent can be any Node object (default `null`)
  24899. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24900. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24901. * @returns a new mesh
  24902. */
  24903. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24904. /**
  24905. * Releases resources associated with this mesh.
  24906. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24907. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24908. */
  24909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24910. /** @hidden */
  24911. _disposeInstanceSpecificData(): void;
  24912. /**
  24913. * Modifies the mesh geometry according to a displacement map.
  24914. * 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.
  24915. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24916. * @param url is a string, the URL from the image file is to be downloaded.
  24917. * @param minHeight is the lower limit of the displacement.
  24918. * @param maxHeight is the upper limit of the displacement.
  24919. * @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.
  24920. * @param uvOffset is an optional vector2 used to offset UV.
  24921. * @param uvScale is an optional vector2 used to scale UV.
  24922. * @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.
  24923. * @returns the Mesh.
  24924. */
  24925. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24926. /**
  24927. * Modifies the mesh geometry according to a displacementMap buffer.
  24928. * 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.
  24929. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24930. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24931. * @param heightMapWidth is the width of the buffer image.
  24932. * @param heightMapHeight is the height of the buffer image.
  24933. * @param minHeight is the lower limit of the displacement.
  24934. * @param maxHeight is the upper limit of the displacement.
  24935. * @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.
  24936. * @param uvOffset is an optional vector2 used to offset UV.
  24937. * @param uvScale is an optional vector2 used to scale UV.
  24938. * @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.
  24939. * @returns the Mesh.
  24940. */
  24941. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24942. /**
  24943. * Modify the mesh to get a flat shading rendering.
  24944. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24945. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24946. * @returns current mesh
  24947. */
  24948. convertToFlatShadedMesh(): Mesh;
  24949. /**
  24950. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24951. * In other words, more vertices, no more indices and a single bigger VBO.
  24952. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24953. * @returns current mesh
  24954. */
  24955. convertToUnIndexedMesh(): Mesh;
  24956. /**
  24957. * Inverses facet orientations.
  24958. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24959. * @param flipNormals will also inverts the normals
  24960. * @returns current mesh
  24961. */
  24962. flipFaces(flipNormals?: boolean): Mesh;
  24963. /**
  24964. * Increase the number of facets and hence vertices in a mesh
  24965. * Vertex normals are interpolated from existing vertex normals
  24966. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24967. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24968. */
  24969. increaseVertices(numberPerEdge: number): void;
  24970. /**
  24971. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24972. * This will undo any application of covertToFlatShadedMesh
  24973. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24974. */
  24975. forceSharedVertices(): void;
  24976. /** @hidden */
  24977. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24978. /** @hidden */
  24979. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24980. /**
  24981. * Creates a new InstancedMesh object from the mesh model.
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24983. * @param name defines the name of the new instance
  24984. * @returns a new InstancedMesh
  24985. */
  24986. createInstance(name: string): InstancedMesh;
  24987. /**
  24988. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24989. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24990. * @returns the current mesh
  24991. */
  24992. synchronizeInstances(): Mesh;
  24993. /**
  24994. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24995. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24996. * This should be used together with the simplification to avoid disappearing triangles.
  24997. * @param successCallback an optional success callback to be called after the optimization finished.
  24998. * @returns the current mesh
  24999. */
  25000. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25001. /**
  25002. * Serialize current mesh
  25003. * @param serializationObject defines the object which will receive the serialization data
  25004. */
  25005. serialize(serializationObject: any): void;
  25006. /** @hidden */
  25007. _syncGeometryWithMorphTargetManager(): void;
  25008. /** @hidden */
  25009. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25010. /**
  25011. * Returns a new Mesh object parsed from the source provided.
  25012. * @param parsedMesh is the source
  25013. * @param scene defines the hosting scene
  25014. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25015. * @returns a new Mesh
  25016. */
  25017. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25018. /**
  25019. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25020. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25021. * @param name defines the name of the mesh to create
  25022. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25023. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25024. * @param closePath creates a seam between the first and the last points of each path of the path array
  25025. * @param offset is taken in account only if the `pathArray` is containing a single path
  25026. * @param scene defines the hosting scene
  25027. * @param updatable defines if the mesh must be flagged as updatable
  25028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25029. * @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)
  25030. * @returns a new Mesh
  25031. */
  25032. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25033. /**
  25034. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25035. * @param name defines the name of the mesh to create
  25036. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25037. * @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
  25038. * @param scene defines the hosting scene
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25044. /**
  25045. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25046. * @param name defines the name of the mesh to create
  25047. * @param size sets the size (float) of each box side (default 1)
  25048. * @param scene defines the hosting scene
  25049. * @param updatable defines if the mesh must be flagged as updatable
  25050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25051. * @returns a new Mesh
  25052. */
  25053. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25054. /**
  25055. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25056. * @param name defines the name of the mesh to create
  25057. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25058. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25059. * @param scene defines the hosting scene
  25060. * @param updatable defines if the mesh must be flagged as updatable
  25061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25062. * @returns a new Mesh
  25063. */
  25064. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25065. /**
  25066. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25067. * @param name defines the name of the mesh to create
  25068. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25069. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25070. * @param scene defines the hosting scene
  25071. * @returns a new Mesh
  25072. */
  25073. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25074. /**
  25075. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25076. * @param name defines the name of the mesh to create
  25077. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25078. * @param diameterTop set the top cap diameter (floats, default 1)
  25079. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25080. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25081. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25082. * @param scene defines the hosting scene
  25083. * @param updatable defines if the mesh must be flagged as updatable
  25084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25085. * @returns a new Mesh
  25086. */
  25087. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25088. /**
  25089. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25090. * @param name defines the name of the mesh to create
  25091. * @param diameter sets the diameter size (float) of the torus (default 1)
  25092. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25093. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25094. * @param scene defines the hosting scene
  25095. * @param updatable defines if the mesh must be flagged as updatable
  25096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25097. * @returns a new Mesh
  25098. */
  25099. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25100. /**
  25101. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25102. * @param name defines the name of the mesh to create
  25103. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25104. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25105. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25106. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25107. * @param p the number of windings on X axis (positive integers, default 2)
  25108. * @param q the number of windings on Y axis (positive integers, default 3)
  25109. * @param scene defines the hosting scene
  25110. * @param updatable defines if the mesh must be flagged as updatable
  25111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25112. * @returns a new Mesh
  25113. */
  25114. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25115. /**
  25116. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25117. * @param name defines the name of the mesh to create
  25118. * @param points is an array successive Vector3
  25119. * @param scene defines the hosting scene
  25120. * @param updatable defines if the mesh must be flagged as updatable
  25121. * @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).
  25122. * @returns a new Mesh
  25123. */
  25124. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25125. /**
  25126. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25127. * @param name defines the name of the mesh to create
  25128. * @param points is an array successive Vector3
  25129. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25130. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25131. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25132. * @param scene defines the hosting scene
  25133. * @param updatable defines if the mesh must be flagged as updatable
  25134. * @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)
  25135. * @returns a new Mesh
  25136. */
  25137. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25138. /**
  25139. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25140. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25141. * 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.
  25142. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25143. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25144. * Remember you can only change the shape positions, not their number when updating a polygon.
  25145. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25146. * @param name defines the name of the mesh to create
  25147. * @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
  25148. * @param scene defines the hosting scene
  25149. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25150. * @param updatable defines if the mesh must be flagged as updatable
  25151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25152. * @param earcutInjection can be used to inject your own earcut reference
  25153. * @returns a new Mesh
  25154. */
  25155. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25156. /**
  25157. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25158. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25159. * @param name defines the name of the mesh to create
  25160. * @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
  25161. * @param depth defines the height of extrusion
  25162. * @param scene defines the hosting scene
  25163. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25164. * @param updatable defines if the mesh must be flagged as updatable
  25165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25166. * @param earcutInjection can be used to inject your own earcut reference
  25167. * @returns a new Mesh
  25168. */
  25169. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25170. /**
  25171. * Creates an extruded shape mesh.
  25172. * 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
  25173. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25174. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25175. * @param name defines the name of the mesh to create
  25176. * @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
  25177. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25178. * @param scale is the value to scale the shape
  25179. * @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
  25180. * @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
  25181. * @param scene defines the hosting scene
  25182. * @param updatable defines if the mesh must be flagged as updatable
  25183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25184. * @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)
  25185. * @returns a new Mesh
  25186. */
  25187. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25188. /**
  25189. * Creates an custom extruded shape mesh.
  25190. * The custom extrusion is a parametric shape.
  25191. * It has no predefined shape. Its final shape will depend on the input parameters.
  25192. * Please consider using the same method from the MeshBuilder class instead
  25193. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25194. * @param name defines the name of the mesh to create
  25195. * @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
  25196. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25197. * @param scaleFunction is a custom Javascript function called on each path point
  25198. * @param rotationFunction is a custom Javascript function called on each path point
  25199. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25200. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25201. * @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
  25202. * @param scene defines the hosting scene
  25203. * @param updatable defines if the mesh must be flagged as updatable
  25204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25205. * @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)
  25206. * @returns a new Mesh
  25207. */
  25208. 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;
  25209. /**
  25210. * Creates lathe mesh.
  25211. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25212. * Please consider using the same method from the MeshBuilder class instead
  25213. * @param name defines the name of the mesh to create
  25214. * @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
  25215. * @param radius is the radius value of the lathe
  25216. * @param tessellation is the side number of the lathe.
  25217. * @param scene defines the hosting scene
  25218. * @param updatable defines if the mesh must be flagged as updatable
  25219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25220. * @returns a new Mesh
  25221. */
  25222. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25223. /**
  25224. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25225. * @param name defines the name of the mesh to create
  25226. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25227. * @param scene defines the hosting scene
  25228. * @param updatable defines if the mesh must be flagged as updatable
  25229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25230. * @returns a new Mesh
  25231. */
  25232. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25233. /**
  25234. * Creates a ground mesh.
  25235. * Please consider using the same method from the MeshBuilder class instead
  25236. * @param name defines the name of the mesh to create
  25237. * @param width set the width of the ground
  25238. * @param height set the height of the ground
  25239. * @param subdivisions sets the number of subdivisions per side
  25240. * @param scene defines the hosting scene
  25241. * @param updatable defines if the mesh must be flagged as updatable
  25242. * @returns a new Mesh
  25243. */
  25244. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25245. /**
  25246. * Creates a tiled ground mesh.
  25247. * Please consider using the same method from the MeshBuilder class instead
  25248. * @param name defines the name of the mesh to create
  25249. * @param xmin set the ground minimum X coordinate
  25250. * @param zmin set the ground minimum Y coordinate
  25251. * @param xmax set the ground maximum X coordinate
  25252. * @param zmax set the ground maximum Z coordinate
  25253. * @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
  25254. * @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
  25255. * @param scene defines the hosting scene
  25256. * @param updatable defines if the mesh must be flagged as updatable
  25257. * @returns a new Mesh
  25258. */
  25259. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25260. w: number;
  25261. h: number;
  25262. }, precision: {
  25263. w: number;
  25264. h: number;
  25265. }, scene: Scene, updatable?: boolean): Mesh;
  25266. /**
  25267. * Creates a ground mesh from a height map.
  25268. * Please consider using the same method from the MeshBuilder class instead
  25269. * @see http://doc.babylonjs.com/babylon101/height_map
  25270. * @param name defines the name of the mesh to create
  25271. * @param url sets the URL of the height map image resource
  25272. * @param width set the ground width size
  25273. * @param height set the ground height size
  25274. * @param subdivisions sets the number of subdivision per side
  25275. * @param minHeight is the minimum altitude on the ground
  25276. * @param maxHeight is the maximum altitude on the ground
  25277. * @param scene defines the hosting scene
  25278. * @param updatable defines if the mesh must be flagged as updatable
  25279. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25280. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25281. * @returns a new Mesh
  25282. */
  25283. 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;
  25284. /**
  25285. * Creates a tube mesh.
  25286. * The tube is a parametric shape.
  25287. * It has no predefined shape. Its final shape will depend on the input parameters.
  25288. * Please consider using the same method from the MeshBuilder class instead
  25289. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25290. * @param name defines the name of the mesh to create
  25291. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25292. * @param radius sets the tube radius size
  25293. * @param tessellation is the number of sides on the tubular surface
  25294. * @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
  25295. * @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
  25296. * @param scene defines the hosting scene
  25297. * @param updatable defines if the mesh must be flagged as updatable
  25298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25299. * @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)
  25300. * @returns a new Mesh
  25301. */
  25302. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25303. (i: number, distance: number): number;
  25304. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25305. /**
  25306. * Creates a polyhedron mesh.
  25307. * Please consider using the same method from the MeshBuilder class instead.
  25308. * * 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
  25309. * * The parameter `size` (positive float, default 1) sets the polygon size
  25310. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25311. * * 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`
  25312. * * 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
  25313. * * 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)`)
  25314. * * 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
  25315. * * 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
  25316. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25317. * * If you create a double-sided mesh, you can choose what parts of 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
  25318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25319. * @param name defines the name of the mesh to create
  25320. * @param options defines the options used to create the mesh
  25321. * @param scene defines the hosting scene
  25322. * @returns a new Mesh
  25323. */
  25324. static CreatePolyhedron(name: string, options: {
  25325. type?: number;
  25326. size?: number;
  25327. sizeX?: number;
  25328. sizeY?: number;
  25329. sizeZ?: number;
  25330. custom?: any;
  25331. faceUV?: Vector4[];
  25332. faceColors?: Color4[];
  25333. updatable?: boolean;
  25334. sideOrientation?: number;
  25335. }, scene: Scene): Mesh;
  25336. /**
  25337. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25338. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25339. * * 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`)
  25340. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25341. * * 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
  25342. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25343. * * If you create a double-sided mesh, you can choose what parts of 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
  25344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25345. * @param name defines the name of the mesh
  25346. * @param options defines the options used to create the mesh
  25347. * @param scene defines the hosting scene
  25348. * @returns a new Mesh
  25349. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25350. */
  25351. static CreateIcoSphere(name: string, options: {
  25352. radius?: number;
  25353. flat?: boolean;
  25354. subdivisions?: number;
  25355. sideOrientation?: number;
  25356. updatable?: boolean;
  25357. }, scene: Scene): Mesh;
  25358. /**
  25359. * Creates a decal mesh.
  25360. * Please consider using the same method from the MeshBuilder class instead.
  25361. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25362. * @param name defines the name of the mesh
  25363. * @param sourceMesh defines the mesh receiving the decal
  25364. * @param position sets the position of the decal in world coordinates
  25365. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25366. * @param size sets the decal scaling
  25367. * @param angle sets the angle to rotate the decal
  25368. * @returns a new Mesh
  25369. */
  25370. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25371. /**
  25372. * Prepare internal position array for software CPU skinning
  25373. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25374. */
  25375. setPositionsForCPUSkinning(): Float32Array;
  25376. /**
  25377. * Prepare internal normal array for software CPU skinning
  25378. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25379. */
  25380. setNormalsForCPUSkinning(): Float32Array;
  25381. /**
  25382. * Updates the vertex buffer by applying transformation from the bones
  25383. * @param skeleton defines the skeleton to apply to current mesh
  25384. * @returns the current mesh
  25385. */
  25386. applySkeleton(skeleton: Skeleton): Mesh;
  25387. /**
  25388. * 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
  25389. * @param meshes defines the list of meshes to scan
  25390. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25391. */
  25392. static MinMax(meshes: AbstractMesh[]): {
  25393. min: Vector3;
  25394. max: Vector3;
  25395. };
  25396. /**
  25397. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25398. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25399. * @returns a vector3
  25400. */
  25401. static Center(meshesOrMinMaxVector: {
  25402. min: Vector3;
  25403. max: Vector3;
  25404. } | AbstractMesh[]): Vector3;
  25405. /**
  25406. * Merge the array of meshes into a single mesh for performance reasons.
  25407. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25408. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25409. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25410. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25411. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25412. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25413. * @returns a new mesh
  25414. */
  25415. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25416. /** @hidden */
  25417. addInstance(instance: InstancedMesh): void;
  25418. /** @hidden */
  25419. removeInstance(instance: InstancedMesh): void;
  25420. }
  25421. }
  25422. declare module "babylonjs/Cameras/camera" {
  25423. import { SmartArray } from "babylonjs/Misc/smartArray";
  25424. import { Observable } from "babylonjs/Misc/observable";
  25425. import { Nullable } from "babylonjs/types";
  25426. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25427. import { Scene } from "babylonjs/scene";
  25428. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25429. import { Node } from "babylonjs/node";
  25430. import { Mesh } from "babylonjs/Meshes/mesh";
  25431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25432. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25433. import { Viewport } from "babylonjs/Maths/math.viewport";
  25434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25436. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25437. import { Ray } from "babylonjs/Culling/ray";
  25438. /**
  25439. * This is the base class of all the camera used in the application.
  25440. * @see http://doc.babylonjs.com/features/cameras
  25441. */
  25442. export class Camera extends Node {
  25443. /** @hidden */
  25444. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25445. /**
  25446. * This is the default projection mode used by the cameras.
  25447. * It helps recreating a feeling of perspective and better appreciate depth.
  25448. * This is the best way to simulate real life cameras.
  25449. */
  25450. static readonly PERSPECTIVE_CAMERA: number;
  25451. /**
  25452. * This helps creating camera with an orthographic mode.
  25453. * 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.
  25454. */
  25455. static readonly ORTHOGRAPHIC_CAMERA: number;
  25456. /**
  25457. * This is the default FOV mode for perspective cameras.
  25458. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25459. */
  25460. static readonly FOVMODE_VERTICAL_FIXED: number;
  25461. /**
  25462. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25463. */
  25464. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25465. /**
  25466. * This specifies ther is no need for a camera rig.
  25467. * Basically only one eye is rendered corresponding to the camera.
  25468. */
  25469. static readonly RIG_MODE_NONE: number;
  25470. /**
  25471. * Simulates a camera Rig with one blue eye and one red eye.
  25472. * This can be use with 3d blue and red glasses.
  25473. */
  25474. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25475. /**
  25476. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25477. */
  25478. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25479. /**
  25480. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25481. */
  25482. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25483. /**
  25484. * Defines that both eyes of the camera will be rendered over under each other.
  25485. */
  25486. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25487. /**
  25488. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25489. */
  25490. static readonly RIG_MODE_VR: number;
  25491. /**
  25492. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25493. */
  25494. static readonly RIG_MODE_WEBVR: number;
  25495. /**
  25496. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25497. */
  25498. static readonly RIG_MODE_CUSTOM: number;
  25499. /**
  25500. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25501. */
  25502. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25503. /**
  25504. * Define the input manager associated with the camera.
  25505. */
  25506. inputs: CameraInputsManager<Camera>;
  25507. /** @hidden */
  25508. _position: Vector3;
  25509. /**
  25510. * Define the current local position of the camera in the scene
  25511. */
  25512. position: Vector3;
  25513. /**
  25514. * The vector the camera should consider as up.
  25515. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25516. */
  25517. upVector: Vector3;
  25518. /**
  25519. * Define the current limit on the left side for an orthographic camera
  25520. * In scene unit
  25521. */
  25522. orthoLeft: Nullable<number>;
  25523. /**
  25524. * Define the current limit on the right side for an orthographic camera
  25525. * In scene unit
  25526. */
  25527. orthoRight: Nullable<number>;
  25528. /**
  25529. * Define the current limit on the bottom side for an orthographic camera
  25530. * In scene unit
  25531. */
  25532. orthoBottom: Nullable<number>;
  25533. /**
  25534. * Define the current limit on the top side for an orthographic camera
  25535. * In scene unit
  25536. */
  25537. orthoTop: Nullable<number>;
  25538. /**
  25539. * Field Of View is set in Radians. (default is 0.8)
  25540. */
  25541. fov: number;
  25542. /**
  25543. * Define the minimum distance the camera can see from.
  25544. * This is important to note that the depth buffer are not infinite and the closer it starts
  25545. * the more your scene might encounter depth fighting issue.
  25546. */
  25547. minZ: number;
  25548. /**
  25549. * Define the maximum distance the camera can see to.
  25550. * This is important to note that the depth buffer are not infinite and the further it end
  25551. * the more your scene might encounter depth fighting issue.
  25552. */
  25553. maxZ: number;
  25554. /**
  25555. * Define the default inertia of the camera.
  25556. * This helps giving a smooth feeling to the camera movement.
  25557. */
  25558. inertia: number;
  25559. /**
  25560. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25561. */
  25562. mode: number;
  25563. /**
  25564. * Define wether the camera is intermediate.
  25565. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25566. */
  25567. isIntermediate: boolean;
  25568. /**
  25569. * Define the viewport of the camera.
  25570. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25571. */
  25572. viewport: Viewport;
  25573. /**
  25574. * Restricts the camera to viewing objects with the same layerMask.
  25575. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25576. */
  25577. layerMask: number;
  25578. /**
  25579. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25580. */
  25581. fovMode: number;
  25582. /**
  25583. * Rig mode of the camera.
  25584. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25585. * This is normally controlled byt the camera themselves as internal use.
  25586. */
  25587. cameraRigMode: number;
  25588. /**
  25589. * Defines the distance between both "eyes" in case of a RIG
  25590. */
  25591. interaxialDistance: number;
  25592. /**
  25593. * Defines if stereoscopic rendering is done side by side or over under.
  25594. */
  25595. isStereoscopicSideBySide: boolean;
  25596. /**
  25597. * 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
  25598. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25599. * else in the scene. (Eg. security camera)
  25600. *
  25601. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25602. */
  25603. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25604. /**
  25605. * When set, the camera will render to this render target instead of the default canvas
  25606. *
  25607. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25608. */
  25609. outputRenderTarget: Nullable<RenderTargetTexture>;
  25610. /**
  25611. * Observable triggered when the camera view matrix has changed.
  25612. */
  25613. onViewMatrixChangedObservable: Observable<Camera>;
  25614. /**
  25615. * Observable triggered when the camera Projection matrix has changed.
  25616. */
  25617. onProjectionMatrixChangedObservable: Observable<Camera>;
  25618. /**
  25619. * Observable triggered when the inputs have been processed.
  25620. */
  25621. onAfterCheckInputsObservable: Observable<Camera>;
  25622. /**
  25623. * Observable triggered when reset has been called and applied to the camera.
  25624. */
  25625. onRestoreStateObservable: Observable<Camera>;
  25626. /** @hidden */
  25627. _cameraRigParams: any;
  25628. /** @hidden */
  25629. _rigCameras: Camera[];
  25630. /** @hidden */
  25631. _rigPostProcess: Nullable<PostProcess>;
  25632. protected _webvrViewMatrix: Matrix;
  25633. /** @hidden */
  25634. _skipRendering: boolean;
  25635. /** @hidden */
  25636. _projectionMatrix: Matrix;
  25637. /** @hidden */
  25638. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25639. /** @hidden */
  25640. _activeMeshes: SmartArray<AbstractMesh>;
  25641. protected _globalPosition: Vector3;
  25642. /** @hidden */
  25643. _computedViewMatrix: Matrix;
  25644. private _doNotComputeProjectionMatrix;
  25645. private _transformMatrix;
  25646. private _frustumPlanes;
  25647. private _refreshFrustumPlanes;
  25648. private _storedFov;
  25649. private _stateStored;
  25650. /**
  25651. * Instantiates a new camera object.
  25652. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25653. * @see http://doc.babylonjs.com/features/cameras
  25654. * @param name Defines the name of the camera in the scene
  25655. * @param position Defines the position of the camera
  25656. * @param scene Defines the scene the camera belongs too
  25657. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25658. */
  25659. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25660. /**
  25661. * Store current camera state (fov, position, etc..)
  25662. * @returns the camera
  25663. */
  25664. storeState(): Camera;
  25665. /**
  25666. * Restores the camera state values if it has been stored. You must call storeState() first
  25667. */
  25668. protected _restoreStateValues(): boolean;
  25669. /**
  25670. * Restored camera state. You must call storeState() first.
  25671. * @returns true if restored and false otherwise
  25672. */
  25673. restoreState(): boolean;
  25674. /**
  25675. * Gets the class name of the camera.
  25676. * @returns the class name
  25677. */
  25678. getClassName(): string;
  25679. /** @hidden */
  25680. readonly _isCamera: boolean;
  25681. /**
  25682. * Gets a string representation of the camera useful for debug purpose.
  25683. * @param fullDetails Defines that a more verboe level of logging is required
  25684. * @returns the string representation
  25685. */
  25686. toString(fullDetails?: boolean): string;
  25687. /**
  25688. * Gets the current world space position of the camera.
  25689. */
  25690. readonly globalPosition: Vector3;
  25691. /**
  25692. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25693. * @returns the active meshe list
  25694. */
  25695. getActiveMeshes(): SmartArray<AbstractMesh>;
  25696. /**
  25697. * Check wether a mesh is part of the current active mesh list of the camera
  25698. * @param mesh Defines the mesh to check
  25699. * @returns true if active, false otherwise
  25700. */
  25701. isActiveMesh(mesh: Mesh): boolean;
  25702. /**
  25703. * Is this camera ready to be used/rendered
  25704. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25705. * @return true if the camera is ready
  25706. */
  25707. isReady(completeCheck?: boolean): boolean;
  25708. /** @hidden */
  25709. _initCache(): void;
  25710. /** @hidden */
  25711. _updateCache(ignoreParentClass?: boolean): void;
  25712. /** @hidden */
  25713. _isSynchronized(): boolean;
  25714. /** @hidden */
  25715. _isSynchronizedViewMatrix(): boolean;
  25716. /** @hidden */
  25717. _isSynchronizedProjectionMatrix(): boolean;
  25718. /**
  25719. * Attach the input controls to a specific dom element to get the input from.
  25720. * @param element Defines the element the controls should be listened from
  25721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25722. */
  25723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25724. /**
  25725. * Detach the current controls from the specified dom element.
  25726. * @param element Defines the element to stop listening the inputs from
  25727. */
  25728. detachControl(element: HTMLElement): void;
  25729. /**
  25730. * Update the camera state according to the different inputs gathered during the frame.
  25731. */
  25732. update(): void;
  25733. /** @hidden */
  25734. _checkInputs(): void;
  25735. /** @hidden */
  25736. readonly rigCameras: Camera[];
  25737. /**
  25738. * Gets the post process used by the rig cameras
  25739. */
  25740. readonly rigPostProcess: Nullable<PostProcess>;
  25741. /**
  25742. * Internal, gets the first post proces.
  25743. * @returns the first post process to be run on this camera.
  25744. */
  25745. _getFirstPostProcess(): Nullable<PostProcess>;
  25746. private _cascadePostProcessesToRigCams;
  25747. /**
  25748. * Attach a post process to the camera.
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25750. * @param postProcess The post process to attach to the camera
  25751. * @param insertAt The position of the post process in case several of them are in use in the scene
  25752. * @returns the position the post process has been inserted at
  25753. */
  25754. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25755. /**
  25756. * Detach a post process to the camera.
  25757. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25758. * @param postProcess The post process to detach from the camera
  25759. */
  25760. detachPostProcess(postProcess: PostProcess): void;
  25761. /**
  25762. * Gets the current world matrix of the camera
  25763. */
  25764. getWorldMatrix(): Matrix;
  25765. /** @hidden */
  25766. _getViewMatrix(): Matrix;
  25767. /**
  25768. * Gets the current view matrix of the camera.
  25769. * @param force forces the camera to recompute the matrix without looking at the cached state
  25770. * @returns the view matrix
  25771. */
  25772. getViewMatrix(force?: boolean): Matrix;
  25773. /**
  25774. * Freeze the projection matrix.
  25775. * It will prevent the cache check of the camera projection compute and can speed up perf
  25776. * if no parameter of the camera are meant to change
  25777. * @param projection Defines manually a projection if necessary
  25778. */
  25779. freezeProjectionMatrix(projection?: Matrix): void;
  25780. /**
  25781. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25782. */
  25783. unfreezeProjectionMatrix(): void;
  25784. /**
  25785. * Gets the current projection matrix of the camera.
  25786. * @param force forces the camera to recompute the matrix without looking at the cached state
  25787. * @returns the projection matrix
  25788. */
  25789. getProjectionMatrix(force?: boolean): Matrix;
  25790. /**
  25791. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25792. * @returns a Matrix
  25793. */
  25794. getTransformationMatrix(): Matrix;
  25795. private _updateFrustumPlanes;
  25796. /**
  25797. * Checks if a cullable object (mesh...) is in the camera frustum
  25798. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25799. * @param target The object to check
  25800. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25801. * @returns true if the object is in frustum otherwise false
  25802. */
  25803. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25804. /**
  25805. * Checks if a cullable object (mesh...) is in the camera frustum
  25806. * Unlike isInFrustum this cheks the full bounding box
  25807. * @param target The object to check
  25808. * @returns true if the object is in frustum otherwise false
  25809. */
  25810. isCompletelyInFrustum(target: ICullable): boolean;
  25811. /**
  25812. * Gets a ray in the forward direction from the camera.
  25813. * @param length Defines the length of the ray to create
  25814. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25815. * @param origin Defines the start point of the ray which defaults to the camera position
  25816. * @returns the forward ray
  25817. */
  25818. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25819. /**
  25820. * Releases resources associated with this node.
  25821. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25822. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25823. */
  25824. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25825. /** @hidden */
  25826. _isLeftCamera: boolean;
  25827. /**
  25828. * Gets the left camera of a rig setup in case of Rigged Camera
  25829. */
  25830. readonly isLeftCamera: boolean;
  25831. /** @hidden */
  25832. _isRightCamera: boolean;
  25833. /**
  25834. * Gets the right camera of a rig setup in case of Rigged Camera
  25835. */
  25836. readonly isRightCamera: boolean;
  25837. /**
  25838. * Gets the left camera of a rig setup in case of Rigged Camera
  25839. */
  25840. readonly leftCamera: Nullable<FreeCamera>;
  25841. /**
  25842. * Gets the right camera of a rig setup in case of Rigged Camera
  25843. */
  25844. readonly rightCamera: Nullable<FreeCamera>;
  25845. /**
  25846. * Gets the left camera target of a rig setup in case of Rigged Camera
  25847. * @returns the target position
  25848. */
  25849. getLeftTarget(): Nullable<Vector3>;
  25850. /**
  25851. * Gets the right camera target of a rig setup in case of Rigged Camera
  25852. * @returns the target position
  25853. */
  25854. getRightTarget(): Nullable<Vector3>;
  25855. /**
  25856. * @hidden
  25857. */
  25858. setCameraRigMode(mode: number, rigParams: any): void;
  25859. /** @hidden */
  25860. static _setStereoscopicRigMode(camera: Camera): void;
  25861. /** @hidden */
  25862. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25863. /** @hidden */
  25864. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25865. /** @hidden */
  25866. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25867. /** @hidden */
  25868. _getVRProjectionMatrix(): Matrix;
  25869. protected _updateCameraRotationMatrix(): void;
  25870. protected _updateWebVRCameraRotationMatrix(): void;
  25871. /**
  25872. * This function MUST be overwritten by the different WebVR cameras available.
  25873. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25874. * @hidden
  25875. */
  25876. _getWebVRProjectionMatrix(): Matrix;
  25877. /**
  25878. * This function MUST be overwritten by the different WebVR cameras available.
  25879. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25880. * @hidden
  25881. */
  25882. _getWebVRViewMatrix(): Matrix;
  25883. /** @hidden */
  25884. setCameraRigParameter(name: string, value: any): void;
  25885. /**
  25886. * needs to be overridden by children so sub has required properties to be copied
  25887. * @hidden
  25888. */
  25889. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25890. /**
  25891. * May need to be overridden by children
  25892. * @hidden
  25893. */
  25894. _updateRigCameras(): void;
  25895. /** @hidden */
  25896. _setupInputs(): void;
  25897. /**
  25898. * Serialiaze the camera setup to a json represention
  25899. * @returns the JSON representation
  25900. */
  25901. serialize(): any;
  25902. /**
  25903. * Clones the current camera.
  25904. * @param name The cloned camera name
  25905. * @returns the cloned camera
  25906. */
  25907. clone(name: string): Camera;
  25908. /**
  25909. * Gets the direction of the camera relative to a given local axis.
  25910. * @param localAxis Defines the reference axis to provide a relative direction.
  25911. * @return the direction
  25912. */
  25913. getDirection(localAxis: Vector3): Vector3;
  25914. /**
  25915. * Returns the current camera absolute rotation
  25916. */
  25917. readonly absoluteRotation: Quaternion;
  25918. /**
  25919. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25920. * @param localAxis Defines the reference axis to provide a relative direction.
  25921. * @param result Defines the vector to store the result in
  25922. */
  25923. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25924. /**
  25925. * Gets a camera constructor for a given camera type
  25926. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25927. * @param name The name of the camera the result will be able to instantiate
  25928. * @param scene The scene the result will construct the camera in
  25929. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25930. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25931. * @returns a factory method to construc the camera
  25932. */
  25933. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25934. /**
  25935. * Compute the world matrix of the camera.
  25936. * @returns the camera workd matrix
  25937. */
  25938. computeWorldMatrix(): Matrix;
  25939. /**
  25940. * Parse a JSON and creates the camera from the parsed information
  25941. * @param parsedCamera The JSON to parse
  25942. * @param scene The scene to instantiate the camera in
  25943. * @returns the newly constructed camera
  25944. */
  25945. static Parse(parsedCamera: any, scene: Scene): Camera;
  25946. }
  25947. }
  25948. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25949. import { Nullable } from "babylonjs/types";
  25950. import { Scene } from "babylonjs/scene";
  25951. import { Vector4 } from "babylonjs/Maths/math.vector";
  25952. import { Mesh } from "babylonjs/Meshes/mesh";
  25953. /**
  25954. * Class containing static functions to help procedurally build meshes
  25955. */
  25956. export class DiscBuilder {
  25957. /**
  25958. * Creates a plane polygonal mesh. By default, this is a disc
  25959. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25960. * * 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
  25961. * * 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
  25962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25965. * @param name defines the name of the mesh
  25966. * @param options defines the options used to create the mesh
  25967. * @param scene defines the hosting scene
  25968. * @returns the plane polygonal mesh
  25969. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25970. */
  25971. static CreateDisc(name: string, options: {
  25972. radius?: number;
  25973. tessellation?: number;
  25974. arc?: number;
  25975. updatable?: boolean;
  25976. sideOrientation?: number;
  25977. frontUVs?: Vector4;
  25978. backUVs?: Vector4;
  25979. }, scene?: Nullable<Scene>): Mesh;
  25980. }
  25981. }
  25982. declare module "babylonjs/Particles/solidParticleSystem" {
  25983. import { Vector3 } from "babylonjs/Maths/math.vector";
  25984. import { Mesh } from "babylonjs/Meshes/mesh";
  25985. import { Scene, IDisposable } from "babylonjs/scene";
  25986. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25987. /**
  25988. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25989. *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.
  25990. * The SPS is also a particle system. It provides some methods to manage the particles.
  25991. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25992. *
  25993. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25994. */
  25995. export class SolidParticleSystem implements IDisposable {
  25996. /**
  25997. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25998. * Example : var p = SPS.particles[i];
  25999. */
  26000. particles: SolidParticle[];
  26001. /**
  26002. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26003. */
  26004. nbParticles: number;
  26005. /**
  26006. * If the particles must ever face the camera (default false). Useful for planar particles.
  26007. */
  26008. billboard: boolean;
  26009. /**
  26010. * Recompute normals when adding a shape
  26011. */
  26012. recomputeNormals: boolean;
  26013. /**
  26014. * This a counter ofr your own usage. It's not set by any SPS functions.
  26015. */
  26016. counter: number;
  26017. /**
  26018. * The SPS name. This name is also given to the underlying mesh.
  26019. */
  26020. name: string;
  26021. /**
  26022. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26023. */
  26024. mesh: Mesh;
  26025. /**
  26026. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26027. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26028. */
  26029. vars: any;
  26030. /**
  26031. * This array is populated when the SPS is set as 'pickable'.
  26032. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26033. * Each element of this array is an object `{idx: int, faceId: int}`.
  26034. * `idx` is the picked particle index in the `SPS.particles` array
  26035. * `faceId` is the picked face index counted within this particle.
  26036. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26037. */
  26038. pickedParticles: {
  26039. idx: number;
  26040. faceId: number;
  26041. }[];
  26042. /**
  26043. * This array is populated when `enableDepthSort` is set to true.
  26044. * Each element of this array is an instance of the class DepthSortedParticle.
  26045. */
  26046. depthSortedParticles: DepthSortedParticle[];
  26047. /**
  26048. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26049. * @hidden
  26050. */
  26051. _bSphereOnly: boolean;
  26052. /**
  26053. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26054. * @hidden
  26055. */
  26056. _bSphereRadiusFactor: number;
  26057. private _scene;
  26058. private _positions;
  26059. private _indices;
  26060. private _normals;
  26061. private _colors;
  26062. private _uvs;
  26063. private _indices32;
  26064. private _positions32;
  26065. private _normals32;
  26066. private _fixedNormal32;
  26067. private _colors32;
  26068. private _uvs32;
  26069. private _index;
  26070. private _updatable;
  26071. private _pickable;
  26072. private _isVisibilityBoxLocked;
  26073. private _alwaysVisible;
  26074. private _depthSort;
  26075. private _expandable;
  26076. private _shapeCounter;
  26077. private _copy;
  26078. private _color;
  26079. private _computeParticleColor;
  26080. private _computeParticleTexture;
  26081. private _computeParticleRotation;
  26082. private _computeParticleVertex;
  26083. private _computeBoundingBox;
  26084. private _depthSortParticles;
  26085. private _camera;
  26086. private _mustUnrotateFixedNormals;
  26087. private _particlesIntersect;
  26088. private _needs32Bits;
  26089. private _isNotBuilt;
  26090. /**
  26091. * Creates a SPS (Solid Particle System) object.
  26092. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26093. * @param scene (Scene) is the scene in which the SPS is added.
  26094. * @param options defines the options of the sps e.g.
  26095. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26096. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26097. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26098. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26099. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26100. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26101. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26102. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26103. */
  26104. constructor(name: string, scene: Scene, options?: {
  26105. updatable?: boolean;
  26106. isPickable?: boolean;
  26107. enableDepthSort?: boolean;
  26108. particleIntersection?: boolean;
  26109. boundingSphereOnly?: boolean;
  26110. bSphereRadiusFactor?: number;
  26111. expandable?: boolean;
  26112. });
  26113. /**
  26114. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26115. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26116. * @returns the created mesh
  26117. */
  26118. buildMesh(): Mesh;
  26119. /**
  26120. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26121. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26122. * Thus the particles generated from `digest()` have their property `position` set yet.
  26123. * @param mesh ( Mesh ) is the mesh to be digested
  26124. * @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
  26125. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26126. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26127. * @returns the current SPS
  26128. */
  26129. digest(mesh: Mesh, options?: {
  26130. facetNb?: number;
  26131. number?: number;
  26132. delta?: number;
  26133. }): SolidParticleSystem;
  26134. private _unrotateFixedNormals;
  26135. private _resetCopy;
  26136. private _meshBuilder;
  26137. private _posToShape;
  26138. private _uvsToShapeUV;
  26139. private _addParticle;
  26140. /**
  26141. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26142. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26143. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26144. * @param nb (positive integer) the number of particles to be created from this model
  26145. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26146. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26147. * @returns the number of shapes in the system
  26148. */
  26149. addShape(mesh: Mesh, nb: number, options?: {
  26150. positionFunction?: any;
  26151. vertexFunction?: any;
  26152. }): number;
  26153. private _rebuildParticle;
  26154. /**
  26155. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26156. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26157. * @returns the SPS.
  26158. */
  26159. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26160. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26161. * Returns an array with the removed particles.
  26162. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26163. * The SPS can't be empty so at least one particle needs to remain in place.
  26164. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26165. * @param start index of the first particle to remove
  26166. * @param end index of the last particle to remove (included)
  26167. * @returns an array populated with the removed particles
  26168. */
  26169. removeParticles(start: number, end: number): SolidParticle[];
  26170. /**
  26171. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26172. * This method calls `updateParticle()` for each particle of the SPS.
  26173. * For an animated SPS, it is usually called within the render loop.
  26174. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26175. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26176. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26177. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26178. * @returns the SPS.
  26179. */
  26180. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26181. /**
  26182. * Disposes the SPS.
  26183. */
  26184. dispose(): void;
  26185. /**
  26186. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26188. * @returns the SPS.
  26189. */
  26190. refreshVisibleSize(): SolidParticleSystem;
  26191. /**
  26192. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26193. * @param size the size (float) of the visibility box
  26194. * note : this doesn't lock the SPS mesh bounding box.
  26195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26196. */
  26197. setVisibilityBox(size: number): void;
  26198. /**
  26199. * Gets whether the SPS as always visible or not
  26200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26201. */
  26202. /**
  26203. * Sets the SPS as always visible or not
  26204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26205. */
  26206. isAlwaysVisible: boolean;
  26207. /**
  26208. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26210. */
  26211. /**
  26212. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26214. */
  26215. isVisibilityBoxLocked: boolean;
  26216. /**
  26217. * Tells to `setParticles()` to compute the particle rotations or not.
  26218. * Default value : true. The SPS is faster when it's set to false.
  26219. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26220. */
  26221. /**
  26222. * Gets if `setParticles()` computes the particle rotations or not.
  26223. * Default value : true. The SPS is faster when it's set to false.
  26224. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26225. */
  26226. computeParticleRotation: boolean;
  26227. /**
  26228. * Tells to `setParticles()` to compute the particle colors or not.
  26229. * Default value : true. The SPS is faster when it's set to false.
  26230. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26231. */
  26232. /**
  26233. * Gets if `setParticles()` computes the particle colors or not.
  26234. * Default value : true. The SPS is faster when it's set to false.
  26235. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26236. */
  26237. computeParticleColor: boolean;
  26238. /**
  26239. * Gets if `setParticles()` computes the particle textures or not.
  26240. * Default value : true. The SPS is faster when it's set to false.
  26241. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26242. */
  26243. computeParticleTexture: boolean;
  26244. /**
  26245. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26246. * Default value : false. The SPS is faster when it's set to false.
  26247. * Note : the particle custom vertex positions aren't stored values.
  26248. */
  26249. /**
  26250. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26251. * Default value : false. The SPS is faster when it's set to false.
  26252. * Note : the particle custom vertex positions aren't stored values.
  26253. */
  26254. computeParticleVertex: boolean;
  26255. /**
  26256. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26257. */
  26258. /**
  26259. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26260. */
  26261. computeBoundingBox: boolean;
  26262. /**
  26263. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26264. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26265. * Default : `true`
  26266. */
  26267. /**
  26268. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26269. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26270. * Default : `true`
  26271. */
  26272. depthSortParticles: boolean;
  26273. /**
  26274. * Gets if the SPS is created as expandable at construction time.
  26275. * Default : `false`
  26276. */
  26277. readonly expandable: boolean;
  26278. /**
  26279. * This function does nothing. It may be overwritten to set all the particle first values.
  26280. * The SPS doesn't call this function, you may have to call it by your own.
  26281. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26282. */
  26283. initParticles(): void;
  26284. /**
  26285. * This function does nothing. It may be overwritten to recycle a particle.
  26286. * The SPS doesn't call this function, you may have to call it by your own.
  26287. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26288. * @param particle The particle to recycle
  26289. * @returns the recycled particle
  26290. */
  26291. recycleParticle(particle: SolidParticle): SolidParticle;
  26292. /**
  26293. * Updates a particle : this function should be overwritten by the user.
  26294. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26295. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26296. * @example : just set a particle position or velocity and recycle conditions
  26297. * @param particle The particle to update
  26298. * @returns the updated particle
  26299. */
  26300. updateParticle(particle: SolidParticle): SolidParticle;
  26301. /**
  26302. * Updates a vertex of a particle : it can be overwritten by the user.
  26303. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26304. * @param particle the current particle
  26305. * @param vertex the current index of the current particle
  26306. * @param pt the index of the current vertex in the particle shape
  26307. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26308. * @example : just set a vertex particle position
  26309. * @returns the updated vertex
  26310. */
  26311. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26312. /**
  26313. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26314. * This does nothing and may be overwritten by the user.
  26315. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26316. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26317. * @param update the boolean update value actually passed to setParticles()
  26318. */
  26319. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26320. /**
  26321. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26322. * This will be passed three parameters.
  26323. * This does nothing and may be overwritten by the user.
  26324. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26325. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26326. * @param update the boolean update value actually passed to setParticles()
  26327. */
  26328. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26329. }
  26330. }
  26331. declare module "babylonjs/Particles/solidParticle" {
  26332. import { Nullable } from "babylonjs/types";
  26333. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26334. import { Color4 } from "babylonjs/Maths/math.color";
  26335. import { Mesh } from "babylonjs/Meshes/mesh";
  26336. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26337. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26338. import { Plane } from "babylonjs/Maths/math.plane";
  26339. /**
  26340. * Represents one particle of a solid particle system.
  26341. */
  26342. export class SolidParticle {
  26343. /**
  26344. * particle global index
  26345. */
  26346. idx: number;
  26347. /**
  26348. * The color of the particle
  26349. */
  26350. color: Nullable<Color4>;
  26351. /**
  26352. * The world space position of the particle.
  26353. */
  26354. position: Vector3;
  26355. /**
  26356. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26357. */
  26358. rotation: Vector3;
  26359. /**
  26360. * The world space rotation quaternion of the particle.
  26361. */
  26362. rotationQuaternion: Nullable<Quaternion>;
  26363. /**
  26364. * The scaling of the particle.
  26365. */
  26366. scaling: Vector3;
  26367. /**
  26368. * The uvs of the particle.
  26369. */
  26370. uvs: Vector4;
  26371. /**
  26372. * The current speed of the particle.
  26373. */
  26374. velocity: Vector3;
  26375. /**
  26376. * The pivot point in the particle local space.
  26377. */
  26378. pivot: Vector3;
  26379. /**
  26380. * Must the particle be translated from its pivot point in its local space ?
  26381. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26382. * Default : false
  26383. */
  26384. translateFromPivot: boolean;
  26385. /**
  26386. * Is the particle active or not ?
  26387. */
  26388. alive: boolean;
  26389. /**
  26390. * Is the particle visible or not ?
  26391. */
  26392. isVisible: boolean;
  26393. /**
  26394. * Index of this particle in the global "positions" array (Internal use)
  26395. * @hidden
  26396. */
  26397. _pos: number;
  26398. /**
  26399. * @hidden Index of this particle in the global "indices" array (Internal use)
  26400. */
  26401. _ind: number;
  26402. /**
  26403. * @hidden ModelShape of this particle (Internal use)
  26404. */
  26405. _model: ModelShape;
  26406. /**
  26407. * ModelShape id of this particle
  26408. */
  26409. shapeId: number;
  26410. /**
  26411. * Index of the particle in its shape id
  26412. */
  26413. idxInShape: number;
  26414. /**
  26415. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26416. */
  26417. _modelBoundingInfo: BoundingInfo;
  26418. /**
  26419. * @hidden Particle BoundingInfo object (Internal use)
  26420. */
  26421. _boundingInfo: BoundingInfo;
  26422. /**
  26423. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26424. */
  26425. _sps: SolidParticleSystem;
  26426. /**
  26427. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26428. */
  26429. _stillInvisible: boolean;
  26430. /**
  26431. * @hidden Last computed particle rotation matrix
  26432. */
  26433. _rotationMatrix: number[];
  26434. /**
  26435. * Parent particle Id, if any.
  26436. * Default null.
  26437. */
  26438. parentId: Nullable<number>;
  26439. /**
  26440. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26441. * The possible values are :
  26442. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26443. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26444. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26445. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26446. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26447. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26448. * */
  26449. cullingStrategy: number;
  26450. /**
  26451. * @hidden Internal global position in the SPS.
  26452. */
  26453. _globalPosition: Vector3;
  26454. /**
  26455. * Creates a Solid Particle object.
  26456. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26457. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26458. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26459. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26460. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26461. * @param shapeId (integer) is the model shape identifier in the SPS.
  26462. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26463. * @param sps defines the sps it is associated to
  26464. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26465. */
  26466. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26467. /**
  26468. * Legacy support, changed scale to scaling
  26469. */
  26470. /**
  26471. * Legacy support, changed scale to scaling
  26472. */
  26473. scale: Vector3;
  26474. /**
  26475. * Legacy support, changed quaternion to rotationQuaternion
  26476. */
  26477. /**
  26478. * Legacy support, changed quaternion to rotationQuaternion
  26479. */
  26480. quaternion: Nullable<Quaternion>;
  26481. /**
  26482. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26483. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26484. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26485. * @returns true if it intersects
  26486. */
  26487. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26488. /**
  26489. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26490. * A particle is in the frustum if its bounding box intersects the frustum
  26491. * @param frustumPlanes defines the frustum to test
  26492. * @returns true if the particle is in the frustum planes
  26493. */
  26494. isInFrustum(frustumPlanes: Plane[]): boolean;
  26495. /**
  26496. * get the rotation matrix of the particle
  26497. * @hidden
  26498. */
  26499. getRotationMatrix(m: Matrix): void;
  26500. }
  26501. /**
  26502. * Represents the shape of the model used by one particle of a solid particle system.
  26503. * SPS internal tool, don't use it manually.
  26504. */
  26505. export class ModelShape {
  26506. /**
  26507. * The shape id
  26508. * @hidden
  26509. */
  26510. shapeID: number;
  26511. /**
  26512. * flat array of model positions (internal use)
  26513. * @hidden
  26514. */
  26515. _shape: Vector3[];
  26516. /**
  26517. * flat array of model UVs (internal use)
  26518. * @hidden
  26519. */
  26520. _shapeUV: number[];
  26521. /**
  26522. * color array of the model
  26523. * @hidden
  26524. */
  26525. _shapeColors: number[];
  26526. /**
  26527. * indices array of the model
  26528. * @hidden
  26529. */
  26530. _indices: number[];
  26531. /**
  26532. * normals array of the model
  26533. * @hidden
  26534. */
  26535. _normals: number[];
  26536. /**
  26537. * length of the shape in the model indices array (internal use)
  26538. * @hidden
  26539. */
  26540. _indicesLength: number;
  26541. /**
  26542. * Custom position function (internal use)
  26543. * @hidden
  26544. */
  26545. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26546. /**
  26547. * Custom vertex function (internal use)
  26548. * @hidden
  26549. */
  26550. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26551. /**
  26552. * 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.
  26553. * SPS internal tool, don't use it manually.
  26554. * @hidden
  26555. */
  26556. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26557. }
  26558. /**
  26559. * Represents a Depth Sorted Particle in the solid particle system.
  26560. */
  26561. export class DepthSortedParticle {
  26562. /**
  26563. * Index of the particle in the "indices" array
  26564. */
  26565. ind: number;
  26566. /**
  26567. * Length of the particle shape in the "indices" array
  26568. */
  26569. indicesLength: number;
  26570. /**
  26571. * Squared distance from the particle to the camera
  26572. */
  26573. sqDistance: number;
  26574. }
  26575. }
  26576. declare module "babylonjs/Collisions/meshCollisionData" {
  26577. import { Collider } from "babylonjs/Collisions/collider";
  26578. import { Vector3 } from "babylonjs/Maths/math.vector";
  26579. import { Nullable } from "babylonjs/types";
  26580. import { Observer } from "babylonjs/Misc/observable";
  26581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26582. /**
  26583. * @hidden
  26584. */
  26585. export class _MeshCollisionData {
  26586. _checkCollisions: boolean;
  26587. _collisionMask: number;
  26588. _collisionGroup: number;
  26589. _collider: Nullable<Collider>;
  26590. _oldPositionForCollisions: Vector3;
  26591. _diffPositionForCollisions: Vector3;
  26592. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26593. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26594. }
  26595. }
  26596. declare module "babylonjs/Meshes/abstractMesh" {
  26597. import { Observable } from "babylonjs/Misc/observable";
  26598. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26599. import { Camera } from "babylonjs/Cameras/camera";
  26600. import { Scene, IDisposable } from "babylonjs/scene";
  26601. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26602. import { Node } from "babylonjs/node";
  26603. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26604. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26607. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26608. import { Material } from "babylonjs/Materials/material";
  26609. import { Light } from "babylonjs/Lights/light";
  26610. import { Skeleton } from "babylonjs/Bones/skeleton";
  26611. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26612. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26613. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26614. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26615. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26616. import { Plane } from "babylonjs/Maths/math.plane";
  26617. import { Ray } from "babylonjs/Culling/ray";
  26618. import { Collider } from "babylonjs/Collisions/collider";
  26619. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26620. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26621. /** @hidden */
  26622. class _FacetDataStorage {
  26623. facetPositions: Vector3[];
  26624. facetNormals: Vector3[];
  26625. facetPartitioning: number[][];
  26626. facetNb: number;
  26627. partitioningSubdivisions: number;
  26628. partitioningBBoxRatio: number;
  26629. facetDataEnabled: boolean;
  26630. facetParameters: any;
  26631. bbSize: Vector3;
  26632. subDiv: {
  26633. max: number;
  26634. X: number;
  26635. Y: number;
  26636. Z: number;
  26637. };
  26638. facetDepthSort: boolean;
  26639. facetDepthSortEnabled: boolean;
  26640. depthSortedIndices: IndicesArray;
  26641. depthSortedFacets: {
  26642. ind: number;
  26643. sqDistance: number;
  26644. }[];
  26645. facetDepthSortFunction: (f1: {
  26646. ind: number;
  26647. sqDistance: number;
  26648. }, f2: {
  26649. ind: number;
  26650. sqDistance: number;
  26651. }) => number;
  26652. facetDepthSortFrom: Vector3;
  26653. facetDepthSortOrigin: Vector3;
  26654. invertedMatrix: Matrix;
  26655. }
  26656. /**
  26657. * @hidden
  26658. **/
  26659. class _InternalAbstractMeshDataInfo {
  26660. _hasVertexAlpha: boolean;
  26661. _useVertexColors: boolean;
  26662. _numBoneInfluencers: number;
  26663. _applyFog: boolean;
  26664. _receiveShadows: boolean;
  26665. _facetData: _FacetDataStorage;
  26666. _visibility: number;
  26667. _skeleton: Nullable<Skeleton>;
  26668. _layerMask: number;
  26669. _computeBonesUsingShaders: boolean;
  26670. _isActive: boolean;
  26671. _onlyForInstances: boolean;
  26672. _isActiveIntermediate: boolean;
  26673. _onlyForInstancesIntermediate: boolean;
  26674. _actAsRegularMesh: boolean;
  26675. }
  26676. /**
  26677. * Class used to store all common mesh properties
  26678. */
  26679. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26680. /** No occlusion */
  26681. static OCCLUSION_TYPE_NONE: number;
  26682. /** Occlusion set to optimisitic */
  26683. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26684. /** Occlusion set to strict */
  26685. static OCCLUSION_TYPE_STRICT: number;
  26686. /** Use an accurante occlusion algorithm */
  26687. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26688. /** Use a conservative occlusion algorithm */
  26689. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26690. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26691. * Test order :
  26692. * Is the bounding sphere outside the frustum ?
  26693. * If not, are the bounding box vertices outside the frustum ?
  26694. * It not, then the cullable object is in the frustum.
  26695. */
  26696. static readonly CULLINGSTRATEGY_STANDARD: number;
  26697. /** Culling strategy : Bounding Sphere Only.
  26698. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26699. * It's also less accurate than the standard because some not visible objects can still be selected.
  26700. * Test : is the bounding sphere outside the frustum ?
  26701. * If not, then the cullable object is in the frustum.
  26702. */
  26703. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26704. /** Culling strategy : Optimistic Inclusion.
  26705. * This in an inclusion test first, then the standard exclusion test.
  26706. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26707. * 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.
  26708. * Anyway, it's as accurate as the standard strategy.
  26709. * Test :
  26710. * Is the cullable object bounding sphere center in the frustum ?
  26711. * If not, apply the default culling strategy.
  26712. */
  26713. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26714. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26715. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26716. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26717. * 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.
  26718. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26719. * Test :
  26720. * Is the cullable object bounding sphere center in the frustum ?
  26721. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26722. */
  26723. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26724. /**
  26725. * No billboard
  26726. */
  26727. static readonly BILLBOARDMODE_NONE: number;
  26728. /** Billboard on X axis */
  26729. static readonly BILLBOARDMODE_X: number;
  26730. /** Billboard on Y axis */
  26731. static readonly BILLBOARDMODE_Y: number;
  26732. /** Billboard on Z axis */
  26733. static readonly BILLBOARDMODE_Z: number;
  26734. /** Billboard on all axes */
  26735. static readonly BILLBOARDMODE_ALL: number;
  26736. /** Billboard on using position instead of orientation */
  26737. static readonly BILLBOARDMODE_USE_POSITION: number;
  26738. /** @hidden */
  26739. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26740. /**
  26741. * The culling strategy to use to check whether the mesh must be rendered or not.
  26742. * This value can be changed at any time and will be used on the next render mesh selection.
  26743. * The possible values are :
  26744. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26745. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26746. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26747. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26748. * Please read each static variable documentation to get details about the culling process.
  26749. * */
  26750. cullingStrategy: number;
  26751. /**
  26752. * Gets the number of facets in the mesh
  26753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26754. */
  26755. readonly facetNb: number;
  26756. /**
  26757. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26759. */
  26760. partitioningSubdivisions: number;
  26761. /**
  26762. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26763. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26765. */
  26766. partitioningBBoxRatio: number;
  26767. /**
  26768. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26769. * Works only for updatable meshes.
  26770. * Doesn't work with multi-materials
  26771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26772. */
  26773. mustDepthSortFacets: boolean;
  26774. /**
  26775. * The location (Vector3) where the facet depth sort must be computed from.
  26776. * By default, the active camera position.
  26777. * Used only when facet depth sort is enabled
  26778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26779. */
  26780. facetDepthSortFrom: Vector3;
  26781. /**
  26782. * gets a boolean indicating if facetData is enabled
  26783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26784. */
  26785. readonly isFacetDataEnabled: boolean;
  26786. /** @hidden */
  26787. _updateNonUniformScalingState(value: boolean): boolean;
  26788. /**
  26789. * An event triggered when this mesh collides with another one
  26790. */
  26791. onCollideObservable: Observable<AbstractMesh>;
  26792. /** Set a function to call when this mesh collides with another one */
  26793. onCollide: () => void;
  26794. /**
  26795. * An event triggered when the collision's position changes
  26796. */
  26797. onCollisionPositionChangeObservable: Observable<Vector3>;
  26798. /** Set a function to call when the collision's position changes */
  26799. onCollisionPositionChange: () => void;
  26800. /**
  26801. * An event triggered when material is changed
  26802. */
  26803. onMaterialChangedObservable: Observable<AbstractMesh>;
  26804. /**
  26805. * Gets or sets the orientation for POV movement & rotation
  26806. */
  26807. definedFacingForward: boolean;
  26808. /** @hidden */
  26809. _occlusionQuery: Nullable<WebGLQuery>;
  26810. /** @hidden */
  26811. _renderingGroup: Nullable<RenderingGroup>;
  26812. /**
  26813. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26814. */
  26815. /**
  26816. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26817. */
  26818. visibility: number;
  26819. /** Gets or sets the alpha index used to sort transparent meshes
  26820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26821. */
  26822. alphaIndex: number;
  26823. /**
  26824. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26825. */
  26826. isVisible: boolean;
  26827. /**
  26828. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26829. */
  26830. isPickable: boolean;
  26831. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26832. showSubMeshesBoundingBox: boolean;
  26833. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26834. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26835. */
  26836. isBlocker: boolean;
  26837. /**
  26838. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26839. */
  26840. enablePointerMoveEvents: boolean;
  26841. /**
  26842. * Specifies the rendering group id for this mesh (0 by default)
  26843. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26844. */
  26845. renderingGroupId: number;
  26846. private _material;
  26847. /** Gets or sets current material */
  26848. material: Nullable<Material>;
  26849. /**
  26850. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26851. * @see http://doc.babylonjs.com/babylon101/shadows
  26852. */
  26853. receiveShadows: boolean;
  26854. /** Defines color to use when rendering outline */
  26855. outlineColor: Color3;
  26856. /** Define width to use when rendering outline */
  26857. outlineWidth: number;
  26858. /** Defines color to use when rendering overlay */
  26859. overlayColor: Color3;
  26860. /** Defines alpha to use when rendering overlay */
  26861. overlayAlpha: number;
  26862. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26863. hasVertexAlpha: boolean;
  26864. /** 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) */
  26865. useVertexColors: boolean;
  26866. /**
  26867. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26868. */
  26869. computeBonesUsingShaders: boolean;
  26870. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26871. numBoneInfluencers: number;
  26872. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26873. applyFog: boolean;
  26874. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26875. useOctreeForRenderingSelection: boolean;
  26876. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26877. useOctreeForPicking: boolean;
  26878. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26879. useOctreeForCollisions: boolean;
  26880. /**
  26881. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26882. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26883. */
  26884. layerMask: number;
  26885. /**
  26886. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26887. */
  26888. alwaysSelectAsActiveMesh: boolean;
  26889. /**
  26890. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26891. */
  26892. doNotSyncBoundingInfo: boolean;
  26893. /**
  26894. * Gets or sets the current action manager
  26895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26896. */
  26897. actionManager: Nullable<AbstractActionManager>;
  26898. private _meshCollisionData;
  26899. /**
  26900. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26902. */
  26903. ellipsoid: Vector3;
  26904. /**
  26905. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26906. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26907. */
  26908. ellipsoidOffset: Vector3;
  26909. /**
  26910. * Gets or sets a collision mask used to mask collisions (default is -1).
  26911. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26912. */
  26913. collisionMask: number;
  26914. /**
  26915. * Gets or sets the current collision group mask (-1 by default).
  26916. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26917. */
  26918. collisionGroup: number;
  26919. /**
  26920. * Defines edge width used when edgesRenderer is enabled
  26921. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26922. */
  26923. edgesWidth: number;
  26924. /**
  26925. * Defines edge color used when edgesRenderer is enabled
  26926. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26927. */
  26928. edgesColor: Color4;
  26929. /** @hidden */
  26930. _edgesRenderer: Nullable<IEdgesRenderer>;
  26931. /** @hidden */
  26932. _masterMesh: Nullable<AbstractMesh>;
  26933. /** @hidden */
  26934. _boundingInfo: Nullable<BoundingInfo>;
  26935. /** @hidden */
  26936. _renderId: number;
  26937. /**
  26938. * Gets or sets the list of subMeshes
  26939. * @see http://doc.babylonjs.com/how_to/multi_materials
  26940. */
  26941. subMeshes: SubMesh[];
  26942. /** @hidden */
  26943. _intersectionsInProgress: AbstractMesh[];
  26944. /** @hidden */
  26945. _unIndexed: boolean;
  26946. /** @hidden */
  26947. _lightSources: Light[];
  26948. /** Gets the list of lights affecting that mesh */
  26949. readonly lightSources: Light[];
  26950. /** @hidden */
  26951. readonly _positions: Nullable<Vector3[]>;
  26952. /** @hidden */
  26953. _waitingData: {
  26954. lods: Nullable<any>;
  26955. actions: Nullable<any>;
  26956. freezeWorldMatrix: Nullable<boolean>;
  26957. };
  26958. /** @hidden */
  26959. _bonesTransformMatrices: Nullable<Float32Array>;
  26960. /** @hidden */
  26961. _transformMatrixTexture: Nullable<RawTexture>;
  26962. /**
  26963. * Gets or sets a skeleton to apply skining transformations
  26964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26965. */
  26966. skeleton: Nullable<Skeleton>;
  26967. /**
  26968. * An event triggered when the mesh is rebuilt.
  26969. */
  26970. onRebuildObservable: Observable<AbstractMesh>;
  26971. /**
  26972. * Creates a new AbstractMesh
  26973. * @param name defines the name of the mesh
  26974. * @param scene defines the hosting scene
  26975. */
  26976. constructor(name: string, scene?: Nullable<Scene>);
  26977. /**
  26978. * Returns the string "AbstractMesh"
  26979. * @returns "AbstractMesh"
  26980. */
  26981. getClassName(): string;
  26982. /**
  26983. * Gets a string representation of the current mesh
  26984. * @param fullDetails defines a boolean indicating if full details must be included
  26985. * @returns a string representation of the current mesh
  26986. */
  26987. toString(fullDetails?: boolean): string;
  26988. /**
  26989. * @hidden
  26990. */
  26991. protected _getEffectiveParent(): Nullable<Node>;
  26992. /** @hidden */
  26993. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26994. /** @hidden */
  26995. _rebuild(): void;
  26996. /** @hidden */
  26997. _resyncLightSources(): void;
  26998. /** @hidden */
  26999. _resyncLighSource(light: Light): void;
  27000. /** @hidden */
  27001. _unBindEffect(): void;
  27002. /** @hidden */
  27003. _removeLightSource(light: Light, dispose: boolean): void;
  27004. private _markSubMeshesAsDirty;
  27005. /** @hidden */
  27006. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27007. /** @hidden */
  27008. _markSubMeshesAsAttributesDirty(): void;
  27009. /** @hidden */
  27010. _markSubMeshesAsMiscDirty(): void;
  27011. /**
  27012. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27013. */
  27014. scaling: Vector3;
  27015. /**
  27016. * Returns true if the mesh is blocked. Implemented by child classes
  27017. */
  27018. readonly isBlocked: boolean;
  27019. /**
  27020. * Returns the mesh itself by default. Implemented by child classes
  27021. * @param camera defines the camera to use to pick the right LOD level
  27022. * @returns the currentAbstractMesh
  27023. */
  27024. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27025. /**
  27026. * Returns 0 by default. Implemented by child classes
  27027. * @returns an integer
  27028. */
  27029. getTotalVertices(): number;
  27030. /**
  27031. * Returns a positive integer : the total number of indices in this mesh geometry.
  27032. * @returns the numner of indices or zero if the mesh has no geometry.
  27033. */
  27034. getTotalIndices(): number;
  27035. /**
  27036. * Returns null by default. Implemented by child classes
  27037. * @returns null
  27038. */
  27039. getIndices(): Nullable<IndicesArray>;
  27040. /**
  27041. * Returns the array of the requested vertex data kind. Implemented by child classes
  27042. * @param kind defines the vertex data kind to use
  27043. * @returns null
  27044. */
  27045. getVerticesData(kind: string): Nullable<FloatArray>;
  27046. /**
  27047. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27048. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27049. * Note that a new underlying VertexBuffer object is created each call.
  27050. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27051. * @param kind defines vertex data kind:
  27052. * * VertexBuffer.PositionKind
  27053. * * VertexBuffer.UVKind
  27054. * * VertexBuffer.UV2Kind
  27055. * * VertexBuffer.UV3Kind
  27056. * * VertexBuffer.UV4Kind
  27057. * * VertexBuffer.UV5Kind
  27058. * * VertexBuffer.UV6Kind
  27059. * * VertexBuffer.ColorKind
  27060. * * VertexBuffer.MatricesIndicesKind
  27061. * * VertexBuffer.MatricesIndicesExtraKind
  27062. * * VertexBuffer.MatricesWeightsKind
  27063. * * VertexBuffer.MatricesWeightsExtraKind
  27064. * @param data defines the data source
  27065. * @param updatable defines if the data must be flagged as updatable (or static)
  27066. * @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
  27067. * @returns the current mesh
  27068. */
  27069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27070. /**
  27071. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27072. * If the mesh has no geometry, it is simply returned as it is.
  27073. * @param kind defines vertex data kind:
  27074. * * VertexBuffer.PositionKind
  27075. * * VertexBuffer.UVKind
  27076. * * VertexBuffer.UV2Kind
  27077. * * VertexBuffer.UV3Kind
  27078. * * VertexBuffer.UV4Kind
  27079. * * VertexBuffer.UV5Kind
  27080. * * VertexBuffer.UV6Kind
  27081. * * VertexBuffer.ColorKind
  27082. * * VertexBuffer.MatricesIndicesKind
  27083. * * VertexBuffer.MatricesIndicesExtraKind
  27084. * * VertexBuffer.MatricesWeightsKind
  27085. * * VertexBuffer.MatricesWeightsExtraKind
  27086. * @param data defines the data source
  27087. * @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
  27088. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27089. * @returns the current mesh
  27090. */
  27091. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27092. /**
  27093. * Sets the mesh indices,
  27094. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27095. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27096. * @param totalVertices Defines the total number of vertices
  27097. * @returns the current mesh
  27098. */
  27099. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27100. /**
  27101. * Gets a boolean indicating if specific vertex data is present
  27102. * @param kind defines the vertex data kind to use
  27103. * @returns true is data kind is present
  27104. */
  27105. isVerticesDataPresent(kind: string): boolean;
  27106. /**
  27107. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27108. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27109. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27110. * @returns a BoundingInfo
  27111. */
  27112. getBoundingInfo(): BoundingInfo;
  27113. /**
  27114. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27115. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27116. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27117. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27118. * @returns the current mesh
  27119. */
  27120. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27121. /**
  27122. * Overwrite the current bounding info
  27123. * @param boundingInfo defines the new bounding info
  27124. * @returns the current mesh
  27125. */
  27126. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27127. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27128. readonly useBones: boolean;
  27129. /** @hidden */
  27130. _preActivate(): void;
  27131. /** @hidden */
  27132. _preActivateForIntermediateRendering(renderId: number): void;
  27133. /** @hidden */
  27134. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27135. /** @hidden */
  27136. _postActivate(): void;
  27137. /** @hidden */
  27138. _freeze(): void;
  27139. /** @hidden */
  27140. _unFreeze(): void;
  27141. /**
  27142. * Gets the current world matrix
  27143. * @returns a Matrix
  27144. */
  27145. getWorldMatrix(): Matrix;
  27146. /** @hidden */
  27147. _getWorldMatrixDeterminant(): number;
  27148. /**
  27149. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27150. */
  27151. readonly isAnInstance: boolean;
  27152. /**
  27153. * Gets a boolean indicating if this mesh has instances
  27154. */
  27155. readonly hasInstances: boolean;
  27156. /**
  27157. * Perform relative position change from the point of view of behind the front of the mesh.
  27158. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27159. * Supports definition of mesh facing forward or backward
  27160. * @param amountRight defines the distance on the right axis
  27161. * @param amountUp defines the distance on the up axis
  27162. * @param amountForward defines the distance on the forward axis
  27163. * @returns the current mesh
  27164. */
  27165. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27166. /**
  27167. * Calculate relative position change from the point of view of behind the front of the mesh.
  27168. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27169. * Supports definition of mesh facing forward or backward
  27170. * @param amountRight defines the distance on the right axis
  27171. * @param amountUp defines the distance on the up axis
  27172. * @param amountForward defines the distance on the forward axis
  27173. * @returns the new displacement vector
  27174. */
  27175. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27176. /**
  27177. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27178. * Supports definition of mesh facing forward or backward
  27179. * @param flipBack defines the flip
  27180. * @param twirlClockwise defines the twirl
  27181. * @param tiltRight defines the tilt
  27182. * @returns the current mesh
  27183. */
  27184. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27185. /**
  27186. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27187. * Supports definition of mesh facing forward or backward.
  27188. * @param flipBack defines the flip
  27189. * @param twirlClockwise defines the twirl
  27190. * @param tiltRight defines the tilt
  27191. * @returns the new rotation vector
  27192. */
  27193. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27194. /**
  27195. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27196. * This means the mesh underlying bounding box and sphere are recomputed.
  27197. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27198. * @returns the current mesh
  27199. */
  27200. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27201. /** @hidden */
  27202. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27203. /** @hidden */
  27204. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27205. /** @hidden */
  27206. _updateBoundingInfo(): AbstractMesh;
  27207. /** @hidden */
  27208. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27209. /** @hidden */
  27210. protected _afterComputeWorldMatrix(): void;
  27211. /** @hidden */
  27212. readonly _effectiveMesh: AbstractMesh;
  27213. /**
  27214. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27215. * A mesh is in the frustum if its bounding box intersects the frustum
  27216. * @param frustumPlanes defines the frustum to test
  27217. * @returns true if the mesh is in the frustum planes
  27218. */
  27219. isInFrustum(frustumPlanes: Plane[]): boolean;
  27220. /**
  27221. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27222. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27223. * @param frustumPlanes defines the frustum to test
  27224. * @returns true if the mesh is completely in the frustum planes
  27225. */
  27226. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27227. /**
  27228. * True if the mesh intersects another mesh or a SolidParticle object
  27229. * @param mesh defines a target mesh or SolidParticle to test
  27230. * @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)
  27231. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27232. * @returns true if there is an intersection
  27233. */
  27234. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27235. /**
  27236. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27237. * @param point defines the point to test
  27238. * @returns true if there is an intersection
  27239. */
  27240. intersectsPoint(point: Vector3): boolean;
  27241. /**
  27242. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27244. */
  27245. checkCollisions: boolean;
  27246. /**
  27247. * Gets Collider object used to compute collisions (not physics)
  27248. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27249. */
  27250. readonly collider: Nullable<Collider>;
  27251. /**
  27252. * Move the mesh using collision engine
  27253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27254. * @param displacement defines the requested displacement vector
  27255. * @returns the current mesh
  27256. */
  27257. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27258. private _onCollisionPositionChange;
  27259. /** @hidden */
  27260. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27261. /** @hidden */
  27262. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27263. /** @hidden */
  27264. _checkCollision(collider: Collider): AbstractMesh;
  27265. /** @hidden */
  27266. _generatePointsArray(): boolean;
  27267. /**
  27268. * Checks if the passed Ray intersects with the mesh
  27269. * @param ray defines the ray to use
  27270. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27271. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27272. * @returns the picking info
  27273. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27274. */
  27275. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27276. /**
  27277. * Clones the current mesh
  27278. * @param name defines the mesh name
  27279. * @param newParent defines the new mesh parent
  27280. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27281. * @returns the new mesh
  27282. */
  27283. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27284. /**
  27285. * Disposes all the submeshes of the current meshnp
  27286. * @returns the current mesh
  27287. */
  27288. releaseSubMeshes(): AbstractMesh;
  27289. /**
  27290. * Releases resources associated with this abstract mesh.
  27291. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27292. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27293. */
  27294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27295. /**
  27296. * Adds the passed mesh as a child to the current mesh
  27297. * @param mesh defines the child mesh
  27298. * @returns the current mesh
  27299. */
  27300. addChild(mesh: AbstractMesh): AbstractMesh;
  27301. /**
  27302. * Removes the passed mesh from the current mesh children list
  27303. * @param mesh defines the child mesh
  27304. * @returns the current mesh
  27305. */
  27306. removeChild(mesh: AbstractMesh): AbstractMesh;
  27307. /** @hidden */
  27308. private _initFacetData;
  27309. /**
  27310. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27311. * This method can be called within the render loop.
  27312. * 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
  27313. * @returns the current mesh
  27314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27315. */
  27316. updateFacetData(): AbstractMesh;
  27317. /**
  27318. * Returns the facetLocalNormals array.
  27319. * The normals are expressed in the mesh local spac
  27320. * @returns an array of Vector3
  27321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27322. */
  27323. getFacetLocalNormals(): Vector3[];
  27324. /**
  27325. * Returns the facetLocalPositions array.
  27326. * The facet positions are expressed in the mesh local space
  27327. * @returns an array of Vector3
  27328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27329. */
  27330. getFacetLocalPositions(): Vector3[];
  27331. /**
  27332. * Returns the facetLocalPartioning array
  27333. * @returns an array of array of numbers
  27334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27335. */
  27336. getFacetLocalPartitioning(): number[][];
  27337. /**
  27338. * Returns the i-th facet position in the world system.
  27339. * This method allocates a new Vector3 per call
  27340. * @param i defines the facet index
  27341. * @returns a new Vector3
  27342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27343. */
  27344. getFacetPosition(i: number): Vector3;
  27345. /**
  27346. * Sets the reference Vector3 with the i-th facet position in the world system
  27347. * @param i defines the facet index
  27348. * @param ref defines the target vector
  27349. * @returns the current mesh
  27350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27351. */
  27352. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27353. /**
  27354. * Returns the i-th facet normal in the world system.
  27355. * This method allocates a new Vector3 per call
  27356. * @param i defines the facet index
  27357. * @returns a new Vector3
  27358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27359. */
  27360. getFacetNormal(i: number): Vector3;
  27361. /**
  27362. * Sets the reference Vector3 with the i-th facet normal in the world system
  27363. * @param i defines the facet index
  27364. * @param ref defines the target vector
  27365. * @returns the current mesh
  27366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27367. */
  27368. getFacetNormalToRef(i: number, ref: Vector3): this;
  27369. /**
  27370. * 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)
  27371. * @param x defines x coordinate
  27372. * @param y defines y coordinate
  27373. * @param z defines z coordinate
  27374. * @returns the array of facet indexes
  27375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27376. */
  27377. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27378. /**
  27379. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27380. * @param projected sets as the (x,y,z) world projection on the facet
  27381. * @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
  27382. * @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
  27383. * @param x defines x coordinate
  27384. * @param y defines y coordinate
  27385. * @param z defines z coordinate
  27386. * @returns the face index if found (or null instead)
  27387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27388. */
  27389. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27390. /**
  27391. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27392. * @param projected sets as the (x,y,z) local projection on the facet
  27393. * @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
  27394. * @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
  27395. * @param x defines x coordinate
  27396. * @param y defines y coordinate
  27397. * @param z defines z coordinate
  27398. * @returns the face index if found (or null instead)
  27399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27400. */
  27401. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27402. /**
  27403. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27404. * @returns the parameters
  27405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27406. */
  27407. getFacetDataParameters(): any;
  27408. /**
  27409. * Disables the feature FacetData and frees the related memory
  27410. * @returns the current mesh
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27412. */
  27413. disableFacetData(): AbstractMesh;
  27414. /**
  27415. * Updates the AbstractMesh indices array
  27416. * @param indices defines the data source
  27417. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27418. * @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)
  27419. * @returns the current mesh
  27420. */
  27421. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27422. /**
  27423. * Creates new normals data for the mesh
  27424. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27425. * @returns the current mesh
  27426. */
  27427. createNormals(updatable: boolean): AbstractMesh;
  27428. /**
  27429. * Align the mesh with a normal
  27430. * @param normal defines the normal to use
  27431. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27432. * @returns the current mesh
  27433. */
  27434. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27435. /** @hidden */
  27436. _checkOcclusionQuery(): boolean;
  27437. /**
  27438. * Disables the mesh edge rendering mode
  27439. * @returns the currentAbstractMesh
  27440. */
  27441. disableEdgesRendering(): AbstractMesh;
  27442. /**
  27443. * Enables the edge rendering mode on the mesh.
  27444. * This mode makes the mesh edges visible
  27445. * @param epsilon defines the maximal distance between two angles to detect a face
  27446. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27447. * @returns the currentAbstractMesh
  27448. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27449. */
  27450. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27451. }
  27452. }
  27453. declare module "babylonjs/Actions/actionEvent" {
  27454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27455. import { Nullable } from "babylonjs/types";
  27456. import { Sprite } from "babylonjs/Sprites/sprite";
  27457. import { Scene } from "babylonjs/scene";
  27458. import { Vector2 } from "babylonjs/Maths/math.vector";
  27459. /**
  27460. * Interface used to define ActionEvent
  27461. */
  27462. export interface IActionEvent {
  27463. /** The mesh or sprite that triggered the action */
  27464. source: any;
  27465. /** The X mouse cursor position at the time of the event */
  27466. pointerX: number;
  27467. /** The Y mouse cursor position at the time of the event */
  27468. pointerY: number;
  27469. /** The mesh that is currently pointed at (can be null) */
  27470. meshUnderPointer: Nullable<AbstractMesh>;
  27471. /** the original (browser) event that triggered the ActionEvent */
  27472. sourceEvent?: any;
  27473. /** additional data for the event */
  27474. additionalData?: any;
  27475. }
  27476. /**
  27477. * ActionEvent is the event being sent when an action is triggered.
  27478. */
  27479. export class ActionEvent implements IActionEvent {
  27480. /** The mesh or sprite that triggered the action */
  27481. source: any;
  27482. /** The X mouse cursor position at the time of the event */
  27483. pointerX: number;
  27484. /** The Y mouse cursor position at the time of the event */
  27485. pointerY: number;
  27486. /** The mesh that is currently pointed at (can be null) */
  27487. meshUnderPointer: Nullable<AbstractMesh>;
  27488. /** the original (browser) event that triggered the ActionEvent */
  27489. sourceEvent?: any;
  27490. /** additional data for the event */
  27491. additionalData?: any;
  27492. /**
  27493. * Creates a new ActionEvent
  27494. * @param source The mesh or sprite that triggered the action
  27495. * @param pointerX The X mouse cursor position at the time of the event
  27496. * @param pointerY The Y mouse cursor position at the time of the event
  27497. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27498. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27499. * @param additionalData additional data for the event
  27500. */
  27501. constructor(
  27502. /** The mesh or sprite that triggered the action */
  27503. source: any,
  27504. /** The X mouse cursor position at the time of the event */
  27505. pointerX: number,
  27506. /** The Y mouse cursor position at the time of the event */
  27507. pointerY: number,
  27508. /** The mesh that is currently pointed at (can be null) */
  27509. meshUnderPointer: Nullable<AbstractMesh>,
  27510. /** the original (browser) event that triggered the ActionEvent */
  27511. sourceEvent?: any,
  27512. /** additional data for the event */
  27513. additionalData?: any);
  27514. /**
  27515. * Helper function to auto-create an ActionEvent from a source mesh.
  27516. * @param source The source mesh that triggered the event
  27517. * @param evt The original (browser) event
  27518. * @param additionalData additional data for the event
  27519. * @returns the new ActionEvent
  27520. */
  27521. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27522. /**
  27523. * Helper function to auto-create an ActionEvent from a source sprite
  27524. * @param source The source sprite that triggered the event
  27525. * @param scene Scene associated with the sprite
  27526. * @param evt The original (browser) event
  27527. * @param additionalData additional data for the event
  27528. * @returns the new ActionEvent
  27529. */
  27530. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27531. /**
  27532. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27533. * @param scene the scene where the event occurred
  27534. * @param evt The original (browser) event
  27535. * @returns the new ActionEvent
  27536. */
  27537. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27538. /**
  27539. * Helper function to auto-create an ActionEvent from a primitive
  27540. * @param prim defines the target primitive
  27541. * @param pointerPos defines the pointer position
  27542. * @param evt The original (browser) event
  27543. * @param additionalData additional data for the event
  27544. * @returns the new ActionEvent
  27545. */
  27546. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27547. }
  27548. }
  27549. declare module "babylonjs/Actions/abstractActionManager" {
  27550. import { IDisposable } from "babylonjs/scene";
  27551. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27552. import { IAction } from "babylonjs/Actions/action";
  27553. import { Nullable } from "babylonjs/types";
  27554. /**
  27555. * Abstract class used to decouple action Manager from scene and meshes.
  27556. * Do not instantiate.
  27557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27558. */
  27559. export abstract class AbstractActionManager implements IDisposable {
  27560. /** Gets the list of active triggers */
  27561. static Triggers: {
  27562. [key: string]: number;
  27563. };
  27564. /** Gets the cursor to use when hovering items */
  27565. hoverCursor: string;
  27566. /** Gets the list of actions */
  27567. actions: IAction[];
  27568. /**
  27569. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27570. */
  27571. isRecursive: boolean;
  27572. /**
  27573. * Releases all associated resources
  27574. */
  27575. abstract dispose(): void;
  27576. /**
  27577. * Does this action manager has pointer triggers
  27578. */
  27579. abstract readonly hasPointerTriggers: boolean;
  27580. /**
  27581. * Does this action manager has pick triggers
  27582. */
  27583. abstract readonly hasPickTriggers: boolean;
  27584. /**
  27585. * Process a specific trigger
  27586. * @param trigger defines the trigger to process
  27587. * @param evt defines the event details to be processed
  27588. */
  27589. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27590. /**
  27591. * Does this action manager handles actions of any of the given triggers
  27592. * @param triggers defines the triggers to be tested
  27593. * @return a boolean indicating whether one (or more) of the triggers is handled
  27594. */
  27595. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27596. /**
  27597. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27598. * speed.
  27599. * @param triggerA defines the trigger to be tested
  27600. * @param triggerB defines the trigger to be tested
  27601. * @return a boolean indicating whether one (or more) of the triggers is handled
  27602. */
  27603. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27604. /**
  27605. * Does this action manager handles actions of a given trigger
  27606. * @param trigger defines the trigger to be tested
  27607. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27608. * @return whether the trigger is handled
  27609. */
  27610. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27611. /**
  27612. * Serialize this manager to a JSON object
  27613. * @param name defines the property name to store this manager
  27614. * @returns a JSON representation of this manager
  27615. */
  27616. abstract serialize(name: string): any;
  27617. /**
  27618. * Registers an action to this action manager
  27619. * @param action defines the action to be registered
  27620. * @return the action amended (prepared) after registration
  27621. */
  27622. abstract registerAction(action: IAction): Nullable<IAction>;
  27623. /**
  27624. * Unregisters an action to this action manager
  27625. * @param action defines the action to be unregistered
  27626. * @return a boolean indicating whether the action has been unregistered
  27627. */
  27628. abstract unregisterAction(action: IAction): Boolean;
  27629. /**
  27630. * Does exist one action manager with at least one trigger
  27631. **/
  27632. static readonly HasTriggers: boolean;
  27633. /**
  27634. * Does exist one action manager with at least one pick trigger
  27635. **/
  27636. static readonly HasPickTriggers: boolean;
  27637. /**
  27638. * Does exist one action manager that handles actions of a given trigger
  27639. * @param trigger defines the trigger to be tested
  27640. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27641. **/
  27642. static HasSpecificTrigger(trigger: number): boolean;
  27643. }
  27644. }
  27645. declare module "babylonjs/node" {
  27646. import { Scene } from "babylonjs/scene";
  27647. import { Nullable } from "babylonjs/types";
  27648. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27649. import { Engine } from "babylonjs/Engines/engine";
  27650. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27651. import { Observable } from "babylonjs/Misc/observable";
  27652. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27653. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27654. import { Animatable } from "babylonjs/Animations/animatable";
  27655. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27656. import { Animation } from "babylonjs/Animations/animation";
  27657. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27659. /**
  27660. * Defines how a node can be built from a string name.
  27661. */
  27662. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27663. /**
  27664. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27665. */
  27666. export class Node implements IBehaviorAware<Node> {
  27667. /** @hidden */
  27668. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27669. private static _NodeConstructors;
  27670. /**
  27671. * Add a new node constructor
  27672. * @param type defines the type name of the node to construct
  27673. * @param constructorFunc defines the constructor function
  27674. */
  27675. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27676. /**
  27677. * Returns a node constructor based on type name
  27678. * @param type defines the type name
  27679. * @param name defines the new node name
  27680. * @param scene defines the hosting scene
  27681. * @param options defines optional options to transmit to constructors
  27682. * @returns the new constructor or null
  27683. */
  27684. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27685. /**
  27686. * Gets or sets the name of the node
  27687. */
  27688. name: string;
  27689. /**
  27690. * Gets or sets the id of the node
  27691. */
  27692. id: string;
  27693. /**
  27694. * Gets or sets the unique id of the node
  27695. */
  27696. uniqueId: number;
  27697. /**
  27698. * Gets or sets a string used to store user defined state for the node
  27699. */
  27700. state: string;
  27701. /**
  27702. * Gets or sets an object used to store user defined information for the node
  27703. */
  27704. metadata: any;
  27705. /**
  27706. * For internal use only. Please do not use.
  27707. */
  27708. reservedDataStore: any;
  27709. /**
  27710. * List of inspectable custom properties (used by the Inspector)
  27711. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27712. */
  27713. inspectableCustomProperties: IInspectable[];
  27714. private _doNotSerialize;
  27715. /**
  27716. * Gets or sets a boolean used to define if the node must be serialized
  27717. */
  27718. doNotSerialize: boolean;
  27719. /** @hidden */
  27720. _isDisposed: boolean;
  27721. /**
  27722. * Gets a list of Animations associated with the node
  27723. */
  27724. animations: import("babylonjs/Animations/animation").Animation[];
  27725. protected _ranges: {
  27726. [name: string]: Nullable<AnimationRange>;
  27727. };
  27728. /**
  27729. * Callback raised when the node is ready to be used
  27730. */
  27731. onReady: Nullable<(node: Node) => void>;
  27732. private _isEnabled;
  27733. private _isParentEnabled;
  27734. private _isReady;
  27735. /** @hidden */
  27736. _currentRenderId: number;
  27737. private _parentUpdateId;
  27738. /** @hidden */
  27739. _childUpdateId: number;
  27740. /** @hidden */
  27741. _waitingParentId: Nullable<string>;
  27742. /** @hidden */
  27743. _scene: Scene;
  27744. /** @hidden */
  27745. _cache: any;
  27746. private _parentNode;
  27747. private _children;
  27748. /** @hidden */
  27749. _worldMatrix: Matrix;
  27750. /** @hidden */
  27751. _worldMatrixDeterminant: number;
  27752. /** @hidden */
  27753. _worldMatrixDeterminantIsDirty: boolean;
  27754. /** @hidden */
  27755. private _sceneRootNodesIndex;
  27756. /**
  27757. * Gets a boolean indicating if the node has been disposed
  27758. * @returns true if the node was disposed
  27759. */
  27760. isDisposed(): boolean;
  27761. /**
  27762. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27763. * @see https://doc.babylonjs.com/how_to/parenting
  27764. */
  27765. parent: Nullable<Node>;
  27766. private addToSceneRootNodes;
  27767. private removeFromSceneRootNodes;
  27768. private _animationPropertiesOverride;
  27769. /**
  27770. * Gets or sets the animation properties override
  27771. */
  27772. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27773. /**
  27774. * Gets a string idenfifying the name of the class
  27775. * @returns "Node" string
  27776. */
  27777. getClassName(): string;
  27778. /** @hidden */
  27779. readonly _isNode: boolean;
  27780. /**
  27781. * An event triggered when the mesh is disposed
  27782. */
  27783. onDisposeObservable: Observable<Node>;
  27784. private _onDisposeObserver;
  27785. /**
  27786. * Sets a callback that will be raised when the node will be disposed
  27787. */
  27788. onDispose: () => void;
  27789. /**
  27790. * Creates a new Node
  27791. * @param name the name and id to be given to this node
  27792. * @param scene the scene this node will be added to
  27793. * @param addToRootNodes the node will be added to scene.rootNodes
  27794. */
  27795. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27796. /**
  27797. * Gets the scene of the node
  27798. * @returns a scene
  27799. */
  27800. getScene(): Scene;
  27801. /**
  27802. * Gets the engine of the node
  27803. * @returns a Engine
  27804. */
  27805. getEngine(): Engine;
  27806. private _behaviors;
  27807. /**
  27808. * Attach a behavior to the node
  27809. * @see http://doc.babylonjs.com/features/behaviour
  27810. * @param behavior defines the behavior to attach
  27811. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27812. * @returns the current Node
  27813. */
  27814. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27815. /**
  27816. * Remove an attached behavior
  27817. * @see http://doc.babylonjs.com/features/behaviour
  27818. * @param behavior defines the behavior to attach
  27819. * @returns the current Node
  27820. */
  27821. removeBehavior(behavior: Behavior<Node>): Node;
  27822. /**
  27823. * Gets the list of attached behaviors
  27824. * @see http://doc.babylonjs.com/features/behaviour
  27825. */
  27826. readonly behaviors: Behavior<Node>[];
  27827. /**
  27828. * Gets an attached behavior by name
  27829. * @param name defines the name of the behavior to look for
  27830. * @see http://doc.babylonjs.com/features/behaviour
  27831. * @returns null if behavior was not found else the requested behavior
  27832. */
  27833. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27834. /**
  27835. * Returns the latest update of the World matrix
  27836. * @returns a Matrix
  27837. */
  27838. getWorldMatrix(): Matrix;
  27839. /** @hidden */
  27840. _getWorldMatrixDeterminant(): number;
  27841. /**
  27842. * Returns directly the latest state of the mesh World matrix.
  27843. * A Matrix is returned.
  27844. */
  27845. readonly worldMatrixFromCache: Matrix;
  27846. /** @hidden */
  27847. _initCache(): void;
  27848. /** @hidden */
  27849. updateCache(force?: boolean): void;
  27850. /** @hidden */
  27851. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27852. /** @hidden */
  27853. _updateCache(ignoreParentClass?: boolean): void;
  27854. /** @hidden */
  27855. _isSynchronized(): boolean;
  27856. /** @hidden */
  27857. _markSyncedWithParent(): void;
  27858. /** @hidden */
  27859. isSynchronizedWithParent(): boolean;
  27860. /** @hidden */
  27861. isSynchronized(): boolean;
  27862. /**
  27863. * Is this node ready to be used/rendered
  27864. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27865. * @return true if the node is ready
  27866. */
  27867. isReady(completeCheck?: boolean): boolean;
  27868. /**
  27869. * Is this node enabled?
  27870. * 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
  27871. * @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
  27872. * @return whether this node (and its parent) is enabled
  27873. */
  27874. isEnabled(checkAncestors?: boolean): boolean;
  27875. /** @hidden */
  27876. protected _syncParentEnabledState(): void;
  27877. /**
  27878. * Set the enabled state of this node
  27879. * @param value defines the new enabled state
  27880. */
  27881. setEnabled(value: boolean): void;
  27882. /**
  27883. * Is this node a descendant of the given node?
  27884. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27885. * @param ancestor defines the parent node to inspect
  27886. * @returns a boolean indicating if this node is a descendant of the given node
  27887. */
  27888. isDescendantOf(ancestor: Node): boolean;
  27889. /** @hidden */
  27890. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27891. /**
  27892. * Will return all nodes that have this node as ascendant
  27893. * @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
  27894. * @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
  27895. * @return all children nodes of all types
  27896. */
  27897. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27898. /**
  27899. * Get all child-meshes of this node
  27900. * @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)
  27901. * @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
  27902. * @returns an array of AbstractMesh
  27903. */
  27904. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27905. /**
  27906. * Get all direct children of this node
  27907. * @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
  27908. * @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)
  27909. * @returns an array of Node
  27910. */
  27911. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27912. /** @hidden */
  27913. _setReady(state: boolean): void;
  27914. /**
  27915. * Get an animation by name
  27916. * @param name defines the name of the animation to look for
  27917. * @returns null if not found else the requested animation
  27918. */
  27919. getAnimationByName(name: string): Nullable<Animation>;
  27920. /**
  27921. * Creates an animation range for this node
  27922. * @param name defines the name of the range
  27923. * @param from defines the starting key
  27924. * @param to defines the end key
  27925. */
  27926. createAnimationRange(name: string, from: number, to: number): void;
  27927. /**
  27928. * Delete a specific animation range
  27929. * @param name defines the name of the range to delete
  27930. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27931. */
  27932. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27933. /**
  27934. * Get an animation range by name
  27935. * @param name defines the name of the animation range to look for
  27936. * @returns null if not found else the requested animation range
  27937. */
  27938. getAnimationRange(name: string): Nullable<AnimationRange>;
  27939. /**
  27940. * Gets the list of all animation ranges defined on this node
  27941. * @returns an array
  27942. */
  27943. getAnimationRanges(): Nullable<AnimationRange>[];
  27944. /**
  27945. * Will start the animation sequence
  27946. * @param name defines the range frames for animation sequence
  27947. * @param loop defines if the animation should loop (false by default)
  27948. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27949. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27950. * @returns the object created for this animation. If range does not exist, it will return null
  27951. */
  27952. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27953. /**
  27954. * Serialize animation ranges into a JSON compatible object
  27955. * @returns serialization object
  27956. */
  27957. serializeAnimationRanges(): any;
  27958. /**
  27959. * Computes the world matrix of the node
  27960. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27961. * @returns the world matrix
  27962. */
  27963. computeWorldMatrix(force?: boolean): Matrix;
  27964. /**
  27965. * Releases resources associated with this node.
  27966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27968. */
  27969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27970. /**
  27971. * Parse animation range data from a serialization object and store them into a given node
  27972. * @param node defines where to store the animation ranges
  27973. * @param parsedNode defines the serialization object to read data from
  27974. * @param scene defines the hosting scene
  27975. */
  27976. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27977. /**
  27978. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27979. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27980. * @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
  27981. * @returns the new bounding vectors
  27982. */
  27983. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27984. min: Vector3;
  27985. max: Vector3;
  27986. };
  27987. }
  27988. }
  27989. declare module "babylonjs/Animations/animation" {
  27990. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27991. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27992. import { Color3 } from "babylonjs/Maths/math.color";
  27993. import { Nullable } from "babylonjs/types";
  27994. import { Scene } from "babylonjs/scene";
  27995. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27996. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27997. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27998. import { Node } from "babylonjs/node";
  27999. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28000. import { Size } from "babylonjs/Maths/math.size";
  28001. import { Animatable } from "babylonjs/Animations/animatable";
  28002. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28003. /**
  28004. * @hidden
  28005. */
  28006. export class _IAnimationState {
  28007. key: number;
  28008. repeatCount: number;
  28009. workValue?: any;
  28010. loopMode?: number;
  28011. offsetValue?: any;
  28012. highLimitValue?: any;
  28013. }
  28014. /**
  28015. * Class used to store any kind of animation
  28016. */
  28017. export class Animation {
  28018. /**Name of the animation */
  28019. name: string;
  28020. /**Property to animate */
  28021. targetProperty: string;
  28022. /**The frames per second of the animation */
  28023. framePerSecond: number;
  28024. /**The data type of the animation */
  28025. dataType: number;
  28026. /**The loop mode of the animation */
  28027. loopMode?: number | undefined;
  28028. /**Specifies if blending should be enabled */
  28029. enableBlending?: boolean | undefined;
  28030. /**
  28031. * Use matrix interpolation instead of using direct key value when animating matrices
  28032. */
  28033. static AllowMatricesInterpolation: boolean;
  28034. /**
  28035. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28036. */
  28037. static AllowMatrixDecomposeForInterpolation: boolean;
  28038. /**
  28039. * Stores the key frames of the animation
  28040. */
  28041. private _keys;
  28042. /**
  28043. * Stores the easing function of the animation
  28044. */
  28045. private _easingFunction;
  28046. /**
  28047. * @hidden Internal use only
  28048. */
  28049. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28050. /**
  28051. * The set of event that will be linked to this animation
  28052. */
  28053. private _events;
  28054. /**
  28055. * Stores an array of target property paths
  28056. */
  28057. targetPropertyPath: string[];
  28058. /**
  28059. * Stores the blending speed of the animation
  28060. */
  28061. blendingSpeed: number;
  28062. /**
  28063. * Stores the animation ranges for the animation
  28064. */
  28065. private _ranges;
  28066. /**
  28067. * @hidden Internal use
  28068. */
  28069. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28070. /**
  28071. * Sets up an animation
  28072. * @param property The property to animate
  28073. * @param animationType The animation type to apply
  28074. * @param framePerSecond The frames per second of the animation
  28075. * @param easingFunction The easing function used in the animation
  28076. * @returns The created animation
  28077. */
  28078. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28079. /**
  28080. * Create and start an animation on a node
  28081. * @param name defines the name of the global animation that will be run on all nodes
  28082. * @param node defines the root node where the animation will take place
  28083. * @param targetProperty defines property to animate
  28084. * @param framePerSecond defines the number of frame per second yo use
  28085. * @param totalFrame defines the number of frames in total
  28086. * @param from defines the initial value
  28087. * @param to defines the final value
  28088. * @param loopMode defines which loop mode you want to use (off by default)
  28089. * @param easingFunction defines the easing function to use (linear by default)
  28090. * @param onAnimationEnd defines the callback to call when animation end
  28091. * @returns the animatable created for this animation
  28092. */
  28093. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28094. /**
  28095. * Create and start an animation on a node and its descendants
  28096. * @param name defines the name of the global animation that will be run on all nodes
  28097. * @param node defines the root node where the animation will take place
  28098. * @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
  28099. * @param targetProperty defines property to animate
  28100. * @param framePerSecond defines the number of frame per second to use
  28101. * @param totalFrame defines the number of frames in total
  28102. * @param from defines the initial value
  28103. * @param to defines the final value
  28104. * @param loopMode defines which loop mode you want to use (off by default)
  28105. * @param easingFunction defines the easing function to use (linear by default)
  28106. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28107. * @returns the list of animatables created for all nodes
  28108. * @example https://www.babylonjs-playground.com/#MH0VLI
  28109. */
  28110. 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[]>;
  28111. /**
  28112. * Creates a new animation, merges it with the existing animations and starts it
  28113. * @param name Name of the animation
  28114. * @param node Node which contains the scene that begins the animations
  28115. * @param targetProperty Specifies which property to animate
  28116. * @param framePerSecond The frames per second of the animation
  28117. * @param totalFrame The total number of frames
  28118. * @param from The frame at the beginning of the animation
  28119. * @param to The frame at the end of the animation
  28120. * @param loopMode Specifies the loop mode of the animation
  28121. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28122. * @param onAnimationEnd Callback to run once the animation is complete
  28123. * @returns Nullable animation
  28124. */
  28125. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28126. /**
  28127. * Transition property of an host to the target Value
  28128. * @param property The property to transition
  28129. * @param targetValue The target Value of the property
  28130. * @param host The object where the property to animate belongs
  28131. * @param scene Scene used to run the animation
  28132. * @param frameRate Framerate (in frame/s) to use
  28133. * @param transition The transition type we want to use
  28134. * @param duration The duration of the animation, in milliseconds
  28135. * @param onAnimationEnd Callback trigger at the end of the animation
  28136. * @returns Nullable animation
  28137. */
  28138. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28139. /**
  28140. * Return the array of runtime animations currently using this animation
  28141. */
  28142. readonly runtimeAnimations: RuntimeAnimation[];
  28143. /**
  28144. * Specifies if any of the runtime animations are currently running
  28145. */
  28146. readonly hasRunningRuntimeAnimations: boolean;
  28147. /**
  28148. * Initializes the animation
  28149. * @param name Name of the animation
  28150. * @param targetProperty Property to animate
  28151. * @param framePerSecond The frames per second of the animation
  28152. * @param dataType The data type of the animation
  28153. * @param loopMode The loop mode of the animation
  28154. * @param enableBlending Specifies if blending should be enabled
  28155. */
  28156. constructor(
  28157. /**Name of the animation */
  28158. name: string,
  28159. /**Property to animate */
  28160. targetProperty: string,
  28161. /**The frames per second of the animation */
  28162. framePerSecond: number,
  28163. /**The data type of the animation */
  28164. dataType: number,
  28165. /**The loop mode of the animation */
  28166. loopMode?: number | undefined,
  28167. /**Specifies if blending should be enabled */
  28168. enableBlending?: boolean | undefined);
  28169. /**
  28170. * Converts the animation to a string
  28171. * @param fullDetails support for multiple levels of logging within scene loading
  28172. * @returns String form of the animation
  28173. */
  28174. toString(fullDetails?: boolean): string;
  28175. /**
  28176. * Add an event to this animation
  28177. * @param event Event to add
  28178. */
  28179. addEvent(event: AnimationEvent): void;
  28180. /**
  28181. * Remove all events found at the given frame
  28182. * @param frame The frame to remove events from
  28183. */
  28184. removeEvents(frame: number): void;
  28185. /**
  28186. * Retrieves all the events from the animation
  28187. * @returns Events from the animation
  28188. */
  28189. getEvents(): AnimationEvent[];
  28190. /**
  28191. * Creates an animation range
  28192. * @param name Name of the animation range
  28193. * @param from Starting frame of the animation range
  28194. * @param to Ending frame of the animation
  28195. */
  28196. createRange(name: string, from: number, to: number): void;
  28197. /**
  28198. * Deletes an animation range by name
  28199. * @param name Name of the animation range to delete
  28200. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28201. */
  28202. deleteRange(name: string, deleteFrames?: boolean): void;
  28203. /**
  28204. * Gets the animation range by name, or null if not defined
  28205. * @param name Name of the animation range
  28206. * @returns Nullable animation range
  28207. */
  28208. getRange(name: string): Nullable<AnimationRange>;
  28209. /**
  28210. * Gets the key frames from the animation
  28211. * @returns The key frames of the animation
  28212. */
  28213. getKeys(): Array<IAnimationKey>;
  28214. /**
  28215. * Gets the highest frame rate of the animation
  28216. * @returns Highest frame rate of the animation
  28217. */
  28218. getHighestFrame(): number;
  28219. /**
  28220. * Gets the easing function of the animation
  28221. * @returns Easing function of the animation
  28222. */
  28223. getEasingFunction(): IEasingFunction;
  28224. /**
  28225. * Sets the easing function of the animation
  28226. * @param easingFunction A custom mathematical formula for animation
  28227. */
  28228. setEasingFunction(easingFunction: EasingFunction): void;
  28229. /**
  28230. * Interpolates a scalar linearly
  28231. * @param startValue Start value of the animation curve
  28232. * @param endValue End value of the animation curve
  28233. * @param gradient Scalar amount to interpolate
  28234. * @returns Interpolated scalar value
  28235. */
  28236. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28237. /**
  28238. * Interpolates a scalar cubically
  28239. * @param startValue Start value of the animation curve
  28240. * @param outTangent End tangent of the animation
  28241. * @param endValue End value of the animation curve
  28242. * @param inTangent Start tangent of the animation curve
  28243. * @param gradient Scalar amount to interpolate
  28244. * @returns Interpolated scalar value
  28245. */
  28246. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28247. /**
  28248. * Interpolates a quaternion using a spherical linear interpolation
  28249. * @param startValue Start value of the animation curve
  28250. * @param endValue End value of the animation curve
  28251. * @param gradient Scalar amount to interpolate
  28252. * @returns Interpolated quaternion value
  28253. */
  28254. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28255. /**
  28256. * Interpolates a quaternion cubically
  28257. * @param startValue Start value of the animation curve
  28258. * @param outTangent End tangent of the animation curve
  28259. * @param endValue End value of the animation curve
  28260. * @param inTangent Start tangent of the animation curve
  28261. * @param gradient Scalar amount to interpolate
  28262. * @returns Interpolated quaternion value
  28263. */
  28264. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28265. /**
  28266. * Interpolates a Vector3 linearl
  28267. * @param startValue Start value of the animation curve
  28268. * @param endValue End value of the animation curve
  28269. * @param gradient Scalar amount to interpolate
  28270. * @returns Interpolated scalar value
  28271. */
  28272. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28273. /**
  28274. * Interpolates a Vector3 cubically
  28275. * @param startValue Start value of the animation curve
  28276. * @param outTangent End tangent of the animation
  28277. * @param endValue End value of the animation curve
  28278. * @param inTangent Start tangent of the animation curve
  28279. * @param gradient Scalar amount to interpolate
  28280. * @returns InterpolatedVector3 value
  28281. */
  28282. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28283. /**
  28284. * Interpolates a Vector2 linearly
  28285. * @param startValue Start value of the animation curve
  28286. * @param endValue End value of the animation curve
  28287. * @param gradient Scalar amount to interpolate
  28288. * @returns Interpolated Vector2 value
  28289. */
  28290. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28291. /**
  28292. * Interpolates a Vector2 cubically
  28293. * @param startValue Start value of the animation curve
  28294. * @param outTangent End tangent of the animation
  28295. * @param endValue End value of the animation curve
  28296. * @param inTangent Start tangent of the animation curve
  28297. * @param gradient Scalar amount to interpolate
  28298. * @returns Interpolated Vector2 value
  28299. */
  28300. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28301. /**
  28302. * Interpolates a size linearly
  28303. * @param startValue Start value of the animation curve
  28304. * @param endValue End value of the animation curve
  28305. * @param gradient Scalar amount to interpolate
  28306. * @returns Interpolated Size value
  28307. */
  28308. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28309. /**
  28310. * Interpolates a Color3 linearly
  28311. * @param startValue Start value of the animation curve
  28312. * @param endValue End value of the animation curve
  28313. * @param gradient Scalar amount to interpolate
  28314. * @returns Interpolated Color3 value
  28315. */
  28316. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28317. /**
  28318. * @hidden Internal use only
  28319. */
  28320. _getKeyValue(value: any): any;
  28321. /**
  28322. * @hidden Internal use only
  28323. */
  28324. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28325. /**
  28326. * Defines the function to use to interpolate matrices
  28327. * @param startValue defines the start matrix
  28328. * @param endValue defines the end matrix
  28329. * @param gradient defines the gradient between both matrices
  28330. * @param result defines an optional target matrix where to store the interpolation
  28331. * @returns the interpolated matrix
  28332. */
  28333. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28334. /**
  28335. * Makes a copy of the animation
  28336. * @returns Cloned animation
  28337. */
  28338. clone(): Animation;
  28339. /**
  28340. * Sets the key frames of the animation
  28341. * @param values The animation key frames to set
  28342. */
  28343. setKeys(values: Array<IAnimationKey>): void;
  28344. /**
  28345. * Serializes the animation to an object
  28346. * @returns Serialized object
  28347. */
  28348. serialize(): any;
  28349. /**
  28350. * Float animation type
  28351. */
  28352. private static _ANIMATIONTYPE_FLOAT;
  28353. /**
  28354. * Vector3 animation type
  28355. */
  28356. private static _ANIMATIONTYPE_VECTOR3;
  28357. /**
  28358. * Quaternion animation type
  28359. */
  28360. private static _ANIMATIONTYPE_QUATERNION;
  28361. /**
  28362. * Matrix animation type
  28363. */
  28364. private static _ANIMATIONTYPE_MATRIX;
  28365. /**
  28366. * Color3 animation type
  28367. */
  28368. private static _ANIMATIONTYPE_COLOR3;
  28369. /**
  28370. * Vector2 animation type
  28371. */
  28372. private static _ANIMATIONTYPE_VECTOR2;
  28373. /**
  28374. * Size animation type
  28375. */
  28376. private static _ANIMATIONTYPE_SIZE;
  28377. /**
  28378. * Relative Loop Mode
  28379. */
  28380. private static _ANIMATIONLOOPMODE_RELATIVE;
  28381. /**
  28382. * Cycle Loop Mode
  28383. */
  28384. private static _ANIMATIONLOOPMODE_CYCLE;
  28385. /**
  28386. * Constant Loop Mode
  28387. */
  28388. private static _ANIMATIONLOOPMODE_CONSTANT;
  28389. /**
  28390. * Get the float animation type
  28391. */
  28392. static readonly ANIMATIONTYPE_FLOAT: number;
  28393. /**
  28394. * Get the Vector3 animation type
  28395. */
  28396. static readonly ANIMATIONTYPE_VECTOR3: number;
  28397. /**
  28398. * Get the Vector2 animation type
  28399. */
  28400. static readonly ANIMATIONTYPE_VECTOR2: number;
  28401. /**
  28402. * Get the Size animation type
  28403. */
  28404. static readonly ANIMATIONTYPE_SIZE: number;
  28405. /**
  28406. * Get the Quaternion animation type
  28407. */
  28408. static readonly ANIMATIONTYPE_QUATERNION: number;
  28409. /**
  28410. * Get the Matrix animation type
  28411. */
  28412. static readonly ANIMATIONTYPE_MATRIX: number;
  28413. /**
  28414. * Get the Color3 animation type
  28415. */
  28416. static readonly ANIMATIONTYPE_COLOR3: number;
  28417. /**
  28418. * Get the Relative Loop Mode
  28419. */
  28420. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28421. /**
  28422. * Get the Cycle Loop Mode
  28423. */
  28424. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28425. /**
  28426. * Get the Constant Loop Mode
  28427. */
  28428. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28429. /** @hidden */
  28430. static _UniversalLerp(left: any, right: any, amount: number): any;
  28431. /**
  28432. * Parses an animation object and creates an animation
  28433. * @param parsedAnimation Parsed animation object
  28434. * @returns Animation object
  28435. */
  28436. static Parse(parsedAnimation: any): Animation;
  28437. /**
  28438. * Appends the serialized animations from the source animations
  28439. * @param source Source containing the animations
  28440. * @param destination Target to store the animations
  28441. */
  28442. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28443. }
  28444. }
  28445. declare module "babylonjs/Animations/animatable.interface" {
  28446. import { Nullable } from "babylonjs/types";
  28447. import { Animation } from "babylonjs/Animations/animation";
  28448. /**
  28449. * Interface containing an array of animations
  28450. */
  28451. export interface IAnimatable {
  28452. /**
  28453. * Array of animations
  28454. */
  28455. animations: Nullable<Array<Animation>>;
  28456. }
  28457. }
  28458. declare module "babylonjs/Materials/fresnelParameters" {
  28459. import { Color3 } from "babylonjs/Maths/math.color";
  28460. /**
  28461. * This represents all the required information to add a fresnel effect on a material:
  28462. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28463. */
  28464. export class FresnelParameters {
  28465. private _isEnabled;
  28466. /**
  28467. * Define if the fresnel effect is enable or not.
  28468. */
  28469. isEnabled: boolean;
  28470. /**
  28471. * Define the color used on edges (grazing angle)
  28472. */
  28473. leftColor: Color3;
  28474. /**
  28475. * Define the color used on center
  28476. */
  28477. rightColor: Color3;
  28478. /**
  28479. * Define bias applied to computed fresnel term
  28480. */
  28481. bias: number;
  28482. /**
  28483. * Defined the power exponent applied to fresnel term
  28484. */
  28485. power: number;
  28486. /**
  28487. * Clones the current fresnel and its valuues
  28488. * @returns a clone fresnel configuration
  28489. */
  28490. clone(): FresnelParameters;
  28491. /**
  28492. * Serializes the current fresnel parameters to a JSON representation.
  28493. * @return the JSON serialization
  28494. */
  28495. serialize(): any;
  28496. /**
  28497. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28498. * @param parsedFresnelParameters Define the JSON representation
  28499. * @returns the parsed parameters
  28500. */
  28501. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28502. }
  28503. }
  28504. declare module "babylonjs/Misc/decorators" {
  28505. import { Nullable } from "babylonjs/types";
  28506. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28507. import { Scene } from "babylonjs/scene";
  28508. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28509. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28510. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28511. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28512. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28513. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28514. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28515. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28516. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28517. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28518. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28519. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28520. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28521. /**
  28522. * Decorator used to define property that can be serialized as reference to a camera
  28523. * @param sourceName defines the name of the property to decorate
  28524. */
  28525. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28526. /**
  28527. * Class used to help serialization objects
  28528. */
  28529. export class SerializationHelper {
  28530. /** @hidden */
  28531. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28532. /** @hidden */
  28533. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28534. /** @hidden */
  28535. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28536. /** @hidden */
  28537. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28538. /**
  28539. * Appends the serialized animations from the source animations
  28540. * @param source Source containing the animations
  28541. * @param destination Target to store the animations
  28542. */
  28543. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28544. /**
  28545. * Static function used to serialized a specific entity
  28546. * @param entity defines the entity to serialize
  28547. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28548. * @returns a JSON compatible object representing the serialization of the entity
  28549. */
  28550. static Serialize<T>(entity: T, serializationObject?: any): any;
  28551. /**
  28552. * Creates a new entity from a serialization data object
  28553. * @param creationFunction defines a function used to instanciated the new entity
  28554. * @param source defines the source serialization data
  28555. * @param scene defines the hosting scene
  28556. * @param rootUrl defines the root url for resources
  28557. * @returns a new entity
  28558. */
  28559. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28560. /**
  28561. * Clones an object
  28562. * @param creationFunction defines the function used to instanciate the new object
  28563. * @param source defines the source object
  28564. * @returns the cloned object
  28565. */
  28566. static Clone<T>(creationFunction: () => T, source: T): T;
  28567. /**
  28568. * Instanciates a new object based on a source one (some data will be shared between both object)
  28569. * @param creationFunction defines the function used to instanciate the new object
  28570. * @param source defines the source object
  28571. * @returns the new object
  28572. */
  28573. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28574. }
  28575. }
  28576. declare module "babylonjs/Misc/guid" {
  28577. /**
  28578. * Class used to manipulate GUIDs
  28579. */
  28580. export class GUID {
  28581. /**
  28582. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28583. * Be aware Math.random() could cause collisions, but:
  28584. * "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"
  28585. * @returns a pseudo random id
  28586. */
  28587. static RandomId(): string;
  28588. }
  28589. }
  28590. declare module "babylonjs/Materials/Textures/baseTexture" {
  28591. import { Observable } from "babylonjs/Misc/observable";
  28592. import { Nullable } from "babylonjs/types";
  28593. import { Scene } from "babylonjs/scene";
  28594. import { Matrix } from "babylonjs/Maths/math.vector";
  28595. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28597. import { ISize } from "babylonjs/Maths/math.size";
  28598. /**
  28599. * Base class of all the textures in babylon.
  28600. * It groups all the common properties the materials, post process, lights... might need
  28601. * in order to make a correct use of the texture.
  28602. */
  28603. export class BaseTexture implements IAnimatable {
  28604. /**
  28605. * Default anisotropic filtering level for the application.
  28606. * It is set to 4 as a good tradeoff between perf and quality.
  28607. */
  28608. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28609. /**
  28610. * Gets or sets the unique id of the texture
  28611. */
  28612. uniqueId: number;
  28613. /**
  28614. * Define the name of the texture.
  28615. */
  28616. name: string;
  28617. /**
  28618. * Gets or sets an object used to store user defined information.
  28619. */
  28620. metadata: any;
  28621. /**
  28622. * For internal use only. Please do not use.
  28623. */
  28624. reservedDataStore: any;
  28625. private _hasAlpha;
  28626. /**
  28627. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28628. */
  28629. hasAlpha: boolean;
  28630. /**
  28631. * Defines if the alpha value should be determined via the rgb values.
  28632. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28633. */
  28634. getAlphaFromRGB: boolean;
  28635. /**
  28636. * Intensity or strength of the texture.
  28637. * It is commonly used by materials to fine tune the intensity of the texture
  28638. */
  28639. level: number;
  28640. /**
  28641. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28642. * This is part of the texture as textures usually maps to one uv set.
  28643. */
  28644. coordinatesIndex: number;
  28645. private _coordinatesMode;
  28646. /**
  28647. * How a texture is mapped.
  28648. *
  28649. * | Value | Type | Description |
  28650. * | ----- | ----------------------------------- | ----------- |
  28651. * | 0 | EXPLICIT_MODE | |
  28652. * | 1 | SPHERICAL_MODE | |
  28653. * | 2 | PLANAR_MODE | |
  28654. * | 3 | CUBIC_MODE | |
  28655. * | 4 | PROJECTION_MODE | |
  28656. * | 5 | SKYBOX_MODE | |
  28657. * | 6 | INVCUBIC_MODE | |
  28658. * | 7 | EQUIRECTANGULAR_MODE | |
  28659. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28660. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28661. */
  28662. coordinatesMode: number;
  28663. /**
  28664. * | Value | Type | Description |
  28665. * | ----- | ------------------ | ----------- |
  28666. * | 0 | CLAMP_ADDRESSMODE | |
  28667. * | 1 | WRAP_ADDRESSMODE | |
  28668. * | 2 | MIRROR_ADDRESSMODE | |
  28669. */
  28670. wrapU: number;
  28671. /**
  28672. * | Value | Type | Description |
  28673. * | ----- | ------------------ | ----------- |
  28674. * | 0 | CLAMP_ADDRESSMODE | |
  28675. * | 1 | WRAP_ADDRESSMODE | |
  28676. * | 2 | MIRROR_ADDRESSMODE | |
  28677. */
  28678. wrapV: number;
  28679. /**
  28680. * | Value | Type | Description |
  28681. * | ----- | ------------------ | ----------- |
  28682. * | 0 | CLAMP_ADDRESSMODE | |
  28683. * | 1 | WRAP_ADDRESSMODE | |
  28684. * | 2 | MIRROR_ADDRESSMODE | |
  28685. */
  28686. wrapR: number;
  28687. /**
  28688. * With compliant hardware and browser (supporting anisotropic filtering)
  28689. * this defines the level of anisotropic filtering in the texture.
  28690. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28691. */
  28692. anisotropicFilteringLevel: number;
  28693. /**
  28694. * Define if the texture is a cube texture or if false a 2d texture.
  28695. */
  28696. isCube: boolean;
  28697. /**
  28698. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28699. */
  28700. is3D: boolean;
  28701. /**
  28702. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28703. * HDR texture are usually stored in linear space.
  28704. * This only impacts the PBR and Background materials
  28705. */
  28706. gammaSpace: boolean;
  28707. /**
  28708. * Gets or sets whether or not the texture contains RGBD data.
  28709. */
  28710. isRGBD: boolean;
  28711. /**
  28712. * Is Z inverted in the texture (useful in a cube texture).
  28713. */
  28714. invertZ: boolean;
  28715. /**
  28716. * Are mip maps generated for this texture or not.
  28717. */
  28718. readonly noMipmap: boolean;
  28719. /**
  28720. * @hidden
  28721. */
  28722. lodLevelInAlpha: boolean;
  28723. /**
  28724. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28725. */
  28726. lodGenerationOffset: number;
  28727. /**
  28728. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28729. */
  28730. lodGenerationScale: number;
  28731. /**
  28732. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28733. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28734. * average roughness values.
  28735. */
  28736. linearSpecularLOD: boolean;
  28737. /**
  28738. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28739. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28740. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28741. */
  28742. irradianceTexture: Nullable<BaseTexture>;
  28743. /**
  28744. * Define if the texture is a render target.
  28745. */
  28746. isRenderTarget: boolean;
  28747. /**
  28748. * Define the unique id of the texture in the scene.
  28749. */
  28750. readonly uid: string;
  28751. /**
  28752. * Return a string representation of the texture.
  28753. * @returns the texture as a string
  28754. */
  28755. toString(): string;
  28756. /**
  28757. * Get the class name of the texture.
  28758. * @returns "BaseTexture"
  28759. */
  28760. getClassName(): string;
  28761. /**
  28762. * Define the list of animation attached to the texture.
  28763. */
  28764. animations: import("babylonjs/Animations/animation").Animation[];
  28765. /**
  28766. * An event triggered when the texture is disposed.
  28767. */
  28768. onDisposeObservable: Observable<BaseTexture>;
  28769. private _onDisposeObserver;
  28770. /**
  28771. * Callback triggered when the texture has been disposed.
  28772. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28773. */
  28774. onDispose: () => void;
  28775. /**
  28776. * Define the current state of the loading sequence when in delayed load mode.
  28777. */
  28778. delayLoadState: number;
  28779. private _scene;
  28780. /** @hidden */
  28781. _texture: Nullable<InternalTexture>;
  28782. private _uid;
  28783. /**
  28784. * Define if the texture is preventinga material to render or not.
  28785. * If not and the texture is not ready, the engine will use a default black texture instead.
  28786. */
  28787. readonly isBlocking: boolean;
  28788. /**
  28789. * Instantiates a new BaseTexture.
  28790. * Base class of all the textures in babylon.
  28791. * It groups all the common properties the materials, post process, lights... might need
  28792. * in order to make a correct use of the texture.
  28793. * @param scene Define the scene the texture blongs to
  28794. */
  28795. constructor(scene: Nullable<Scene>);
  28796. /**
  28797. * Get the scene the texture belongs to.
  28798. * @returns the scene or null if undefined
  28799. */
  28800. getScene(): Nullable<Scene>;
  28801. /**
  28802. * Get the texture transform matrix used to offset tile the texture for istance.
  28803. * @returns the transformation matrix
  28804. */
  28805. getTextureMatrix(): Matrix;
  28806. /**
  28807. * Get the texture reflection matrix used to rotate/transform the reflection.
  28808. * @returns the reflection matrix
  28809. */
  28810. getReflectionTextureMatrix(): Matrix;
  28811. /**
  28812. * Get the underlying lower level texture from Babylon.
  28813. * @returns the insternal texture
  28814. */
  28815. getInternalTexture(): Nullable<InternalTexture>;
  28816. /**
  28817. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28818. * @returns true if ready or not blocking
  28819. */
  28820. isReadyOrNotBlocking(): boolean;
  28821. /**
  28822. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28823. * @returns true if fully ready
  28824. */
  28825. isReady(): boolean;
  28826. private _cachedSize;
  28827. /**
  28828. * Get the size of the texture.
  28829. * @returns the texture size.
  28830. */
  28831. getSize(): ISize;
  28832. /**
  28833. * Get the base size of the texture.
  28834. * It can be different from the size if the texture has been resized for POT for instance
  28835. * @returns the base size
  28836. */
  28837. getBaseSize(): ISize;
  28838. /**
  28839. * Update the sampling mode of the texture.
  28840. * Default is Trilinear mode.
  28841. *
  28842. * | Value | Type | Description |
  28843. * | ----- | ------------------ | ----------- |
  28844. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28845. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28846. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28847. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28848. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28849. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28850. * | 7 | NEAREST_LINEAR | |
  28851. * | 8 | NEAREST_NEAREST | |
  28852. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28853. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28854. * | 11 | LINEAR_LINEAR | |
  28855. * | 12 | LINEAR_NEAREST | |
  28856. *
  28857. * > _mag_: magnification filter (close to the viewer)
  28858. * > _min_: minification filter (far from the viewer)
  28859. * > _mip_: filter used between mip map levels
  28860. *@param samplingMode Define the new sampling mode of the texture
  28861. */
  28862. updateSamplingMode(samplingMode: number): void;
  28863. /**
  28864. * Scales the texture if is `canRescale()`
  28865. * @param ratio the resize factor we want to use to rescale
  28866. */
  28867. scale(ratio: number): void;
  28868. /**
  28869. * Get if the texture can rescale.
  28870. */
  28871. readonly canRescale: boolean;
  28872. /** @hidden */
  28873. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28874. /** @hidden */
  28875. _rebuild(): void;
  28876. /**
  28877. * Triggers the load sequence in delayed load mode.
  28878. */
  28879. delayLoad(): void;
  28880. /**
  28881. * Clones the texture.
  28882. * @returns the cloned texture
  28883. */
  28884. clone(): Nullable<BaseTexture>;
  28885. /**
  28886. * Get the texture underlying type (INT, FLOAT...)
  28887. */
  28888. readonly textureType: number;
  28889. /**
  28890. * Get the texture underlying format (RGB, RGBA...)
  28891. */
  28892. readonly textureFormat: number;
  28893. /**
  28894. * Indicates that textures need to be re-calculated for all materials
  28895. */
  28896. protected _markAllSubMeshesAsTexturesDirty(): void;
  28897. /**
  28898. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28899. * This will returns an RGBA array buffer containing either in values (0-255) or
  28900. * float values (0-1) depending of the underlying buffer type.
  28901. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28902. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28903. * @param buffer defines a user defined buffer to fill with data (can be null)
  28904. * @returns The Array buffer containing the pixels data.
  28905. */
  28906. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28907. /**
  28908. * Release and destroy the underlying lower level texture aka internalTexture.
  28909. */
  28910. releaseInternalTexture(): void;
  28911. /** @hidden */
  28912. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28913. /** @hidden */
  28914. readonly _lodTextureMid: Nullable<BaseTexture>;
  28915. /** @hidden */
  28916. readonly _lodTextureLow: Nullable<BaseTexture>;
  28917. /**
  28918. * Dispose the texture and release its associated resources.
  28919. */
  28920. dispose(): void;
  28921. /**
  28922. * Serialize the texture into a JSON representation that can be parsed later on.
  28923. * @returns the JSON representation of the texture
  28924. */
  28925. serialize(): any;
  28926. /**
  28927. * Helper function to be called back once a list of texture contains only ready textures.
  28928. * @param textures Define the list of textures to wait for
  28929. * @param callback Define the callback triggered once the entire list will be ready
  28930. */
  28931. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28932. }
  28933. }
  28934. declare module "babylonjs/Materials/effect" {
  28935. import { Observable } from "babylonjs/Misc/observable";
  28936. import { Nullable } from "babylonjs/types";
  28937. import { IDisposable } from "babylonjs/scene";
  28938. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28939. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28940. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28941. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28942. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28943. import { Engine } from "babylonjs/Engines/engine";
  28944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28947. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28948. /**
  28949. * Options to be used when creating an effect.
  28950. */
  28951. export interface IEffectCreationOptions {
  28952. /**
  28953. * Atrributes that will be used in the shader.
  28954. */
  28955. attributes: string[];
  28956. /**
  28957. * Uniform varible names that will be set in the shader.
  28958. */
  28959. uniformsNames: string[];
  28960. /**
  28961. * Uniform buffer varible names that will be set in the shader.
  28962. */
  28963. uniformBuffersNames: string[];
  28964. /**
  28965. * Sampler texture variable names that will be set in the shader.
  28966. */
  28967. samplers: string[];
  28968. /**
  28969. * Define statements that will be set in the shader.
  28970. */
  28971. defines: any;
  28972. /**
  28973. * Possible fallbacks for this effect to improve performance when needed.
  28974. */
  28975. fallbacks: Nullable<IEffectFallbacks>;
  28976. /**
  28977. * Callback that will be called when the shader is compiled.
  28978. */
  28979. onCompiled: Nullable<(effect: Effect) => void>;
  28980. /**
  28981. * Callback that will be called if an error occurs during shader compilation.
  28982. */
  28983. onError: Nullable<(effect: Effect, errors: string) => void>;
  28984. /**
  28985. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28986. */
  28987. indexParameters?: any;
  28988. /**
  28989. * Max number of lights that can be used in the shader.
  28990. */
  28991. maxSimultaneousLights?: number;
  28992. /**
  28993. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28994. */
  28995. transformFeedbackVaryings?: Nullable<string[]>;
  28996. }
  28997. /**
  28998. * Effect containing vertex and fragment shader that can be executed on an object.
  28999. */
  29000. export class Effect implements IDisposable {
  29001. /**
  29002. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29003. */
  29004. static ShadersRepository: string;
  29005. /**
  29006. * Name of the effect.
  29007. */
  29008. name: any;
  29009. /**
  29010. * String container all the define statements that should be set on the shader.
  29011. */
  29012. defines: string;
  29013. /**
  29014. * Callback that will be called when the shader is compiled.
  29015. */
  29016. onCompiled: Nullable<(effect: Effect) => void>;
  29017. /**
  29018. * Callback that will be called if an error occurs during shader compilation.
  29019. */
  29020. onError: Nullable<(effect: Effect, errors: string) => void>;
  29021. /**
  29022. * Callback that will be called when effect is bound.
  29023. */
  29024. onBind: Nullable<(effect: Effect) => void>;
  29025. /**
  29026. * Unique ID of the effect.
  29027. */
  29028. uniqueId: number;
  29029. /**
  29030. * Observable that will be called when the shader is compiled.
  29031. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29032. */
  29033. onCompileObservable: Observable<Effect>;
  29034. /**
  29035. * Observable that will be called if an error occurs during shader compilation.
  29036. */
  29037. onErrorObservable: Observable<Effect>;
  29038. /** @hidden */
  29039. _onBindObservable: Nullable<Observable<Effect>>;
  29040. /**
  29041. * Observable that will be called when effect is bound.
  29042. */
  29043. readonly onBindObservable: Observable<Effect>;
  29044. /** @hidden */
  29045. _bonesComputationForcedToCPU: boolean;
  29046. private static _uniqueIdSeed;
  29047. private _engine;
  29048. private _uniformBuffersNames;
  29049. private _uniformsNames;
  29050. private _samplerList;
  29051. private _samplers;
  29052. private _isReady;
  29053. private _compilationError;
  29054. private _allFallbacksProcessed;
  29055. private _attributesNames;
  29056. private _attributes;
  29057. private _uniforms;
  29058. /**
  29059. * Key for the effect.
  29060. * @hidden
  29061. */
  29062. _key: string;
  29063. private _indexParameters;
  29064. private _fallbacks;
  29065. private _vertexSourceCode;
  29066. private _fragmentSourceCode;
  29067. private _vertexSourceCodeOverride;
  29068. private _fragmentSourceCodeOverride;
  29069. private _transformFeedbackVaryings;
  29070. /**
  29071. * Compiled shader to webGL program.
  29072. * @hidden
  29073. */
  29074. _pipelineContext: Nullable<IPipelineContext>;
  29075. private _valueCache;
  29076. private static _baseCache;
  29077. /**
  29078. * Instantiates an effect.
  29079. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29080. * @param baseName Name of the effect.
  29081. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29082. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29083. * @param samplers List of sampler variables that will be passed to the shader.
  29084. * @param engine Engine to be used to render the effect
  29085. * @param defines Define statements to be added to the shader.
  29086. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29087. * @param onCompiled Callback that will be called when the shader is compiled.
  29088. * @param onError Callback that will be called if an error occurs during shader compilation.
  29089. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29090. */
  29091. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29092. private _useFinalCode;
  29093. /**
  29094. * Unique key for this effect
  29095. */
  29096. readonly key: string;
  29097. /**
  29098. * If the effect has been compiled and prepared.
  29099. * @returns if the effect is compiled and prepared.
  29100. */
  29101. isReady(): boolean;
  29102. private _isReadyInternal;
  29103. /**
  29104. * The engine the effect was initialized with.
  29105. * @returns the engine.
  29106. */
  29107. getEngine(): Engine;
  29108. /**
  29109. * The pipeline context for this effect
  29110. * @returns the associated pipeline context
  29111. */
  29112. getPipelineContext(): Nullable<IPipelineContext>;
  29113. /**
  29114. * The set of names of attribute variables for the shader.
  29115. * @returns An array of attribute names.
  29116. */
  29117. getAttributesNames(): string[];
  29118. /**
  29119. * Returns the attribute at the given index.
  29120. * @param index The index of the attribute.
  29121. * @returns The location of the attribute.
  29122. */
  29123. getAttributeLocation(index: number): number;
  29124. /**
  29125. * Returns the attribute based on the name of the variable.
  29126. * @param name of the attribute to look up.
  29127. * @returns the attribute location.
  29128. */
  29129. getAttributeLocationByName(name: string): number;
  29130. /**
  29131. * The number of attributes.
  29132. * @returns the numnber of attributes.
  29133. */
  29134. getAttributesCount(): number;
  29135. /**
  29136. * Gets the index of a uniform variable.
  29137. * @param uniformName of the uniform to look up.
  29138. * @returns the index.
  29139. */
  29140. getUniformIndex(uniformName: string): number;
  29141. /**
  29142. * Returns the attribute based on the name of the variable.
  29143. * @param uniformName of the uniform to look up.
  29144. * @returns the location of the uniform.
  29145. */
  29146. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29147. /**
  29148. * Returns an array of sampler variable names
  29149. * @returns The array of sampler variable neames.
  29150. */
  29151. getSamplers(): string[];
  29152. /**
  29153. * The error from the last compilation.
  29154. * @returns the error string.
  29155. */
  29156. getCompilationError(): string;
  29157. /**
  29158. * Gets a boolean indicating that all fallbacks were used during compilation
  29159. * @returns true if all fallbacks were used
  29160. */
  29161. allFallbacksProcessed(): boolean;
  29162. /**
  29163. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29164. * @param func The callback to be used.
  29165. */
  29166. executeWhenCompiled(func: (effect: Effect) => void): void;
  29167. private _checkIsReady;
  29168. private _loadShader;
  29169. /**
  29170. * Recompiles the webGL program
  29171. * @param vertexSourceCode The source code for the vertex shader.
  29172. * @param fragmentSourceCode The source code for the fragment shader.
  29173. * @param onCompiled Callback called when completed.
  29174. * @param onError Callback called on error.
  29175. * @hidden
  29176. */
  29177. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29178. /**
  29179. * Prepares the effect
  29180. * @hidden
  29181. */
  29182. _prepareEffect(): void;
  29183. private _processCompilationErrors;
  29184. /**
  29185. * Checks if the effect is supported. (Must be called after compilation)
  29186. */
  29187. readonly isSupported: boolean;
  29188. /**
  29189. * Binds a texture to the engine to be used as output of the shader.
  29190. * @param channel Name of the output variable.
  29191. * @param texture Texture to bind.
  29192. * @hidden
  29193. */
  29194. _bindTexture(channel: string, texture: InternalTexture): void;
  29195. /**
  29196. * Sets a texture on the engine to be used in the shader.
  29197. * @param channel Name of the sampler variable.
  29198. * @param texture Texture to set.
  29199. */
  29200. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29201. /**
  29202. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29203. * @param channel Name of the sampler variable.
  29204. * @param texture Texture to set.
  29205. */
  29206. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29207. /**
  29208. * Sets an array of textures on the engine to be used in the shader.
  29209. * @param channel Name of the variable.
  29210. * @param textures Textures to set.
  29211. */
  29212. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29213. /**
  29214. * 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)
  29215. * @param channel Name of the sampler variable.
  29216. * @param postProcess Post process to get the input texture from.
  29217. */
  29218. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29219. /**
  29220. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29221. * 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)
  29222. * @param channel Name of the sampler variable.
  29223. * @param postProcess Post process to get the output texture from.
  29224. */
  29225. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29226. /** @hidden */
  29227. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29228. /** @hidden */
  29229. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29230. /** @hidden */
  29231. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29232. /** @hidden */
  29233. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29234. /**
  29235. * Binds a buffer to a uniform.
  29236. * @param buffer Buffer to bind.
  29237. * @param name Name of the uniform variable to bind to.
  29238. */
  29239. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29240. /**
  29241. * Binds block to a uniform.
  29242. * @param blockName Name of the block to bind.
  29243. * @param index Index to bind.
  29244. */
  29245. bindUniformBlock(blockName: string, index: number): void;
  29246. /**
  29247. * Sets an interger value on a uniform variable.
  29248. * @param uniformName Name of the variable.
  29249. * @param value Value to be set.
  29250. * @returns this effect.
  29251. */
  29252. setInt(uniformName: string, value: number): Effect;
  29253. /**
  29254. * Sets an int array on a uniform variable.
  29255. * @param uniformName Name of the variable.
  29256. * @param array array to be set.
  29257. * @returns this effect.
  29258. */
  29259. setIntArray(uniformName: string, array: Int32Array): Effect;
  29260. /**
  29261. * 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)
  29262. * @param uniformName Name of the variable.
  29263. * @param array array to be set.
  29264. * @returns this effect.
  29265. */
  29266. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29267. /**
  29268. * 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)
  29269. * @param uniformName Name of the variable.
  29270. * @param array array to be set.
  29271. * @returns this effect.
  29272. */
  29273. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29274. /**
  29275. * 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)
  29276. * @param uniformName Name of the variable.
  29277. * @param array array to be set.
  29278. * @returns this effect.
  29279. */
  29280. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29281. /**
  29282. * Sets an float array on a uniform variable.
  29283. * @param uniformName Name of the variable.
  29284. * @param array array to be set.
  29285. * @returns this effect.
  29286. */
  29287. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29288. /**
  29289. * 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)
  29290. * @param uniformName Name of the variable.
  29291. * @param array array to be set.
  29292. * @returns this effect.
  29293. */
  29294. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29295. /**
  29296. * 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)
  29297. * @param uniformName Name of the variable.
  29298. * @param array array to be set.
  29299. * @returns this effect.
  29300. */
  29301. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29302. /**
  29303. * 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)
  29304. * @param uniformName Name of the variable.
  29305. * @param array array to be set.
  29306. * @returns this effect.
  29307. */
  29308. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29309. /**
  29310. * Sets an array on a uniform variable.
  29311. * @param uniformName Name of the variable.
  29312. * @param array array to be set.
  29313. * @returns this effect.
  29314. */
  29315. setArray(uniformName: string, array: number[]): Effect;
  29316. /**
  29317. * 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)
  29318. * @param uniformName Name of the variable.
  29319. * @param array array to be set.
  29320. * @returns this effect.
  29321. */
  29322. setArray2(uniformName: string, array: number[]): Effect;
  29323. /**
  29324. * 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)
  29325. * @param uniformName Name of the variable.
  29326. * @param array array to be set.
  29327. * @returns this effect.
  29328. */
  29329. setArray3(uniformName: string, array: number[]): Effect;
  29330. /**
  29331. * 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)
  29332. * @param uniformName Name of the variable.
  29333. * @param array array to be set.
  29334. * @returns this effect.
  29335. */
  29336. setArray4(uniformName: string, array: number[]): Effect;
  29337. /**
  29338. * Sets matrices on a uniform variable.
  29339. * @param uniformName Name of the variable.
  29340. * @param matrices matrices to be set.
  29341. * @returns this effect.
  29342. */
  29343. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29344. /**
  29345. * Sets matrix on a uniform variable.
  29346. * @param uniformName Name of the variable.
  29347. * @param matrix matrix to be set.
  29348. * @returns this effect.
  29349. */
  29350. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29351. /**
  29352. * 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)
  29353. * @param uniformName Name of the variable.
  29354. * @param matrix matrix to be set.
  29355. * @returns this effect.
  29356. */
  29357. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29358. /**
  29359. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29360. * @param uniformName Name of the variable.
  29361. * @param matrix matrix to be set.
  29362. * @returns this effect.
  29363. */
  29364. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29365. /**
  29366. * Sets a float on a uniform variable.
  29367. * @param uniformName Name of the variable.
  29368. * @param value value to be set.
  29369. * @returns this effect.
  29370. */
  29371. setFloat(uniformName: string, value: number): Effect;
  29372. /**
  29373. * Sets a boolean on a uniform variable.
  29374. * @param uniformName Name of the variable.
  29375. * @param bool value to be set.
  29376. * @returns this effect.
  29377. */
  29378. setBool(uniformName: string, bool: boolean): Effect;
  29379. /**
  29380. * Sets a Vector2 on a uniform variable.
  29381. * @param uniformName Name of the variable.
  29382. * @param vector2 vector2 to be set.
  29383. * @returns this effect.
  29384. */
  29385. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29386. /**
  29387. * Sets a float2 on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param x First float in float2.
  29390. * @param y Second float in float2.
  29391. * @returns this effect.
  29392. */
  29393. setFloat2(uniformName: string, x: number, y: number): Effect;
  29394. /**
  29395. * Sets a Vector3 on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param vector3 Value to be set.
  29398. * @returns this effect.
  29399. */
  29400. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29401. /**
  29402. * Sets a float3 on a uniform variable.
  29403. * @param uniformName Name of the variable.
  29404. * @param x First float in float3.
  29405. * @param y Second float in float3.
  29406. * @param z Third float in float3.
  29407. * @returns this effect.
  29408. */
  29409. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29410. /**
  29411. * Sets a Vector4 on a uniform variable.
  29412. * @param uniformName Name of the variable.
  29413. * @param vector4 Value to be set.
  29414. * @returns this effect.
  29415. */
  29416. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29417. /**
  29418. * Sets a float4 on a uniform variable.
  29419. * @param uniformName Name of the variable.
  29420. * @param x First float in float4.
  29421. * @param y Second float in float4.
  29422. * @param z Third float in float4.
  29423. * @param w Fourth float in float4.
  29424. * @returns this effect.
  29425. */
  29426. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29427. /**
  29428. * Sets a Color3 on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param color3 Value to be set.
  29431. * @returns this effect.
  29432. */
  29433. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29434. /**
  29435. * Sets a Color4 on a uniform variable.
  29436. * @param uniformName Name of the variable.
  29437. * @param color3 Value to be set.
  29438. * @param alpha Alpha value to be set.
  29439. * @returns this effect.
  29440. */
  29441. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29442. /**
  29443. * Sets a Color4 on a uniform variable
  29444. * @param uniformName defines the name of the variable
  29445. * @param color4 defines the value to be set
  29446. * @returns this effect.
  29447. */
  29448. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29449. /** Release all associated resources */
  29450. dispose(): void;
  29451. /**
  29452. * This function will add a new shader to the shader store
  29453. * @param name the name of the shader
  29454. * @param pixelShader optional pixel shader content
  29455. * @param vertexShader optional vertex shader content
  29456. */
  29457. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29458. /**
  29459. * Store of each shader (The can be looked up using effect.key)
  29460. */
  29461. static ShadersStore: {
  29462. [key: string]: string;
  29463. };
  29464. /**
  29465. * Store of each included file for a shader (The can be looked up using effect.key)
  29466. */
  29467. static IncludesShadersStore: {
  29468. [key: string]: string;
  29469. };
  29470. /**
  29471. * Resets the cache of effects.
  29472. */
  29473. static ResetCache(): void;
  29474. }
  29475. }
  29476. declare module "babylonjs/Engines/engineCapabilities" {
  29477. import { Nullable } from "babylonjs/types";
  29478. /**
  29479. * Class used to describe the capabilities of the engine relatively to the current browser
  29480. */
  29481. export class EngineCapabilities {
  29482. /** Maximum textures units per fragment shader */
  29483. maxTexturesImageUnits: number;
  29484. /** Maximum texture units per vertex shader */
  29485. maxVertexTextureImageUnits: number;
  29486. /** Maximum textures units in the entire pipeline */
  29487. maxCombinedTexturesImageUnits: number;
  29488. /** Maximum texture size */
  29489. maxTextureSize: number;
  29490. /** Maximum cube texture size */
  29491. maxCubemapTextureSize: number;
  29492. /** Maximum render texture size */
  29493. maxRenderTextureSize: number;
  29494. /** Maximum number of vertex attributes */
  29495. maxVertexAttribs: number;
  29496. /** Maximum number of varyings */
  29497. maxVaryingVectors: number;
  29498. /** Maximum number of uniforms per vertex shader */
  29499. maxVertexUniformVectors: number;
  29500. /** Maximum number of uniforms per fragment shader */
  29501. maxFragmentUniformVectors: number;
  29502. /** Defines if standard derivates (dx/dy) are supported */
  29503. standardDerivatives: boolean;
  29504. /** Defines if s3tc texture compression is supported */
  29505. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29506. /** Defines if pvrtc texture compression is supported */
  29507. pvrtc: any;
  29508. /** Defines if etc1 texture compression is supported */
  29509. etc1: any;
  29510. /** Defines if etc2 texture compression is supported */
  29511. etc2: any;
  29512. /** Defines if astc texture compression is supported */
  29513. astc: any;
  29514. /** Defines if float textures are supported */
  29515. textureFloat: boolean;
  29516. /** Defines if vertex array objects are supported */
  29517. vertexArrayObject: boolean;
  29518. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29519. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29520. /** Gets the maximum level of anisotropy supported */
  29521. maxAnisotropy: number;
  29522. /** Defines if instancing is supported */
  29523. instancedArrays: boolean;
  29524. /** Defines if 32 bits indices are supported */
  29525. uintIndices: boolean;
  29526. /** Defines if high precision shaders are supported */
  29527. highPrecisionShaderSupported: boolean;
  29528. /** Defines if depth reading in the fragment shader is supported */
  29529. fragmentDepthSupported: boolean;
  29530. /** Defines if float texture linear filtering is supported*/
  29531. textureFloatLinearFiltering: boolean;
  29532. /** Defines if rendering to float textures is supported */
  29533. textureFloatRender: boolean;
  29534. /** Defines if half float textures are supported*/
  29535. textureHalfFloat: boolean;
  29536. /** Defines if half float texture linear filtering is supported*/
  29537. textureHalfFloatLinearFiltering: boolean;
  29538. /** Defines if rendering to half float textures is supported */
  29539. textureHalfFloatRender: boolean;
  29540. /** Defines if textureLOD shader command is supported */
  29541. textureLOD: boolean;
  29542. /** Defines if draw buffers extension is supported */
  29543. drawBuffersExtension: boolean;
  29544. /** Defines if depth textures are supported */
  29545. depthTextureExtension: boolean;
  29546. /** Defines if float color buffer are supported */
  29547. colorBufferFloat: boolean;
  29548. /** Gets disjoint timer query extension (null if not supported) */
  29549. timerQuery: EXT_disjoint_timer_query;
  29550. /** Defines if timestamp can be used with timer query */
  29551. canUseTimestampForTimerQuery: boolean;
  29552. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29553. multiview: any;
  29554. /** Function used to let the system compiles shaders in background */
  29555. parallelShaderCompile: {
  29556. COMPLETION_STATUS_KHR: number;
  29557. };
  29558. /** Max number of texture samples for MSAA */
  29559. maxMSAASamples: number;
  29560. /** Defines if the blend min max extension is supported */
  29561. blendMinMax: boolean;
  29562. }
  29563. }
  29564. declare module "babylonjs/States/depthCullingState" {
  29565. import { Nullable } from "babylonjs/types";
  29566. /**
  29567. * @hidden
  29568. **/
  29569. export class DepthCullingState {
  29570. private _isDepthTestDirty;
  29571. private _isDepthMaskDirty;
  29572. private _isDepthFuncDirty;
  29573. private _isCullFaceDirty;
  29574. private _isCullDirty;
  29575. private _isZOffsetDirty;
  29576. private _isFrontFaceDirty;
  29577. private _depthTest;
  29578. private _depthMask;
  29579. private _depthFunc;
  29580. private _cull;
  29581. private _cullFace;
  29582. private _zOffset;
  29583. private _frontFace;
  29584. /**
  29585. * Initializes the state.
  29586. */
  29587. constructor();
  29588. readonly isDirty: boolean;
  29589. zOffset: number;
  29590. cullFace: Nullable<number>;
  29591. cull: Nullable<boolean>;
  29592. depthFunc: Nullable<number>;
  29593. depthMask: boolean;
  29594. depthTest: boolean;
  29595. frontFace: Nullable<number>;
  29596. reset(): void;
  29597. apply(gl: WebGLRenderingContext): void;
  29598. }
  29599. }
  29600. declare module "babylonjs/States/stencilState" {
  29601. /**
  29602. * @hidden
  29603. **/
  29604. export class StencilState {
  29605. /** 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 */
  29606. static readonly ALWAYS: number;
  29607. /** Passed to stencilOperation to specify that stencil value must be kept */
  29608. static readonly KEEP: number;
  29609. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29610. static readonly REPLACE: number;
  29611. private _isStencilTestDirty;
  29612. private _isStencilMaskDirty;
  29613. private _isStencilFuncDirty;
  29614. private _isStencilOpDirty;
  29615. private _stencilTest;
  29616. private _stencilMask;
  29617. private _stencilFunc;
  29618. private _stencilFuncRef;
  29619. private _stencilFuncMask;
  29620. private _stencilOpStencilFail;
  29621. private _stencilOpDepthFail;
  29622. private _stencilOpStencilDepthPass;
  29623. readonly isDirty: boolean;
  29624. stencilFunc: number;
  29625. stencilFuncRef: number;
  29626. stencilFuncMask: number;
  29627. stencilOpStencilFail: number;
  29628. stencilOpDepthFail: number;
  29629. stencilOpStencilDepthPass: number;
  29630. stencilMask: number;
  29631. stencilTest: boolean;
  29632. constructor();
  29633. reset(): void;
  29634. apply(gl: WebGLRenderingContext): void;
  29635. }
  29636. }
  29637. declare module "babylonjs/States/alphaCullingState" {
  29638. /**
  29639. * @hidden
  29640. **/
  29641. export class AlphaState {
  29642. private _isAlphaBlendDirty;
  29643. private _isBlendFunctionParametersDirty;
  29644. private _isBlendEquationParametersDirty;
  29645. private _isBlendConstantsDirty;
  29646. private _alphaBlend;
  29647. private _blendFunctionParameters;
  29648. private _blendEquationParameters;
  29649. private _blendConstants;
  29650. /**
  29651. * Initializes the state.
  29652. */
  29653. constructor();
  29654. readonly isDirty: boolean;
  29655. alphaBlend: boolean;
  29656. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29657. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29658. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29659. reset(): void;
  29660. apply(gl: WebGLRenderingContext): void;
  29661. }
  29662. }
  29663. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29664. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29665. /** @hidden */
  29666. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29667. attributeProcessor(attribute: string): string;
  29668. varyingProcessor(varying: string, isFragment: boolean): string;
  29669. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29670. }
  29671. }
  29672. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29673. /**
  29674. * Interface for attribute information associated with buffer instanciation
  29675. */
  29676. export class InstancingAttributeInfo {
  29677. /**
  29678. * Index/offset of the attribute in the vertex shader
  29679. */
  29680. index: number;
  29681. /**
  29682. * size of the attribute, 1, 2, 3 or 4
  29683. */
  29684. attributeSize: number;
  29685. /**
  29686. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29687. * default is FLOAT
  29688. */
  29689. attribyteType: number;
  29690. /**
  29691. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29692. */
  29693. normalized: boolean;
  29694. /**
  29695. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29696. */
  29697. offset: number;
  29698. /**
  29699. * Name of the GLSL attribute, for debugging purpose only
  29700. */
  29701. attributeName: string;
  29702. }
  29703. }
  29704. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29706. import { Nullable } from "babylonjs/types";
  29707. module "babylonjs/Engines/thinEngine" {
  29708. interface ThinEngine {
  29709. /**
  29710. * Update a video texture
  29711. * @param texture defines the texture to update
  29712. * @param video defines the video element to use
  29713. * @param invertY defines if data must be stored with Y axis inverted
  29714. */
  29715. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29716. }
  29717. }
  29718. }
  29719. declare module "babylonjs/Materials/Textures/videoTexture" {
  29720. import { Observable } from "babylonjs/Misc/observable";
  29721. import { Nullable } from "babylonjs/types";
  29722. import { Scene } from "babylonjs/scene";
  29723. import { Texture } from "babylonjs/Materials/Textures/texture";
  29724. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29725. /**
  29726. * Settings for finer control over video usage
  29727. */
  29728. export interface VideoTextureSettings {
  29729. /**
  29730. * Applies `autoplay` to video, if specified
  29731. */
  29732. autoPlay?: boolean;
  29733. /**
  29734. * Applies `loop` to video, if specified
  29735. */
  29736. loop?: boolean;
  29737. /**
  29738. * Automatically updates internal texture from video at every frame in the render loop
  29739. */
  29740. autoUpdateTexture: boolean;
  29741. /**
  29742. * Image src displayed during the video loading or until the user interacts with the video.
  29743. */
  29744. poster?: string;
  29745. }
  29746. /**
  29747. * If you want to display a video in your scene, this is the special texture for that.
  29748. * This special texture works similar to other textures, with the exception of a few parameters.
  29749. * @see https://doc.babylonjs.com/how_to/video_texture
  29750. */
  29751. export class VideoTexture extends Texture {
  29752. /**
  29753. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29754. */
  29755. readonly autoUpdateTexture: boolean;
  29756. /**
  29757. * The video instance used by the texture internally
  29758. */
  29759. readonly video: HTMLVideoElement;
  29760. private _onUserActionRequestedObservable;
  29761. /**
  29762. * Event triggerd when a dom action is required by the user to play the video.
  29763. * This happens due to recent changes in browser policies preventing video to auto start.
  29764. */
  29765. readonly onUserActionRequestedObservable: Observable<Texture>;
  29766. private _generateMipMaps;
  29767. private _engine;
  29768. private _stillImageCaptured;
  29769. private _displayingPosterTexture;
  29770. private _settings;
  29771. private _createInternalTextureOnEvent;
  29772. private _frameId;
  29773. /**
  29774. * Creates a video texture.
  29775. * If you want to display a video in your scene, this is the special texture for that.
  29776. * This special texture works similar to other textures, with the exception of a few parameters.
  29777. * @see https://doc.babylonjs.com/how_to/video_texture
  29778. * @param name optional name, will detect from video source, if not defined
  29779. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29780. * @param scene is obviously the current scene.
  29781. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29782. * @param invertY is false by default but can be used to invert video on Y axis
  29783. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29784. * @param settings allows finer control over video usage
  29785. */
  29786. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29787. private _getName;
  29788. private _getVideo;
  29789. private _createInternalTexture;
  29790. private reset;
  29791. /**
  29792. * @hidden Internal method to initiate `update`.
  29793. */
  29794. _rebuild(): void;
  29795. /**
  29796. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29797. */
  29798. update(): void;
  29799. /**
  29800. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29801. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29802. */
  29803. updateTexture(isVisible: boolean): void;
  29804. protected _updateInternalTexture: () => void;
  29805. /**
  29806. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29807. * @param url New url.
  29808. */
  29809. updateURL(url: string): void;
  29810. /**
  29811. * Dispose the texture and release its associated resources.
  29812. */
  29813. dispose(): void;
  29814. /**
  29815. * Creates a video texture straight from a stream.
  29816. * @param scene Define the scene the texture should be created in
  29817. * @param stream Define the stream the texture should be created from
  29818. * @returns The created video texture as a promise
  29819. */
  29820. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29821. /**
  29822. * Creates a video texture straight from your WebCam video feed.
  29823. * @param scene Define the scene the texture should be created in
  29824. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29825. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29826. * @returns The created video texture as a promise
  29827. */
  29828. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29829. minWidth: number;
  29830. maxWidth: number;
  29831. minHeight: number;
  29832. maxHeight: number;
  29833. deviceId: string;
  29834. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29835. /**
  29836. * Creates a video texture straight from your WebCam video feed.
  29837. * @param scene Define the scene the texture should be created in
  29838. * @param onReady Define a callback to triggered once the texture will be ready
  29839. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29840. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29841. */
  29842. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29843. minWidth: number;
  29844. maxWidth: number;
  29845. minHeight: number;
  29846. maxHeight: number;
  29847. deviceId: string;
  29848. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29849. }
  29850. }
  29851. declare module "babylonjs/Engines/thinEngine" {
  29852. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29853. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29854. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29855. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29856. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29857. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29858. import { Observable } from "babylonjs/Misc/observable";
  29859. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29860. import { StencilState } from "babylonjs/States/stencilState";
  29861. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29862. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29863. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29864. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29865. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29866. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29867. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29868. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29869. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29870. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29872. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29873. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29874. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29875. /**
  29876. * Defines the interface used by objects working like Scene
  29877. * @hidden
  29878. */
  29879. interface ISceneLike {
  29880. _addPendingData(data: any): void;
  29881. _removePendingData(data: any): void;
  29882. offlineProvider: IOfflineProvider;
  29883. }
  29884. /** Interface defining initialization parameters for Engine class */
  29885. export interface EngineOptions extends WebGLContextAttributes {
  29886. /**
  29887. * Defines if the engine should no exceed a specified device ratio
  29888. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29889. */
  29890. limitDeviceRatio?: number;
  29891. /**
  29892. * Defines if webvr should be enabled automatically
  29893. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29894. */
  29895. autoEnableWebVR?: boolean;
  29896. /**
  29897. * Defines if webgl2 should be turned off even if supported
  29898. * @see http://doc.babylonjs.com/features/webgl2
  29899. */
  29900. disableWebGL2Support?: boolean;
  29901. /**
  29902. * Defines if webaudio should be initialized as well
  29903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29904. */
  29905. audioEngine?: boolean;
  29906. /**
  29907. * Defines if animations should run using a deterministic lock step
  29908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29909. */
  29910. deterministicLockstep?: boolean;
  29911. /** Defines the maximum steps to use with deterministic lock step mode */
  29912. lockstepMaxSteps?: number;
  29913. /**
  29914. * Defines that engine should ignore context lost events
  29915. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29916. */
  29917. doNotHandleContextLost?: boolean;
  29918. /**
  29919. * Defines that engine should ignore modifying touch action attribute and style
  29920. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29921. */
  29922. doNotHandleTouchAction?: boolean;
  29923. /**
  29924. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29925. */
  29926. useHighPrecisionFloats?: boolean;
  29927. }
  29928. /**
  29929. * The base engine class (root of all engines)
  29930. */
  29931. export class ThinEngine {
  29932. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29933. static ExceptionList: ({
  29934. key: string;
  29935. capture: string;
  29936. captureConstraint: number;
  29937. targets: string[];
  29938. } | {
  29939. key: string;
  29940. capture: null;
  29941. captureConstraint: null;
  29942. targets: string[];
  29943. })[];
  29944. /** @hidden */
  29945. static _TextureLoaders: IInternalTextureLoader[];
  29946. /**
  29947. * Returns the current npm package of the sdk
  29948. */
  29949. static readonly NpmPackage: string;
  29950. /**
  29951. * Returns the current version of the framework
  29952. */
  29953. static readonly Version: string;
  29954. /**
  29955. * Returns a string describing the current engine
  29956. */
  29957. readonly description: string;
  29958. /**
  29959. * Gets or sets the epsilon value used by collision engine
  29960. */
  29961. static CollisionsEpsilon: number;
  29962. /**
  29963. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29964. */
  29965. static ShadersRepository: string;
  29966. /** @hidden */
  29967. _shaderProcessor: IShaderProcessor;
  29968. /**
  29969. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29970. */
  29971. forcePOTTextures: boolean;
  29972. /**
  29973. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29974. */
  29975. isFullscreen: boolean;
  29976. /**
  29977. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29978. */
  29979. cullBackFaces: boolean;
  29980. /**
  29981. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29982. */
  29983. renderEvenInBackground: boolean;
  29984. /**
  29985. * Gets or sets a boolean indicating that cache can be kept between frames
  29986. */
  29987. preventCacheWipeBetweenFrames: boolean;
  29988. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29989. validateShaderPrograms: boolean;
  29990. /**
  29991. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29992. */
  29993. disableUniformBuffers: boolean;
  29994. /** @hidden */
  29995. _uniformBuffers: UniformBuffer[];
  29996. /**
  29997. * Gets a boolean indicating that the engine supports uniform buffers
  29998. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29999. */
  30000. readonly supportsUniformBuffers: boolean;
  30001. /** @hidden */
  30002. _gl: WebGLRenderingContext;
  30003. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30004. protected _windowIsBackground: boolean;
  30005. protected _webGLVersion: number;
  30006. protected _highPrecisionShadersAllowed: boolean;
  30007. /** @hidden */
  30008. readonly _shouldUseHighPrecisionShader: boolean;
  30009. /**
  30010. * Gets a boolean indicating that only power of 2 textures are supported
  30011. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30012. */
  30013. readonly needPOTTextures: boolean;
  30014. /** @hidden */
  30015. _badOS: boolean;
  30016. /** @hidden */
  30017. _badDesktopOS: boolean;
  30018. private _hardwareScalingLevel;
  30019. /** @hidden */
  30020. _caps: EngineCapabilities;
  30021. private _isStencilEnable;
  30022. protected _colorWrite: boolean;
  30023. private _glVersion;
  30024. private _glRenderer;
  30025. private _glVendor;
  30026. /** @hidden */
  30027. _videoTextureSupported: boolean;
  30028. protected _renderingQueueLaunched: boolean;
  30029. protected _activeRenderLoops: (() => void)[];
  30030. /**
  30031. * Observable signaled when a context lost event is raised
  30032. */
  30033. onContextLostObservable: Observable<ThinEngine>;
  30034. /**
  30035. * Observable signaled when a context restored event is raised
  30036. */
  30037. onContextRestoredObservable: Observable<ThinEngine>;
  30038. private _onContextLost;
  30039. private _onContextRestored;
  30040. protected _contextWasLost: boolean;
  30041. /** @hidden */
  30042. _doNotHandleContextLost: boolean;
  30043. /**
  30044. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30046. */
  30047. doNotHandleContextLost: boolean;
  30048. /**
  30049. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30050. */
  30051. disableVertexArrayObjects: boolean;
  30052. /** @hidden */
  30053. protected _depthCullingState: DepthCullingState;
  30054. /** @hidden */
  30055. protected _stencilState: StencilState;
  30056. /** @hidden */
  30057. protected _alphaState: AlphaState;
  30058. /** @hidden */
  30059. _internalTexturesCache: InternalTexture[];
  30060. /** @hidden */
  30061. protected _activeChannel: number;
  30062. private _currentTextureChannel;
  30063. /** @hidden */
  30064. protected _boundTexturesCache: {
  30065. [key: string]: Nullable<InternalTexture>;
  30066. };
  30067. /** @hidden */
  30068. protected _currentEffect: Nullable<Effect>;
  30069. /** @hidden */
  30070. protected _currentProgram: Nullable<WebGLProgram>;
  30071. private _compiledEffects;
  30072. private _vertexAttribArraysEnabled;
  30073. /** @hidden */
  30074. protected _cachedViewport: Nullable<IViewportLike>;
  30075. private _cachedVertexArrayObject;
  30076. /** @hidden */
  30077. protected _cachedVertexBuffers: any;
  30078. /** @hidden */
  30079. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30080. /** @hidden */
  30081. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30082. /** @hidden */
  30083. _currentRenderTarget: Nullable<InternalTexture>;
  30084. private _uintIndicesCurrentlySet;
  30085. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30086. /** @hidden */
  30087. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30088. private _currentBufferPointers;
  30089. private _currentInstanceLocations;
  30090. private _currentInstanceBuffers;
  30091. private _textureUnits;
  30092. /** @hidden */
  30093. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30094. /** @hidden */
  30095. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30096. /** @hidden */
  30097. _bindedRenderFunction: any;
  30098. private _vaoRecordInProgress;
  30099. private _mustWipeVertexAttributes;
  30100. private _emptyTexture;
  30101. private _emptyCubeTexture;
  30102. private _emptyTexture3D;
  30103. /** @hidden */
  30104. _frameHandler: number;
  30105. private _nextFreeTextureSlots;
  30106. private _maxSimultaneousTextures;
  30107. private _activeRequests;
  30108. protected _texturesSupported: string[];
  30109. /** @hidden */
  30110. _textureFormatInUse: Nullable<string>;
  30111. protected readonly _supportsHardwareTextureRescaling: boolean;
  30112. /**
  30113. * Gets the list of texture formats supported
  30114. */
  30115. readonly texturesSupported: Array<string>;
  30116. /**
  30117. * Gets the list of texture formats in use
  30118. */
  30119. readonly textureFormatInUse: Nullable<string>;
  30120. /**
  30121. * Gets the current viewport
  30122. */
  30123. readonly currentViewport: Nullable<IViewportLike>;
  30124. /**
  30125. * Gets the default empty texture
  30126. */
  30127. readonly emptyTexture: InternalTexture;
  30128. /**
  30129. * Gets the default empty 3D texture
  30130. */
  30131. readonly emptyTexture3D: InternalTexture;
  30132. /**
  30133. * Gets the default empty cube texture
  30134. */
  30135. readonly emptyCubeTexture: InternalTexture;
  30136. /**
  30137. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30138. */
  30139. readonly premultipliedAlpha: boolean;
  30140. /**
  30141. * Observable event triggered before each texture is initialized
  30142. */
  30143. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30144. /**
  30145. * Creates a new engine
  30146. * @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
  30147. * @param antialias defines enable antialiasing (default: false)
  30148. * @param options defines further options to be sent to the getContext() function
  30149. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30150. */
  30151. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30152. private _rebuildInternalTextures;
  30153. private _rebuildEffects;
  30154. /**
  30155. * Gets a boolean indicating if all created effects are ready
  30156. * @returns true if all effects are ready
  30157. */
  30158. areAllEffectsReady(): boolean;
  30159. protected _rebuildBuffers(): void;
  30160. private _initGLContext;
  30161. /**
  30162. * Gets version of the current webGL context
  30163. */
  30164. readonly webGLVersion: number;
  30165. /**
  30166. * Gets a string idenfifying the name of the class
  30167. * @returns "Engine" string
  30168. */
  30169. getClassName(): string;
  30170. /**
  30171. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30172. */
  30173. readonly isStencilEnable: boolean;
  30174. /** @hidden */
  30175. _prepareWorkingCanvas(): void;
  30176. /**
  30177. * Reset the texture cache to empty state
  30178. */
  30179. resetTextureCache(): void;
  30180. /**
  30181. * Gets an object containing information about the current webGL context
  30182. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30183. */
  30184. getGlInfo(): {
  30185. vendor: string;
  30186. renderer: string;
  30187. version: string;
  30188. };
  30189. /**
  30190. * Defines the hardware scaling level.
  30191. * By default the hardware scaling level is computed from the window device ratio.
  30192. * 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.
  30193. * @param level defines the level to use
  30194. */
  30195. setHardwareScalingLevel(level: number): void;
  30196. /**
  30197. * Gets the current hardware scaling level.
  30198. * By default the hardware scaling level is computed from the window device ratio.
  30199. * 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.
  30200. * @returns a number indicating the current hardware scaling level
  30201. */
  30202. getHardwareScalingLevel(): number;
  30203. /**
  30204. * Gets the list of loaded textures
  30205. * @returns an array containing all loaded textures
  30206. */
  30207. getLoadedTexturesCache(): InternalTexture[];
  30208. /**
  30209. * Gets the object containing all engine capabilities
  30210. * @returns the EngineCapabilities object
  30211. */
  30212. getCaps(): EngineCapabilities;
  30213. /**
  30214. * stop executing a render loop function and remove it from the execution array
  30215. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30216. */
  30217. stopRenderLoop(renderFunction?: () => void): void;
  30218. /** @hidden */
  30219. _renderLoop(): void;
  30220. /**
  30221. * Gets the HTML canvas attached with the current webGL context
  30222. * @returns a HTML canvas
  30223. */
  30224. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30225. /**
  30226. * Gets host window
  30227. * @returns the host window object
  30228. */
  30229. getHostWindow(): Nullable<Window>;
  30230. /**
  30231. * Gets the current render width
  30232. * @param useScreen defines if screen size must be used (or the current render target if any)
  30233. * @returns a number defining the current render width
  30234. */
  30235. getRenderWidth(useScreen?: boolean): number;
  30236. /**
  30237. * Gets the current render height
  30238. * @param useScreen defines if screen size must be used (or the current render target if any)
  30239. * @returns a number defining the current render height
  30240. */
  30241. getRenderHeight(useScreen?: boolean): number;
  30242. /**
  30243. * Can be used to override the current requestAnimationFrame requester.
  30244. * @hidden
  30245. */
  30246. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30247. /**
  30248. * Register and execute a render loop. The engine can have more than one render function
  30249. * @param renderFunction defines the function to continuously execute
  30250. */
  30251. runRenderLoop(renderFunction: () => void): void;
  30252. /**
  30253. * Clear the current render buffer or the current render target (if any is set up)
  30254. * @param color defines the color to use
  30255. * @param backBuffer defines if the back buffer must be cleared
  30256. * @param depth defines if the depth buffer must be cleared
  30257. * @param stencil defines if the stencil buffer must be cleared
  30258. */
  30259. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30260. private _viewportCached;
  30261. /** @hidden */
  30262. _viewport(x: number, y: number, width: number, height: number): void;
  30263. /**
  30264. * Set the WebGL's viewport
  30265. * @param viewport defines the viewport element to be used
  30266. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30267. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30268. */
  30269. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30270. /**
  30271. * Begin a new frame
  30272. */
  30273. beginFrame(): void;
  30274. /**
  30275. * Enf the current frame
  30276. */
  30277. endFrame(): void;
  30278. /**
  30279. * Resize the view according to the canvas' size
  30280. */
  30281. resize(): void;
  30282. /**
  30283. * Force a specific size of the canvas
  30284. * @param width defines the new canvas' width
  30285. * @param height defines the new canvas' height
  30286. */
  30287. setSize(width: number, height: number): void;
  30288. /**
  30289. * Binds the frame buffer to the specified texture.
  30290. * @param texture The texture to render to or null for the default canvas
  30291. * @param faceIndex The face of the texture to render to in case of cube texture
  30292. * @param requiredWidth The width of the target to render to
  30293. * @param requiredHeight The height of the target to render to
  30294. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30295. * @param depthStencilTexture The depth stencil texture to use to render
  30296. * @param lodLevel defines le lod level to bind to the frame buffer
  30297. */
  30298. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30299. /** @hidden */
  30300. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30301. /**
  30302. * Unbind the current render target texture from the webGL context
  30303. * @param texture defines the render target texture to unbind
  30304. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30305. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30306. */
  30307. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30308. /**
  30309. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30310. */
  30311. flushFramebuffer(): void;
  30312. /**
  30313. * Unbind the current render target and bind the default framebuffer
  30314. */
  30315. restoreDefaultFramebuffer(): void;
  30316. private _resetVertexBufferBinding;
  30317. /**
  30318. * Creates a vertex buffer
  30319. * @param data the data for the vertex buffer
  30320. * @returns the new WebGL static buffer
  30321. */
  30322. createVertexBuffer(data: DataArray): DataBuffer;
  30323. private _createVertexBuffer;
  30324. /**
  30325. * Creates a dynamic vertex buffer
  30326. * @param data the data for the dynamic vertex buffer
  30327. * @returns the new WebGL dynamic buffer
  30328. */
  30329. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30330. /**
  30331. * Updates a dynamic vertex buffer.
  30332. * @param vertexBuffer the vertex buffer to update
  30333. * @param data the data used to update the vertex buffer
  30334. * @param byteOffset the byte offset of the data
  30335. * @param byteLength the byte length of the data
  30336. */
  30337. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30338. protected _resetIndexBufferBinding(): void;
  30339. /**
  30340. * Creates a new index buffer
  30341. * @param indices defines the content of the index buffer
  30342. * @param updatable defines if the index buffer must be updatable
  30343. * @returns a new webGL buffer
  30344. */
  30345. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30346. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30347. /**
  30348. * Bind a webGL buffer to the webGL context
  30349. * @param buffer defines the buffer to bind
  30350. */
  30351. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30352. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30353. private bindBuffer;
  30354. /**
  30355. * update the bound buffer with the given data
  30356. * @param data defines the data to update
  30357. */
  30358. updateArrayBuffer(data: Float32Array): void;
  30359. private _vertexAttribPointer;
  30360. private _bindIndexBufferWithCache;
  30361. private _bindVertexBuffersAttributes;
  30362. /**
  30363. * Records a vertex array object
  30364. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30365. * @param vertexBuffers defines the list of vertex buffers to store
  30366. * @param indexBuffer defines the index buffer to store
  30367. * @param effect defines the effect to store
  30368. * @returns the new vertex array object
  30369. */
  30370. recordVertexArrayObject(vertexBuffers: {
  30371. [key: string]: VertexBuffer;
  30372. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30373. /**
  30374. * Bind a specific vertex array object
  30375. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30376. * @param vertexArrayObject defines the vertex array object to bind
  30377. * @param indexBuffer defines the index buffer to bind
  30378. */
  30379. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30380. /**
  30381. * Bind webGl buffers directly to the webGL context
  30382. * @param vertexBuffer defines the vertex buffer to bind
  30383. * @param indexBuffer defines the index buffer to bind
  30384. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30385. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30386. * @param effect defines the effect associated with the vertex buffer
  30387. */
  30388. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30389. private _unbindVertexArrayObject;
  30390. /**
  30391. * Bind a list of vertex buffers to the webGL context
  30392. * @param vertexBuffers defines the list of vertex buffers to bind
  30393. * @param indexBuffer defines the index buffer to bind
  30394. * @param effect defines the effect associated with the vertex buffers
  30395. */
  30396. bindBuffers(vertexBuffers: {
  30397. [key: string]: Nullable<VertexBuffer>;
  30398. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30399. /**
  30400. * Unbind all instance attributes
  30401. */
  30402. unbindInstanceAttributes(): void;
  30403. /**
  30404. * Release and free the memory of a vertex array object
  30405. * @param vao defines the vertex array object to delete
  30406. */
  30407. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30408. /** @hidden */
  30409. _releaseBuffer(buffer: DataBuffer): boolean;
  30410. protected _deleteBuffer(buffer: DataBuffer): void;
  30411. /**
  30412. * Creates a webGL buffer to use with instanciation
  30413. * @param capacity defines the size of the buffer
  30414. * @returns the webGL buffer
  30415. */
  30416. createInstancesBuffer(capacity: number): DataBuffer;
  30417. /**
  30418. * Delete a webGL buffer used with instanciation
  30419. * @param buffer defines the webGL buffer to delete
  30420. */
  30421. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30422. /**
  30423. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30424. * @param instancesBuffer defines the webGL buffer to update and bind
  30425. * @param data defines the data to store in the buffer
  30426. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30427. */
  30428. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30429. /**
  30430. * Apply all cached states (depth, culling, stencil and alpha)
  30431. */
  30432. applyStates(): void;
  30433. /**
  30434. * Send a draw order
  30435. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30436. * @param indexStart defines the starting index
  30437. * @param indexCount defines the number of index to draw
  30438. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30439. */
  30440. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30441. /**
  30442. * Draw a list of points
  30443. * @param verticesStart defines the index of first vertex to draw
  30444. * @param verticesCount defines the count of vertices to draw
  30445. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30446. */
  30447. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30448. /**
  30449. * Draw a list of unindexed primitives
  30450. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30451. * @param verticesStart defines the index of first vertex to draw
  30452. * @param verticesCount defines the count of vertices to draw
  30453. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30454. */
  30455. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30456. /**
  30457. * Draw a list of indexed primitives
  30458. * @param fillMode defines the primitive to use
  30459. * @param indexStart defines the starting index
  30460. * @param indexCount defines the number of index to draw
  30461. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30462. */
  30463. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30464. /**
  30465. * Draw a list of unindexed primitives
  30466. * @param fillMode defines the primitive to use
  30467. * @param verticesStart defines the index of first vertex to draw
  30468. * @param verticesCount defines the count of vertices to draw
  30469. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30470. */
  30471. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30472. private _drawMode;
  30473. /** @hidden */
  30474. protected _reportDrawCall(): void;
  30475. /** @hidden */
  30476. _releaseEffect(effect: Effect): void;
  30477. /** @hidden */
  30478. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30479. /**
  30480. * Create a new effect (used to store vertex/fragment shaders)
  30481. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30482. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30483. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30484. * @param samplers defines an array of string used to represent textures
  30485. * @param defines defines the string containing the defines to use to compile the shaders
  30486. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30487. * @param onCompiled defines a function to call when the effect creation is successful
  30488. * @param onError defines a function to call when the effect creation has failed
  30489. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30490. * @returns the new Effect
  30491. */
  30492. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30493. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30494. private _compileShader;
  30495. private _compileRawShader;
  30496. /**
  30497. * Directly creates a webGL program
  30498. * @param pipelineContext defines the pipeline context to attach to
  30499. * @param vertexCode defines the vertex shader code to use
  30500. * @param fragmentCode defines the fragment shader code to use
  30501. * @param context defines the webGL context to use (if not set, the current one will be used)
  30502. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30503. * @returns the new webGL program
  30504. */
  30505. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30506. /**
  30507. * Creates a webGL program
  30508. * @param pipelineContext defines the pipeline context to attach to
  30509. * @param vertexCode defines the vertex shader code to use
  30510. * @param fragmentCode defines the fragment shader code to use
  30511. * @param defines defines the string containing the defines to use to compile the shaders
  30512. * @param context defines the webGL context to use (if not set, the current one will be used)
  30513. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30514. * @returns the new webGL program
  30515. */
  30516. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30517. /**
  30518. * Creates a new pipeline context
  30519. * @returns the new pipeline
  30520. */
  30521. createPipelineContext(): IPipelineContext;
  30522. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30523. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30524. /** @hidden */
  30525. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30526. /** @hidden */
  30527. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30528. /** @hidden */
  30529. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30530. /**
  30531. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30532. * @param pipelineContext defines the pipeline context to use
  30533. * @param uniformsNames defines the list of uniform names
  30534. * @returns an array of webGL uniform locations
  30535. */
  30536. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30537. /**
  30538. * Gets the lsit of active attributes for a given webGL program
  30539. * @param pipelineContext defines the pipeline context to use
  30540. * @param attributesNames defines the list of attribute names to get
  30541. * @returns an array of indices indicating the offset of each attribute
  30542. */
  30543. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30544. /**
  30545. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30546. * @param effect defines the effect to activate
  30547. */
  30548. enableEffect(effect: Nullable<Effect>): void;
  30549. /**
  30550. * Set the value of an uniform to an array of int32
  30551. * @param uniform defines the webGL uniform location where to store the value
  30552. * @param array defines the array of int32 to store
  30553. */
  30554. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30555. /**
  30556. * Set the value of an uniform to an array of int32 (stored as vec2)
  30557. * @param uniform defines the webGL uniform location where to store the value
  30558. * @param array defines the array of int32 to store
  30559. */
  30560. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30561. /**
  30562. * Set the value of an uniform to an array of int32 (stored as vec3)
  30563. * @param uniform defines the webGL uniform location where to store the value
  30564. * @param array defines the array of int32 to store
  30565. */
  30566. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30567. /**
  30568. * Set the value of an uniform to an array of int32 (stored as vec4)
  30569. * @param uniform defines the webGL uniform location where to store the value
  30570. * @param array defines the array of int32 to store
  30571. */
  30572. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30573. /**
  30574. * Set the value of an uniform to an array of float32
  30575. * @param uniform defines the webGL uniform location where to store the value
  30576. * @param array defines the array of float32 to store
  30577. */
  30578. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30579. /**
  30580. * Set the value of an uniform to an array of float32 (stored as vec2)
  30581. * @param uniform defines the webGL uniform location where to store the value
  30582. * @param array defines the array of float32 to store
  30583. */
  30584. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30585. /**
  30586. * Set the value of an uniform to an array of float32 (stored as vec3)
  30587. * @param uniform defines the webGL uniform location where to store the value
  30588. * @param array defines the array of float32 to store
  30589. */
  30590. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30591. /**
  30592. * Set the value of an uniform to an array of float32 (stored as vec4)
  30593. * @param uniform defines the webGL uniform location where to store the value
  30594. * @param array defines the array of float32 to store
  30595. */
  30596. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30597. /**
  30598. * Set the value of an uniform to an array of number
  30599. * @param uniform defines the webGL uniform location where to store the value
  30600. * @param array defines the array of number to store
  30601. */
  30602. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30603. /**
  30604. * Set the value of an uniform to an array of number (stored as vec2)
  30605. * @param uniform defines the webGL uniform location where to store the value
  30606. * @param array defines the array of number to store
  30607. */
  30608. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30609. /**
  30610. * Set the value of an uniform to an array of number (stored as vec3)
  30611. * @param uniform defines the webGL uniform location where to store the value
  30612. * @param array defines the array of number to store
  30613. */
  30614. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30615. /**
  30616. * Set the value of an uniform to an array of number (stored as vec4)
  30617. * @param uniform defines the webGL uniform location where to store the value
  30618. * @param array defines the array of number to store
  30619. */
  30620. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30621. /**
  30622. * Set the value of an uniform to an array of float32 (stored as matrices)
  30623. * @param uniform defines the webGL uniform location where to store the value
  30624. * @param matrices defines the array of float32 to store
  30625. */
  30626. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30627. /**
  30628. * Set the value of an uniform to a matrix (3x3)
  30629. * @param uniform defines the webGL uniform location where to store the value
  30630. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30631. */
  30632. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30633. /**
  30634. * Set the value of an uniform to a matrix (2x2)
  30635. * @param uniform defines the webGL uniform location where to store the value
  30636. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30637. */
  30638. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30639. /**
  30640. * Set the value of an uniform to a number (int)
  30641. * @param uniform defines the webGL uniform location where to store the value
  30642. * @param value defines the int number to store
  30643. */
  30644. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30645. /**
  30646. * Set the value of an uniform to a number (float)
  30647. * @param uniform defines the webGL uniform location where to store the value
  30648. * @param value defines the float number to store
  30649. */
  30650. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30651. /**
  30652. * Set the value of an uniform to a vec2
  30653. * @param uniform defines the webGL uniform location where to store the value
  30654. * @param x defines the 1st component of the value
  30655. * @param y defines the 2nd component of the value
  30656. */
  30657. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30658. /**
  30659. * Set the value of an uniform to a vec3
  30660. * @param uniform defines the webGL uniform location where to store the value
  30661. * @param x defines the 1st component of the value
  30662. * @param y defines the 2nd component of the value
  30663. * @param z defines the 3rd component of the value
  30664. */
  30665. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30666. /**
  30667. * Set the value of an uniform to a boolean
  30668. * @param uniform defines the webGL uniform location where to store the value
  30669. * @param bool defines the boolean to store
  30670. */
  30671. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30672. /**
  30673. * Set the value of an uniform to a vec4
  30674. * @param uniform defines the webGL uniform location where to store the value
  30675. * @param x defines the 1st component of the value
  30676. * @param y defines the 2nd component of the value
  30677. * @param z defines the 3rd component of the value
  30678. * @param w defines the 4th component of the value
  30679. */
  30680. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30681. /**
  30682. * Sets a Color4 on a uniform variable
  30683. * @param uniform defines the uniform location
  30684. * @param color4 defines the value to be set
  30685. */
  30686. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30687. /**
  30688. * Gets the depth culling state manager
  30689. */
  30690. readonly depthCullingState: DepthCullingState;
  30691. /**
  30692. * Gets the alpha state manager
  30693. */
  30694. readonly alphaState: AlphaState;
  30695. /**
  30696. * Gets the stencil state manager
  30697. */
  30698. readonly stencilState: StencilState;
  30699. /**
  30700. * Clears the list of texture accessible through engine.
  30701. * This can help preventing texture load conflict due to name collision.
  30702. */
  30703. clearInternalTexturesCache(): void;
  30704. /**
  30705. * Force the entire cache to be cleared
  30706. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30707. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30708. */
  30709. wipeCaches(bruteForce?: boolean): void;
  30710. /** @hidden */
  30711. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30712. min: number;
  30713. mag: number;
  30714. };
  30715. /** @hidden */
  30716. _createTexture(): WebGLTexture;
  30717. /**
  30718. * Usually called from Texture.ts.
  30719. * Passed information to create a WebGLTexture
  30720. * @param urlArg defines a value which contains one of the following:
  30721. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30722. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30723. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30725. * @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)
  30726. * @param scene needed for loading to the correct scene
  30727. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30728. * @param onLoad optional callback to be called upon successful completion
  30729. * @param onError optional callback to be called upon failure
  30730. * @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
  30731. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30732. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30733. * @param forcedExtension defines the extension to use to pick the right loader
  30734. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30735. * @param mimeType defines an optional mime type
  30736. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30737. */
  30738. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30739. /**
  30740. * @hidden
  30741. */
  30742. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30743. /**
  30744. * Creates a raw texture
  30745. * @param data defines the data to store in the texture
  30746. * @param width defines the width of the texture
  30747. * @param height defines the height of the texture
  30748. * @param format defines the format of the data
  30749. * @param generateMipMaps defines if the engine should generate the mip levels
  30750. * @param invertY defines if data must be stored with Y axis inverted
  30751. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30752. * @param compression defines the compression used (null by default)
  30753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30754. * @returns the raw texture inside an InternalTexture
  30755. */
  30756. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30757. /**
  30758. * Creates a new raw cube texture
  30759. * @param data defines the array of data to use to create each face
  30760. * @param size defines the size of the textures
  30761. * @param format defines the format of the data
  30762. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30763. * @param generateMipMaps defines if the engine should generate the mip levels
  30764. * @param invertY defines if data must be stored with Y axis inverted
  30765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30766. * @param compression defines the compression used (null by default)
  30767. * @returns the cube texture as an InternalTexture
  30768. */
  30769. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30770. /**
  30771. * Creates a new raw 3D texture
  30772. * @param data defines the data used to create the texture
  30773. * @param width defines the width of the texture
  30774. * @param height defines the height of the texture
  30775. * @param depth defines the depth of the texture
  30776. * @param format defines the format of the texture
  30777. * @param generateMipMaps defines if the engine must generate mip levels
  30778. * @param invertY defines if data must be stored with Y axis inverted
  30779. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30780. * @param compression defines the compressed used (can be null)
  30781. * @param textureType defines the compressed used (can be null)
  30782. * @returns a new raw 3D texture (stored in an InternalTexture)
  30783. */
  30784. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30785. private _unpackFlipYCached;
  30786. /**
  30787. * In case you are sharing the context with other applications, it might
  30788. * be interested to not cache the unpack flip y state to ensure a consistent
  30789. * value would be set.
  30790. */
  30791. enableUnpackFlipYCached: boolean;
  30792. /** @hidden */
  30793. _unpackFlipY(value: boolean): void;
  30794. /** @hidden */
  30795. _getUnpackAlignement(): number;
  30796. /**
  30797. * Update the sampling mode of a given texture
  30798. * @param samplingMode defines the required sampling mode
  30799. * @param texture defines the texture to update
  30800. */
  30801. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30802. /**
  30803. * Updates a depth texture Comparison Mode and Function.
  30804. * If the comparison Function is equal to 0, the mode will be set to none.
  30805. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30806. * @param texture The texture to set the comparison function for
  30807. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30808. */
  30809. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30810. /** @hidden */
  30811. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30812. width: number;
  30813. height: number;
  30814. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30815. /**
  30816. * Creates a depth stencil texture.
  30817. * This is only available in WebGL 2 or with the depth texture extension available.
  30818. * @param size The size of face edge in the texture.
  30819. * @param options The options defining the texture.
  30820. * @returns The texture
  30821. */
  30822. createDepthStencilTexture(size: number | {
  30823. width: number;
  30824. height: number;
  30825. }, options: DepthTextureCreationOptions): InternalTexture;
  30826. /**
  30827. * Creates a depth stencil texture.
  30828. * This is only available in WebGL 2 or with the depth texture extension available.
  30829. * @param size The size of face edge in the texture.
  30830. * @param options The options defining the texture.
  30831. * @returns The texture
  30832. */
  30833. private _createDepthStencilTexture;
  30834. /** @hidden */
  30835. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30836. /** @hidden */
  30837. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30838. /** @hidden */
  30839. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30840. /** @hidden */
  30841. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  30842. /**
  30843. * @hidden
  30844. */
  30845. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30846. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30847. private _prepareWebGLTexture;
  30848. /** @hidden */
  30849. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30850. /** @hidden */
  30851. _releaseFramebufferObjects(texture: InternalTexture): void;
  30852. /** @hidden */
  30853. _releaseTexture(texture: InternalTexture): void;
  30854. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30855. protected _setProgram(program: WebGLProgram): void;
  30856. protected _boundUniforms: {
  30857. [key: number]: WebGLUniformLocation;
  30858. };
  30859. /**
  30860. * Binds an effect to the webGL context
  30861. * @param effect defines the effect to bind
  30862. */
  30863. bindSamplers(effect: Effect): void;
  30864. private _activateCurrentTexture;
  30865. /** @hidden */
  30866. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30867. /** @hidden */
  30868. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30869. /**
  30870. * Unbind all textures from the webGL context
  30871. */
  30872. unbindAllTextures(): void;
  30873. /**
  30874. * Sets a texture to the according uniform.
  30875. * @param channel The texture channel
  30876. * @param uniform The uniform to set
  30877. * @param texture The texture to apply
  30878. */
  30879. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30880. private _bindSamplerUniformToChannel;
  30881. private _getTextureWrapMode;
  30882. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30883. /**
  30884. * Sets an array of texture to the webGL context
  30885. * @param channel defines the channel where the texture array must be set
  30886. * @param uniform defines the associated uniform location
  30887. * @param textures defines the array of textures to bind
  30888. */
  30889. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30890. /** @hidden */
  30891. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30892. private _setTextureParameterFloat;
  30893. private _setTextureParameterInteger;
  30894. /**
  30895. * Unbind all vertex attributes from the webGL context
  30896. */
  30897. unbindAllAttributes(): void;
  30898. /**
  30899. * 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
  30900. */
  30901. releaseEffects(): void;
  30902. /**
  30903. * Dispose and release all associated resources
  30904. */
  30905. dispose(): void;
  30906. /**
  30907. * Attach a new callback raised when context lost event is fired
  30908. * @param callback defines the callback to call
  30909. */
  30910. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30911. /**
  30912. * Attach a new callback raised when context restored event is fired
  30913. * @param callback defines the callback to call
  30914. */
  30915. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30916. /**
  30917. * Get the current error code of the webGL context
  30918. * @returns the error code
  30919. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30920. */
  30921. getError(): number;
  30922. private _canRenderToFloatFramebuffer;
  30923. private _canRenderToHalfFloatFramebuffer;
  30924. private _canRenderToFramebuffer;
  30925. /** @hidden */
  30926. _getWebGLTextureType(type: number): number;
  30927. /** @hidden */
  30928. _getInternalFormat(format: number): number;
  30929. /** @hidden */
  30930. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30931. /** @hidden */
  30932. _getRGBAMultiSampleBufferFormat(type: number): number;
  30933. /** @hidden */
  30934. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30935. /**
  30936. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30937. * @returns true if the engine can be created
  30938. * @ignorenaming
  30939. */
  30940. static isSupported(): boolean;
  30941. /**
  30942. * Find the next highest power of two.
  30943. * @param x Number to start search from.
  30944. * @return Next highest power of two.
  30945. */
  30946. static CeilingPOT(x: number): number;
  30947. /**
  30948. * Find the next lowest power of two.
  30949. * @param x Number to start search from.
  30950. * @return Next lowest power of two.
  30951. */
  30952. static FloorPOT(x: number): number;
  30953. /**
  30954. * Find the nearest power of two.
  30955. * @param x Number to start search from.
  30956. * @return Next nearest power of two.
  30957. */
  30958. static NearestPOT(x: number): number;
  30959. /**
  30960. * Get the closest exponent of two
  30961. * @param value defines the value to approximate
  30962. * @param max defines the maximum value to return
  30963. * @param mode defines how to define the closest value
  30964. * @returns closest exponent of two of the given value
  30965. */
  30966. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30967. /**
  30968. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30969. * @param func - the function to be called
  30970. * @param requester - the object that will request the next frame. Falls back to window.
  30971. * @returns frame number
  30972. */
  30973. static QueueNewFrame(func: () => void, requester?: any): number;
  30974. }
  30975. }
  30976. declare module "babylonjs/Maths/sphericalPolynomial" {
  30977. import { Vector3 } from "babylonjs/Maths/math.vector";
  30978. import { Color3 } from "babylonjs/Maths/math.color";
  30979. /**
  30980. * Class representing spherical harmonics coefficients to the 3rd degree
  30981. */
  30982. export class SphericalHarmonics {
  30983. /**
  30984. * Defines whether or not the harmonics have been prescaled for rendering.
  30985. */
  30986. preScaled: boolean;
  30987. /**
  30988. * The l0,0 coefficients of the spherical harmonics
  30989. */
  30990. l00: Vector3;
  30991. /**
  30992. * The l1,-1 coefficients of the spherical harmonics
  30993. */
  30994. l1_1: Vector3;
  30995. /**
  30996. * The l1,0 coefficients of the spherical harmonics
  30997. */
  30998. l10: Vector3;
  30999. /**
  31000. * The l1,1 coefficients of the spherical harmonics
  31001. */
  31002. l11: Vector3;
  31003. /**
  31004. * The l2,-2 coefficients of the spherical harmonics
  31005. */
  31006. l2_2: Vector3;
  31007. /**
  31008. * The l2,-1 coefficients of the spherical harmonics
  31009. */
  31010. l2_1: Vector3;
  31011. /**
  31012. * The l2,0 coefficients of the spherical harmonics
  31013. */
  31014. l20: Vector3;
  31015. /**
  31016. * The l2,1 coefficients of the spherical harmonics
  31017. */
  31018. l21: Vector3;
  31019. /**
  31020. * The l2,2 coefficients of the spherical harmonics
  31021. */
  31022. l22: Vector3;
  31023. /**
  31024. * Adds a light to the spherical harmonics
  31025. * @param direction the direction of the light
  31026. * @param color the color of the light
  31027. * @param deltaSolidAngle the delta solid angle of the light
  31028. */
  31029. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31030. /**
  31031. * Scales the spherical harmonics by the given amount
  31032. * @param scale the amount to scale
  31033. */
  31034. scaleInPlace(scale: number): void;
  31035. /**
  31036. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31037. *
  31038. * ```
  31039. * E_lm = A_l * L_lm
  31040. * ```
  31041. *
  31042. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31043. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31044. * the scaling factors are given in equation 9.
  31045. */
  31046. convertIncidentRadianceToIrradiance(): void;
  31047. /**
  31048. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31049. *
  31050. * ```
  31051. * L = (1/pi) * E * rho
  31052. * ```
  31053. *
  31054. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31055. */
  31056. convertIrradianceToLambertianRadiance(): void;
  31057. /**
  31058. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31059. * required operations at run time.
  31060. *
  31061. * This is simply done by scaling back the SH with Ylm constants parameter.
  31062. * The trigonometric part being applied by the shader at run time.
  31063. */
  31064. preScaleForRendering(): void;
  31065. /**
  31066. * Constructs a spherical harmonics from an array.
  31067. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31068. * @returns the spherical harmonics
  31069. */
  31070. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31071. /**
  31072. * Gets the spherical harmonics from polynomial
  31073. * @param polynomial the spherical polynomial
  31074. * @returns the spherical harmonics
  31075. */
  31076. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31077. }
  31078. /**
  31079. * Class representing spherical polynomial coefficients to the 3rd degree
  31080. */
  31081. export class SphericalPolynomial {
  31082. private _harmonics;
  31083. /**
  31084. * The spherical harmonics used to create the polynomials.
  31085. */
  31086. readonly preScaledHarmonics: SphericalHarmonics;
  31087. /**
  31088. * The x coefficients of the spherical polynomial
  31089. */
  31090. x: Vector3;
  31091. /**
  31092. * The y coefficients of the spherical polynomial
  31093. */
  31094. y: Vector3;
  31095. /**
  31096. * The z coefficients of the spherical polynomial
  31097. */
  31098. z: Vector3;
  31099. /**
  31100. * The xx coefficients of the spherical polynomial
  31101. */
  31102. xx: Vector3;
  31103. /**
  31104. * The yy coefficients of the spherical polynomial
  31105. */
  31106. yy: Vector3;
  31107. /**
  31108. * The zz coefficients of the spherical polynomial
  31109. */
  31110. zz: Vector3;
  31111. /**
  31112. * The xy coefficients of the spherical polynomial
  31113. */
  31114. xy: Vector3;
  31115. /**
  31116. * The yz coefficients of the spherical polynomial
  31117. */
  31118. yz: Vector3;
  31119. /**
  31120. * The zx coefficients of the spherical polynomial
  31121. */
  31122. zx: Vector3;
  31123. /**
  31124. * Adds an ambient color to the spherical polynomial
  31125. * @param color the color to add
  31126. */
  31127. addAmbient(color: Color3): void;
  31128. /**
  31129. * Scales the spherical polynomial by the given amount
  31130. * @param scale the amount to scale
  31131. */
  31132. scaleInPlace(scale: number): void;
  31133. /**
  31134. * Gets the spherical polynomial from harmonics
  31135. * @param harmonics the spherical harmonics
  31136. * @returns the spherical polynomial
  31137. */
  31138. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31139. /**
  31140. * Constructs a spherical polynomial from an array.
  31141. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31142. * @returns the spherical polynomial
  31143. */
  31144. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31145. }
  31146. }
  31147. declare module "babylonjs/Materials/Textures/internalTexture" {
  31148. import { Observable } from "babylonjs/Misc/observable";
  31149. import { Nullable, int } from "babylonjs/types";
  31150. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31152. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31153. /**
  31154. * Defines the source of the internal texture
  31155. */
  31156. export enum InternalTextureSource {
  31157. /**
  31158. * The source of the texture data is unknown
  31159. */
  31160. Unknown = 0,
  31161. /**
  31162. * Texture data comes from an URL
  31163. */
  31164. Url = 1,
  31165. /**
  31166. * Texture data is only used for temporary storage
  31167. */
  31168. Temp = 2,
  31169. /**
  31170. * Texture data comes from raw data (ArrayBuffer)
  31171. */
  31172. Raw = 3,
  31173. /**
  31174. * Texture content is dynamic (video or dynamic texture)
  31175. */
  31176. Dynamic = 4,
  31177. /**
  31178. * Texture content is generated by rendering to it
  31179. */
  31180. RenderTarget = 5,
  31181. /**
  31182. * Texture content is part of a multi render target process
  31183. */
  31184. MultiRenderTarget = 6,
  31185. /**
  31186. * Texture data comes from a cube data file
  31187. */
  31188. Cube = 7,
  31189. /**
  31190. * Texture data comes from a raw cube data
  31191. */
  31192. CubeRaw = 8,
  31193. /**
  31194. * Texture data come from a prefiltered cube data file
  31195. */
  31196. CubePrefiltered = 9,
  31197. /**
  31198. * Texture content is raw 3D data
  31199. */
  31200. Raw3D = 10,
  31201. /**
  31202. * Texture content is a depth texture
  31203. */
  31204. Depth = 11,
  31205. /**
  31206. * Texture data comes from a raw cube data encoded with RGBD
  31207. */
  31208. CubeRawRGBD = 12
  31209. }
  31210. /**
  31211. * Class used to store data associated with WebGL texture data for the engine
  31212. * This class should not be used directly
  31213. */
  31214. export class InternalTexture {
  31215. /** @hidden */
  31216. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31217. /**
  31218. * Defines if the texture is ready
  31219. */
  31220. isReady: boolean;
  31221. /**
  31222. * Defines if the texture is a cube texture
  31223. */
  31224. isCube: boolean;
  31225. /**
  31226. * Defines if the texture contains 3D data
  31227. */
  31228. is3D: boolean;
  31229. /**
  31230. * Defines if the texture contains multiview data
  31231. */
  31232. isMultiview: boolean;
  31233. /**
  31234. * Gets the URL used to load this texture
  31235. */
  31236. url: string;
  31237. /**
  31238. * Gets the sampling mode of the texture
  31239. */
  31240. samplingMode: number;
  31241. /**
  31242. * Gets a boolean indicating if the texture needs mipmaps generation
  31243. */
  31244. generateMipMaps: boolean;
  31245. /**
  31246. * Gets the number of samples used by the texture (WebGL2+ only)
  31247. */
  31248. samples: number;
  31249. /**
  31250. * Gets the type of the texture (int, float...)
  31251. */
  31252. type: number;
  31253. /**
  31254. * Gets the format of the texture (RGB, RGBA...)
  31255. */
  31256. format: number;
  31257. /**
  31258. * Observable called when the texture is loaded
  31259. */
  31260. onLoadedObservable: Observable<InternalTexture>;
  31261. /**
  31262. * Gets the width of the texture
  31263. */
  31264. width: number;
  31265. /**
  31266. * Gets the height of the texture
  31267. */
  31268. height: number;
  31269. /**
  31270. * Gets the depth of the texture
  31271. */
  31272. depth: number;
  31273. /**
  31274. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31275. */
  31276. baseWidth: number;
  31277. /**
  31278. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31279. */
  31280. baseHeight: number;
  31281. /**
  31282. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31283. */
  31284. baseDepth: number;
  31285. /**
  31286. * Gets a boolean indicating if the texture is inverted on Y axis
  31287. */
  31288. invertY: boolean;
  31289. /** @hidden */
  31290. _invertVScale: boolean;
  31291. /** @hidden */
  31292. _associatedChannel: number;
  31293. /** @hidden */
  31294. _source: InternalTextureSource;
  31295. /** @hidden */
  31296. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31297. /** @hidden */
  31298. _bufferView: Nullable<ArrayBufferView>;
  31299. /** @hidden */
  31300. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31301. /** @hidden */
  31302. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31303. /** @hidden */
  31304. _size: number;
  31305. /** @hidden */
  31306. _extension: string;
  31307. /** @hidden */
  31308. _files: Nullable<string[]>;
  31309. /** @hidden */
  31310. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31311. /** @hidden */
  31312. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31313. /** @hidden */
  31314. _framebuffer: Nullable<WebGLFramebuffer>;
  31315. /** @hidden */
  31316. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31317. /** @hidden */
  31318. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31319. /** @hidden */
  31320. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31321. /** @hidden */
  31322. _attachments: Nullable<number[]>;
  31323. /** @hidden */
  31324. _cachedCoordinatesMode: Nullable<number>;
  31325. /** @hidden */
  31326. _cachedWrapU: Nullable<number>;
  31327. /** @hidden */
  31328. _cachedWrapV: Nullable<number>;
  31329. /** @hidden */
  31330. _cachedWrapR: Nullable<number>;
  31331. /** @hidden */
  31332. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31333. /** @hidden */
  31334. _isDisabled: boolean;
  31335. /** @hidden */
  31336. _compression: Nullable<string>;
  31337. /** @hidden */
  31338. _generateStencilBuffer: boolean;
  31339. /** @hidden */
  31340. _generateDepthBuffer: boolean;
  31341. /** @hidden */
  31342. _comparisonFunction: number;
  31343. /** @hidden */
  31344. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31345. /** @hidden */
  31346. _lodGenerationScale: number;
  31347. /** @hidden */
  31348. _lodGenerationOffset: number;
  31349. /** @hidden */
  31350. _colorTextureArray: Nullable<WebGLTexture>;
  31351. /** @hidden */
  31352. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31353. /** @hidden */
  31354. _lodTextureHigh: Nullable<BaseTexture>;
  31355. /** @hidden */
  31356. _lodTextureMid: Nullable<BaseTexture>;
  31357. /** @hidden */
  31358. _lodTextureLow: Nullable<BaseTexture>;
  31359. /** @hidden */
  31360. _isRGBD: boolean;
  31361. /** @hidden */
  31362. _linearSpecularLOD: boolean;
  31363. /** @hidden */
  31364. _irradianceTexture: Nullable<BaseTexture>;
  31365. /** @hidden */
  31366. _webGLTexture: Nullable<WebGLTexture>;
  31367. /** @hidden */
  31368. _references: number;
  31369. private _engine;
  31370. /**
  31371. * Gets the Engine the texture belongs to.
  31372. * @returns The babylon engine
  31373. */
  31374. getEngine(): ThinEngine;
  31375. /**
  31376. * Gets the data source type of the texture
  31377. */
  31378. readonly source: InternalTextureSource;
  31379. /**
  31380. * Creates a new InternalTexture
  31381. * @param engine defines the engine to use
  31382. * @param source defines the type of data that will be used
  31383. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31384. */
  31385. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31386. /**
  31387. * Increments the number of references (ie. the number of Texture that point to it)
  31388. */
  31389. incrementReferences(): void;
  31390. /**
  31391. * Change the size of the texture (not the size of the content)
  31392. * @param width defines the new width
  31393. * @param height defines the new height
  31394. * @param depth defines the new depth (1 by default)
  31395. */
  31396. updateSize(width: int, height: int, depth?: int): void;
  31397. /** @hidden */
  31398. _rebuild(): void;
  31399. /** @hidden */
  31400. _swapAndDie(target: InternalTexture): void;
  31401. /**
  31402. * Dispose the current allocated resources
  31403. */
  31404. dispose(): void;
  31405. }
  31406. }
  31407. declare module "babylonjs/Audio/analyser" {
  31408. import { Scene } from "babylonjs/scene";
  31409. /**
  31410. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31412. */
  31413. export class Analyser {
  31414. /**
  31415. * Gets or sets the smoothing
  31416. * @ignorenaming
  31417. */
  31418. SMOOTHING: number;
  31419. /**
  31420. * Gets or sets the FFT table size
  31421. * @ignorenaming
  31422. */
  31423. FFT_SIZE: number;
  31424. /**
  31425. * Gets or sets the bar graph amplitude
  31426. * @ignorenaming
  31427. */
  31428. BARGRAPHAMPLITUDE: number;
  31429. /**
  31430. * Gets or sets the position of the debug canvas
  31431. * @ignorenaming
  31432. */
  31433. DEBUGCANVASPOS: {
  31434. x: number;
  31435. y: number;
  31436. };
  31437. /**
  31438. * Gets or sets the debug canvas size
  31439. * @ignorenaming
  31440. */
  31441. DEBUGCANVASSIZE: {
  31442. width: number;
  31443. height: number;
  31444. };
  31445. private _byteFreqs;
  31446. private _byteTime;
  31447. private _floatFreqs;
  31448. private _webAudioAnalyser;
  31449. private _debugCanvas;
  31450. private _debugCanvasContext;
  31451. private _scene;
  31452. private _registerFunc;
  31453. private _audioEngine;
  31454. /**
  31455. * Creates a new analyser
  31456. * @param scene defines hosting scene
  31457. */
  31458. constructor(scene: Scene);
  31459. /**
  31460. * Get the number of data values you will have to play with for the visualization
  31461. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31462. * @returns a number
  31463. */
  31464. getFrequencyBinCount(): number;
  31465. /**
  31466. * Gets the current frequency data as a byte array
  31467. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31468. * @returns a Uint8Array
  31469. */
  31470. getByteFrequencyData(): Uint8Array;
  31471. /**
  31472. * Gets the current waveform as a byte array
  31473. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31474. * @returns a Uint8Array
  31475. */
  31476. getByteTimeDomainData(): Uint8Array;
  31477. /**
  31478. * Gets the current frequency data as a float array
  31479. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31480. * @returns a Float32Array
  31481. */
  31482. getFloatFrequencyData(): Float32Array;
  31483. /**
  31484. * Renders the debug canvas
  31485. */
  31486. drawDebugCanvas(): void;
  31487. /**
  31488. * Stops rendering the debug canvas and removes it
  31489. */
  31490. stopDebugCanvas(): void;
  31491. /**
  31492. * Connects two audio nodes
  31493. * @param inputAudioNode defines first node to connect
  31494. * @param outputAudioNode defines second node to connect
  31495. */
  31496. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31497. /**
  31498. * Releases all associated resources
  31499. */
  31500. dispose(): void;
  31501. }
  31502. }
  31503. declare module "babylonjs/Audio/audioEngine" {
  31504. import { IDisposable } from "babylonjs/scene";
  31505. import { Analyser } from "babylonjs/Audio/analyser";
  31506. import { Nullable } from "babylonjs/types";
  31507. import { Observable } from "babylonjs/Misc/observable";
  31508. /**
  31509. * This represents an audio engine and it is responsible
  31510. * to play, synchronize and analyse sounds throughout the application.
  31511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31512. */
  31513. export interface IAudioEngine extends IDisposable {
  31514. /**
  31515. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31516. */
  31517. readonly canUseWebAudio: boolean;
  31518. /**
  31519. * Gets the current AudioContext if available.
  31520. */
  31521. readonly audioContext: Nullable<AudioContext>;
  31522. /**
  31523. * The master gain node defines the global audio volume of your audio engine.
  31524. */
  31525. readonly masterGain: GainNode;
  31526. /**
  31527. * Gets whether or not mp3 are supported by your browser.
  31528. */
  31529. readonly isMP3supported: boolean;
  31530. /**
  31531. * Gets whether or not ogg are supported by your browser.
  31532. */
  31533. readonly isOGGsupported: boolean;
  31534. /**
  31535. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31536. * @ignoreNaming
  31537. */
  31538. WarnedWebAudioUnsupported: boolean;
  31539. /**
  31540. * Defines if the audio engine relies on a custom unlocked button.
  31541. * In this case, the embedded button will not be displayed.
  31542. */
  31543. useCustomUnlockedButton: boolean;
  31544. /**
  31545. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31546. */
  31547. readonly unlocked: boolean;
  31548. /**
  31549. * Event raised when audio has been unlocked on the browser.
  31550. */
  31551. onAudioUnlockedObservable: Observable<AudioEngine>;
  31552. /**
  31553. * Event raised when audio has been locked on the browser.
  31554. */
  31555. onAudioLockedObservable: Observable<AudioEngine>;
  31556. /**
  31557. * Flags the audio engine in Locked state.
  31558. * This happens due to new browser policies preventing audio to autoplay.
  31559. */
  31560. lock(): void;
  31561. /**
  31562. * Unlocks the audio engine once a user action has been done on the dom.
  31563. * This is helpful to resume play once browser policies have been satisfied.
  31564. */
  31565. unlock(): void;
  31566. }
  31567. /**
  31568. * This represents the default audio engine used in babylon.
  31569. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31571. */
  31572. export class AudioEngine implements IAudioEngine {
  31573. private _audioContext;
  31574. private _audioContextInitialized;
  31575. private _muteButton;
  31576. private _hostElement;
  31577. /**
  31578. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31579. */
  31580. canUseWebAudio: boolean;
  31581. /**
  31582. * The master gain node defines the global audio volume of your audio engine.
  31583. */
  31584. masterGain: GainNode;
  31585. /**
  31586. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31587. * @ignoreNaming
  31588. */
  31589. WarnedWebAudioUnsupported: boolean;
  31590. /**
  31591. * Gets whether or not mp3 are supported by your browser.
  31592. */
  31593. isMP3supported: boolean;
  31594. /**
  31595. * Gets whether or not ogg are supported by your browser.
  31596. */
  31597. isOGGsupported: boolean;
  31598. /**
  31599. * Gets whether audio has been unlocked on the device.
  31600. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31601. * a user interaction has happened.
  31602. */
  31603. unlocked: boolean;
  31604. /**
  31605. * Defines if the audio engine relies on a custom unlocked button.
  31606. * In this case, the embedded button will not be displayed.
  31607. */
  31608. useCustomUnlockedButton: boolean;
  31609. /**
  31610. * Event raised when audio has been unlocked on the browser.
  31611. */
  31612. onAudioUnlockedObservable: Observable<AudioEngine>;
  31613. /**
  31614. * Event raised when audio has been locked on the browser.
  31615. */
  31616. onAudioLockedObservable: Observable<AudioEngine>;
  31617. /**
  31618. * Gets the current AudioContext if available.
  31619. */
  31620. readonly audioContext: Nullable<AudioContext>;
  31621. private _connectedAnalyser;
  31622. /**
  31623. * Instantiates a new audio engine.
  31624. *
  31625. * There should be only one per page as some browsers restrict the number
  31626. * of audio contexts you can create.
  31627. * @param hostElement defines the host element where to display the mute icon if necessary
  31628. */
  31629. constructor(hostElement?: Nullable<HTMLElement>);
  31630. /**
  31631. * Flags the audio engine in Locked state.
  31632. * This happens due to new browser policies preventing audio to autoplay.
  31633. */
  31634. lock(): void;
  31635. /**
  31636. * Unlocks the audio engine once a user action has been done on the dom.
  31637. * This is helpful to resume play once browser policies have been satisfied.
  31638. */
  31639. unlock(): void;
  31640. private _resumeAudioContext;
  31641. private _initializeAudioContext;
  31642. private _tryToRun;
  31643. private _triggerRunningState;
  31644. private _triggerSuspendedState;
  31645. private _displayMuteButton;
  31646. private _moveButtonToTopLeft;
  31647. private _onResize;
  31648. private _hideMuteButton;
  31649. /**
  31650. * Destroy and release the resources associated with the audio ccontext.
  31651. */
  31652. dispose(): void;
  31653. /**
  31654. * Gets the global volume sets on the master gain.
  31655. * @returns the global volume if set or -1 otherwise
  31656. */
  31657. getGlobalVolume(): number;
  31658. /**
  31659. * Sets the global volume of your experience (sets on the master gain).
  31660. * @param newVolume Defines the new global volume of the application
  31661. */
  31662. setGlobalVolume(newVolume: number): void;
  31663. /**
  31664. * Connect the audio engine to an audio analyser allowing some amazing
  31665. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31667. * @param analyser The analyser to connect to the engine
  31668. */
  31669. connectToAnalyser(analyser: Analyser): void;
  31670. }
  31671. }
  31672. declare module "babylonjs/Loading/loadingScreen" {
  31673. /**
  31674. * Interface used to present a loading screen while loading a scene
  31675. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31676. */
  31677. export interface ILoadingScreen {
  31678. /**
  31679. * Function called to display the loading screen
  31680. */
  31681. displayLoadingUI: () => void;
  31682. /**
  31683. * Function called to hide the loading screen
  31684. */
  31685. hideLoadingUI: () => void;
  31686. /**
  31687. * Gets or sets the color to use for the background
  31688. */
  31689. loadingUIBackgroundColor: string;
  31690. /**
  31691. * Gets or sets the text to display while loading
  31692. */
  31693. loadingUIText: string;
  31694. }
  31695. /**
  31696. * Class used for the default loading screen
  31697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31698. */
  31699. export class DefaultLoadingScreen implements ILoadingScreen {
  31700. private _renderingCanvas;
  31701. private _loadingText;
  31702. private _loadingDivBackgroundColor;
  31703. private _loadingDiv;
  31704. private _loadingTextDiv;
  31705. /** Gets or sets the logo url to use for the default loading screen */
  31706. static DefaultLogoUrl: string;
  31707. /** Gets or sets the spinner url to use for the default loading screen */
  31708. static DefaultSpinnerUrl: string;
  31709. /**
  31710. * Creates a new default loading screen
  31711. * @param _renderingCanvas defines the canvas used to render the scene
  31712. * @param _loadingText defines the default text to display
  31713. * @param _loadingDivBackgroundColor defines the default background color
  31714. */
  31715. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31716. /**
  31717. * Function called to display the loading screen
  31718. */
  31719. displayLoadingUI(): void;
  31720. /**
  31721. * Function called to hide the loading screen
  31722. */
  31723. hideLoadingUI(): void;
  31724. /**
  31725. * Gets or sets the text to display while loading
  31726. */
  31727. loadingUIText: string;
  31728. /**
  31729. * Gets or sets the color to use for the background
  31730. */
  31731. loadingUIBackgroundColor: string;
  31732. private _resizeLoadingUI;
  31733. }
  31734. }
  31735. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31736. /**
  31737. * Interface for any object that can request an animation frame
  31738. */
  31739. export interface ICustomAnimationFrameRequester {
  31740. /**
  31741. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31742. */
  31743. renderFunction?: Function;
  31744. /**
  31745. * Called to request the next frame to render to
  31746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31747. */
  31748. requestAnimationFrame: Function;
  31749. /**
  31750. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31751. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31752. */
  31753. requestID?: number;
  31754. }
  31755. }
  31756. declare module "babylonjs/Misc/performanceMonitor" {
  31757. /**
  31758. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31759. */
  31760. export class PerformanceMonitor {
  31761. private _enabled;
  31762. private _rollingFrameTime;
  31763. private _lastFrameTimeMs;
  31764. /**
  31765. * constructor
  31766. * @param frameSampleSize The number of samples required to saturate the sliding window
  31767. */
  31768. constructor(frameSampleSize?: number);
  31769. /**
  31770. * Samples current frame
  31771. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31772. */
  31773. sampleFrame(timeMs?: number): void;
  31774. /**
  31775. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31776. */
  31777. readonly averageFrameTime: number;
  31778. /**
  31779. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31780. */
  31781. readonly averageFrameTimeVariance: number;
  31782. /**
  31783. * Returns the frame time of the most recent frame
  31784. */
  31785. readonly instantaneousFrameTime: number;
  31786. /**
  31787. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31788. */
  31789. readonly averageFPS: number;
  31790. /**
  31791. * Returns the average framerate in frames per second using the most recent frame time
  31792. */
  31793. readonly instantaneousFPS: number;
  31794. /**
  31795. * Returns true if enough samples have been taken to completely fill the sliding window
  31796. */
  31797. readonly isSaturated: boolean;
  31798. /**
  31799. * Enables contributions to the sliding window sample set
  31800. */
  31801. enable(): void;
  31802. /**
  31803. * Disables contributions to the sliding window sample set
  31804. * Samples will not be interpolated over the disabled period
  31805. */
  31806. disable(): void;
  31807. /**
  31808. * Returns true if sampling is enabled
  31809. */
  31810. readonly isEnabled: boolean;
  31811. /**
  31812. * Resets performance monitor
  31813. */
  31814. reset(): void;
  31815. }
  31816. /**
  31817. * RollingAverage
  31818. *
  31819. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31820. */
  31821. export class RollingAverage {
  31822. /**
  31823. * Current average
  31824. */
  31825. average: number;
  31826. /**
  31827. * Current variance
  31828. */
  31829. variance: number;
  31830. protected _samples: Array<number>;
  31831. protected _sampleCount: number;
  31832. protected _pos: number;
  31833. protected _m2: number;
  31834. /**
  31835. * constructor
  31836. * @param length The number of samples required to saturate the sliding window
  31837. */
  31838. constructor(length: number);
  31839. /**
  31840. * Adds a sample to the sample set
  31841. * @param v The sample value
  31842. */
  31843. add(v: number): void;
  31844. /**
  31845. * Returns previously added values or null if outside of history or outside the sliding window domain
  31846. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31847. * @return Value previously recorded with add() or null if outside of range
  31848. */
  31849. history(i: number): number;
  31850. /**
  31851. * Returns true if enough samples have been taken to completely fill the sliding window
  31852. * @return true if sample-set saturated
  31853. */
  31854. isSaturated(): boolean;
  31855. /**
  31856. * Resets the rolling average (equivalent to 0 samples taken so far)
  31857. */
  31858. reset(): void;
  31859. /**
  31860. * Wraps a value around the sample range boundaries
  31861. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31862. * @return Wrapped position in sample range
  31863. */
  31864. protected _wrapPosition(i: number): number;
  31865. }
  31866. }
  31867. declare module "babylonjs/Misc/perfCounter" {
  31868. /**
  31869. * This class is used to track a performance counter which is number based.
  31870. * The user has access to many properties which give statistics of different nature.
  31871. *
  31872. * The implementer can track two kinds of Performance Counter: time and count.
  31873. * 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.
  31874. * 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.
  31875. */
  31876. export class PerfCounter {
  31877. /**
  31878. * Gets or sets a global boolean to turn on and off all the counters
  31879. */
  31880. static Enabled: boolean;
  31881. /**
  31882. * Returns the smallest value ever
  31883. */
  31884. readonly min: number;
  31885. /**
  31886. * Returns the biggest value ever
  31887. */
  31888. readonly max: number;
  31889. /**
  31890. * Returns the average value since the performance counter is running
  31891. */
  31892. readonly average: number;
  31893. /**
  31894. * Returns the average value of the last second the counter was monitored
  31895. */
  31896. readonly lastSecAverage: number;
  31897. /**
  31898. * Returns the current value
  31899. */
  31900. readonly current: number;
  31901. /**
  31902. * Gets the accumulated total
  31903. */
  31904. readonly total: number;
  31905. /**
  31906. * Gets the total value count
  31907. */
  31908. readonly count: number;
  31909. /**
  31910. * Creates a new counter
  31911. */
  31912. constructor();
  31913. /**
  31914. * Call this method to start monitoring a new frame.
  31915. * 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.
  31916. */
  31917. fetchNewFrame(): void;
  31918. /**
  31919. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31920. * @param newCount the count value to add to the monitored count
  31921. * @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.
  31922. */
  31923. addCount(newCount: number, fetchResult: boolean): void;
  31924. /**
  31925. * Start monitoring this performance counter
  31926. */
  31927. beginMonitoring(): void;
  31928. /**
  31929. * Compute the time lapsed since the previous beginMonitoring() call.
  31930. * @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
  31931. */
  31932. endMonitoring(newFrame?: boolean): void;
  31933. private _fetchResult;
  31934. private _startMonitoringTime;
  31935. private _min;
  31936. private _max;
  31937. private _average;
  31938. private _current;
  31939. private _totalValueCount;
  31940. private _totalAccumulated;
  31941. private _lastSecAverage;
  31942. private _lastSecAccumulated;
  31943. private _lastSecTime;
  31944. private _lastSecValueCount;
  31945. }
  31946. }
  31947. declare module "babylonjs/Engines/engine" {
  31948. import { Observable } from "babylonjs/Misc/observable";
  31949. import { Nullable, IndicesArray } from "babylonjs/types";
  31950. import { Scene } from "babylonjs/scene";
  31951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31952. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31953. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31954. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31955. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31956. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31957. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31958. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31959. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31961. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31962. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31963. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31964. import { Material } from "babylonjs/Materials/material";
  31965. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31966. /**
  31967. * Defines the interface used by display changed events
  31968. */
  31969. export interface IDisplayChangedEventArgs {
  31970. /** Gets the vrDisplay object (if any) */
  31971. vrDisplay: Nullable<any>;
  31972. /** Gets a boolean indicating if webVR is supported */
  31973. vrSupported: boolean;
  31974. }
  31975. /**
  31976. * Defines the interface used by objects containing a viewport (like a camera)
  31977. */
  31978. interface IViewportOwnerLike {
  31979. /**
  31980. * Gets or sets the viewport
  31981. */
  31982. viewport: IViewportLike;
  31983. }
  31984. /**
  31985. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31986. */
  31987. export class Engine extends ThinEngine {
  31988. /** Defines that alpha blending is disabled */
  31989. static readonly ALPHA_DISABLE: number;
  31990. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31991. static readonly ALPHA_ADD: number;
  31992. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31993. static readonly ALPHA_COMBINE: number;
  31994. /** Defines that alpha blending to DEST - SRC * DEST */
  31995. static readonly ALPHA_SUBTRACT: number;
  31996. /** Defines that alpha blending to SRC * DEST */
  31997. static readonly ALPHA_MULTIPLY: number;
  31998. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31999. static readonly ALPHA_MAXIMIZED: number;
  32000. /** Defines that alpha blending to SRC + DEST */
  32001. static readonly ALPHA_ONEONE: number;
  32002. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32003. static readonly ALPHA_PREMULTIPLIED: number;
  32004. /**
  32005. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32006. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32007. */
  32008. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32009. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32010. static readonly ALPHA_INTERPOLATE: number;
  32011. /**
  32012. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32013. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32014. */
  32015. static readonly ALPHA_SCREENMODE: number;
  32016. /** Defines that the ressource is not delayed*/
  32017. static readonly DELAYLOADSTATE_NONE: number;
  32018. /** Defines that the ressource was successfully delay loaded */
  32019. static readonly DELAYLOADSTATE_LOADED: number;
  32020. /** Defines that the ressource is currently delay loading */
  32021. static readonly DELAYLOADSTATE_LOADING: number;
  32022. /** Defines that the ressource is delayed and has not started loading */
  32023. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32025. static readonly NEVER: number;
  32026. /** 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 */
  32027. static readonly ALWAYS: number;
  32028. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32029. static readonly LESS: number;
  32030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32031. static readonly EQUAL: number;
  32032. /** 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 */
  32033. static readonly LEQUAL: number;
  32034. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32035. static readonly GREATER: number;
  32036. /** 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 */
  32037. static readonly GEQUAL: number;
  32038. /** 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 */
  32039. static readonly NOTEQUAL: number;
  32040. /** Passed to stencilOperation to specify that stencil value must be kept */
  32041. static readonly KEEP: number;
  32042. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32043. static readonly REPLACE: number;
  32044. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32045. static readonly INCR: number;
  32046. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32047. static readonly DECR: number;
  32048. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32049. static readonly INVERT: number;
  32050. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32051. static readonly INCR_WRAP: number;
  32052. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32053. static readonly DECR_WRAP: number;
  32054. /** Texture is not repeating outside of 0..1 UVs */
  32055. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32056. /** Texture is repeating outside of 0..1 UVs */
  32057. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32058. /** Texture is repeating and mirrored */
  32059. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32060. /** ALPHA */
  32061. static readonly TEXTUREFORMAT_ALPHA: number;
  32062. /** LUMINANCE */
  32063. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32064. /** LUMINANCE_ALPHA */
  32065. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32066. /** RGB */
  32067. static readonly TEXTUREFORMAT_RGB: number;
  32068. /** RGBA */
  32069. static readonly TEXTUREFORMAT_RGBA: number;
  32070. /** RED */
  32071. static readonly TEXTUREFORMAT_RED: number;
  32072. /** RED (2nd reference) */
  32073. static readonly TEXTUREFORMAT_R: number;
  32074. /** RG */
  32075. static readonly TEXTUREFORMAT_RG: number;
  32076. /** RED_INTEGER */
  32077. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32078. /** RED_INTEGER (2nd reference) */
  32079. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32080. /** RG_INTEGER */
  32081. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32082. /** RGB_INTEGER */
  32083. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32084. /** RGBA_INTEGER */
  32085. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32086. /** UNSIGNED_BYTE */
  32087. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32088. /** UNSIGNED_BYTE (2nd reference) */
  32089. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32090. /** FLOAT */
  32091. static readonly TEXTURETYPE_FLOAT: number;
  32092. /** HALF_FLOAT */
  32093. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32094. /** BYTE */
  32095. static readonly TEXTURETYPE_BYTE: number;
  32096. /** SHORT */
  32097. static readonly TEXTURETYPE_SHORT: number;
  32098. /** UNSIGNED_SHORT */
  32099. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32100. /** INT */
  32101. static readonly TEXTURETYPE_INT: number;
  32102. /** UNSIGNED_INT */
  32103. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32104. /** UNSIGNED_SHORT_4_4_4_4 */
  32105. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32106. /** UNSIGNED_SHORT_5_5_5_1 */
  32107. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32108. /** UNSIGNED_SHORT_5_6_5 */
  32109. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32110. /** UNSIGNED_INT_2_10_10_10_REV */
  32111. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32112. /** UNSIGNED_INT_24_8 */
  32113. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32114. /** UNSIGNED_INT_10F_11F_11F_REV */
  32115. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32116. /** UNSIGNED_INT_5_9_9_9_REV */
  32117. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32118. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32119. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32120. /** nearest is mag = nearest and min = nearest and mip = linear */
  32121. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32123. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32124. /** Trilinear is mag = linear and min = linear and mip = linear */
  32125. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32126. /** nearest is mag = nearest and min = nearest and mip = linear */
  32127. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32128. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32129. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32130. /** Trilinear is mag = linear and min = linear and mip = linear */
  32131. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32132. /** mag = nearest and min = nearest and mip = nearest */
  32133. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32134. /** mag = nearest and min = linear and mip = nearest */
  32135. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32136. /** mag = nearest and min = linear and mip = linear */
  32137. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32138. /** mag = nearest and min = linear and mip = none */
  32139. static readonly TEXTURE_NEAREST_LINEAR: number;
  32140. /** mag = nearest and min = nearest and mip = none */
  32141. static readonly TEXTURE_NEAREST_NEAREST: number;
  32142. /** mag = linear and min = nearest and mip = nearest */
  32143. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32144. /** mag = linear and min = nearest and mip = linear */
  32145. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32146. /** mag = linear and min = linear and mip = none */
  32147. static readonly TEXTURE_LINEAR_LINEAR: number;
  32148. /** mag = linear and min = nearest and mip = none */
  32149. static readonly TEXTURE_LINEAR_NEAREST: number;
  32150. /** Explicit coordinates mode */
  32151. static readonly TEXTURE_EXPLICIT_MODE: number;
  32152. /** Spherical coordinates mode */
  32153. static readonly TEXTURE_SPHERICAL_MODE: number;
  32154. /** Planar coordinates mode */
  32155. static readonly TEXTURE_PLANAR_MODE: number;
  32156. /** Cubic coordinates mode */
  32157. static readonly TEXTURE_CUBIC_MODE: number;
  32158. /** Projection coordinates mode */
  32159. static readonly TEXTURE_PROJECTION_MODE: number;
  32160. /** Skybox coordinates mode */
  32161. static readonly TEXTURE_SKYBOX_MODE: number;
  32162. /** Inverse Cubic coordinates mode */
  32163. static readonly TEXTURE_INVCUBIC_MODE: number;
  32164. /** Equirectangular coordinates mode */
  32165. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32166. /** Equirectangular Fixed coordinates mode */
  32167. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32168. /** Equirectangular Fixed Mirrored coordinates mode */
  32169. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32170. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32171. static readonly SCALEMODE_FLOOR: number;
  32172. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32173. static readonly SCALEMODE_NEAREST: number;
  32174. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32175. static readonly SCALEMODE_CEILING: number;
  32176. /**
  32177. * Returns the current npm package of the sdk
  32178. */
  32179. static readonly NpmPackage: string;
  32180. /**
  32181. * Returns the current version of the framework
  32182. */
  32183. static readonly Version: string;
  32184. /** Gets the list of created engines */
  32185. static readonly Instances: Engine[];
  32186. /**
  32187. * Gets the latest created engine
  32188. */
  32189. static readonly LastCreatedEngine: Nullable<Engine>;
  32190. /**
  32191. * Gets the latest created scene
  32192. */
  32193. static readonly LastCreatedScene: Nullable<Scene>;
  32194. /**
  32195. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32196. * @param flag defines which part of the materials must be marked as dirty
  32197. * @param predicate defines a predicate used to filter which materials should be affected
  32198. */
  32199. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32200. /**
  32201. * Method called to create the default loading screen.
  32202. * This can be overriden in your own app.
  32203. * @param canvas The rendering canvas element
  32204. * @returns The loading screen
  32205. */
  32206. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32207. /**
  32208. * Method called to create the default rescale post process on each engine.
  32209. */
  32210. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32211. /**
  32212. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32213. **/
  32214. enableOfflineSupport: boolean;
  32215. /**
  32216. * 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)
  32217. **/
  32218. disableManifestCheck: boolean;
  32219. /**
  32220. * Gets the list of created scenes
  32221. */
  32222. scenes: Scene[];
  32223. /**
  32224. * Event raised when a new scene is created
  32225. */
  32226. onNewSceneAddedObservable: Observable<Scene>;
  32227. /**
  32228. * Gets the list of created postprocesses
  32229. */
  32230. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32231. /**
  32232. * Gets a boolean indicating if the pointer is currently locked
  32233. */
  32234. isPointerLock: boolean;
  32235. /**
  32236. * Observable event triggered each time the rendering canvas is resized
  32237. */
  32238. onResizeObservable: Observable<Engine>;
  32239. /**
  32240. * Observable event triggered each time the canvas loses focus
  32241. */
  32242. onCanvasBlurObservable: Observable<Engine>;
  32243. /**
  32244. * Observable event triggered each time the canvas gains focus
  32245. */
  32246. onCanvasFocusObservable: Observable<Engine>;
  32247. /**
  32248. * Observable event triggered each time the canvas receives pointerout event
  32249. */
  32250. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32251. /**
  32252. * Observable raised when the engine begins a new frame
  32253. */
  32254. onBeginFrameObservable: Observable<Engine>;
  32255. /**
  32256. * If set, will be used to request the next animation frame for the render loop
  32257. */
  32258. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32259. /**
  32260. * Observable raised when the engine ends the current frame
  32261. */
  32262. onEndFrameObservable: Observable<Engine>;
  32263. /**
  32264. * Observable raised when the engine is about to compile a shader
  32265. */
  32266. onBeforeShaderCompilationObservable: Observable<Engine>;
  32267. /**
  32268. * Observable raised when the engine has jsut compiled a shader
  32269. */
  32270. onAfterShaderCompilationObservable: Observable<Engine>;
  32271. /**
  32272. * Gets the audio engine
  32273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32274. * @ignorenaming
  32275. */
  32276. static audioEngine: IAudioEngine;
  32277. /**
  32278. * Default AudioEngine factory responsible of creating the Audio Engine.
  32279. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32280. */
  32281. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32282. /**
  32283. * Default offline support factory responsible of creating a tool used to store data locally.
  32284. * By default, this will create a Database object if the workload has been embedded.
  32285. */
  32286. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32287. private _loadingScreen;
  32288. private _pointerLockRequested;
  32289. private _dummyFramebuffer;
  32290. private _rescalePostProcess;
  32291. /** @hidden */
  32292. protected _alphaMode: number;
  32293. /** @hidden */
  32294. protected _alphaEquation: number;
  32295. private _deterministicLockstep;
  32296. private _lockstepMaxSteps;
  32297. protected readonly _supportsHardwareTextureRescaling: boolean;
  32298. private _fps;
  32299. private _deltaTime;
  32300. /** @hidden */
  32301. _drawCalls: PerfCounter;
  32302. /**
  32303. * Turn this value on if you want to pause FPS computation when in background
  32304. */
  32305. disablePerformanceMonitorInBackground: boolean;
  32306. private _performanceMonitor;
  32307. /**
  32308. * Gets the performance monitor attached to this engine
  32309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32310. */
  32311. readonly performanceMonitor: PerformanceMonitor;
  32312. private _onFocus;
  32313. private _onBlur;
  32314. private _onCanvasPointerOut;
  32315. private _onCanvasBlur;
  32316. private _onCanvasFocus;
  32317. private _onFullscreenChange;
  32318. private _onPointerLockChange;
  32319. /**
  32320. * Creates a new engine
  32321. * @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
  32322. * @param antialias defines enable antialiasing (default: false)
  32323. * @param options defines further options to be sent to the getContext() function
  32324. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32325. */
  32326. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32327. /**
  32328. * Gets current aspect ratio
  32329. * @param viewportOwner defines the camera to use to get the aspect ratio
  32330. * @param useScreen defines if screen size must be used (or the current render target if any)
  32331. * @returns a number defining the aspect ratio
  32332. */
  32333. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32334. /**
  32335. * Gets current screen aspect ratio
  32336. * @returns a number defining the aspect ratio
  32337. */
  32338. getScreenAspectRatio(): number;
  32339. /**
  32340. * Gets host document
  32341. * @returns the host document object
  32342. */
  32343. getHostDocument(): Document;
  32344. /**
  32345. * Gets the client rect of the HTML canvas attached with the current webGL context
  32346. * @returns a client rectanglee
  32347. */
  32348. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32349. /**
  32350. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32352. * @returns true if engine is in deterministic lock step mode
  32353. */
  32354. isDeterministicLockStep(): boolean;
  32355. /**
  32356. * Gets the max steps when engine is running in deterministic lock step
  32357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32358. * @returns the max steps
  32359. */
  32360. getLockstepMaxSteps(): number;
  32361. /**
  32362. * Force the mipmap generation for the given render target texture
  32363. * @param texture defines the render target texture to use
  32364. */
  32365. generateMipMapsForCubemap(texture: InternalTexture): void;
  32366. /** States */
  32367. /**
  32368. * Set various states to the webGL context
  32369. * @param culling defines backface culling state
  32370. * @param zOffset defines the value to apply to zOffset (0 by default)
  32371. * @param force defines if states must be applied even if cache is up to date
  32372. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32373. */
  32374. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32375. /**
  32376. * Set the z offset to apply to current rendering
  32377. * @param value defines the offset to apply
  32378. */
  32379. setZOffset(value: number): void;
  32380. /**
  32381. * Gets the current value of the zOffset
  32382. * @returns the current zOffset state
  32383. */
  32384. getZOffset(): number;
  32385. /**
  32386. * Enable or disable depth buffering
  32387. * @param enable defines the state to set
  32388. */
  32389. setDepthBuffer(enable: boolean): void;
  32390. /**
  32391. * Gets a boolean indicating if depth writing is enabled
  32392. * @returns the current depth writing state
  32393. */
  32394. getDepthWrite(): boolean;
  32395. /**
  32396. * Enable or disable depth writing
  32397. * @param enable defines the state to set
  32398. */
  32399. setDepthWrite(enable: boolean): void;
  32400. /**
  32401. * Enable or disable color writing
  32402. * @param enable defines the state to set
  32403. */
  32404. setColorWrite(enable: boolean): void;
  32405. /**
  32406. * Gets a boolean indicating if color writing is enabled
  32407. * @returns the current color writing state
  32408. */
  32409. getColorWrite(): boolean;
  32410. /**
  32411. * Sets alpha constants used by some alpha blending modes
  32412. * @param r defines the red component
  32413. * @param g defines the green component
  32414. * @param b defines the blue component
  32415. * @param a defines the alpha component
  32416. */
  32417. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32418. /**
  32419. * Sets the current alpha mode
  32420. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32421. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32422. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32423. */
  32424. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32425. /**
  32426. * Gets the current alpha mode
  32427. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32428. * @returns the current alpha mode
  32429. */
  32430. getAlphaMode(): number;
  32431. /**
  32432. * Sets the current alpha equation
  32433. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32434. */
  32435. setAlphaEquation(equation: number): void;
  32436. /**
  32437. * Gets the current alpha equation.
  32438. * @returns the current alpha equation
  32439. */
  32440. getAlphaEquation(): number;
  32441. /**
  32442. * Gets a boolean indicating if stencil buffer is enabled
  32443. * @returns the current stencil buffer state
  32444. */
  32445. getStencilBuffer(): boolean;
  32446. /**
  32447. * Enable or disable the stencil buffer
  32448. * @param enable defines if the stencil buffer must be enabled or disabled
  32449. */
  32450. setStencilBuffer(enable: boolean): void;
  32451. /**
  32452. * Gets the current stencil mask
  32453. * @returns a number defining the new stencil mask to use
  32454. */
  32455. getStencilMask(): number;
  32456. /**
  32457. * Sets the current stencil mask
  32458. * @param mask defines the new stencil mask to use
  32459. */
  32460. setStencilMask(mask: number): void;
  32461. /**
  32462. * Gets the current stencil function
  32463. * @returns a number defining the stencil function to use
  32464. */
  32465. getStencilFunction(): number;
  32466. /**
  32467. * Gets the current stencil reference value
  32468. * @returns a number defining the stencil reference value to use
  32469. */
  32470. getStencilFunctionReference(): number;
  32471. /**
  32472. * Gets the current stencil mask
  32473. * @returns a number defining the stencil mask to use
  32474. */
  32475. getStencilFunctionMask(): number;
  32476. /**
  32477. * Sets the current stencil function
  32478. * @param stencilFunc defines the new stencil function to use
  32479. */
  32480. setStencilFunction(stencilFunc: number): void;
  32481. /**
  32482. * Sets the current stencil reference
  32483. * @param reference defines the new stencil reference to use
  32484. */
  32485. setStencilFunctionReference(reference: number): void;
  32486. /**
  32487. * Sets the current stencil mask
  32488. * @param mask defines the new stencil mask to use
  32489. */
  32490. setStencilFunctionMask(mask: number): void;
  32491. /**
  32492. * Gets the current stencil operation when stencil fails
  32493. * @returns a number defining stencil operation to use when stencil fails
  32494. */
  32495. getStencilOperationFail(): number;
  32496. /**
  32497. * Gets the current stencil operation when depth fails
  32498. * @returns a number defining stencil operation to use when depth fails
  32499. */
  32500. getStencilOperationDepthFail(): number;
  32501. /**
  32502. * Gets the current stencil operation when stencil passes
  32503. * @returns a number defining stencil operation to use when stencil passes
  32504. */
  32505. getStencilOperationPass(): number;
  32506. /**
  32507. * Sets the stencil operation to use when stencil fails
  32508. * @param operation defines the stencil operation to use when stencil fails
  32509. */
  32510. setStencilOperationFail(operation: number): void;
  32511. /**
  32512. * Sets the stencil operation to use when depth fails
  32513. * @param operation defines the stencil operation to use when depth fails
  32514. */
  32515. setStencilOperationDepthFail(operation: number): void;
  32516. /**
  32517. * Sets the stencil operation to use when stencil passes
  32518. * @param operation defines the stencil operation to use when stencil passes
  32519. */
  32520. setStencilOperationPass(operation: number): void;
  32521. /**
  32522. * Sets a boolean indicating if the dithering state is enabled or disabled
  32523. * @param value defines the dithering state
  32524. */
  32525. setDitheringState(value: boolean): void;
  32526. /**
  32527. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32528. * @param value defines the rasterizer state
  32529. */
  32530. setRasterizerState(value: boolean): void;
  32531. /**
  32532. * Gets the current depth function
  32533. * @returns a number defining the depth function
  32534. */
  32535. getDepthFunction(): Nullable<number>;
  32536. /**
  32537. * Sets the current depth function
  32538. * @param depthFunc defines the function to use
  32539. */
  32540. setDepthFunction(depthFunc: number): void;
  32541. /**
  32542. * Sets the current depth function to GREATER
  32543. */
  32544. setDepthFunctionToGreater(): void;
  32545. /**
  32546. * Sets the current depth function to GEQUAL
  32547. */
  32548. setDepthFunctionToGreaterOrEqual(): void;
  32549. /**
  32550. * Sets the current depth function to LESS
  32551. */
  32552. setDepthFunctionToLess(): void;
  32553. /**
  32554. * Sets the current depth function to LEQUAL
  32555. */
  32556. setDepthFunctionToLessOrEqual(): void;
  32557. private _cachedStencilBuffer;
  32558. private _cachedStencilFunction;
  32559. private _cachedStencilMask;
  32560. private _cachedStencilOperationPass;
  32561. private _cachedStencilOperationFail;
  32562. private _cachedStencilOperationDepthFail;
  32563. private _cachedStencilReference;
  32564. /**
  32565. * Caches the the state of the stencil buffer
  32566. */
  32567. cacheStencilState(): void;
  32568. /**
  32569. * Restores the state of the stencil buffer
  32570. */
  32571. restoreStencilState(): void;
  32572. /**
  32573. * Directly set the WebGL Viewport
  32574. * @param x defines the x coordinate of the viewport (in screen space)
  32575. * @param y defines the y coordinate of the viewport (in screen space)
  32576. * @param width defines the width of the viewport (in screen space)
  32577. * @param height defines the height of the viewport (in screen space)
  32578. * @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
  32579. */
  32580. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32581. /**
  32582. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32583. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32584. * @param y defines the y-coordinate of the corner of the clear rectangle
  32585. * @param width defines the width of the clear rectangle
  32586. * @param height defines the height of the clear rectangle
  32587. * @param clearColor defines the clear color
  32588. */
  32589. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32590. /**
  32591. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32592. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32593. * @param y defines the y-coordinate of the corner of the clear rectangle
  32594. * @param width defines the width of the clear rectangle
  32595. * @param height defines the height of the clear rectangle
  32596. */
  32597. enableScissor(x: number, y: number, width: number, height: number): void;
  32598. /**
  32599. * Disable previously set scissor test rectangle
  32600. */
  32601. disableScissor(): void;
  32602. protected _reportDrawCall(): void;
  32603. /**
  32604. * Initializes a webVR display and starts listening to display change events
  32605. * The onVRDisplayChangedObservable will be notified upon these changes
  32606. * @returns The onVRDisplayChangedObservable
  32607. */
  32608. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32609. /** @hidden */
  32610. _prepareVRComponent(): void;
  32611. /** @hidden */
  32612. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32613. /** @hidden */
  32614. _submitVRFrame(): void;
  32615. /**
  32616. * Call this function to leave webVR mode
  32617. * Will do nothing if webVR is not supported or if there is no webVR device
  32618. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32619. */
  32620. disableVR(): void;
  32621. /**
  32622. * Gets a boolean indicating that the system is in VR mode and is presenting
  32623. * @returns true if VR mode is engaged
  32624. */
  32625. isVRPresenting(): boolean;
  32626. /** @hidden */
  32627. _requestVRFrame(): void;
  32628. /** @hidden */
  32629. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32630. /**
  32631. * Gets the source code of the vertex shader associated with a specific webGL program
  32632. * @param program defines the program to use
  32633. * @returns a string containing the source code of the vertex shader associated with the program
  32634. */
  32635. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32636. /**
  32637. * Gets the source code of the fragment shader associated with a specific webGL program
  32638. * @param program defines the program to use
  32639. * @returns a string containing the source code of the fragment shader associated with the program
  32640. */
  32641. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32642. /**
  32643. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32644. * @param x defines the x coordinate of the rectangle where pixels must be read
  32645. * @param y defines the y coordinate of the rectangle where pixels must be read
  32646. * @param width defines the width of the rectangle where pixels must be read
  32647. * @param height defines the height of the rectangle where pixels must be read
  32648. * @returns a Uint8Array containing RGBA colors
  32649. */
  32650. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32651. /**
  32652. * Sets a depth stencil texture from a render target to the according uniform.
  32653. * @param channel The texture channel
  32654. * @param uniform The uniform to set
  32655. * @param texture The render target texture containing the depth stencil texture to apply
  32656. */
  32657. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32658. /**
  32659. * Sets a texture to the webGL context from a postprocess
  32660. * @param channel defines the channel to use
  32661. * @param postProcess defines the source postprocess
  32662. */
  32663. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32664. /**
  32665. * Binds the output of the passed in post process to the texture channel specified
  32666. * @param channel The channel the texture should be bound to
  32667. * @param postProcess The post process which's output should be bound
  32668. */
  32669. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32670. /** @hidden */
  32671. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32672. protected _rebuildBuffers(): void;
  32673. _renderLoop(): void;
  32674. /**
  32675. * Toggle full screen mode
  32676. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32677. */
  32678. switchFullscreen(requestPointerLock: boolean): void;
  32679. /**
  32680. * Enters full screen mode
  32681. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32682. */
  32683. enterFullscreen(requestPointerLock: boolean): void;
  32684. /**
  32685. * Exits full screen mode
  32686. */
  32687. exitFullscreen(): void;
  32688. /**
  32689. * Enters Pointerlock mode
  32690. */
  32691. enterPointerlock(): void;
  32692. /**
  32693. * Exits Pointerlock mode
  32694. */
  32695. exitPointerlock(): void;
  32696. /**
  32697. * Begin a new frame
  32698. */
  32699. beginFrame(): void;
  32700. /**
  32701. * Enf the current frame
  32702. */
  32703. endFrame(): void;
  32704. resize(): void;
  32705. /**
  32706. * Set the compressed texture format to use, based on the formats you have, and the formats
  32707. * supported by the hardware / browser.
  32708. *
  32709. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32710. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32711. * to API arguments needed to compressed textures. This puts the burden on the container
  32712. * generator to house the arcane code for determining these for current & future formats.
  32713. *
  32714. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32715. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32716. *
  32717. * Note: The result of this call is not taken into account when a texture is base64.
  32718. *
  32719. * @param formatsAvailable defines the list of those format families you have created
  32720. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32721. *
  32722. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32723. * @returns The extension selected.
  32724. */
  32725. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32726. /**
  32727. * Force a specific size of the canvas
  32728. * @param width defines the new canvas' width
  32729. * @param height defines the new canvas' height
  32730. */
  32731. setSize(width: number, height: number): void;
  32732. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32733. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32734. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32735. _releaseTexture(texture: InternalTexture): void;
  32736. /**
  32737. * @hidden
  32738. * Rescales a texture
  32739. * @param source input texutre
  32740. * @param destination destination texture
  32741. * @param scene scene to use to render the resize
  32742. * @param internalFormat format to use when resizing
  32743. * @param onComplete callback to be called when resize has completed
  32744. */
  32745. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32746. /**
  32747. * Gets the current framerate
  32748. * @returns a number representing the framerate
  32749. */
  32750. getFps(): number;
  32751. /**
  32752. * Gets the time spent between current and previous frame
  32753. * @returns a number representing the delta time in ms
  32754. */
  32755. getDeltaTime(): number;
  32756. private _measureFps;
  32757. /**
  32758. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32759. * @param renderTarget The render target to set the frame buffer for
  32760. */
  32761. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32762. /**
  32763. * Update a dynamic index buffer
  32764. * @param indexBuffer defines the target index buffer
  32765. * @param indices defines the data to update
  32766. * @param offset defines the offset in the target index buffer where update should start
  32767. */
  32768. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32769. /**
  32770. * Updates the sample count of a render target texture
  32771. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32772. * @param texture defines the texture to update
  32773. * @param samples defines the sample count to set
  32774. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32775. */
  32776. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32777. /** @hidden */
  32778. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32779. dispose(): void;
  32780. private _disableTouchAction;
  32781. /**
  32782. * Display the loading screen
  32783. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32784. */
  32785. displayLoadingUI(): void;
  32786. /**
  32787. * Hide the loading screen
  32788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32789. */
  32790. hideLoadingUI(): void;
  32791. /**
  32792. * Gets the current loading screen object
  32793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32794. */
  32795. /**
  32796. * Sets the current loading screen object
  32797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32798. */
  32799. loadingScreen: ILoadingScreen;
  32800. /**
  32801. * Sets the current loading screen text
  32802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32803. */
  32804. loadingUIText: string;
  32805. /**
  32806. * Sets the current loading screen background color
  32807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32808. */
  32809. loadingUIBackgroundColor: string;
  32810. /** Pointerlock and fullscreen */
  32811. /**
  32812. * Ask the browser to promote the current element to pointerlock mode
  32813. * @param element defines the DOM element to promote
  32814. */
  32815. static _RequestPointerlock(element: HTMLElement): void;
  32816. /**
  32817. * Asks the browser to exit pointerlock mode
  32818. */
  32819. static _ExitPointerlock(): void;
  32820. /**
  32821. * Ask the browser to promote the current element to fullscreen rendering mode
  32822. * @param element defines the DOM element to promote
  32823. */
  32824. static _RequestFullscreen(element: HTMLElement): void;
  32825. /**
  32826. * Asks the browser to exit fullscreen mode
  32827. */
  32828. static _ExitFullscreen(): void;
  32829. }
  32830. }
  32831. declare module "babylonjs/Engines/engineStore" {
  32832. import { Nullable } from "babylonjs/types";
  32833. import { Engine } from "babylonjs/Engines/engine";
  32834. import { Scene } from "babylonjs/scene";
  32835. /**
  32836. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32837. * during the life time of the application.
  32838. */
  32839. export class EngineStore {
  32840. /** Gets the list of created engines */
  32841. static Instances: import("babylonjs/Engines/engine").Engine[];
  32842. /** @hidden */
  32843. static _LastCreatedScene: Nullable<Scene>;
  32844. /**
  32845. * Gets the latest created engine
  32846. */
  32847. static readonly LastCreatedEngine: Nullable<Engine>;
  32848. /**
  32849. * Gets the latest created scene
  32850. */
  32851. static readonly LastCreatedScene: Nullable<Scene>;
  32852. /**
  32853. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32854. * @ignorenaming
  32855. */
  32856. static UseFallbackTexture: boolean;
  32857. /**
  32858. * Texture content used if a texture cannot loaded
  32859. * @ignorenaming
  32860. */
  32861. static FallbackTexture: string;
  32862. }
  32863. }
  32864. declare module "babylonjs/Misc/promise" {
  32865. /**
  32866. * Helper class that provides a small promise polyfill
  32867. */
  32868. export class PromisePolyfill {
  32869. /**
  32870. * Static function used to check if the polyfill is required
  32871. * If this is the case then the function will inject the polyfill to window.Promise
  32872. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32873. */
  32874. static Apply(force?: boolean): void;
  32875. }
  32876. }
  32877. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32878. /**
  32879. * Interface for screenshot methods with describe argument called `size` as object with options
  32880. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32881. */
  32882. export interface IScreenshotSize {
  32883. /**
  32884. * number in pixels for canvas height
  32885. */
  32886. height?: number;
  32887. /**
  32888. * multiplier allowing render at a higher or lower resolution
  32889. * If value is defined then height and width will be ignored and taken from camera
  32890. */
  32891. precision?: number;
  32892. /**
  32893. * number in pixels for canvas width
  32894. */
  32895. width?: number;
  32896. }
  32897. }
  32898. declare module "babylonjs/Misc/tools" {
  32899. import { Nullable, float } from "babylonjs/types";
  32900. import { DomManagement } from "babylonjs/Misc/domManagement";
  32901. import { WebRequest } from "babylonjs/Misc/webRequest";
  32902. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32903. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32904. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32905. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32906. import { Camera } from "babylonjs/Cameras/camera";
  32907. import { Engine } from "babylonjs/Engines/engine";
  32908. interface IColor4Like {
  32909. r: float;
  32910. g: float;
  32911. b: float;
  32912. a: float;
  32913. }
  32914. /**
  32915. * Class containing a set of static utilities functions
  32916. */
  32917. export class Tools {
  32918. /**
  32919. * Gets or sets the base URL to use to load assets
  32920. */
  32921. static BaseUrl: string;
  32922. /**
  32923. * Enable/Disable Custom HTTP Request Headers globally.
  32924. * default = false
  32925. * @see CustomRequestHeaders
  32926. */
  32927. static UseCustomRequestHeaders: boolean;
  32928. /**
  32929. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32930. * i.e. when loading files, where the server/service expects an Authorization header
  32931. */
  32932. static CustomRequestHeaders: {
  32933. [key: string]: string;
  32934. };
  32935. /**
  32936. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32937. */
  32938. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32939. /**
  32940. * Default behaviour for cors in the application.
  32941. * It can be a string if the expected behavior is identical in the entire app.
  32942. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32943. */
  32944. static CorsBehavior: string | ((url: string | string[]) => string);
  32945. /**
  32946. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32947. * @ignorenaming
  32948. */
  32949. static UseFallbackTexture: boolean;
  32950. /**
  32951. * Use this object to register external classes like custom textures or material
  32952. * to allow the laoders to instantiate them
  32953. */
  32954. static RegisteredExternalClasses: {
  32955. [key: string]: Object;
  32956. };
  32957. /**
  32958. * Texture content used if a texture cannot loaded
  32959. * @ignorenaming
  32960. */
  32961. static fallbackTexture: string;
  32962. /**
  32963. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32964. * @param u defines the coordinate on X axis
  32965. * @param v defines the coordinate on Y axis
  32966. * @param width defines the width of the source data
  32967. * @param height defines the height of the source data
  32968. * @param pixels defines the source byte array
  32969. * @param color defines the output color
  32970. */
  32971. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32972. /**
  32973. * Interpolates between a and b via alpha
  32974. * @param a The lower value (returned when alpha = 0)
  32975. * @param b The upper value (returned when alpha = 1)
  32976. * @param alpha The interpolation-factor
  32977. * @return The mixed value
  32978. */
  32979. static Mix(a: number, b: number, alpha: number): number;
  32980. /**
  32981. * Tries to instantiate a new object from a given class name
  32982. * @param className defines the class name to instantiate
  32983. * @returns the new object or null if the system was not able to do the instantiation
  32984. */
  32985. static Instantiate(className: string): any;
  32986. /**
  32987. * Provides a slice function that will work even on IE
  32988. * @param data defines the array to slice
  32989. * @param start defines the start of the data (optional)
  32990. * @param end defines the end of the data (optional)
  32991. * @returns the new sliced array
  32992. */
  32993. static Slice<T>(data: T, start?: number, end?: number): T;
  32994. /**
  32995. * Polyfill for setImmediate
  32996. * @param action defines the action to execute after the current execution block
  32997. */
  32998. static SetImmediate(action: () => void): void;
  32999. /**
  33000. * Function indicating if a number is an exponent of 2
  33001. * @param value defines the value to test
  33002. * @returns true if the value is an exponent of 2
  33003. */
  33004. static IsExponentOfTwo(value: number): boolean;
  33005. private static _tmpFloatArray;
  33006. /**
  33007. * Returns the nearest 32-bit single precision float representation of a Number
  33008. * @param value A Number. If the parameter is of a different type, it will get converted
  33009. * to a number or to NaN if it cannot be converted
  33010. * @returns number
  33011. */
  33012. static FloatRound(value: number): number;
  33013. /**
  33014. * Extracts the filename from a path
  33015. * @param path defines the path to use
  33016. * @returns the filename
  33017. */
  33018. static GetFilename(path: string): string;
  33019. /**
  33020. * Extracts the "folder" part of a path (everything before the filename).
  33021. * @param uri The URI to extract the info from
  33022. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33023. * @returns The "folder" part of the path
  33024. */
  33025. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33026. /**
  33027. * Extracts text content from a DOM element hierarchy
  33028. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33029. */
  33030. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33031. /**
  33032. * Convert an angle in radians to degrees
  33033. * @param angle defines the angle to convert
  33034. * @returns the angle in degrees
  33035. */
  33036. static ToDegrees(angle: number): number;
  33037. /**
  33038. * Convert an angle in degrees to radians
  33039. * @param angle defines the angle to convert
  33040. * @returns the angle in radians
  33041. */
  33042. static ToRadians(angle: number): number;
  33043. /**
  33044. * Encode a buffer to a base64 string
  33045. * @param buffer defines the buffer to encode
  33046. * @returns the encoded string
  33047. */
  33048. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  33049. /**
  33050. * Returns an array if obj is not an array
  33051. * @param obj defines the object to evaluate as an array
  33052. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33053. * @returns either obj directly if obj is an array or a new array containing obj
  33054. */
  33055. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33056. /**
  33057. * Gets the pointer prefix to use
  33058. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33059. */
  33060. static GetPointerPrefix(): string;
  33061. /**
  33062. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33063. * @param url define the url we are trying
  33064. * @param element define the dom element where to configure the cors policy
  33065. */
  33066. static SetCorsBehavior(url: string | string[], element: {
  33067. crossOrigin: string | null;
  33068. }): void;
  33069. /**
  33070. * Removes unwanted characters from an url
  33071. * @param url defines the url to clean
  33072. * @returns the cleaned url
  33073. */
  33074. static CleanUrl(url: string): string;
  33075. /**
  33076. * Gets or sets a function used to pre-process url before using them to load assets
  33077. */
  33078. static PreprocessUrl: (url: string) => string;
  33079. /**
  33080. * Loads an image as an HTMLImageElement.
  33081. * @param input url string, ArrayBuffer, or Blob to load
  33082. * @param onLoad callback called when the image successfully loads
  33083. * @param onError callback called when the image fails to load
  33084. * @param offlineProvider offline provider for caching
  33085. * @param mimeType optional mime type
  33086. * @returns the HTMLImageElement of the loaded image
  33087. */
  33088. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33089. /**
  33090. * Loads a file from a url
  33091. * @param url url string, ArrayBuffer, or Blob to load
  33092. * @param onSuccess callback called when the file successfully loads
  33093. * @param onProgress callback called while file is loading (if the server supports this mode)
  33094. * @param offlineProvider defines the offline provider for caching
  33095. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33096. * @param onError callback called when the file fails to load
  33097. * @returns a file request object
  33098. */
  33099. 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;
  33100. /**
  33101. * Loads a file from a url
  33102. * @param url the file url to load
  33103. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33104. */
  33105. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33106. /**
  33107. * Load a script (identified by an url). When the url returns, the
  33108. * content of this file is added into a new script element, attached to the DOM (body element)
  33109. * @param scriptUrl defines the url of the script to laod
  33110. * @param onSuccess defines the callback called when the script is loaded
  33111. * @param onError defines the callback to call if an error occurs
  33112. * @param scriptId defines the id of the script element
  33113. */
  33114. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33115. /**
  33116. * Load an asynchronous script (identified by an url). When the url returns, the
  33117. * content of this file is added into a new script element, attached to the DOM (body element)
  33118. * @param scriptUrl defines the url of the script to laod
  33119. * @param scriptId defines the id of the script element
  33120. * @returns a promise request object
  33121. */
  33122. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33123. /**
  33124. * Loads a file from a blob
  33125. * @param fileToLoad defines the blob to use
  33126. * @param callback defines the callback to call when data is loaded
  33127. * @param progressCallback defines the callback to call during loading process
  33128. * @returns a file request object
  33129. */
  33130. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33131. /**
  33132. * Reads a file from a File object
  33133. * @param file defines the file to load
  33134. * @param onSuccess defines the callback to call when data is loaded
  33135. * @param onProgress defines the callback to call during loading process
  33136. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33137. * @param onError defines the callback to call when an error occurs
  33138. * @returns a file request object
  33139. */
  33140. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33141. /**
  33142. * Creates a data url from a given string content
  33143. * @param content defines the content to convert
  33144. * @returns the new data url link
  33145. */
  33146. static FileAsURL(content: string): string;
  33147. /**
  33148. * Format the given number to a specific decimal format
  33149. * @param value defines the number to format
  33150. * @param decimals defines the number of decimals to use
  33151. * @returns the formatted string
  33152. */
  33153. static Format(value: number, decimals?: number): string;
  33154. /**
  33155. * Tries to copy an object by duplicating every property
  33156. * @param source defines the source object
  33157. * @param destination defines the target object
  33158. * @param doNotCopyList defines a list of properties to avoid
  33159. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33160. */
  33161. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33162. /**
  33163. * Gets a boolean indicating if the given object has no own property
  33164. * @param obj defines the object to test
  33165. * @returns true if object has no own property
  33166. */
  33167. static IsEmpty(obj: any): boolean;
  33168. /**
  33169. * Function used to register events at window level
  33170. * @param windowElement defines the Window object to use
  33171. * @param events defines the events to register
  33172. */
  33173. static RegisterTopRootEvents(windowElement: Window, events: {
  33174. name: string;
  33175. handler: Nullable<(e: FocusEvent) => any>;
  33176. }[]): void;
  33177. /**
  33178. * Function used to unregister events from window level
  33179. * @param windowElement defines the Window object to use
  33180. * @param events defines the events to unregister
  33181. */
  33182. static UnregisterTopRootEvents(windowElement: Window, events: {
  33183. name: string;
  33184. handler: Nullable<(e: FocusEvent) => any>;
  33185. }[]): void;
  33186. /**
  33187. * @ignore
  33188. */
  33189. static _ScreenshotCanvas: HTMLCanvasElement;
  33190. /**
  33191. * Dumps the current bound framebuffer
  33192. * @param width defines the rendering width
  33193. * @param height defines the rendering height
  33194. * @param engine defines the hosting engine
  33195. * @param successCallback defines the callback triggered once the data are available
  33196. * @param mimeType defines the mime type of the result
  33197. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33198. */
  33199. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33200. /**
  33201. * Converts the canvas data to blob.
  33202. * This acts as a polyfill for browsers not supporting the to blob function.
  33203. * @param canvas Defines the canvas to extract the data from
  33204. * @param successCallback Defines the callback triggered once the data are available
  33205. * @param mimeType Defines the mime type of the result
  33206. */
  33207. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33208. /**
  33209. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33210. * @param successCallback defines the callback triggered once the data are available
  33211. * @param mimeType defines the mime type of the result
  33212. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33213. */
  33214. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33215. /**
  33216. * Downloads a blob in the browser
  33217. * @param blob defines the blob to download
  33218. * @param fileName defines the name of the downloaded file
  33219. */
  33220. static Download(blob: Blob, fileName: string): void;
  33221. /**
  33222. * Captures a screenshot of the current rendering
  33223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33224. * @param engine defines the rendering engine
  33225. * @param camera defines the source camera
  33226. * @param size This parameter can be set to a single number or to an object with the
  33227. * following (optional) properties: precision, width, height. If a single number is passed,
  33228. * it will be used for both width and height. If an object is passed, the screenshot size
  33229. * will be derived from the parameters. The precision property is a multiplier allowing
  33230. * rendering at a higher or lower resolution
  33231. * @param successCallback defines the callback receives a single parameter which contains the
  33232. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33233. * src parameter of an <img> to display it
  33234. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33235. * Check your browser for supported MIME types
  33236. */
  33237. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33238. /**
  33239. * Captures a screenshot of the current rendering
  33240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33241. * @param engine defines the rendering engine
  33242. * @param camera defines the source camera
  33243. * @param size This parameter can be set to a single number or to an object with the
  33244. * following (optional) properties: precision, width, height. If a single number is passed,
  33245. * it will be used for both width and height. If an object is passed, the screenshot size
  33246. * will be derived from the parameters. The precision property is a multiplier allowing
  33247. * rendering at a higher or lower resolution
  33248. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33249. * Check your browser for supported MIME types
  33250. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33251. * to the src parameter of an <img> to display it
  33252. */
  33253. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33254. /**
  33255. * Generates an image screenshot from the specified camera.
  33256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33257. * @param engine The engine to use for rendering
  33258. * @param camera The camera to use for rendering
  33259. * @param size This parameter can be set to a single number or to an object with the
  33260. * following (optional) properties: precision, width, height. If a single number is passed,
  33261. * it will be used for both width and height. If an object is passed, the screenshot size
  33262. * will be derived from the parameters. The precision property is a multiplier allowing
  33263. * rendering at a higher or lower resolution
  33264. * @param successCallback The callback receives a single parameter which contains the
  33265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33266. * src parameter of an <img> to display it
  33267. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33268. * Check your browser for supported MIME types
  33269. * @param samples Texture samples (default: 1)
  33270. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33271. * @param fileName A name for for the downloaded file.
  33272. */
  33273. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33274. /**
  33275. * Generates an image screenshot from the specified camera.
  33276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33277. * @param engine The engine to use for rendering
  33278. * @param camera The camera to use for rendering
  33279. * @param size This parameter can be set to a single number or to an object with the
  33280. * following (optional) properties: precision, width, height. If a single number is passed,
  33281. * it will be used for both width and height. If an object is passed, the screenshot size
  33282. * will be derived from the parameters. The precision property is a multiplier allowing
  33283. * rendering at a higher or lower resolution
  33284. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33285. * Check your browser for supported MIME types
  33286. * @param samples Texture samples (default: 1)
  33287. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33288. * @param fileName A name for for the downloaded file.
  33289. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33290. * to the src parameter of an <img> to display it
  33291. */
  33292. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33293. /**
  33294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33295. * Be aware Math.random() could cause collisions, but:
  33296. * "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"
  33297. * @returns a pseudo random id
  33298. */
  33299. static RandomId(): string;
  33300. /**
  33301. * Test if the given uri is a base64 string
  33302. * @param uri The uri to test
  33303. * @return True if the uri is a base64 string or false otherwise
  33304. */
  33305. static IsBase64(uri: string): boolean;
  33306. /**
  33307. * Decode the given base64 uri.
  33308. * @param uri The uri to decode
  33309. * @return The decoded base64 data.
  33310. */
  33311. static DecodeBase64(uri: string): ArrayBuffer;
  33312. /**
  33313. * Gets the absolute url.
  33314. * @param url the input url
  33315. * @return the absolute url
  33316. */
  33317. static GetAbsoluteUrl(url: string): string;
  33318. /**
  33319. * No log
  33320. */
  33321. static readonly NoneLogLevel: number;
  33322. /**
  33323. * Only message logs
  33324. */
  33325. static readonly MessageLogLevel: number;
  33326. /**
  33327. * Only warning logs
  33328. */
  33329. static readonly WarningLogLevel: number;
  33330. /**
  33331. * Only error logs
  33332. */
  33333. static readonly ErrorLogLevel: number;
  33334. /**
  33335. * All logs
  33336. */
  33337. static readonly AllLogLevel: number;
  33338. /**
  33339. * Gets a value indicating the number of loading errors
  33340. * @ignorenaming
  33341. */
  33342. static readonly errorsCount: number;
  33343. /**
  33344. * Callback called when a new log is added
  33345. */
  33346. static OnNewCacheEntry: (entry: string) => void;
  33347. /**
  33348. * Log a message to the console
  33349. * @param message defines the message to log
  33350. */
  33351. static Log(message: string): void;
  33352. /**
  33353. * Write a warning message to the console
  33354. * @param message defines the message to log
  33355. */
  33356. static Warn(message: string): void;
  33357. /**
  33358. * Write an error message to the console
  33359. * @param message defines the message to log
  33360. */
  33361. static Error(message: string): void;
  33362. /**
  33363. * Gets current log cache (list of logs)
  33364. */
  33365. static readonly LogCache: string;
  33366. /**
  33367. * Clears the log cache
  33368. */
  33369. static ClearLogCache(): void;
  33370. /**
  33371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33372. */
  33373. static LogLevels: number;
  33374. /**
  33375. * Checks if the window object exists
  33376. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33377. */
  33378. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33379. /**
  33380. * No performance log
  33381. */
  33382. static readonly PerformanceNoneLogLevel: number;
  33383. /**
  33384. * Use user marks to log performance
  33385. */
  33386. static readonly PerformanceUserMarkLogLevel: number;
  33387. /**
  33388. * Log performance to the console
  33389. */
  33390. static readonly PerformanceConsoleLogLevel: number;
  33391. private static _performance;
  33392. /**
  33393. * Sets the current performance log level
  33394. */
  33395. static PerformanceLogLevel: number;
  33396. private static _StartPerformanceCounterDisabled;
  33397. private static _EndPerformanceCounterDisabled;
  33398. private static _StartUserMark;
  33399. private static _EndUserMark;
  33400. private static _StartPerformanceConsole;
  33401. private static _EndPerformanceConsole;
  33402. /**
  33403. * Starts a performance counter
  33404. */
  33405. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33406. /**
  33407. * Ends a specific performance coutner
  33408. */
  33409. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33410. /**
  33411. * Gets either window.performance.now() if supported or Date.now() else
  33412. */
  33413. static readonly Now: number;
  33414. /**
  33415. * This method will return the name of the class used to create the instance of the given object.
  33416. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33417. * @param object the object to get the class name from
  33418. * @param isType defines if the object is actually a type
  33419. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33420. */
  33421. static GetClassName(object: any, isType?: boolean): string;
  33422. /**
  33423. * Gets the first element of an array satisfying a given predicate
  33424. * @param array defines the array to browse
  33425. * @param predicate defines the predicate to use
  33426. * @returns null if not found or the element
  33427. */
  33428. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33429. /**
  33430. * This method will return the name of the full name of the class, including its owning module (if any).
  33431. * 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).
  33432. * @param object the object to get the class name from
  33433. * @param isType defines if the object is actually a type
  33434. * @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.
  33435. * @ignorenaming
  33436. */
  33437. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33438. /**
  33439. * Returns a promise that resolves after the given amount of time.
  33440. * @param delay Number of milliseconds to delay
  33441. * @returns Promise that resolves after the given amount of time
  33442. */
  33443. static DelayAsync(delay: number): Promise<void>;
  33444. }
  33445. /**
  33446. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33447. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33448. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33449. * @param name The name of the class, case should be preserved
  33450. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33451. */
  33452. export function className(name: string, module?: string): (target: Object) => void;
  33453. /**
  33454. * An implementation of a loop for asynchronous functions.
  33455. */
  33456. export class AsyncLoop {
  33457. /**
  33458. * Defines the number of iterations for the loop
  33459. */
  33460. iterations: number;
  33461. /**
  33462. * Defines the current index of the loop.
  33463. */
  33464. index: number;
  33465. private _done;
  33466. private _fn;
  33467. private _successCallback;
  33468. /**
  33469. * Constructor.
  33470. * @param iterations the number of iterations.
  33471. * @param func the function to run each iteration
  33472. * @param successCallback the callback that will be called upon succesful execution
  33473. * @param offset starting offset.
  33474. */
  33475. constructor(
  33476. /**
  33477. * Defines the number of iterations for the loop
  33478. */
  33479. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33480. /**
  33481. * Execute the next iteration. Must be called after the last iteration was finished.
  33482. */
  33483. executeNext(): void;
  33484. /**
  33485. * Break the loop and run the success callback.
  33486. */
  33487. breakLoop(): void;
  33488. /**
  33489. * Create and run an async loop.
  33490. * @param iterations the number of iterations.
  33491. * @param fn the function to run each iteration
  33492. * @param successCallback the callback that will be called upon succesful execution
  33493. * @param offset starting offset.
  33494. * @returns the created async loop object
  33495. */
  33496. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33497. /**
  33498. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33499. * @param iterations total number of iterations
  33500. * @param syncedIterations number of synchronous iterations in each async iteration.
  33501. * @param fn the function to call each iteration.
  33502. * @param callback a success call back that will be called when iterating stops.
  33503. * @param breakFunction a break condition (optional)
  33504. * @param timeout timeout settings for the setTimeout function. default - 0.
  33505. * @returns the created async loop object
  33506. */
  33507. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33508. }
  33509. }
  33510. declare module "babylonjs/Misc/stringDictionary" {
  33511. import { Nullable } from "babylonjs/types";
  33512. /**
  33513. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33514. * The underlying implementation relies on an associative array to ensure the best performances.
  33515. * The value can be anything including 'null' but except 'undefined'
  33516. */
  33517. export class StringDictionary<T> {
  33518. /**
  33519. * This will clear this dictionary and copy the content from the 'source' one.
  33520. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33521. * @param source the dictionary to take the content from and copy to this dictionary
  33522. */
  33523. copyFrom(source: StringDictionary<T>): void;
  33524. /**
  33525. * Get a value based from its key
  33526. * @param key the given key to get the matching value from
  33527. * @return the value if found, otherwise undefined is returned
  33528. */
  33529. get(key: string): T | undefined;
  33530. /**
  33531. * Get a value from its key or add it if it doesn't exist.
  33532. * This method will ensure you that a given key/data will be present in the dictionary.
  33533. * @param key the given key to get the matching value from
  33534. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33535. * The factory will only be invoked if there's no data for the given key.
  33536. * @return the value corresponding to the key.
  33537. */
  33538. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33539. /**
  33540. * Get a value from its key if present in the dictionary otherwise add it
  33541. * @param key the key to get the value from
  33542. * @param val if there's no such key/value pair in the dictionary add it with this value
  33543. * @return the value corresponding to the key
  33544. */
  33545. getOrAdd(key: string, val: T): T;
  33546. /**
  33547. * Check if there's a given key in the dictionary
  33548. * @param key the key to check for
  33549. * @return true if the key is present, false otherwise
  33550. */
  33551. contains(key: string): boolean;
  33552. /**
  33553. * Add a new key and its corresponding value
  33554. * @param key the key to add
  33555. * @param value the value corresponding to the key
  33556. * @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
  33557. */
  33558. add(key: string, value: T): boolean;
  33559. /**
  33560. * Update a specific value associated to a key
  33561. * @param key defines the key to use
  33562. * @param value defines the value to store
  33563. * @returns true if the value was updated (or false if the key was not found)
  33564. */
  33565. set(key: string, value: T): boolean;
  33566. /**
  33567. * Get the element of the given key and remove it from the dictionary
  33568. * @param key defines the key to search
  33569. * @returns the value associated with the key or null if not found
  33570. */
  33571. getAndRemove(key: string): Nullable<T>;
  33572. /**
  33573. * Remove a key/value from the dictionary.
  33574. * @param key the key to remove
  33575. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33576. */
  33577. remove(key: string): boolean;
  33578. /**
  33579. * Clear the whole content of the dictionary
  33580. */
  33581. clear(): void;
  33582. /**
  33583. * Gets the current count
  33584. */
  33585. readonly count: number;
  33586. /**
  33587. * Execute a callback on each key/val of the dictionary.
  33588. * Note that you can remove any element in this dictionary in the callback implementation
  33589. * @param callback the callback to execute on a given key/value pair
  33590. */
  33591. forEach(callback: (key: string, val: T) => void): void;
  33592. /**
  33593. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33594. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33595. * Note that you can remove any element in this dictionary in the callback implementation
  33596. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33597. * @returns the first item
  33598. */
  33599. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33600. private _count;
  33601. private _data;
  33602. }
  33603. }
  33604. declare module "babylonjs/Collisions/collisionCoordinator" {
  33605. import { Nullable } from "babylonjs/types";
  33606. import { Scene } from "babylonjs/scene";
  33607. import { Vector3 } from "babylonjs/Maths/math.vector";
  33608. import { Collider } from "babylonjs/Collisions/collider";
  33609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33610. /** @hidden */
  33611. export interface ICollisionCoordinator {
  33612. createCollider(): Collider;
  33613. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33614. init(scene: Scene): void;
  33615. }
  33616. /** @hidden */
  33617. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33618. private _scene;
  33619. private _scaledPosition;
  33620. private _scaledVelocity;
  33621. private _finalPosition;
  33622. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33623. createCollider(): Collider;
  33624. init(scene: Scene): void;
  33625. private _collideWithWorld;
  33626. }
  33627. }
  33628. declare module "babylonjs/Inputs/scene.inputManager" {
  33629. import { Nullable } from "babylonjs/types";
  33630. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33631. import { Vector2 } from "babylonjs/Maths/math.vector";
  33632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33633. import { Scene } from "babylonjs/scene";
  33634. /**
  33635. * Class used to manage all inputs for the scene.
  33636. */
  33637. export class InputManager {
  33638. /** The distance in pixel that you have to move to prevent some events */
  33639. static DragMovementThreshold: number;
  33640. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33641. static LongPressDelay: number;
  33642. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33643. static DoubleClickDelay: number;
  33644. /** If you need to check double click without raising a single click at first click, enable this flag */
  33645. static ExclusiveDoubleClickMode: boolean;
  33646. private _wheelEventName;
  33647. private _onPointerMove;
  33648. private _onPointerDown;
  33649. private _onPointerUp;
  33650. private _initClickEvent;
  33651. private _initActionManager;
  33652. private _delayedSimpleClick;
  33653. private _delayedSimpleClickTimeout;
  33654. private _previousDelayedSimpleClickTimeout;
  33655. private _meshPickProceed;
  33656. private _previousButtonPressed;
  33657. private _currentPickResult;
  33658. private _previousPickResult;
  33659. private _totalPointersPressed;
  33660. private _doubleClickOccured;
  33661. private _pointerOverMesh;
  33662. private _pickedDownMesh;
  33663. private _pickedUpMesh;
  33664. private _pointerX;
  33665. private _pointerY;
  33666. private _unTranslatedPointerX;
  33667. private _unTranslatedPointerY;
  33668. private _startingPointerPosition;
  33669. private _previousStartingPointerPosition;
  33670. private _startingPointerTime;
  33671. private _previousStartingPointerTime;
  33672. private _pointerCaptures;
  33673. private _onKeyDown;
  33674. private _onKeyUp;
  33675. private _onCanvasFocusObserver;
  33676. private _onCanvasBlurObserver;
  33677. private _scene;
  33678. /**
  33679. * Creates a new InputManager
  33680. * @param scene defines the hosting scene
  33681. */
  33682. constructor(scene: Scene);
  33683. /**
  33684. * Gets the mesh that is currently under the pointer
  33685. */
  33686. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33687. /**
  33688. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33689. */
  33690. readonly unTranslatedPointer: Vector2;
  33691. /**
  33692. * Gets or sets the current on-screen X position of the pointer
  33693. */
  33694. pointerX: number;
  33695. /**
  33696. * Gets or sets the current on-screen Y position of the pointer
  33697. */
  33698. pointerY: number;
  33699. private _updatePointerPosition;
  33700. private _processPointerMove;
  33701. private _setRayOnPointerInfo;
  33702. private _checkPrePointerObservable;
  33703. /**
  33704. * Use this method to simulate a pointer move on a mesh
  33705. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33706. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33707. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33708. */
  33709. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33710. /**
  33711. * Use this method to simulate a pointer down on a mesh
  33712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33715. */
  33716. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33717. private _processPointerDown;
  33718. /** @hidden */
  33719. _isPointerSwiping(): boolean;
  33720. /**
  33721. * Use this method to simulate a pointer up on a mesh
  33722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33726. */
  33727. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33728. private _processPointerUp;
  33729. /**
  33730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33732. * @returns true if the pointer was captured
  33733. */
  33734. isPointerCaptured(pointerId?: number): boolean;
  33735. /**
  33736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33737. * @param attachUp defines if you want to attach events to pointerup
  33738. * @param attachDown defines if you want to attach events to pointerdown
  33739. * @param attachMove defines if you want to attach events to pointermove
  33740. */
  33741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33742. /**
  33743. * Detaches all event handlers
  33744. */
  33745. detachControl(): void;
  33746. /**
  33747. * Force the value of meshUnderPointer
  33748. * @param mesh defines the mesh to use
  33749. */
  33750. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33751. /**
  33752. * Gets the mesh under the pointer
  33753. * @returns a Mesh or null if no mesh is under the pointer
  33754. */
  33755. getPointerOverMesh(): Nullable<AbstractMesh>;
  33756. }
  33757. }
  33758. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33759. /**
  33760. * Helper class used to generate session unique ID
  33761. */
  33762. export class UniqueIdGenerator {
  33763. private static _UniqueIdCounter;
  33764. /**
  33765. * Gets an unique (relatively to the current scene) Id
  33766. */
  33767. static readonly UniqueId: number;
  33768. }
  33769. }
  33770. declare module "babylonjs/Animations/animationGroup" {
  33771. import { Animatable } from "babylonjs/Animations/animatable";
  33772. import { Animation } from "babylonjs/Animations/animation";
  33773. import { Scene, IDisposable } from "babylonjs/scene";
  33774. import { Observable } from "babylonjs/Misc/observable";
  33775. import { Nullable } from "babylonjs/types";
  33776. import "babylonjs/Animations/animatable";
  33777. /**
  33778. * This class defines the direct association between an animation and a target
  33779. */
  33780. export class TargetedAnimation {
  33781. /**
  33782. * Animation to perform
  33783. */
  33784. animation: Animation;
  33785. /**
  33786. * Target to animate
  33787. */
  33788. target: any;
  33789. /**
  33790. * Serialize the object
  33791. * @returns the JSON object representing the current entity
  33792. */
  33793. serialize(): any;
  33794. }
  33795. /**
  33796. * Use this class to create coordinated animations on multiple targets
  33797. */
  33798. export class AnimationGroup implements IDisposable {
  33799. /** The name of the animation group */
  33800. name: string;
  33801. private _scene;
  33802. private _targetedAnimations;
  33803. private _animatables;
  33804. private _from;
  33805. private _to;
  33806. private _isStarted;
  33807. private _isPaused;
  33808. private _speedRatio;
  33809. private _loopAnimation;
  33810. /**
  33811. * Gets or sets the unique id of the node
  33812. */
  33813. uniqueId: number;
  33814. /**
  33815. * This observable will notify when one animation have ended
  33816. */
  33817. onAnimationEndObservable: Observable<TargetedAnimation>;
  33818. /**
  33819. * Observer raised when one animation loops
  33820. */
  33821. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33822. /**
  33823. * This observable will notify when all animations have ended.
  33824. */
  33825. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33826. /**
  33827. * This observable will notify when all animations have paused.
  33828. */
  33829. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33830. /**
  33831. * This observable will notify when all animations are playing.
  33832. */
  33833. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33834. /**
  33835. * Gets the first frame
  33836. */
  33837. readonly from: number;
  33838. /**
  33839. * Gets the last frame
  33840. */
  33841. readonly to: number;
  33842. /**
  33843. * Define if the animations are started
  33844. */
  33845. readonly isStarted: boolean;
  33846. /**
  33847. * Gets a value indicating that the current group is playing
  33848. */
  33849. readonly isPlaying: boolean;
  33850. /**
  33851. * Gets or sets the speed ratio to use for all animations
  33852. */
  33853. /**
  33854. * Gets or sets the speed ratio to use for all animations
  33855. */
  33856. speedRatio: number;
  33857. /**
  33858. * Gets or sets if all animations should loop or not
  33859. */
  33860. loopAnimation: boolean;
  33861. /**
  33862. * Gets the targeted animations for this animation group
  33863. */
  33864. readonly targetedAnimations: Array<TargetedAnimation>;
  33865. /**
  33866. * returning the list of animatables controlled by this animation group.
  33867. */
  33868. readonly animatables: Array<Animatable>;
  33869. /**
  33870. * Instantiates a new Animation Group.
  33871. * This helps managing several animations at once.
  33872. * @see http://doc.babylonjs.com/how_to/group
  33873. * @param name Defines the name of the group
  33874. * @param scene Defines the scene the group belongs to
  33875. */
  33876. constructor(
  33877. /** The name of the animation group */
  33878. name: string, scene?: Nullable<Scene>);
  33879. /**
  33880. * Add an animation (with its target) in the group
  33881. * @param animation defines the animation we want to add
  33882. * @param target defines the target of the animation
  33883. * @returns the TargetedAnimation object
  33884. */
  33885. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33886. /**
  33887. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33888. * It can add constant keys at begin or end
  33889. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33890. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33891. * @returns the animation group
  33892. */
  33893. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33894. /**
  33895. * Start all animations on given targets
  33896. * @param loop defines if animations must loop
  33897. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33898. * @param from defines the from key (optional)
  33899. * @param to defines the to key (optional)
  33900. * @returns the current animation group
  33901. */
  33902. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33903. /**
  33904. * Pause all animations
  33905. * @returns the animation group
  33906. */
  33907. pause(): AnimationGroup;
  33908. /**
  33909. * Play all animations to initial state
  33910. * This function will start() the animations if they were not started or will restart() them if they were paused
  33911. * @param loop defines if animations must loop
  33912. * @returns the animation group
  33913. */
  33914. play(loop?: boolean): AnimationGroup;
  33915. /**
  33916. * Reset all animations to initial state
  33917. * @returns the animation group
  33918. */
  33919. reset(): AnimationGroup;
  33920. /**
  33921. * Restart animations from key 0
  33922. * @returns the animation group
  33923. */
  33924. restart(): AnimationGroup;
  33925. /**
  33926. * Stop all animations
  33927. * @returns the animation group
  33928. */
  33929. stop(): AnimationGroup;
  33930. /**
  33931. * Set animation weight for all animatables
  33932. * @param weight defines the weight to use
  33933. * @return the animationGroup
  33934. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33935. */
  33936. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33937. /**
  33938. * Synchronize and normalize all animatables with a source animatable
  33939. * @param root defines the root animatable to synchronize with
  33940. * @return the animationGroup
  33941. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33942. */
  33943. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33944. /**
  33945. * Goes to a specific frame in this animation group
  33946. * @param frame the frame number to go to
  33947. * @return the animationGroup
  33948. */
  33949. goToFrame(frame: number): AnimationGroup;
  33950. /**
  33951. * Dispose all associated resources
  33952. */
  33953. dispose(): void;
  33954. private _checkAnimationGroupEnded;
  33955. /**
  33956. * Clone the current animation group and returns a copy
  33957. * @param newName defines the name of the new group
  33958. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33959. * @returns the new aniamtion group
  33960. */
  33961. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33962. /**
  33963. * Serializes the animationGroup to an object
  33964. * @returns Serialized object
  33965. */
  33966. serialize(): any;
  33967. /**
  33968. * Returns a new AnimationGroup object parsed from the source provided.
  33969. * @param parsedAnimationGroup defines the source
  33970. * @param scene defines the scene that will receive the animationGroup
  33971. * @returns a new AnimationGroup
  33972. */
  33973. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33974. /**
  33975. * Returns the string "AnimationGroup"
  33976. * @returns "AnimationGroup"
  33977. */
  33978. getClassName(): string;
  33979. /**
  33980. * Creates a detailled string about the object
  33981. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33982. * @returns a string representing the object
  33983. */
  33984. toString(fullDetails?: boolean): string;
  33985. }
  33986. }
  33987. declare module "babylonjs/scene" {
  33988. import { Nullable } from "babylonjs/types";
  33989. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33990. import { Observable } from "babylonjs/Misc/observable";
  33991. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33992. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33993. import { Geometry } from "babylonjs/Meshes/geometry";
  33994. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33995. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33997. import { Mesh } from "babylonjs/Meshes/mesh";
  33998. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33999. import { Bone } from "babylonjs/Bones/bone";
  34000. import { Skeleton } from "babylonjs/Bones/skeleton";
  34001. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34002. import { Camera } from "babylonjs/Cameras/camera";
  34003. import { AbstractScene } from "babylonjs/abstractScene";
  34004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34006. import { Material } from "babylonjs/Materials/material";
  34007. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34008. import { Effect } from "babylonjs/Materials/effect";
  34009. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34010. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34011. import { Light } from "babylonjs/Lights/light";
  34012. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34013. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34014. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34015. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34017. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34018. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34019. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34020. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34021. import { Engine } from "babylonjs/Engines/engine";
  34022. import { Node } from "babylonjs/node";
  34023. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34024. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34025. import { WebRequest } from "babylonjs/Misc/webRequest";
  34026. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34027. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34028. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34029. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34030. import { Plane } from "babylonjs/Maths/math.plane";
  34031. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34032. import { Ray } from "babylonjs/Culling/ray";
  34033. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34034. import { Animation } from "babylonjs/Animations/animation";
  34035. import { Animatable } from "babylonjs/Animations/animatable";
  34036. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34037. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34038. import { Collider } from "babylonjs/Collisions/collider";
  34039. /**
  34040. * Define an interface for all classes that will hold resources
  34041. */
  34042. export interface IDisposable {
  34043. /**
  34044. * Releases all held resources
  34045. */
  34046. dispose(): void;
  34047. }
  34048. /** Interface defining initialization parameters for Scene class */
  34049. export interface SceneOptions {
  34050. /**
  34051. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34052. * It will improve performance when the number of geometries becomes important.
  34053. */
  34054. useGeometryUniqueIdsMap?: boolean;
  34055. /**
  34056. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34057. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34058. */
  34059. useMaterialMeshMap?: boolean;
  34060. /**
  34061. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34062. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34063. */
  34064. useClonedMeshhMap?: boolean;
  34065. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34066. virtual?: boolean;
  34067. }
  34068. /**
  34069. * Represents a scene to be rendered by the engine.
  34070. * @see http://doc.babylonjs.com/features/scene
  34071. */
  34072. export class Scene extends AbstractScene implements IAnimatable {
  34073. /** The fog is deactivated */
  34074. static readonly FOGMODE_NONE: number;
  34075. /** The fog density is following an exponential function */
  34076. static readonly FOGMODE_EXP: number;
  34077. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34078. static readonly FOGMODE_EXP2: number;
  34079. /** The fog density is following a linear function. */
  34080. static readonly FOGMODE_LINEAR: number;
  34081. /**
  34082. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34084. */
  34085. static MinDeltaTime: number;
  34086. /**
  34087. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34088. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34089. */
  34090. static MaxDeltaTime: number;
  34091. /**
  34092. * Factory used to create the default material.
  34093. * @param name The name of the material to create
  34094. * @param scene The scene to create the material for
  34095. * @returns The default material
  34096. */
  34097. static DefaultMaterialFactory(scene: Scene): Material;
  34098. /**
  34099. * Factory used to create the a collision coordinator.
  34100. * @returns The collision coordinator
  34101. */
  34102. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34103. /** @hidden */
  34104. _inputManager: InputManager;
  34105. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34106. cameraToUseForPointers: Nullable<Camera>;
  34107. /** @hidden */
  34108. readonly _isScene: boolean;
  34109. /**
  34110. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34111. */
  34112. autoClear: boolean;
  34113. /**
  34114. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34115. */
  34116. autoClearDepthAndStencil: boolean;
  34117. /**
  34118. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34119. */
  34120. clearColor: Color4;
  34121. /**
  34122. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34123. */
  34124. ambientColor: Color3;
  34125. /**
  34126. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34127. * It should only be one of the following (if not the default embedded one):
  34128. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34129. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34130. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34131. * The material properties need to be setup according to the type of texture in use.
  34132. */
  34133. environmentBRDFTexture: BaseTexture;
  34134. /** @hidden */
  34135. protected _environmentTexture: Nullable<BaseTexture>;
  34136. /**
  34137. * Texture used in all pbr material as the reflection texture.
  34138. * As in the majority of the scene they are the same (exception for multi room and so on),
  34139. * this is easier to reference from here than from all the materials.
  34140. */
  34141. /**
  34142. * Texture used in all pbr material as the reflection texture.
  34143. * As in the majority of the scene they are the same (exception for multi room and so on),
  34144. * this is easier to set here than in all the materials.
  34145. */
  34146. environmentTexture: Nullable<BaseTexture>;
  34147. /** @hidden */
  34148. protected _environmentIntensity: number;
  34149. /**
  34150. * Intensity of the environment in all pbr material.
  34151. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34152. * As in the majority of the scene they are the same (exception for multi room and so on),
  34153. * this is easier to reference from here than from all the materials.
  34154. */
  34155. /**
  34156. * Intensity of the environment in all pbr material.
  34157. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34158. * As in the majority of the scene they are the same (exception for multi room and so on),
  34159. * this is easier to set here than in all the materials.
  34160. */
  34161. environmentIntensity: number;
  34162. /** @hidden */
  34163. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34164. /**
  34165. * Default image processing configuration used either in the rendering
  34166. * Forward main pass or through the imageProcessingPostProcess if present.
  34167. * As in the majority of the scene they are the same (exception for multi camera),
  34168. * this is easier to reference from here than from all the materials and post process.
  34169. *
  34170. * No setter as we it is a shared configuration, you can set the values instead.
  34171. */
  34172. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34173. private _forceWireframe;
  34174. /**
  34175. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34176. */
  34177. forceWireframe: boolean;
  34178. private _forcePointsCloud;
  34179. /**
  34180. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34181. */
  34182. forcePointsCloud: boolean;
  34183. /**
  34184. * Gets or sets the active clipplane 1
  34185. */
  34186. clipPlane: Nullable<Plane>;
  34187. /**
  34188. * Gets or sets the active clipplane 2
  34189. */
  34190. clipPlane2: Nullable<Plane>;
  34191. /**
  34192. * Gets or sets the active clipplane 3
  34193. */
  34194. clipPlane3: Nullable<Plane>;
  34195. /**
  34196. * Gets or sets the active clipplane 4
  34197. */
  34198. clipPlane4: Nullable<Plane>;
  34199. /**
  34200. * Gets or sets a boolean indicating if animations are enabled
  34201. */
  34202. animationsEnabled: boolean;
  34203. private _animationPropertiesOverride;
  34204. /**
  34205. * Gets or sets the animation properties override
  34206. */
  34207. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34208. /**
  34209. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34210. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34211. */
  34212. useConstantAnimationDeltaTime: boolean;
  34213. /**
  34214. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34215. * Please note that it requires to run a ray cast through the scene on every frame
  34216. */
  34217. constantlyUpdateMeshUnderPointer: boolean;
  34218. /**
  34219. * Defines the HTML cursor to use when hovering over interactive elements
  34220. */
  34221. hoverCursor: string;
  34222. /**
  34223. * Defines the HTML default cursor to use (empty by default)
  34224. */
  34225. defaultCursor: string;
  34226. /**
  34227. * Defines wether cursors are handled by the scene.
  34228. */
  34229. doNotHandleCursors: boolean;
  34230. /**
  34231. * This is used to call preventDefault() on pointer down
  34232. * in order to block unwanted artifacts like system double clicks
  34233. */
  34234. preventDefaultOnPointerDown: boolean;
  34235. /**
  34236. * This is used to call preventDefault() on pointer up
  34237. * in order to block unwanted artifacts like system double clicks
  34238. */
  34239. preventDefaultOnPointerUp: boolean;
  34240. /**
  34241. * Gets or sets user defined metadata
  34242. */
  34243. metadata: any;
  34244. /**
  34245. * For internal use only. Please do not use.
  34246. */
  34247. reservedDataStore: any;
  34248. /**
  34249. * Gets the name of the plugin used to load this scene (null by default)
  34250. */
  34251. loadingPluginName: string;
  34252. /**
  34253. * Use this array to add regular expressions used to disable offline support for specific urls
  34254. */
  34255. disableOfflineSupportExceptionRules: RegExp[];
  34256. /**
  34257. * An event triggered when the scene is disposed.
  34258. */
  34259. onDisposeObservable: Observable<Scene>;
  34260. private _onDisposeObserver;
  34261. /** Sets a function to be executed when this scene is disposed. */
  34262. onDispose: () => void;
  34263. /**
  34264. * An event triggered before rendering the scene (right after animations and physics)
  34265. */
  34266. onBeforeRenderObservable: Observable<Scene>;
  34267. private _onBeforeRenderObserver;
  34268. /** Sets a function to be executed before rendering this scene */
  34269. beforeRender: Nullable<() => void>;
  34270. /**
  34271. * An event triggered after rendering the scene
  34272. */
  34273. onAfterRenderObservable: Observable<Scene>;
  34274. /**
  34275. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34276. */
  34277. onAfterRenderCameraObservable: Observable<Camera>;
  34278. private _onAfterRenderObserver;
  34279. /** Sets a function to be executed after rendering this scene */
  34280. afterRender: Nullable<() => void>;
  34281. /**
  34282. * An event triggered before animating the scene
  34283. */
  34284. onBeforeAnimationsObservable: Observable<Scene>;
  34285. /**
  34286. * An event triggered after animations processing
  34287. */
  34288. onAfterAnimationsObservable: Observable<Scene>;
  34289. /**
  34290. * An event triggered before draw calls are ready to be sent
  34291. */
  34292. onBeforeDrawPhaseObservable: Observable<Scene>;
  34293. /**
  34294. * An event triggered after draw calls have been sent
  34295. */
  34296. onAfterDrawPhaseObservable: Observable<Scene>;
  34297. /**
  34298. * An event triggered when the scene is ready
  34299. */
  34300. onReadyObservable: Observable<Scene>;
  34301. /**
  34302. * An event triggered before rendering a camera
  34303. */
  34304. onBeforeCameraRenderObservable: Observable<Camera>;
  34305. private _onBeforeCameraRenderObserver;
  34306. /** Sets a function to be executed before rendering a camera*/
  34307. beforeCameraRender: () => void;
  34308. /**
  34309. * An event triggered after rendering a camera
  34310. */
  34311. onAfterCameraRenderObservable: Observable<Camera>;
  34312. private _onAfterCameraRenderObserver;
  34313. /** Sets a function to be executed after rendering a camera*/
  34314. afterCameraRender: () => void;
  34315. /**
  34316. * An event triggered when active meshes evaluation is about to start
  34317. */
  34318. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34319. /**
  34320. * An event triggered when active meshes evaluation is done
  34321. */
  34322. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34323. /**
  34324. * An event triggered when particles rendering is about to start
  34325. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34326. */
  34327. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34328. /**
  34329. * An event triggered when particles rendering is done
  34330. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34331. */
  34332. onAfterParticlesRenderingObservable: Observable<Scene>;
  34333. /**
  34334. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34335. */
  34336. onDataLoadedObservable: Observable<Scene>;
  34337. /**
  34338. * An event triggered when a camera is created
  34339. */
  34340. onNewCameraAddedObservable: Observable<Camera>;
  34341. /**
  34342. * An event triggered when a camera is removed
  34343. */
  34344. onCameraRemovedObservable: Observable<Camera>;
  34345. /**
  34346. * An event triggered when a light is created
  34347. */
  34348. onNewLightAddedObservable: Observable<Light>;
  34349. /**
  34350. * An event triggered when a light is removed
  34351. */
  34352. onLightRemovedObservable: Observable<Light>;
  34353. /**
  34354. * An event triggered when a geometry is created
  34355. */
  34356. onNewGeometryAddedObservable: Observable<Geometry>;
  34357. /**
  34358. * An event triggered when a geometry is removed
  34359. */
  34360. onGeometryRemovedObservable: Observable<Geometry>;
  34361. /**
  34362. * An event triggered when a transform node is created
  34363. */
  34364. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34365. /**
  34366. * An event triggered when a transform node is removed
  34367. */
  34368. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34369. /**
  34370. * An event triggered when a mesh is created
  34371. */
  34372. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34373. /**
  34374. * An event triggered when a mesh is removed
  34375. */
  34376. onMeshRemovedObservable: Observable<AbstractMesh>;
  34377. /**
  34378. * An event triggered when a skeleton is created
  34379. */
  34380. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34381. /**
  34382. * An event triggered when a skeleton is removed
  34383. */
  34384. onSkeletonRemovedObservable: Observable<Skeleton>;
  34385. /**
  34386. * An event triggered when a material is created
  34387. */
  34388. onNewMaterialAddedObservable: Observable<Material>;
  34389. /**
  34390. * An event triggered when a material is removed
  34391. */
  34392. onMaterialRemovedObservable: Observable<Material>;
  34393. /**
  34394. * An event triggered when a texture is created
  34395. */
  34396. onNewTextureAddedObservable: Observable<BaseTexture>;
  34397. /**
  34398. * An event triggered when a texture is removed
  34399. */
  34400. onTextureRemovedObservable: Observable<BaseTexture>;
  34401. /**
  34402. * An event triggered when render targets are about to be rendered
  34403. * Can happen multiple times per frame.
  34404. */
  34405. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34406. /**
  34407. * An event triggered when render targets were rendered.
  34408. * Can happen multiple times per frame.
  34409. */
  34410. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34411. /**
  34412. * An event triggered before calculating deterministic simulation step
  34413. */
  34414. onBeforeStepObservable: Observable<Scene>;
  34415. /**
  34416. * An event triggered after calculating deterministic simulation step
  34417. */
  34418. onAfterStepObservable: Observable<Scene>;
  34419. /**
  34420. * An event triggered when the activeCamera property is updated
  34421. */
  34422. onActiveCameraChanged: Observable<Scene>;
  34423. /**
  34424. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34425. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34426. * 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)
  34427. */
  34428. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34429. /**
  34430. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34431. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34432. * 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)
  34433. */
  34434. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34435. /**
  34436. * This Observable will when a mesh has been imported into the scene.
  34437. */
  34438. onMeshImportedObservable: Observable<AbstractMesh>;
  34439. /**
  34440. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34441. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34442. */
  34443. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34444. /** @hidden */
  34445. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34446. /**
  34447. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34448. */
  34449. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34450. /**
  34451. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34452. */
  34453. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34454. /**
  34455. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34456. */
  34457. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34458. /** Callback called when a pointer move is detected */
  34459. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34460. /** Callback called when a pointer down is detected */
  34461. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34462. /** Callback called when a pointer up is detected */
  34463. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34464. /** Callback called when a pointer pick is detected */
  34465. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34466. /**
  34467. * 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).
  34468. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34469. */
  34470. onPrePointerObservable: Observable<PointerInfoPre>;
  34471. /**
  34472. * Observable event triggered each time an input event is received from the rendering canvas
  34473. */
  34474. onPointerObservable: Observable<PointerInfo>;
  34475. /**
  34476. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34477. */
  34478. readonly unTranslatedPointer: Vector2;
  34479. /**
  34480. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34481. */
  34482. static DragMovementThreshold: number;
  34483. /**
  34484. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34485. */
  34486. static LongPressDelay: number;
  34487. /**
  34488. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34489. */
  34490. static DoubleClickDelay: number;
  34491. /** If you need to check double click without raising a single click at first click, enable this flag */
  34492. static ExclusiveDoubleClickMode: boolean;
  34493. /** @hidden */
  34494. _mirroredCameraPosition: Nullable<Vector3>;
  34495. /**
  34496. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34497. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34498. */
  34499. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34500. /**
  34501. * Observable event triggered each time an keyboard event is received from the hosting window
  34502. */
  34503. onKeyboardObservable: Observable<KeyboardInfo>;
  34504. private _useRightHandedSystem;
  34505. /**
  34506. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34507. */
  34508. useRightHandedSystem: boolean;
  34509. private _timeAccumulator;
  34510. private _currentStepId;
  34511. private _currentInternalStep;
  34512. /**
  34513. * Sets the step Id used by deterministic lock step
  34514. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34515. * @param newStepId defines the step Id
  34516. */
  34517. setStepId(newStepId: number): void;
  34518. /**
  34519. * Gets the step Id used by deterministic lock step
  34520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34521. * @returns the step Id
  34522. */
  34523. getStepId(): number;
  34524. /**
  34525. * Gets the internal step used by deterministic lock step
  34526. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34527. * @returns the internal step
  34528. */
  34529. getInternalStep(): number;
  34530. private _fogEnabled;
  34531. /**
  34532. * Gets or sets a boolean indicating if fog is enabled on this scene
  34533. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34534. * (Default is true)
  34535. */
  34536. fogEnabled: boolean;
  34537. private _fogMode;
  34538. /**
  34539. * Gets or sets the fog mode to use
  34540. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34541. * | mode | value |
  34542. * | --- | --- |
  34543. * | FOGMODE_NONE | 0 |
  34544. * | FOGMODE_EXP | 1 |
  34545. * | FOGMODE_EXP2 | 2 |
  34546. * | FOGMODE_LINEAR | 3 |
  34547. */
  34548. fogMode: number;
  34549. /**
  34550. * Gets or sets the fog color to use
  34551. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34552. * (Default is Color3(0.2, 0.2, 0.3))
  34553. */
  34554. fogColor: Color3;
  34555. /**
  34556. * Gets or sets the fog density to use
  34557. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34558. * (Default is 0.1)
  34559. */
  34560. fogDensity: number;
  34561. /**
  34562. * Gets or sets the fog start distance to use
  34563. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34564. * (Default is 0)
  34565. */
  34566. fogStart: number;
  34567. /**
  34568. * Gets or sets the fog end distance to use
  34569. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34570. * (Default is 1000)
  34571. */
  34572. fogEnd: number;
  34573. private _shadowsEnabled;
  34574. /**
  34575. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34576. */
  34577. shadowsEnabled: boolean;
  34578. private _lightsEnabled;
  34579. /**
  34580. * Gets or sets a boolean indicating if lights are enabled on this scene
  34581. */
  34582. lightsEnabled: boolean;
  34583. /** All of the active cameras added to this scene. */
  34584. activeCameras: Camera[];
  34585. /** @hidden */
  34586. _activeCamera: Nullable<Camera>;
  34587. /** Gets or sets the current active camera */
  34588. activeCamera: Nullable<Camera>;
  34589. private _defaultMaterial;
  34590. /** The default material used on meshes when no material is affected */
  34591. /** The default material used on meshes when no material is affected */
  34592. defaultMaterial: Material;
  34593. private _texturesEnabled;
  34594. /**
  34595. * Gets or sets a boolean indicating if textures are enabled on this scene
  34596. */
  34597. texturesEnabled: boolean;
  34598. /**
  34599. * Gets or sets a boolean indicating if particles are enabled on this scene
  34600. */
  34601. particlesEnabled: boolean;
  34602. /**
  34603. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34604. */
  34605. spritesEnabled: boolean;
  34606. private _skeletonsEnabled;
  34607. /**
  34608. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34609. */
  34610. skeletonsEnabled: boolean;
  34611. /**
  34612. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34613. */
  34614. lensFlaresEnabled: boolean;
  34615. /**
  34616. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34617. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34618. */
  34619. collisionsEnabled: boolean;
  34620. private _collisionCoordinator;
  34621. /** @hidden */
  34622. readonly collisionCoordinator: ICollisionCoordinator;
  34623. /**
  34624. * Defines the gravity applied to this scene (used only for collisions)
  34625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34626. */
  34627. gravity: Vector3;
  34628. /**
  34629. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34630. */
  34631. postProcessesEnabled: boolean;
  34632. /**
  34633. * The list of postprocesses added to the scene
  34634. */
  34635. postProcesses: PostProcess[];
  34636. /**
  34637. * Gets the current postprocess manager
  34638. */
  34639. postProcessManager: PostProcessManager;
  34640. /**
  34641. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34642. */
  34643. renderTargetsEnabled: boolean;
  34644. /**
  34645. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34646. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34647. */
  34648. dumpNextRenderTargets: boolean;
  34649. /**
  34650. * The list of user defined render targets added to the scene
  34651. */
  34652. customRenderTargets: RenderTargetTexture[];
  34653. /**
  34654. * Defines if texture loading must be delayed
  34655. * If true, textures will only be loaded when they need to be rendered
  34656. */
  34657. useDelayedTextureLoading: boolean;
  34658. /**
  34659. * Gets the list of meshes imported to the scene through SceneLoader
  34660. */
  34661. importedMeshesFiles: String[];
  34662. /**
  34663. * Gets or sets a boolean indicating if probes are enabled on this scene
  34664. */
  34665. probesEnabled: boolean;
  34666. /**
  34667. * Gets or sets the current offline provider to use to store scene data
  34668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34669. */
  34670. offlineProvider: IOfflineProvider;
  34671. /**
  34672. * Gets or sets the action manager associated with the scene
  34673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34674. */
  34675. actionManager: AbstractActionManager;
  34676. private _meshesForIntersections;
  34677. /**
  34678. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34679. */
  34680. proceduralTexturesEnabled: boolean;
  34681. private _engine;
  34682. private _totalVertices;
  34683. /** @hidden */
  34684. _activeIndices: PerfCounter;
  34685. /** @hidden */
  34686. _activeParticles: PerfCounter;
  34687. /** @hidden */
  34688. _activeBones: PerfCounter;
  34689. private _animationRatio;
  34690. /** @hidden */
  34691. _animationTimeLast: number;
  34692. /** @hidden */
  34693. _animationTime: number;
  34694. /**
  34695. * Gets or sets a general scale for animation speed
  34696. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34697. */
  34698. animationTimeScale: number;
  34699. /** @hidden */
  34700. _cachedMaterial: Nullable<Material>;
  34701. /** @hidden */
  34702. _cachedEffect: Nullable<Effect>;
  34703. /** @hidden */
  34704. _cachedVisibility: Nullable<number>;
  34705. private _renderId;
  34706. private _frameId;
  34707. private _executeWhenReadyTimeoutId;
  34708. private _intermediateRendering;
  34709. private _viewUpdateFlag;
  34710. private _projectionUpdateFlag;
  34711. /** @hidden */
  34712. _toBeDisposed: Nullable<IDisposable>[];
  34713. private _activeRequests;
  34714. /** @hidden */
  34715. _pendingData: any[];
  34716. private _isDisposed;
  34717. /**
  34718. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34719. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34720. */
  34721. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34722. private _activeMeshes;
  34723. private _processedMaterials;
  34724. private _renderTargets;
  34725. /** @hidden */
  34726. _activeParticleSystems: SmartArray<IParticleSystem>;
  34727. private _activeSkeletons;
  34728. private _softwareSkinnedMeshes;
  34729. private _renderingManager;
  34730. /** @hidden */
  34731. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34732. private _transformMatrix;
  34733. private _sceneUbo;
  34734. /** @hidden */
  34735. _viewMatrix: Matrix;
  34736. private _projectionMatrix;
  34737. /** @hidden */
  34738. _forcedViewPosition: Nullable<Vector3>;
  34739. /** @hidden */
  34740. _frustumPlanes: Plane[];
  34741. /**
  34742. * Gets the list of frustum planes (built from the active camera)
  34743. */
  34744. readonly frustumPlanes: Plane[];
  34745. /**
  34746. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34747. * This is useful if there are more lights that the maximum simulteanous authorized
  34748. */
  34749. requireLightSorting: boolean;
  34750. /** @hidden */
  34751. readonly useMaterialMeshMap: boolean;
  34752. /** @hidden */
  34753. readonly useClonedMeshhMap: boolean;
  34754. private _externalData;
  34755. private _uid;
  34756. /**
  34757. * @hidden
  34758. * Backing store of defined scene components.
  34759. */
  34760. _components: ISceneComponent[];
  34761. /**
  34762. * @hidden
  34763. * Backing store of defined scene components.
  34764. */
  34765. _serializableComponents: ISceneSerializableComponent[];
  34766. /**
  34767. * List of components to register on the next registration step.
  34768. */
  34769. private _transientComponents;
  34770. /**
  34771. * Registers the transient components if needed.
  34772. */
  34773. private _registerTransientComponents;
  34774. /**
  34775. * @hidden
  34776. * Add a component to the scene.
  34777. * Note that the ccomponent could be registered on th next frame if this is called after
  34778. * the register component stage.
  34779. * @param component Defines the component to add to the scene
  34780. */
  34781. _addComponent(component: ISceneComponent): void;
  34782. /**
  34783. * @hidden
  34784. * Gets a component from the scene.
  34785. * @param name defines the name of the component to retrieve
  34786. * @returns the component or null if not present
  34787. */
  34788. _getComponent(name: string): Nullable<ISceneComponent>;
  34789. /**
  34790. * @hidden
  34791. * Defines the actions happening before camera updates.
  34792. */
  34793. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34794. /**
  34795. * @hidden
  34796. * Defines the actions happening before clear the canvas.
  34797. */
  34798. _beforeClearStage: Stage<SimpleStageAction>;
  34799. /**
  34800. * @hidden
  34801. * Defines the actions when collecting render targets for the frame.
  34802. */
  34803. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34804. /**
  34805. * @hidden
  34806. * Defines the actions happening for one camera in the frame.
  34807. */
  34808. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34809. /**
  34810. * @hidden
  34811. * Defines the actions happening during the per mesh ready checks.
  34812. */
  34813. _isReadyForMeshStage: Stage<MeshStageAction>;
  34814. /**
  34815. * @hidden
  34816. * Defines the actions happening before evaluate active mesh checks.
  34817. */
  34818. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34819. /**
  34820. * @hidden
  34821. * Defines the actions happening during the evaluate sub mesh checks.
  34822. */
  34823. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34824. /**
  34825. * @hidden
  34826. * Defines the actions happening during the active mesh stage.
  34827. */
  34828. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34829. /**
  34830. * @hidden
  34831. * Defines the actions happening during the per camera render target step.
  34832. */
  34833. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34834. /**
  34835. * @hidden
  34836. * Defines the actions happening just before the active camera is drawing.
  34837. */
  34838. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34839. /**
  34840. * @hidden
  34841. * Defines the actions happening just before a render target is drawing.
  34842. */
  34843. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34844. /**
  34845. * @hidden
  34846. * Defines the actions happening just before a rendering group is drawing.
  34847. */
  34848. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34849. /**
  34850. * @hidden
  34851. * Defines the actions happening just before a mesh is drawing.
  34852. */
  34853. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34854. /**
  34855. * @hidden
  34856. * Defines the actions happening just after a mesh has been drawn.
  34857. */
  34858. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34859. /**
  34860. * @hidden
  34861. * Defines the actions happening just after a rendering group has been drawn.
  34862. */
  34863. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34864. /**
  34865. * @hidden
  34866. * Defines the actions happening just after the active camera has been drawn.
  34867. */
  34868. _afterCameraDrawStage: Stage<CameraStageAction>;
  34869. /**
  34870. * @hidden
  34871. * Defines the actions happening just after a render target has been drawn.
  34872. */
  34873. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34874. /**
  34875. * @hidden
  34876. * Defines the actions happening just after rendering all cameras and computing intersections.
  34877. */
  34878. _afterRenderStage: Stage<SimpleStageAction>;
  34879. /**
  34880. * @hidden
  34881. * Defines the actions happening when a pointer move event happens.
  34882. */
  34883. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34884. /**
  34885. * @hidden
  34886. * Defines the actions happening when a pointer down event happens.
  34887. */
  34888. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34889. /**
  34890. * @hidden
  34891. * Defines the actions happening when a pointer up event happens.
  34892. */
  34893. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34894. /**
  34895. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34896. */
  34897. private geometriesByUniqueId;
  34898. /**
  34899. * Creates a new Scene
  34900. * @param engine defines the engine to use to render this scene
  34901. * @param options defines the scene options
  34902. */
  34903. constructor(engine: Engine, options?: SceneOptions);
  34904. /**
  34905. * Gets a string idenfifying the name of the class
  34906. * @returns "Scene" string
  34907. */
  34908. getClassName(): string;
  34909. private _defaultMeshCandidates;
  34910. /**
  34911. * @hidden
  34912. */
  34913. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34914. private _defaultSubMeshCandidates;
  34915. /**
  34916. * @hidden
  34917. */
  34918. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34919. /**
  34920. * Sets the default candidate providers for the scene.
  34921. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34922. * and getCollidingSubMeshCandidates to their default function
  34923. */
  34924. setDefaultCandidateProviders(): void;
  34925. /**
  34926. * Gets the mesh that is currently under the pointer
  34927. */
  34928. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34929. /**
  34930. * Gets or sets the current on-screen X position of the pointer
  34931. */
  34932. pointerX: number;
  34933. /**
  34934. * Gets or sets the current on-screen Y position of the pointer
  34935. */
  34936. pointerY: number;
  34937. /**
  34938. * Gets the cached material (ie. the latest rendered one)
  34939. * @returns the cached material
  34940. */
  34941. getCachedMaterial(): Nullable<Material>;
  34942. /**
  34943. * Gets the cached effect (ie. the latest rendered one)
  34944. * @returns the cached effect
  34945. */
  34946. getCachedEffect(): Nullable<Effect>;
  34947. /**
  34948. * Gets the cached visibility state (ie. the latest rendered one)
  34949. * @returns the cached visibility state
  34950. */
  34951. getCachedVisibility(): Nullable<number>;
  34952. /**
  34953. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34954. * @param material defines the current material
  34955. * @param effect defines the current effect
  34956. * @param visibility defines the current visibility state
  34957. * @returns true if one parameter is not cached
  34958. */
  34959. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34960. /**
  34961. * Gets the engine associated with the scene
  34962. * @returns an Engine
  34963. */
  34964. getEngine(): Engine;
  34965. /**
  34966. * Gets the total number of vertices rendered per frame
  34967. * @returns the total number of vertices rendered per frame
  34968. */
  34969. getTotalVertices(): number;
  34970. /**
  34971. * Gets the performance counter for total vertices
  34972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34973. */
  34974. readonly totalVerticesPerfCounter: PerfCounter;
  34975. /**
  34976. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34977. * @returns the total number of active indices rendered per frame
  34978. */
  34979. getActiveIndices(): number;
  34980. /**
  34981. * Gets the performance counter for active indices
  34982. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34983. */
  34984. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34985. /**
  34986. * Gets the total number of active particles rendered per frame
  34987. * @returns the total number of active particles rendered per frame
  34988. */
  34989. getActiveParticles(): number;
  34990. /**
  34991. * Gets the performance counter for active particles
  34992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34993. */
  34994. readonly activeParticlesPerfCounter: PerfCounter;
  34995. /**
  34996. * Gets the total number of active bones rendered per frame
  34997. * @returns the total number of active bones rendered per frame
  34998. */
  34999. getActiveBones(): number;
  35000. /**
  35001. * Gets the performance counter for active bones
  35002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35003. */
  35004. readonly activeBonesPerfCounter: PerfCounter;
  35005. /**
  35006. * Gets the array of active meshes
  35007. * @returns an array of AbstractMesh
  35008. */
  35009. getActiveMeshes(): SmartArray<AbstractMesh>;
  35010. /**
  35011. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35012. * @returns a number
  35013. */
  35014. getAnimationRatio(): number;
  35015. /**
  35016. * Gets an unique Id for the current render phase
  35017. * @returns a number
  35018. */
  35019. getRenderId(): number;
  35020. /**
  35021. * Gets an unique Id for the current frame
  35022. * @returns a number
  35023. */
  35024. getFrameId(): number;
  35025. /** Call this function if you want to manually increment the render Id*/
  35026. incrementRenderId(): void;
  35027. private _createUbo;
  35028. /**
  35029. * Use this method to simulate a pointer move on a mesh
  35030. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35031. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35032. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35033. * @returns the current scene
  35034. */
  35035. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35036. /**
  35037. * Use this method to simulate a pointer down on a mesh
  35038. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35039. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35040. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35041. * @returns the current scene
  35042. */
  35043. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35044. /**
  35045. * Use this method to simulate a pointer up on a mesh
  35046. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35047. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35048. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35049. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35050. * @returns the current scene
  35051. */
  35052. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35053. /**
  35054. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35055. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35056. * @returns true if the pointer was captured
  35057. */
  35058. isPointerCaptured(pointerId?: number): boolean;
  35059. /**
  35060. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35061. * @param attachUp defines if you want to attach events to pointerup
  35062. * @param attachDown defines if you want to attach events to pointerdown
  35063. * @param attachMove defines if you want to attach events to pointermove
  35064. */
  35065. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35066. /** Detaches all event handlers*/
  35067. detachControl(): void;
  35068. /**
  35069. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35070. * Delay loaded resources are not taking in account
  35071. * @return true if all required resources are ready
  35072. */
  35073. isReady(): boolean;
  35074. /** Resets all cached information relative to material (including effect and visibility) */
  35075. resetCachedMaterial(): void;
  35076. /**
  35077. * Registers a function to be called before every frame render
  35078. * @param func defines the function to register
  35079. */
  35080. registerBeforeRender(func: () => void): void;
  35081. /**
  35082. * Unregisters a function called before every frame render
  35083. * @param func defines the function to unregister
  35084. */
  35085. unregisterBeforeRender(func: () => void): void;
  35086. /**
  35087. * Registers a function to be called after every frame render
  35088. * @param func defines the function to register
  35089. */
  35090. registerAfterRender(func: () => void): void;
  35091. /**
  35092. * Unregisters a function called after every frame render
  35093. * @param func defines the function to unregister
  35094. */
  35095. unregisterAfterRender(func: () => void): void;
  35096. private _executeOnceBeforeRender;
  35097. /**
  35098. * The provided function will run before render once and will be disposed afterwards.
  35099. * A timeout delay can be provided so that the function will be executed in N ms.
  35100. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35101. * @param func The function to be executed.
  35102. * @param timeout optional delay in ms
  35103. */
  35104. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35105. /** @hidden */
  35106. _addPendingData(data: any): void;
  35107. /** @hidden */
  35108. _removePendingData(data: any): void;
  35109. /**
  35110. * Returns the number of items waiting to be loaded
  35111. * @returns the number of items waiting to be loaded
  35112. */
  35113. getWaitingItemsCount(): number;
  35114. /**
  35115. * Returns a boolean indicating if the scene is still loading data
  35116. */
  35117. readonly isLoading: boolean;
  35118. /**
  35119. * Registers a function to be executed when the scene is ready
  35120. * @param {Function} func - the function to be executed
  35121. */
  35122. executeWhenReady(func: () => void): void;
  35123. /**
  35124. * Returns a promise that resolves when the scene is ready
  35125. * @returns A promise that resolves when the scene is ready
  35126. */
  35127. whenReadyAsync(): Promise<void>;
  35128. /** @hidden */
  35129. _checkIsReady(): void;
  35130. /**
  35131. * Gets all animatable attached to the scene
  35132. */
  35133. readonly animatables: Animatable[];
  35134. /**
  35135. * Resets the last animation time frame.
  35136. * Useful to override when animations start running when loading a scene for the first time.
  35137. */
  35138. resetLastAnimationTimeFrame(): void;
  35139. /**
  35140. * Gets the current view matrix
  35141. * @returns a Matrix
  35142. */
  35143. getViewMatrix(): Matrix;
  35144. /**
  35145. * Gets the current projection matrix
  35146. * @returns a Matrix
  35147. */
  35148. getProjectionMatrix(): Matrix;
  35149. /**
  35150. * Gets the current transform matrix
  35151. * @returns a Matrix made of View * Projection
  35152. */
  35153. getTransformMatrix(): Matrix;
  35154. /**
  35155. * Sets the current transform matrix
  35156. * @param viewL defines the View matrix to use
  35157. * @param projectionL defines the Projection matrix to use
  35158. * @param viewR defines the right View matrix to use (if provided)
  35159. * @param projectionR defines the right Projection matrix to use (if provided)
  35160. */
  35161. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35162. /**
  35163. * Gets the uniform buffer used to store scene data
  35164. * @returns a UniformBuffer
  35165. */
  35166. getSceneUniformBuffer(): UniformBuffer;
  35167. /**
  35168. * Gets an unique (relatively to the current scene) Id
  35169. * @returns an unique number for the scene
  35170. */
  35171. getUniqueId(): number;
  35172. /**
  35173. * Add a mesh to the list of scene's meshes
  35174. * @param newMesh defines the mesh to add
  35175. * @param recursive if all child meshes should also be added to the scene
  35176. */
  35177. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35178. /**
  35179. * Remove a mesh for the list of scene's meshes
  35180. * @param toRemove defines the mesh to remove
  35181. * @param recursive if all child meshes should also be removed from the scene
  35182. * @returns the index where the mesh was in the mesh list
  35183. */
  35184. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35185. /**
  35186. * Add a transform node to the list of scene's transform nodes
  35187. * @param newTransformNode defines the transform node to add
  35188. */
  35189. addTransformNode(newTransformNode: TransformNode): void;
  35190. /**
  35191. * Remove a transform node for the list of scene's transform nodes
  35192. * @param toRemove defines the transform node to remove
  35193. * @returns the index where the transform node was in the transform node list
  35194. */
  35195. removeTransformNode(toRemove: TransformNode): number;
  35196. /**
  35197. * Remove a skeleton for the list of scene's skeletons
  35198. * @param toRemove defines the skeleton to remove
  35199. * @returns the index where the skeleton was in the skeleton list
  35200. */
  35201. removeSkeleton(toRemove: Skeleton): number;
  35202. /**
  35203. * Remove a morph target for the list of scene's morph targets
  35204. * @param toRemove defines the morph target to remove
  35205. * @returns the index where the morph target was in the morph target list
  35206. */
  35207. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35208. /**
  35209. * Remove a light for the list of scene's lights
  35210. * @param toRemove defines the light to remove
  35211. * @returns the index where the light was in the light list
  35212. */
  35213. removeLight(toRemove: Light): number;
  35214. /**
  35215. * Remove a camera for the list of scene's cameras
  35216. * @param toRemove defines the camera to remove
  35217. * @returns the index where the camera was in the camera list
  35218. */
  35219. removeCamera(toRemove: Camera): number;
  35220. /**
  35221. * Remove a particle system for the list of scene's particle systems
  35222. * @param toRemove defines the particle system to remove
  35223. * @returns the index where the particle system was in the particle system list
  35224. */
  35225. removeParticleSystem(toRemove: IParticleSystem): number;
  35226. /**
  35227. * Remove a animation for the list of scene's animations
  35228. * @param toRemove defines the animation to remove
  35229. * @returns the index where the animation was in the animation list
  35230. */
  35231. removeAnimation(toRemove: Animation): number;
  35232. /**
  35233. * Will stop the animation of the given target
  35234. * @param target - the target
  35235. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35236. * @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)
  35237. */
  35238. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35239. /**
  35240. * Removes the given animation group from this scene.
  35241. * @param toRemove The animation group to remove
  35242. * @returns The index of the removed animation group
  35243. */
  35244. removeAnimationGroup(toRemove: AnimationGroup): number;
  35245. /**
  35246. * Removes the given multi-material from this scene.
  35247. * @param toRemove The multi-material to remove
  35248. * @returns The index of the removed multi-material
  35249. */
  35250. removeMultiMaterial(toRemove: MultiMaterial): number;
  35251. /**
  35252. * Removes the given material from this scene.
  35253. * @param toRemove The material to remove
  35254. * @returns The index of the removed material
  35255. */
  35256. removeMaterial(toRemove: Material): number;
  35257. /**
  35258. * Removes the given action manager from this scene.
  35259. * @param toRemove The action manager to remove
  35260. * @returns The index of the removed action manager
  35261. */
  35262. removeActionManager(toRemove: AbstractActionManager): number;
  35263. /**
  35264. * Removes the given texture from this scene.
  35265. * @param toRemove The texture to remove
  35266. * @returns The index of the removed texture
  35267. */
  35268. removeTexture(toRemove: BaseTexture): number;
  35269. /**
  35270. * Adds the given light to this scene
  35271. * @param newLight The light to add
  35272. */
  35273. addLight(newLight: Light): void;
  35274. /**
  35275. * Sorts the list list based on light priorities
  35276. */
  35277. sortLightsByPriority(): void;
  35278. /**
  35279. * Adds the given camera to this scene
  35280. * @param newCamera The camera to add
  35281. */
  35282. addCamera(newCamera: Camera): void;
  35283. /**
  35284. * Adds the given skeleton to this scene
  35285. * @param newSkeleton The skeleton to add
  35286. */
  35287. addSkeleton(newSkeleton: Skeleton): void;
  35288. /**
  35289. * Adds the given particle system to this scene
  35290. * @param newParticleSystem The particle system to add
  35291. */
  35292. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35293. /**
  35294. * Adds the given animation to this scene
  35295. * @param newAnimation The animation to add
  35296. */
  35297. addAnimation(newAnimation: Animation): void;
  35298. /**
  35299. * Adds the given animation group to this scene.
  35300. * @param newAnimationGroup The animation group to add
  35301. */
  35302. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35303. /**
  35304. * Adds the given multi-material to this scene
  35305. * @param newMultiMaterial The multi-material to add
  35306. */
  35307. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35308. /**
  35309. * Adds the given material to this scene
  35310. * @param newMaterial The material to add
  35311. */
  35312. addMaterial(newMaterial: Material): void;
  35313. /**
  35314. * Adds the given morph target to this scene
  35315. * @param newMorphTargetManager The morph target to add
  35316. */
  35317. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35318. /**
  35319. * Adds the given geometry to this scene
  35320. * @param newGeometry The geometry to add
  35321. */
  35322. addGeometry(newGeometry: Geometry): void;
  35323. /**
  35324. * Adds the given action manager to this scene
  35325. * @param newActionManager The action manager to add
  35326. */
  35327. addActionManager(newActionManager: AbstractActionManager): void;
  35328. /**
  35329. * Adds the given texture to this scene.
  35330. * @param newTexture The texture to add
  35331. */
  35332. addTexture(newTexture: BaseTexture): void;
  35333. /**
  35334. * Switch active camera
  35335. * @param newCamera defines the new active camera
  35336. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35337. */
  35338. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35339. /**
  35340. * sets the active camera of the scene using its ID
  35341. * @param id defines the camera's ID
  35342. * @return the new active camera or null if none found.
  35343. */
  35344. setActiveCameraByID(id: string): Nullable<Camera>;
  35345. /**
  35346. * sets the active camera of the scene using its name
  35347. * @param name defines the camera's name
  35348. * @returns the new active camera or null if none found.
  35349. */
  35350. setActiveCameraByName(name: string): Nullable<Camera>;
  35351. /**
  35352. * get an animation group using its name
  35353. * @param name defines the material's name
  35354. * @return the animation group or null if none found.
  35355. */
  35356. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35357. /**
  35358. * Get a material using its unique id
  35359. * @param uniqueId defines the material's unique id
  35360. * @return the material or null if none found.
  35361. */
  35362. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35363. /**
  35364. * get a material using its id
  35365. * @param id defines the material's ID
  35366. * @return the material or null if none found.
  35367. */
  35368. getMaterialByID(id: string): Nullable<Material>;
  35369. /**
  35370. * Gets a the last added material using a given id
  35371. * @param id defines the material's ID
  35372. * @return the last material with the given id or null if none found.
  35373. */
  35374. getLastMaterialByID(id: string): Nullable<Material>;
  35375. /**
  35376. * Gets a material using its name
  35377. * @param name defines the material's name
  35378. * @return the material or null if none found.
  35379. */
  35380. getMaterialByName(name: string): Nullable<Material>;
  35381. /**
  35382. * Get a texture using its unique id
  35383. * @param uniqueId defines the texture's unique id
  35384. * @return the texture or null if none found.
  35385. */
  35386. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35387. /**
  35388. * Gets a camera using its id
  35389. * @param id defines the id to look for
  35390. * @returns the camera or null if not found
  35391. */
  35392. getCameraByID(id: string): Nullable<Camera>;
  35393. /**
  35394. * Gets a camera using its unique id
  35395. * @param uniqueId defines the unique id to look for
  35396. * @returns the camera or null if not found
  35397. */
  35398. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35399. /**
  35400. * Gets a camera using its name
  35401. * @param name defines the camera's name
  35402. * @return the camera or null if none found.
  35403. */
  35404. getCameraByName(name: string): Nullable<Camera>;
  35405. /**
  35406. * Gets a bone using its id
  35407. * @param id defines the bone's id
  35408. * @return the bone or null if not found
  35409. */
  35410. getBoneByID(id: string): Nullable<Bone>;
  35411. /**
  35412. * Gets a bone using its id
  35413. * @param name defines the bone's name
  35414. * @return the bone or null if not found
  35415. */
  35416. getBoneByName(name: string): Nullable<Bone>;
  35417. /**
  35418. * Gets a light node using its name
  35419. * @param name defines the the light's name
  35420. * @return the light or null if none found.
  35421. */
  35422. getLightByName(name: string): Nullable<Light>;
  35423. /**
  35424. * Gets a light node using its id
  35425. * @param id defines the light's id
  35426. * @return the light or null if none found.
  35427. */
  35428. getLightByID(id: string): Nullable<Light>;
  35429. /**
  35430. * Gets a light node using its scene-generated unique ID
  35431. * @param uniqueId defines the light's unique id
  35432. * @return the light or null if none found.
  35433. */
  35434. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35435. /**
  35436. * Gets a particle system by id
  35437. * @param id defines the particle system id
  35438. * @return the corresponding system or null if none found
  35439. */
  35440. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35441. /**
  35442. * Gets a geometry using its ID
  35443. * @param id defines the geometry's id
  35444. * @return the geometry or null if none found.
  35445. */
  35446. getGeometryByID(id: string): Nullable<Geometry>;
  35447. private _getGeometryByUniqueID;
  35448. /**
  35449. * Add a new geometry to this scene
  35450. * @param geometry defines the geometry to be added to the scene.
  35451. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35452. * @return a boolean defining if the geometry was added or not
  35453. */
  35454. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35455. /**
  35456. * Removes an existing geometry
  35457. * @param geometry defines the geometry to be removed from the scene
  35458. * @return a boolean defining if the geometry was removed or not
  35459. */
  35460. removeGeometry(geometry: Geometry): boolean;
  35461. /**
  35462. * Gets the list of geometries attached to the scene
  35463. * @returns an array of Geometry
  35464. */
  35465. getGeometries(): Geometry[];
  35466. /**
  35467. * Gets the first added mesh found of a given ID
  35468. * @param id defines the id to search for
  35469. * @return the mesh found or null if not found at all
  35470. */
  35471. getMeshByID(id: string): Nullable<AbstractMesh>;
  35472. /**
  35473. * Gets a list of meshes using their id
  35474. * @param id defines the id to search for
  35475. * @returns a list of meshes
  35476. */
  35477. getMeshesByID(id: string): Array<AbstractMesh>;
  35478. /**
  35479. * Gets the first added transform node found of a given ID
  35480. * @param id defines the id to search for
  35481. * @return the found transform node or null if not found at all.
  35482. */
  35483. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35484. /**
  35485. * Gets a transform node with its auto-generated unique id
  35486. * @param uniqueId efines the unique id to search for
  35487. * @return the found transform node or null if not found at all.
  35488. */
  35489. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35490. /**
  35491. * Gets a list of transform nodes using their id
  35492. * @param id defines the id to search for
  35493. * @returns a list of transform nodes
  35494. */
  35495. getTransformNodesByID(id: string): Array<TransformNode>;
  35496. /**
  35497. * Gets a mesh with its auto-generated unique id
  35498. * @param uniqueId defines the unique id to search for
  35499. * @return the found mesh or null if not found at all.
  35500. */
  35501. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35502. /**
  35503. * Gets a the last added mesh using a given id
  35504. * @param id defines the id to search for
  35505. * @return the found mesh or null if not found at all.
  35506. */
  35507. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35508. /**
  35509. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35510. * @param id defines the id to search for
  35511. * @return the found node or null if not found at all
  35512. */
  35513. getLastEntryByID(id: string): Nullable<Node>;
  35514. /**
  35515. * Gets a node (Mesh, Camera, Light) using a given id
  35516. * @param id defines the id to search for
  35517. * @return the found node or null if not found at all
  35518. */
  35519. getNodeByID(id: string): Nullable<Node>;
  35520. /**
  35521. * Gets a node (Mesh, Camera, Light) using a given name
  35522. * @param name defines the name to search for
  35523. * @return the found node or null if not found at all.
  35524. */
  35525. getNodeByName(name: string): Nullable<Node>;
  35526. /**
  35527. * Gets a mesh using a given name
  35528. * @param name defines the name to search for
  35529. * @return the found mesh or null if not found at all.
  35530. */
  35531. getMeshByName(name: string): Nullable<AbstractMesh>;
  35532. /**
  35533. * Gets a transform node using a given name
  35534. * @param name defines the name to search for
  35535. * @return the found transform node or null if not found at all.
  35536. */
  35537. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35538. /**
  35539. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35540. * @param id defines the id to search for
  35541. * @return the found skeleton or null if not found at all.
  35542. */
  35543. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35544. /**
  35545. * Gets a skeleton using a given auto generated unique id
  35546. * @param uniqueId defines the unique id to search for
  35547. * @return the found skeleton or null if not found at all.
  35548. */
  35549. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35550. /**
  35551. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35552. * @param id defines the id to search for
  35553. * @return the found skeleton or null if not found at all.
  35554. */
  35555. getSkeletonById(id: string): Nullable<Skeleton>;
  35556. /**
  35557. * Gets a skeleton using a given name
  35558. * @param name defines the name to search for
  35559. * @return the found skeleton or null if not found at all.
  35560. */
  35561. getSkeletonByName(name: string): Nullable<Skeleton>;
  35562. /**
  35563. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35564. * @param id defines the id to search for
  35565. * @return the found morph target manager or null if not found at all.
  35566. */
  35567. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35568. /**
  35569. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35570. * @param id defines the id to search for
  35571. * @return the found morph target or null if not found at all.
  35572. */
  35573. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35574. /**
  35575. * Gets a boolean indicating if the given mesh is active
  35576. * @param mesh defines the mesh to look for
  35577. * @returns true if the mesh is in the active list
  35578. */
  35579. isActiveMesh(mesh: AbstractMesh): boolean;
  35580. /**
  35581. * Return a unique id as a string which can serve as an identifier for the scene
  35582. */
  35583. readonly uid: string;
  35584. /**
  35585. * Add an externaly attached data from its key.
  35586. * This method call will fail and return false, if such key already exists.
  35587. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35588. * @param key the unique key that identifies the data
  35589. * @param data the data object to associate to the key for this Engine instance
  35590. * @return true if no such key were already present and the data was added successfully, false otherwise
  35591. */
  35592. addExternalData<T>(key: string, data: T): boolean;
  35593. /**
  35594. * Get an externaly attached data from its key
  35595. * @param key the unique key that identifies the data
  35596. * @return the associated data, if present (can be null), or undefined if not present
  35597. */
  35598. getExternalData<T>(key: string): Nullable<T>;
  35599. /**
  35600. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35601. * @param key the unique key that identifies the data
  35602. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35603. * @return the associated data, can be null if the factory returned null.
  35604. */
  35605. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35606. /**
  35607. * Remove an externaly attached data from the Engine instance
  35608. * @param key the unique key that identifies the data
  35609. * @return true if the data was successfully removed, false if it doesn't exist
  35610. */
  35611. removeExternalData(key: string): boolean;
  35612. private _evaluateSubMesh;
  35613. /**
  35614. * Clear the processed materials smart array preventing retention point in material dispose.
  35615. */
  35616. freeProcessedMaterials(): void;
  35617. private _preventFreeActiveMeshesAndRenderingGroups;
  35618. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35619. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35620. * when disposing several meshes in a row or a hierarchy of meshes.
  35621. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35622. */
  35623. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35624. /**
  35625. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35626. */
  35627. freeActiveMeshes(): void;
  35628. /**
  35629. * Clear the info related to rendering groups preventing retention points during dispose.
  35630. */
  35631. freeRenderingGroups(): void;
  35632. /** @hidden */
  35633. _isInIntermediateRendering(): boolean;
  35634. /**
  35635. * Lambda returning the list of potentially active meshes.
  35636. */
  35637. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35638. /**
  35639. * Lambda returning the list of potentially active sub meshes.
  35640. */
  35641. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35642. /**
  35643. * Lambda returning the list of potentially intersecting sub meshes.
  35644. */
  35645. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35646. /**
  35647. * Lambda returning the list of potentially colliding sub meshes.
  35648. */
  35649. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35650. private _activeMeshesFrozen;
  35651. /**
  35652. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35653. * @returns the current scene
  35654. */
  35655. freezeActiveMeshes(): Scene;
  35656. /**
  35657. * Use this function to restart evaluating active meshes on every frame
  35658. * @returns the current scene
  35659. */
  35660. unfreezeActiveMeshes(): Scene;
  35661. private _evaluateActiveMeshes;
  35662. private _activeMesh;
  35663. /**
  35664. * Update the transform matrix to update from the current active camera
  35665. * @param force defines a boolean used to force the update even if cache is up to date
  35666. */
  35667. updateTransformMatrix(force?: boolean): void;
  35668. private _bindFrameBuffer;
  35669. /** @hidden */
  35670. _allowPostProcessClearColor: boolean;
  35671. /** @hidden */
  35672. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35673. private _processSubCameras;
  35674. private _checkIntersections;
  35675. /** @hidden */
  35676. _advancePhysicsEngineStep(step: number): void;
  35677. /**
  35678. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35679. */
  35680. getDeterministicFrameTime: () => number;
  35681. /** @hidden */
  35682. _animate(): void;
  35683. /** Execute all animations (for a frame) */
  35684. animate(): void;
  35685. /**
  35686. * Render the scene
  35687. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35688. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35689. */
  35690. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35691. /**
  35692. * Freeze all materials
  35693. * A frozen material will not be updatable but should be faster to render
  35694. */
  35695. freezeMaterials(): void;
  35696. /**
  35697. * Unfreeze all materials
  35698. * A frozen material will not be updatable but should be faster to render
  35699. */
  35700. unfreezeMaterials(): void;
  35701. /**
  35702. * Releases all held ressources
  35703. */
  35704. dispose(): void;
  35705. /**
  35706. * Gets if the scene is already disposed
  35707. */
  35708. readonly isDisposed: boolean;
  35709. /**
  35710. * Call this function to reduce memory footprint of the scene.
  35711. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35712. */
  35713. clearCachedVertexData(): void;
  35714. /**
  35715. * This function will remove the local cached buffer data from texture.
  35716. * It will save memory but will prevent the texture from being rebuilt
  35717. */
  35718. cleanCachedTextureBuffer(): void;
  35719. /**
  35720. * Get the world extend vectors with an optional filter
  35721. *
  35722. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35723. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35724. */
  35725. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35726. min: Vector3;
  35727. max: Vector3;
  35728. };
  35729. /**
  35730. * Creates a ray that can be used to pick in the scene
  35731. * @param x defines the x coordinate of the origin (on-screen)
  35732. * @param y defines the y coordinate of the origin (on-screen)
  35733. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35734. * @param camera defines the camera to use for the picking
  35735. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35736. * @returns a Ray
  35737. */
  35738. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35739. /**
  35740. * Creates a ray that can be used to pick in the scene
  35741. * @param x defines the x coordinate of the origin (on-screen)
  35742. * @param y defines the y coordinate of the origin (on-screen)
  35743. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35744. * @param result defines the ray where to store the picking ray
  35745. * @param camera defines the camera to use for the picking
  35746. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35747. * @returns the current scene
  35748. */
  35749. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35750. /**
  35751. * Creates a ray that can be used to pick in the scene
  35752. * @param x defines the x coordinate of the origin (on-screen)
  35753. * @param y defines the y coordinate of the origin (on-screen)
  35754. * @param camera defines the camera to use for the picking
  35755. * @returns a Ray
  35756. */
  35757. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35758. /**
  35759. * Creates a ray that can be used to pick in the scene
  35760. * @param x defines the x coordinate of the origin (on-screen)
  35761. * @param y defines the y coordinate of the origin (on-screen)
  35762. * @param result defines the ray where to store the picking ray
  35763. * @param camera defines the camera to use for the picking
  35764. * @returns the current scene
  35765. */
  35766. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35767. /** Launch a ray to try to pick a mesh in the scene
  35768. * @param x position on screen
  35769. * @param y position on screen
  35770. * @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
  35771. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35772. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35773. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35774. * @returns a PickingInfo
  35775. */
  35776. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35777. /** Use the given ray to pick a mesh in the scene
  35778. * @param ray The ray to use to pick meshes
  35779. * @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
  35780. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35781. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35782. * @returns a PickingInfo
  35783. */
  35784. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35785. /**
  35786. * Launch a ray to try to pick a mesh in the scene
  35787. * @param x X position on screen
  35788. * @param y Y position on screen
  35789. * @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
  35790. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35791. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35792. * @returns an array of PickingInfo
  35793. */
  35794. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35795. /**
  35796. * Launch a ray to try to pick a mesh in the scene
  35797. * @param ray Ray to use
  35798. * @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
  35799. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35800. * @returns an array of PickingInfo
  35801. */
  35802. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35803. /**
  35804. * Force the value of meshUnderPointer
  35805. * @param mesh defines the mesh to use
  35806. */
  35807. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35808. /**
  35809. * Gets the mesh under the pointer
  35810. * @returns a Mesh or null if no mesh is under the pointer
  35811. */
  35812. getPointerOverMesh(): Nullable<AbstractMesh>;
  35813. /** @hidden */
  35814. _rebuildGeometries(): void;
  35815. /** @hidden */
  35816. _rebuildTextures(): void;
  35817. private _getByTags;
  35818. /**
  35819. * Get a list of meshes by tags
  35820. * @param tagsQuery defines the tags query to use
  35821. * @param forEach defines a predicate used to filter results
  35822. * @returns an array of Mesh
  35823. */
  35824. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35825. /**
  35826. * Get a list of cameras by tags
  35827. * @param tagsQuery defines the tags query to use
  35828. * @param forEach defines a predicate used to filter results
  35829. * @returns an array of Camera
  35830. */
  35831. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35832. /**
  35833. * Get a list of lights by tags
  35834. * @param tagsQuery defines the tags query to use
  35835. * @param forEach defines a predicate used to filter results
  35836. * @returns an array of Light
  35837. */
  35838. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35839. /**
  35840. * Get a list of materials by tags
  35841. * @param tagsQuery defines the tags query to use
  35842. * @param forEach defines a predicate used to filter results
  35843. * @returns an array of Material
  35844. */
  35845. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35846. /**
  35847. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35848. * This allowed control for front to back rendering or reversly depending of the special needs.
  35849. *
  35850. * @param renderingGroupId The rendering group id corresponding to its index
  35851. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35852. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35853. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35854. */
  35855. 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;
  35856. /**
  35857. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35858. *
  35859. * @param renderingGroupId The rendering group id corresponding to its index
  35860. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35861. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35862. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35863. */
  35864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35865. /**
  35866. * Gets the current auto clear configuration for one rendering group of the rendering
  35867. * manager.
  35868. * @param index the rendering group index to get the information for
  35869. * @returns The auto clear setup for the requested rendering group
  35870. */
  35871. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35872. private _blockMaterialDirtyMechanism;
  35873. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35874. blockMaterialDirtyMechanism: boolean;
  35875. /**
  35876. * Will flag all materials as dirty to trigger new shader compilation
  35877. * @param flag defines the flag used to specify which material part must be marked as dirty
  35878. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35879. */
  35880. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35881. /** @hidden */
  35882. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35883. /** @hidden */
  35884. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35885. /** @hidden */
  35886. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35887. /** @hidden */
  35888. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35889. /** @hidden */
  35890. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35891. /** @hidden */
  35892. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35893. }
  35894. }
  35895. declare module "babylonjs/assetContainer" {
  35896. import { AbstractScene } from "babylonjs/abstractScene";
  35897. import { Scene } from "babylonjs/scene";
  35898. import { Mesh } from "babylonjs/Meshes/mesh";
  35899. /**
  35900. * Set of assets to keep when moving a scene into an asset container.
  35901. */
  35902. export class KeepAssets extends AbstractScene {
  35903. }
  35904. /**
  35905. * Container with a set of assets that can be added or removed from a scene.
  35906. */
  35907. export class AssetContainer extends AbstractScene {
  35908. /**
  35909. * The scene the AssetContainer belongs to.
  35910. */
  35911. scene: Scene;
  35912. /**
  35913. * Instantiates an AssetContainer.
  35914. * @param scene The scene the AssetContainer belongs to.
  35915. */
  35916. constructor(scene: Scene);
  35917. /**
  35918. * Adds all the assets from the container to the scene.
  35919. */
  35920. addAllToScene(): void;
  35921. /**
  35922. * Removes all the assets in the container from the scene
  35923. */
  35924. removeAllFromScene(): void;
  35925. /**
  35926. * Disposes all the assets in the container
  35927. */
  35928. dispose(): void;
  35929. private _moveAssets;
  35930. /**
  35931. * Removes all the assets contained in the scene and adds them to the container.
  35932. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35933. */
  35934. moveAllFromScene(keepAssets?: KeepAssets): void;
  35935. /**
  35936. * 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.
  35937. * @returns the root mesh
  35938. */
  35939. createRootMesh(): Mesh;
  35940. }
  35941. }
  35942. declare module "babylonjs/abstractScene" {
  35943. import { Scene } from "babylonjs/scene";
  35944. import { Nullable } from "babylonjs/types";
  35945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35946. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35947. import { Geometry } from "babylonjs/Meshes/geometry";
  35948. import { Skeleton } from "babylonjs/Bones/skeleton";
  35949. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35950. import { AssetContainer } from "babylonjs/assetContainer";
  35951. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35952. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35954. import { Material } from "babylonjs/Materials/material";
  35955. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35956. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35957. import { Camera } from "babylonjs/Cameras/camera";
  35958. import { Light } from "babylonjs/Lights/light";
  35959. import { Node } from "babylonjs/node";
  35960. import { Animation } from "babylonjs/Animations/animation";
  35961. /**
  35962. * Defines how the parser contract is defined.
  35963. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35964. */
  35965. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35966. /**
  35967. * Defines how the individual parser contract is defined.
  35968. * These parser can parse an individual asset
  35969. */
  35970. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35971. /**
  35972. * Base class of the scene acting as a container for the different elements composing a scene.
  35973. * This class is dynamically extended by the different components of the scene increasing
  35974. * flexibility and reducing coupling
  35975. */
  35976. export abstract class AbstractScene {
  35977. /**
  35978. * Stores the list of available parsers in the application.
  35979. */
  35980. private static _BabylonFileParsers;
  35981. /**
  35982. * Stores the list of available individual parsers in the application.
  35983. */
  35984. private static _IndividualBabylonFileParsers;
  35985. /**
  35986. * Adds a parser in the list of available ones
  35987. * @param name Defines the name of the parser
  35988. * @param parser Defines the parser to add
  35989. */
  35990. static AddParser(name: string, parser: BabylonFileParser): void;
  35991. /**
  35992. * Gets a general parser from the list of avaialble ones
  35993. * @param name Defines the name of the parser
  35994. * @returns the requested parser or null
  35995. */
  35996. static GetParser(name: string): Nullable<BabylonFileParser>;
  35997. /**
  35998. * Adds n individual parser in the list of available ones
  35999. * @param name Defines the name of the parser
  36000. * @param parser Defines the parser to add
  36001. */
  36002. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36003. /**
  36004. * Gets an individual parser from the list of avaialble ones
  36005. * @param name Defines the name of the parser
  36006. * @returns the requested parser or null
  36007. */
  36008. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36009. /**
  36010. * Parser json data and populate both a scene and its associated container object
  36011. * @param jsonData Defines the data to parse
  36012. * @param scene Defines the scene to parse the data for
  36013. * @param container Defines the container attached to the parsing sequence
  36014. * @param rootUrl Defines the root url of the data
  36015. */
  36016. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36017. /**
  36018. * Gets the list of root nodes (ie. nodes with no parent)
  36019. */
  36020. rootNodes: Node[];
  36021. /** All of the cameras added to this scene
  36022. * @see http://doc.babylonjs.com/babylon101/cameras
  36023. */
  36024. cameras: Camera[];
  36025. /**
  36026. * All of the lights added to this scene
  36027. * @see http://doc.babylonjs.com/babylon101/lights
  36028. */
  36029. lights: Light[];
  36030. /**
  36031. * All of the (abstract) meshes added to this scene
  36032. */
  36033. meshes: AbstractMesh[];
  36034. /**
  36035. * The list of skeletons added to the scene
  36036. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36037. */
  36038. skeletons: Skeleton[];
  36039. /**
  36040. * All of the particle systems added to this scene
  36041. * @see http://doc.babylonjs.com/babylon101/particles
  36042. */
  36043. particleSystems: IParticleSystem[];
  36044. /**
  36045. * Gets a list of Animations associated with the scene
  36046. */
  36047. animations: Animation[];
  36048. /**
  36049. * All of the animation groups added to this scene
  36050. * @see http://doc.babylonjs.com/how_to/group
  36051. */
  36052. animationGroups: AnimationGroup[];
  36053. /**
  36054. * All of the multi-materials added to this scene
  36055. * @see http://doc.babylonjs.com/how_to/multi_materials
  36056. */
  36057. multiMaterials: MultiMaterial[];
  36058. /**
  36059. * All of the materials added to this scene
  36060. * In the context of a Scene, it is not supposed to be modified manually.
  36061. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  36062. * Note also that the order of the Material wihin the array is not significant and might change.
  36063. * @see http://doc.babylonjs.com/babylon101/materials
  36064. */
  36065. materials: Material[];
  36066. /**
  36067. * The list of morph target managers added to the scene
  36068. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36069. */
  36070. morphTargetManagers: MorphTargetManager[];
  36071. /**
  36072. * The list of geometries used in the scene.
  36073. */
  36074. geometries: Geometry[];
  36075. /**
  36076. * All of the tranform nodes added to this scene
  36077. * In the context of a Scene, it is not supposed to be modified manually.
  36078. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36079. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36080. * @see http://doc.babylonjs.com/how_to/transformnode
  36081. */
  36082. transformNodes: TransformNode[];
  36083. /**
  36084. * ActionManagers available on the scene.
  36085. */
  36086. actionManagers: AbstractActionManager[];
  36087. /**
  36088. * Textures to keep.
  36089. */
  36090. textures: BaseTexture[];
  36091. /**
  36092. * Environment texture for the scene
  36093. */
  36094. environmentTexture: Nullable<BaseTexture>;
  36095. }
  36096. }
  36097. declare module "babylonjs/Audio/sound" {
  36098. import { Observable } from "babylonjs/Misc/observable";
  36099. import { Vector3 } from "babylonjs/Maths/math.vector";
  36100. import { Nullable } from "babylonjs/types";
  36101. import { Scene } from "babylonjs/scene";
  36102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36103. /**
  36104. * Interface used to define options for Sound class
  36105. */
  36106. export interface ISoundOptions {
  36107. /**
  36108. * Does the sound autoplay once loaded.
  36109. */
  36110. autoplay?: boolean;
  36111. /**
  36112. * Does the sound loop after it finishes playing once.
  36113. */
  36114. loop?: boolean;
  36115. /**
  36116. * Sound's volume
  36117. */
  36118. volume?: number;
  36119. /**
  36120. * Is it a spatial sound?
  36121. */
  36122. spatialSound?: boolean;
  36123. /**
  36124. * Maximum distance to hear that sound
  36125. */
  36126. maxDistance?: number;
  36127. /**
  36128. * Uses user defined attenuation function
  36129. */
  36130. useCustomAttenuation?: boolean;
  36131. /**
  36132. * Define the roll off factor of spatial sounds.
  36133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36134. */
  36135. rolloffFactor?: number;
  36136. /**
  36137. * Define the reference distance the sound should be heard perfectly.
  36138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36139. */
  36140. refDistance?: number;
  36141. /**
  36142. * Define the distance attenuation model the sound will follow.
  36143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36144. */
  36145. distanceModel?: string;
  36146. /**
  36147. * Defines the playback speed (1 by default)
  36148. */
  36149. playbackRate?: number;
  36150. /**
  36151. * Defines if the sound is from a streaming source
  36152. */
  36153. streaming?: boolean;
  36154. /**
  36155. * Defines an optional length (in seconds) inside the sound file
  36156. */
  36157. length?: number;
  36158. /**
  36159. * Defines an optional offset (in seconds) inside the sound file
  36160. */
  36161. offset?: number;
  36162. /**
  36163. * If true, URLs will not be required to state the audio file codec to use.
  36164. */
  36165. skipCodecCheck?: boolean;
  36166. }
  36167. /**
  36168. * Defines a sound that can be played in the application.
  36169. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36171. */
  36172. export class Sound {
  36173. /**
  36174. * The name of the sound in the scene.
  36175. */
  36176. name: string;
  36177. /**
  36178. * Does the sound autoplay once loaded.
  36179. */
  36180. autoplay: boolean;
  36181. /**
  36182. * Does the sound loop after it finishes playing once.
  36183. */
  36184. loop: boolean;
  36185. /**
  36186. * Does the sound use a custom attenuation curve to simulate the falloff
  36187. * happening when the source gets further away from the camera.
  36188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36189. */
  36190. useCustomAttenuation: boolean;
  36191. /**
  36192. * The sound track id this sound belongs to.
  36193. */
  36194. soundTrackId: number;
  36195. /**
  36196. * Is this sound currently played.
  36197. */
  36198. isPlaying: boolean;
  36199. /**
  36200. * Is this sound currently paused.
  36201. */
  36202. isPaused: boolean;
  36203. /**
  36204. * Does this sound enables spatial sound.
  36205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36206. */
  36207. spatialSound: boolean;
  36208. /**
  36209. * Define the reference distance the sound should be heard perfectly.
  36210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36211. */
  36212. refDistance: number;
  36213. /**
  36214. * Define the roll off factor of spatial sounds.
  36215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36216. */
  36217. rolloffFactor: number;
  36218. /**
  36219. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36221. */
  36222. maxDistance: number;
  36223. /**
  36224. * Define the distance attenuation model the sound will follow.
  36225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36226. */
  36227. distanceModel: string;
  36228. /**
  36229. * @hidden
  36230. * Back Compat
  36231. **/
  36232. onended: () => any;
  36233. /**
  36234. * Observable event when the current playing sound finishes.
  36235. */
  36236. onEndedObservable: Observable<Sound>;
  36237. private _panningModel;
  36238. private _playbackRate;
  36239. private _streaming;
  36240. private _startTime;
  36241. private _startOffset;
  36242. private _position;
  36243. /** @hidden */
  36244. _positionInEmitterSpace: boolean;
  36245. private _localDirection;
  36246. private _volume;
  36247. private _isReadyToPlay;
  36248. private _isDirectional;
  36249. private _readyToPlayCallback;
  36250. private _audioBuffer;
  36251. private _soundSource;
  36252. private _streamingSource;
  36253. private _soundPanner;
  36254. private _soundGain;
  36255. private _inputAudioNode;
  36256. private _outputAudioNode;
  36257. private _coneInnerAngle;
  36258. private _coneOuterAngle;
  36259. private _coneOuterGain;
  36260. private _scene;
  36261. private _connectedTransformNode;
  36262. private _customAttenuationFunction;
  36263. private _registerFunc;
  36264. private _isOutputConnected;
  36265. private _htmlAudioElement;
  36266. private _urlType;
  36267. private _length?;
  36268. private _offset?;
  36269. /** @hidden */
  36270. static _SceneComponentInitialization: (scene: Scene) => void;
  36271. /**
  36272. * Create a sound and attach it to a scene
  36273. * @param name Name of your sound
  36274. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36275. * @param scene defines the scene the sound belongs to
  36276. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36277. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36278. */
  36279. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36280. /**
  36281. * Release the sound and its associated resources
  36282. */
  36283. dispose(): void;
  36284. /**
  36285. * Gets if the sounds is ready to be played or not.
  36286. * @returns true if ready, otherwise false
  36287. */
  36288. isReady(): boolean;
  36289. private _soundLoaded;
  36290. /**
  36291. * Sets the data of the sound from an audiobuffer
  36292. * @param audioBuffer The audioBuffer containing the data
  36293. */
  36294. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36295. /**
  36296. * Updates the current sounds options such as maxdistance, loop...
  36297. * @param options A JSON object containing values named as the object properties
  36298. */
  36299. updateOptions(options: ISoundOptions): void;
  36300. private _createSpatialParameters;
  36301. private _updateSpatialParameters;
  36302. /**
  36303. * Switch the panning model to HRTF:
  36304. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36306. */
  36307. switchPanningModelToHRTF(): void;
  36308. /**
  36309. * Switch the panning model to Equal Power:
  36310. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36312. */
  36313. switchPanningModelToEqualPower(): void;
  36314. private _switchPanningModel;
  36315. /**
  36316. * Connect this sound to a sound track audio node like gain...
  36317. * @param soundTrackAudioNode the sound track audio node to connect to
  36318. */
  36319. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36320. /**
  36321. * Transform this sound into a directional source
  36322. * @param coneInnerAngle Size of the inner cone in degree
  36323. * @param coneOuterAngle Size of the outer cone in degree
  36324. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36325. */
  36326. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36327. /**
  36328. * Gets or sets the inner angle for the directional cone.
  36329. */
  36330. /**
  36331. * Gets or sets the inner angle for the directional cone.
  36332. */
  36333. directionalConeInnerAngle: number;
  36334. /**
  36335. * Gets or sets the outer angle for the directional cone.
  36336. */
  36337. /**
  36338. * Gets or sets the outer angle for the directional cone.
  36339. */
  36340. directionalConeOuterAngle: number;
  36341. /**
  36342. * Sets the position of the emitter if spatial sound is enabled
  36343. * @param newPosition Defines the new posisiton
  36344. */
  36345. setPosition(newPosition: Vector3): void;
  36346. /**
  36347. * Sets the local direction of the emitter if spatial sound is enabled
  36348. * @param newLocalDirection Defines the new local direction
  36349. */
  36350. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36351. private _updateDirection;
  36352. /** @hidden */
  36353. updateDistanceFromListener(): void;
  36354. /**
  36355. * Sets a new custom attenuation function for the sound.
  36356. * @param callback Defines the function used for the attenuation
  36357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36358. */
  36359. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36360. /**
  36361. * Play the sound
  36362. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36363. * @param offset (optional) Start the sound at a specific time in seconds
  36364. * @param length (optional) Sound duration (in seconds)
  36365. */
  36366. play(time?: number, offset?: number, length?: number): void;
  36367. private _onended;
  36368. /**
  36369. * Stop the sound
  36370. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36371. */
  36372. stop(time?: number): void;
  36373. /**
  36374. * Put the sound in pause
  36375. */
  36376. pause(): void;
  36377. /**
  36378. * Sets a dedicated volume for this sounds
  36379. * @param newVolume Define the new volume of the sound
  36380. * @param time Define time for gradual change to new volume
  36381. */
  36382. setVolume(newVolume: number, time?: number): void;
  36383. /**
  36384. * Set the sound play back rate
  36385. * @param newPlaybackRate Define the playback rate the sound should be played at
  36386. */
  36387. setPlaybackRate(newPlaybackRate: number): void;
  36388. /**
  36389. * Gets the volume of the sound.
  36390. * @returns the volume of the sound
  36391. */
  36392. getVolume(): number;
  36393. /**
  36394. * Attach the sound to a dedicated mesh
  36395. * @param transformNode The transform node to connect the sound with
  36396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36397. */
  36398. attachToMesh(transformNode: TransformNode): void;
  36399. /**
  36400. * Detach the sound from the previously attached mesh
  36401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36402. */
  36403. detachFromMesh(): void;
  36404. private _onRegisterAfterWorldMatrixUpdate;
  36405. /**
  36406. * Clone the current sound in the scene.
  36407. * @returns the new sound clone
  36408. */
  36409. clone(): Nullable<Sound>;
  36410. /**
  36411. * Gets the current underlying audio buffer containing the data
  36412. * @returns the audio buffer
  36413. */
  36414. getAudioBuffer(): Nullable<AudioBuffer>;
  36415. /**
  36416. * Serializes the Sound in a JSON representation
  36417. * @returns the JSON representation of the sound
  36418. */
  36419. serialize(): any;
  36420. /**
  36421. * Parse a JSON representation of a sound to innstantiate in a given scene
  36422. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36423. * @param scene Define the scene the new parsed sound should be created in
  36424. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36425. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36426. * @returns the newly parsed sound
  36427. */
  36428. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36429. }
  36430. }
  36431. declare module "babylonjs/Actions/directAudioActions" {
  36432. import { Action } from "babylonjs/Actions/action";
  36433. import { Condition } from "babylonjs/Actions/condition";
  36434. import { Sound } from "babylonjs/Audio/sound";
  36435. /**
  36436. * This defines an action helpful to play a defined sound on a triggered action.
  36437. */
  36438. export class PlaySoundAction extends Action {
  36439. private _sound;
  36440. /**
  36441. * Instantiate the action
  36442. * @param triggerOptions defines the trigger options
  36443. * @param sound defines the sound to play
  36444. * @param condition defines the trigger related conditions
  36445. */
  36446. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36447. /** @hidden */
  36448. _prepare(): void;
  36449. /**
  36450. * Execute the action and play the sound.
  36451. */
  36452. execute(): void;
  36453. /**
  36454. * Serializes the actions and its related information.
  36455. * @param parent defines the object to serialize in
  36456. * @returns the serialized object
  36457. */
  36458. serialize(parent: any): any;
  36459. }
  36460. /**
  36461. * This defines an action helpful to stop a defined sound on a triggered action.
  36462. */
  36463. export class StopSoundAction extends Action {
  36464. private _sound;
  36465. /**
  36466. * Instantiate the action
  36467. * @param triggerOptions defines the trigger options
  36468. * @param sound defines the sound to stop
  36469. * @param condition defines the trigger related conditions
  36470. */
  36471. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36472. /** @hidden */
  36473. _prepare(): void;
  36474. /**
  36475. * Execute the action and stop the sound.
  36476. */
  36477. execute(): void;
  36478. /**
  36479. * Serializes the actions and its related information.
  36480. * @param parent defines the object to serialize in
  36481. * @returns the serialized object
  36482. */
  36483. serialize(parent: any): any;
  36484. }
  36485. }
  36486. declare module "babylonjs/Actions/interpolateValueAction" {
  36487. import { Action } from "babylonjs/Actions/action";
  36488. import { Condition } from "babylonjs/Actions/condition";
  36489. import { Observable } from "babylonjs/Misc/observable";
  36490. /**
  36491. * This defines an action responsible to change the value of a property
  36492. * by interpolating between its current value and the newly set one once triggered.
  36493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36494. */
  36495. export class InterpolateValueAction extends Action {
  36496. /**
  36497. * Defines the path of the property where the value should be interpolated
  36498. */
  36499. propertyPath: string;
  36500. /**
  36501. * Defines the target value at the end of the interpolation.
  36502. */
  36503. value: any;
  36504. /**
  36505. * Defines the time it will take for the property to interpolate to the value.
  36506. */
  36507. duration: number;
  36508. /**
  36509. * Defines if the other scene animations should be stopped when the action has been triggered
  36510. */
  36511. stopOtherAnimations?: boolean;
  36512. /**
  36513. * Defines a callback raised once the interpolation animation has been done.
  36514. */
  36515. onInterpolationDone?: () => void;
  36516. /**
  36517. * Observable triggered once the interpolation animation has been done.
  36518. */
  36519. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36520. private _target;
  36521. private _effectiveTarget;
  36522. private _property;
  36523. /**
  36524. * Instantiate the action
  36525. * @param triggerOptions defines the trigger options
  36526. * @param target defines the object containing the value to interpolate
  36527. * @param propertyPath defines the path to the property in the target object
  36528. * @param value defines the target value at the end of the interpolation
  36529. * @param duration deines the time it will take for the property to interpolate to the value.
  36530. * @param condition defines the trigger related conditions
  36531. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36532. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36533. */
  36534. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36535. /** @hidden */
  36536. _prepare(): void;
  36537. /**
  36538. * Execute the action starts the value interpolation.
  36539. */
  36540. execute(): void;
  36541. /**
  36542. * Serializes the actions and its related information.
  36543. * @param parent defines the object to serialize in
  36544. * @returns the serialized object
  36545. */
  36546. serialize(parent: any): any;
  36547. }
  36548. }
  36549. declare module "babylonjs/Actions/index" {
  36550. export * from "babylonjs/Actions/abstractActionManager";
  36551. export * from "babylonjs/Actions/action";
  36552. export * from "babylonjs/Actions/actionEvent";
  36553. export * from "babylonjs/Actions/actionManager";
  36554. export * from "babylonjs/Actions/condition";
  36555. export * from "babylonjs/Actions/directActions";
  36556. export * from "babylonjs/Actions/directAudioActions";
  36557. export * from "babylonjs/Actions/interpolateValueAction";
  36558. }
  36559. declare module "babylonjs/Animations/index" {
  36560. export * from "babylonjs/Animations/animatable";
  36561. export * from "babylonjs/Animations/animation";
  36562. export * from "babylonjs/Animations/animationGroup";
  36563. export * from "babylonjs/Animations/animationPropertiesOverride";
  36564. export * from "babylonjs/Animations/easing";
  36565. export * from "babylonjs/Animations/runtimeAnimation";
  36566. export * from "babylonjs/Animations/animationEvent";
  36567. export * from "babylonjs/Animations/animationGroup";
  36568. export * from "babylonjs/Animations/animationKey";
  36569. export * from "babylonjs/Animations/animationRange";
  36570. export * from "babylonjs/Animations/animatable.interface";
  36571. }
  36572. declare module "babylonjs/Audio/soundTrack" {
  36573. import { Sound } from "babylonjs/Audio/sound";
  36574. import { Analyser } from "babylonjs/Audio/analyser";
  36575. import { Scene } from "babylonjs/scene";
  36576. /**
  36577. * Options allowed during the creation of a sound track.
  36578. */
  36579. export interface ISoundTrackOptions {
  36580. /**
  36581. * The volume the sound track should take during creation
  36582. */
  36583. volume?: number;
  36584. /**
  36585. * Define if the sound track is the main sound track of the scene
  36586. */
  36587. mainTrack?: boolean;
  36588. }
  36589. /**
  36590. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36591. * It will be also used in a future release to apply effects on a specific track.
  36592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36593. */
  36594. export class SoundTrack {
  36595. /**
  36596. * The unique identifier of the sound track in the scene.
  36597. */
  36598. id: number;
  36599. /**
  36600. * The list of sounds included in the sound track.
  36601. */
  36602. soundCollection: Array<Sound>;
  36603. private _outputAudioNode;
  36604. private _scene;
  36605. private _isMainTrack;
  36606. private _connectedAnalyser;
  36607. private _options;
  36608. private _isInitialized;
  36609. /**
  36610. * Creates a new sound track.
  36611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36612. * @param scene Define the scene the sound track belongs to
  36613. * @param options
  36614. */
  36615. constructor(scene: Scene, options?: ISoundTrackOptions);
  36616. private _initializeSoundTrackAudioGraph;
  36617. /**
  36618. * Release the sound track and its associated resources
  36619. */
  36620. dispose(): void;
  36621. /**
  36622. * Adds a sound to this sound track
  36623. * @param sound define the cound to add
  36624. * @ignoreNaming
  36625. */
  36626. AddSound(sound: Sound): void;
  36627. /**
  36628. * Removes a sound to this sound track
  36629. * @param sound define the cound to remove
  36630. * @ignoreNaming
  36631. */
  36632. RemoveSound(sound: Sound): void;
  36633. /**
  36634. * Set a global volume for the full sound track.
  36635. * @param newVolume Define the new volume of the sound track
  36636. */
  36637. setVolume(newVolume: number): void;
  36638. /**
  36639. * Switch the panning model to HRTF:
  36640. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36642. */
  36643. switchPanningModelToHRTF(): void;
  36644. /**
  36645. * Switch the panning model to Equal Power:
  36646. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36648. */
  36649. switchPanningModelToEqualPower(): void;
  36650. /**
  36651. * Connect the sound track to an audio analyser allowing some amazing
  36652. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36654. * @param analyser The analyser to connect to the engine
  36655. */
  36656. connectToAnalyser(analyser: Analyser): void;
  36657. }
  36658. }
  36659. declare module "babylonjs/Audio/audioSceneComponent" {
  36660. import { Sound } from "babylonjs/Audio/sound";
  36661. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36662. import { Nullable } from "babylonjs/types";
  36663. import { Vector3 } from "babylonjs/Maths/math.vector";
  36664. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36665. import { Scene } from "babylonjs/scene";
  36666. import { AbstractScene } from "babylonjs/abstractScene";
  36667. import "babylonjs/Audio/audioEngine";
  36668. module "babylonjs/abstractScene" {
  36669. interface AbstractScene {
  36670. /**
  36671. * The list of sounds used in the scene.
  36672. */
  36673. sounds: Nullable<Array<Sound>>;
  36674. }
  36675. }
  36676. module "babylonjs/scene" {
  36677. interface Scene {
  36678. /**
  36679. * @hidden
  36680. * Backing field
  36681. */
  36682. _mainSoundTrack: SoundTrack;
  36683. /**
  36684. * The main sound track played by the scene.
  36685. * It cotains your primary collection of sounds.
  36686. */
  36687. mainSoundTrack: SoundTrack;
  36688. /**
  36689. * The list of sound tracks added to the scene
  36690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36691. */
  36692. soundTracks: Nullable<Array<SoundTrack>>;
  36693. /**
  36694. * Gets a sound using a given name
  36695. * @param name defines the name to search for
  36696. * @return the found sound or null if not found at all.
  36697. */
  36698. getSoundByName(name: string): Nullable<Sound>;
  36699. /**
  36700. * Gets or sets if audio support is enabled
  36701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36702. */
  36703. audioEnabled: boolean;
  36704. /**
  36705. * Gets or sets if audio will be output to headphones
  36706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36707. */
  36708. headphone: boolean;
  36709. /**
  36710. * Gets or sets custom audio listener position provider
  36711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36712. */
  36713. audioListenerPositionProvider: Nullable<() => Vector3>;
  36714. }
  36715. }
  36716. /**
  36717. * Defines the sound scene component responsible to manage any sounds
  36718. * in a given scene.
  36719. */
  36720. export class AudioSceneComponent implements ISceneSerializableComponent {
  36721. /**
  36722. * The component name helpfull to identify the component in the list of scene components.
  36723. */
  36724. readonly name: string;
  36725. /**
  36726. * The scene the component belongs to.
  36727. */
  36728. scene: Scene;
  36729. private _audioEnabled;
  36730. /**
  36731. * Gets whether audio is enabled or not.
  36732. * Please use related enable/disable method to switch state.
  36733. */
  36734. readonly audioEnabled: boolean;
  36735. private _headphone;
  36736. /**
  36737. * Gets whether audio is outputing to headphone or not.
  36738. * Please use the according Switch methods to change output.
  36739. */
  36740. readonly headphone: boolean;
  36741. private _audioListenerPositionProvider;
  36742. /**
  36743. * Gets the current audio listener position provider
  36744. */
  36745. /**
  36746. * Sets a custom listener position for all sounds in the scene
  36747. * By default, this is the position of the first active camera
  36748. */
  36749. audioListenerPositionProvider: Nullable<() => Vector3>;
  36750. /**
  36751. * Creates a new instance of the component for the given scene
  36752. * @param scene Defines the scene to register the component in
  36753. */
  36754. constructor(scene: Scene);
  36755. /**
  36756. * Registers the component in a given scene
  36757. */
  36758. register(): void;
  36759. /**
  36760. * Rebuilds the elements related to this component in case of
  36761. * context lost for instance.
  36762. */
  36763. rebuild(): void;
  36764. /**
  36765. * Serializes the component data to the specified json object
  36766. * @param serializationObject The object to serialize to
  36767. */
  36768. serialize(serializationObject: any): void;
  36769. /**
  36770. * Adds all the elements from the container to the scene
  36771. * @param container the container holding the elements
  36772. */
  36773. addFromContainer(container: AbstractScene): void;
  36774. /**
  36775. * Removes all the elements in the container from the scene
  36776. * @param container contains the elements to remove
  36777. * @param dispose if the removed element should be disposed (default: false)
  36778. */
  36779. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36780. /**
  36781. * Disposes the component and the associated ressources.
  36782. */
  36783. dispose(): void;
  36784. /**
  36785. * Disables audio in the associated scene.
  36786. */
  36787. disableAudio(): void;
  36788. /**
  36789. * Enables audio in the associated scene.
  36790. */
  36791. enableAudio(): void;
  36792. /**
  36793. * Switch audio to headphone output.
  36794. */
  36795. switchAudioModeForHeadphones(): void;
  36796. /**
  36797. * Switch audio to normal speakers.
  36798. */
  36799. switchAudioModeForNormalSpeakers(): void;
  36800. private _afterRender;
  36801. }
  36802. }
  36803. declare module "babylonjs/Audio/weightedsound" {
  36804. import { Sound } from "babylonjs/Audio/sound";
  36805. /**
  36806. * Wraps one or more Sound objects and selects one with random weight for playback.
  36807. */
  36808. export class WeightedSound {
  36809. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36810. loop: boolean;
  36811. private _coneInnerAngle;
  36812. private _coneOuterAngle;
  36813. private _volume;
  36814. /** A Sound is currently playing. */
  36815. isPlaying: boolean;
  36816. /** A Sound is currently paused. */
  36817. isPaused: boolean;
  36818. private _sounds;
  36819. private _weights;
  36820. private _currentIndex?;
  36821. /**
  36822. * Creates a new WeightedSound from the list of sounds given.
  36823. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36824. * @param sounds Array of Sounds that will be selected from.
  36825. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36826. */
  36827. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36828. /**
  36829. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36830. */
  36831. /**
  36832. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36833. */
  36834. directionalConeInnerAngle: number;
  36835. /**
  36836. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36837. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36838. */
  36839. /**
  36840. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36841. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36842. */
  36843. directionalConeOuterAngle: number;
  36844. /**
  36845. * Playback volume.
  36846. */
  36847. /**
  36848. * Playback volume.
  36849. */
  36850. volume: number;
  36851. private _onended;
  36852. /**
  36853. * Suspend playback
  36854. */
  36855. pause(): void;
  36856. /**
  36857. * Stop playback
  36858. */
  36859. stop(): void;
  36860. /**
  36861. * Start playback.
  36862. * @param startOffset Position the clip head at a specific time in seconds.
  36863. */
  36864. play(startOffset?: number): void;
  36865. }
  36866. }
  36867. declare module "babylonjs/Audio/index" {
  36868. export * from "babylonjs/Audio/analyser";
  36869. export * from "babylonjs/Audio/audioEngine";
  36870. export * from "babylonjs/Audio/audioSceneComponent";
  36871. export * from "babylonjs/Audio/sound";
  36872. export * from "babylonjs/Audio/soundTrack";
  36873. export * from "babylonjs/Audio/weightedsound";
  36874. }
  36875. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36876. import { Behavior } from "babylonjs/Behaviors/behavior";
  36877. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36878. import { BackEase } from "babylonjs/Animations/easing";
  36879. /**
  36880. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36881. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36882. */
  36883. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36884. /**
  36885. * Gets the name of the behavior.
  36886. */
  36887. readonly name: string;
  36888. /**
  36889. * The easing function used by animations
  36890. */
  36891. static EasingFunction: BackEase;
  36892. /**
  36893. * The easing mode used by animations
  36894. */
  36895. static EasingMode: number;
  36896. /**
  36897. * The duration of the animation, in milliseconds
  36898. */
  36899. transitionDuration: number;
  36900. /**
  36901. * Length of the distance animated by the transition when lower radius is reached
  36902. */
  36903. lowerRadiusTransitionRange: number;
  36904. /**
  36905. * Length of the distance animated by the transition when upper radius is reached
  36906. */
  36907. upperRadiusTransitionRange: number;
  36908. private _autoTransitionRange;
  36909. /**
  36910. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36911. */
  36912. /**
  36913. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36914. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36915. */
  36916. autoTransitionRange: boolean;
  36917. private _attachedCamera;
  36918. private _onAfterCheckInputsObserver;
  36919. private _onMeshTargetChangedObserver;
  36920. /**
  36921. * Initializes the behavior.
  36922. */
  36923. init(): void;
  36924. /**
  36925. * Attaches the behavior to its arc rotate camera.
  36926. * @param camera Defines the camera to attach the behavior to
  36927. */
  36928. attach(camera: ArcRotateCamera): void;
  36929. /**
  36930. * Detaches the behavior from its current arc rotate camera.
  36931. */
  36932. detach(): void;
  36933. private _radiusIsAnimating;
  36934. private _radiusBounceTransition;
  36935. private _animatables;
  36936. private _cachedWheelPrecision;
  36937. /**
  36938. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36939. * @param radiusLimit The limit to check against.
  36940. * @return Bool to indicate if at limit.
  36941. */
  36942. private _isRadiusAtLimit;
  36943. /**
  36944. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36945. * @param radiusDelta The delta by which to animate to. Can be negative.
  36946. */
  36947. private _applyBoundRadiusAnimation;
  36948. /**
  36949. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36950. */
  36951. protected _clearAnimationLocks(): void;
  36952. /**
  36953. * Stops and removes all animations that have been applied to the camera
  36954. */
  36955. stopAllAnimations(): void;
  36956. }
  36957. }
  36958. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36959. import { Behavior } from "babylonjs/Behaviors/behavior";
  36960. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36961. import { ExponentialEase } from "babylonjs/Animations/easing";
  36962. import { Nullable } from "babylonjs/types";
  36963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36964. import { Vector3 } from "babylonjs/Maths/math.vector";
  36965. /**
  36966. * 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.
  36967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36968. */
  36969. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36970. /**
  36971. * Gets the name of the behavior.
  36972. */
  36973. readonly name: string;
  36974. private _mode;
  36975. private _radiusScale;
  36976. private _positionScale;
  36977. private _defaultElevation;
  36978. private _elevationReturnTime;
  36979. private _elevationReturnWaitTime;
  36980. private _zoomStopsAnimation;
  36981. private _framingTime;
  36982. /**
  36983. * The easing function used by animations
  36984. */
  36985. static EasingFunction: ExponentialEase;
  36986. /**
  36987. * The easing mode used by animations
  36988. */
  36989. static EasingMode: number;
  36990. /**
  36991. * Sets the current mode used by the behavior
  36992. */
  36993. /**
  36994. * Gets current mode used by the behavior.
  36995. */
  36996. mode: number;
  36997. /**
  36998. * Sets the scale applied to the radius (1 by default)
  36999. */
  37000. /**
  37001. * Gets the scale applied to the radius
  37002. */
  37003. radiusScale: number;
  37004. /**
  37005. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37006. */
  37007. /**
  37008. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37009. */
  37010. positionScale: number;
  37011. /**
  37012. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37013. * behaviour is triggered, in radians.
  37014. */
  37015. /**
  37016. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37017. * behaviour is triggered, in radians.
  37018. */
  37019. defaultElevation: number;
  37020. /**
  37021. * Sets the time (in milliseconds) taken to return to the default beta position.
  37022. * Negative value indicates camera should not return to default.
  37023. */
  37024. /**
  37025. * Gets the time (in milliseconds) taken to return to the default beta position.
  37026. * Negative value indicates camera should not return to default.
  37027. */
  37028. elevationReturnTime: number;
  37029. /**
  37030. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37031. */
  37032. /**
  37033. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37034. */
  37035. elevationReturnWaitTime: number;
  37036. /**
  37037. * Sets the flag that indicates if user zooming should stop animation.
  37038. */
  37039. /**
  37040. * Gets the flag that indicates if user zooming should stop animation.
  37041. */
  37042. zoomStopsAnimation: boolean;
  37043. /**
  37044. * Sets the transition time when framing the mesh, in milliseconds
  37045. */
  37046. /**
  37047. * Gets the transition time when framing the mesh, in milliseconds
  37048. */
  37049. framingTime: number;
  37050. /**
  37051. * Define if the behavior should automatically change the configured
  37052. * camera limits and sensibilities.
  37053. */
  37054. autoCorrectCameraLimitsAndSensibility: boolean;
  37055. private _onPrePointerObservableObserver;
  37056. private _onAfterCheckInputsObserver;
  37057. private _onMeshTargetChangedObserver;
  37058. private _attachedCamera;
  37059. private _isPointerDown;
  37060. private _lastInteractionTime;
  37061. /**
  37062. * Initializes the behavior.
  37063. */
  37064. init(): void;
  37065. /**
  37066. * Attaches the behavior to its arc rotate camera.
  37067. * @param camera Defines the camera to attach the behavior to
  37068. */
  37069. attach(camera: ArcRotateCamera): void;
  37070. /**
  37071. * Detaches the behavior from its current arc rotate camera.
  37072. */
  37073. detach(): void;
  37074. private _animatables;
  37075. private _betaIsAnimating;
  37076. private _betaTransition;
  37077. private _radiusTransition;
  37078. private _vectorTransition;
  37079. /**
  37080. * Targets the given mesh and updates zoom level accordingly.
  37081. * @param mesh The mesh to target.
  37082. * @param radius Optional. If a cached radius position already exists, overrides default.
  37083. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37086. */
  37087. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37088. /**
  37089. * Targets the given mesh with its children and updates zoom level accordingly.
  37090. * @param mesh The mesh to target.
  37091. * @param radius Optional. If a cached radius position already exists, overrides default.
  37092. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37095. */
  37096. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37097. /**
  37098. * Targets the given meshes with their children and updates zoom level accordingly.
  37099. * @param meshes The mesh to target.
  37100. * @param radius Optional. If a cached radius position already exists, overrides default.
  37101. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37104. */
  37105. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37106. /**
  37107. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37108. * @param minimumWorld Determines the smaller position of the bounding box extend
  37109. * @param maximumWorld Determines the bigger position of the bounding box extend
  37110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37112. */
  37113. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37114. /**
  37115. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37116. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37117. * frustum width.
  37118. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37119. * to fully enclose the mesh in the viewing frustum.
  37120. */
  37121. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37122. /**
  37123. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37124. * is automatically returned to its default position (expected to be above ground plane).
  37125. */
  37126. private _maintainCameraAboveGround;
  37127. /**
  37128. * Returns the frustum slope based on the canvas ratio and camera FOV
  37129. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37130. */
  37131. private _getFrustumSlope;
  37132. /**
  37133. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37134. */
  37135. private _clearAnimationLocks;
  37136. /**
  37137. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37138. */
  37139. private _applyUserInteraction;
  37140. /**
  37141. * Stops and removes all animations that have been applied to the camera
  37142. */
  37143. stopAllAnimations(): void;
  37144. /**
  37145. * Gets a value indicating if the user is moving the camera
  37146. */
  37147. readonly isUserIsMoving: boolean;
  37148. /**
  37149. * The camera can move all the way towards the mesh.
  37150. */
  37151. static IgnoreBoundsSizeMode: number;
  37152. /**
  37153. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37154. */
  37155. static FitFrustumSidesMode: number;
  37156. }
  37157. }
  37158. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37159. import { Nullable } from "babylonjs/types";
  37160. import { Camera } from "babylonjs/Cameras/camera";
  37161. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37162. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37163. /**
  37164. * Base class for Camera Pointer Inputs.
  37165. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37166. * for example usage.
  37167. */
  37168. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37169. /**
  37170. * Defines the camera the input is attached to.
  37171. */
  37172. abstract camera: Camera;
  37173. /**
  37174. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37175. */
  37176. protected _altKey: boolean;
  37177. protected _ctrlKey: boolean;
  37178. protected _metaKey: boolean;
  37179. protected _shiftKey: boolean;
  37180. /**
  37181. * Which mouse buttons were pressed at time of last mouse event.
  37182. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37183. */
  37184. protected _buttonsPressed: number;
  37185. /**
  37186. * Defines the buttons associated with the input to handle camera move.
  37187. */
  37188. buttons: number[];
  37189. /**
  37190. * Attach the input controls to a specific dom element to get the input from.
  37191. * @param element Defines the element the controls should be listened from
  37192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37193. */
  37194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37195. /**
  37196. * Detach the current controls from the specified dom element.
  37197. * @param element Defines the element to stop listening the inputs from
  37198. */
  37199. detachControl(element: Nullable<HTMLElement>): void;
  37200. /**
  37201. * Gets the class name of the current input.
  37202. * @returns the class name
  37203. */
  37204. getClassName(): string;
  37205. /**
  37206. * Get the friendly name associated with the input class.
  37207. * @returns the input friendly name
  37208. */
  37209. getSimpleName(): string;
  37210. /**
  37211. * Called on pointer POINTERDOUBLETAP event.
  37212. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37213. */
  37214. protected onDoubleTap(type: string): void;
  37215. /**
  37216. * Called on pointer POINTERMOVE event if only a single touch is active.
  37217. * Override this method to provide functionality.
  37218. */
  37219. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37220. /**
  37221. * Called on pointer POINTERMOVE event if multiple touches are active.
  37222. * Override this method to provide functionality.
  37223. */
  37224. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37225. /**
  37226. * Called on JS contextmenu event.
  37227. * Override this method to provide functionality.
  37228. */
  37229. protected onContextMenu(evt: PointerEvent): void;
  37230. /**
  37231. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37232. * press.
  37233. * Override this method to provide functionality.
  37234. */
  37235. protected onButtonDown(evt: PointerEvent): void;
  37236. /**
  37237. * Called each time a new POINTERUP event occurs. Ie, for each button
  37238. * release.
  37239. * Override this method to provide functionality.
  37240. */
  37241. protected onButtonUp(evt: PointerEvent): void;
  37242. /**
  37243. * Called when window becomes inactive.
  37244. * Override this method to provide functionality.
  37245. */
  37246. protected onLostFocus(): void;
  37247. private _pointerInput;
  37248. private _observer;
  37249. private _onLostFocus;
  37250. private pointA;
  37251. private pointB;
  37252. }
  37253. }
  37254. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37255. import { Nullable } from "babylonjs/types";
  37256. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37257. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37258. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37259. /**
  37260. * Manage the pointers inputs to control an arc rotate camera.
  37261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37262. */
  37263. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37264. /**
  37265. * Defines the camera the input is attached to.
  37266. */
  37267. camera: ArcRotateCamera;
  37268. /**
  37269. * Gets the class name of the current input.
  37270. * @returns the class name
  37271. */
  37272. getClassName(): string;
  37273. /**
  37274. * Defines the buttons associated with the input to handle camera move.
  37275. */
  37276. buttons: number[];
  37277. /**
  37278. * Defines the pointer angular sensibility along the X axis or how fast is
  37279. * the camera rotating.
  37280. */
  37281. angularSensibilityX: number;
  37282. /**
  37283. * Defines the pointer angular sensibility along the Y axis or how fast is
  37284. * the camera rotating.
  37285. */
  37286. angularSensibilityY: number;
  37287. /**
  37288. * Defines the pointer pinch precision or how fast is the camera zooming.
  37289. */
  37290. pinchPrecision: number;
  37291. /**
  37292. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37293. * from 0.
  37294. * It defines the percentage of current camera.radius to use as delta when
  37295. * pinch zoom is used.
  37296. */
  37297. pinchDeltaPercentage: number;
  37298. /**
  37299. * Defines the pointer panning sensibility or how fast is the camera moving.
  37300. */
  37301. panningSensibility: number;
  37302. /**
  37303. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37304. */
  37305. multiTouchPanning: boolean;
  37306. /**
  37307. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37308. * zoom (pinch) through multitouch.
  37309. */
  37310. multiTouchPanAndZoom: boolean;
  37311. /**
  37312. * Revers pinch action direction.
  37313. */
  37314. pinchInwards: boolean;
  37315. private _isPanClick;
  37316. private _twoFingerActivityCount;
  37317. private _isPinching;
  37318. /**
  37319. * Called on pointer POINTERMOVE event if only a single touch is active.
  37320. */
  37321. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37322. /**
  37323. * Called on pointer POINTERDOUBLETAP event.
  37324. */
  37325. protected onDoubleTap(type: string): void;
  37326. /**
  37327. * Called on pointer POINTERMOVE event if multiple touches are active.
  37328. */
  37329. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37330. /**
  37331. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37332. * press.
  37333. */
  37334. protected onButtonDown(evt: PointerEvent): void;
  37335. /**
  37336. * Called each time a new POINTERUP event occurs. Ie, for each button
  37337. * release.
  37338. */
  37339. protected onButtonUp(evt: PointerEvent): void;
  37340. /**
  37341. * Called when window becomes inactive.
  37342. */
  37343. protected onLostFocus(): void;
  37344. }
  37345. }
  37346. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37347. import { Nullable } from "babylonjs/types";
  37348. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37349. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37350. /**
  37351. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37353. */
  37354. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37355. /**
  37356. * Defines the camera the input is attached to.
  37357. */
  37358. camera: ArcRotateCamera;
  37359. /**
  37360. * Defines the list of key codes associated with the up action (increase alpha)
  37361. */
  37362. keysUp: number[];
  37363. /**
  37364. * Defines the list of key codes associated with the down action (decrease alpha)
  37365. */
  37366. keysDown: number[];
  37367. /**
  37368. * Defines the list of key codes associated with the left action (increase beta)
  37369. */
  37370. keysLeft: number[];
  37371. /**
  37372. * Defines the list of key codes associated with the right action (decrease beta)
  37373. */
  37374. keysRight: number[];
  37375. /**
  37376. * Defines the list of key codes associated with the reset action.
  37377. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37378. */
  37379. keysReset: number[];
  37380. /**
  37381. * Defines the panning sensibility of the inputs.
  37382. * (How fast is the camera paning)
  37383. */
  37384. panningSensibility: number;
  37385. /**
  37386. * Defines the zooming sensibility of the inputs.
  37387. * (How fast is the camera zooming)
  37388. */
  37389. zoomingSensibility: number;
  37390. /**
  37391. * Defines wether maintaining the alt key down switch the movement mode from
  37392. * orientation to zoom.
  37393. */
  37394. useAltToZoom: boolean;
  37395. /**
  37396. * Rotation speed of the camera
  37397. */
  37398. angularSpeed: number;
  37399. private _keys;
  37400. private _ctrlPressed;
  37401. private _altPressed;
  37402. private _onCanvasBlurObserver;
  37403. private _onKeyboardObserver;
  37404. private _engine;
  37405. private _scene;
  37406. /**
  37407. * Attach the input controls to a specific dom element to get the input from.
  37408. * @param element Defines the element the controls should be listened from
  37409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37410. */
  37411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37412. /**
  37413. * Detach the current controls from the specified dom element.
  37414. * @param element Defines the element to stop listening the inputs from
  37415. */
  37416. detachControl(element: Nullable<HTMLElement>): void;
  37417. /**
  37418. * Update the current camera state depending on the inputs that have been used this frame.
  37419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37420. */
  37421. checkInputs(): void;
  37422. /**
  37423. * Gets the class name of the current intput.
  37424. * @returns the class name
  37425. */
  37426. getClassName(): string;
  37427. /**
  37428. * Get the friendly name associated with the input class.
  37429. * @returns the input friendly name
  37430. */
  37431. getSimpleName(): string;
  37432. }
  37433. }
  37434. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37435. import { Nullable } from "babylonjs/types";
  37436. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37437. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37438. /**
  37439. * Manage the mouse wheel inputs to control an arc rotate camera.
  37440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37441. */
  37442. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37443. /**
  37444. * Defines the camera the input is attached to.
  37445. */
  37446. camera: ArcRotateCamera;
  37447. /**
  37448. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37449. */
  37450. wheelPrecision: number;
  37451. /**
  37452. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37453. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37454. */
  37455. wheelDeltaPercentage: number;
  37456. private _wheel;
  37457. private _observer;
  37458. private computeDeltaFromMouseWheelLegacyEvent;
  37459. /**
  37460. * Attach the input controls to a specific dom element to get the input from.
  37461. * @param element Defines the element the controls should be listened from
  37462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37463. */
  37464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37465. /**
  37466. * Detach the current controls from the specified dom element.
  37467. * @param element Defines the element to stop listening the inputs from
  37468. */
  37469. detachControl(element: Nullable<HTMLElement>): void;
  37470. /**
  37471. * Gets the class name of the current intput.
  37472. * @returns the class name
  37473. */
  37474. getClassName(): string;
  37475. /**
  37476. * Get the friendly name associated with the input class.
  37477. * @returns the input friendly name
  37478. */
  37479. getSimpleName(): string;
  37480. }
  37481. }
  37482. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37483. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37484. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37485. /**
  37486. * Default Inputs manager for the ArcRotateCamera.
  37487. * It groups all the default supported inputs for ease of use.
  37488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37489. */
  37490. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37491. /**
  37492. * Instantiates a new ArcRotateCameraInputsManager.
  37493. * @param camera Defines the camera the inputs belong to
  37494. */
  37495. constructor(camera: ArcRotateCamera);
  37496. /**
  37497. * Add mouse wheel input support to the input manager.
  37498. * @returns the current input manager
  37499. */
  37500. addMouseWheel(): ArcRotateCameraInputsManager;
  37501. /**
  37502. * Add pointers input support to the input manager.
  37503. * @returns the current input manager
  37504. */
  37505. addPointers(): ArcRotateCameraInputsManager;
  37506. /**
  37507. * Add keyboard input support to the input manager.
  37508. * @returns the current input manager
  37509. */
  37510. addKeyboard(): ArcRotateCameraInputsManager;
  37511. }
  37512. }
  37513. declare module "babylonjs/Cameras/arcRotateCamera" {
  37514. import { Observable } from "babylonjs/Misc/observable";
  37515. import { Nullable } from "babylonjs/types";
  37516. import { Scene } from "babylonjs/scene";
  37517. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37519. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37520. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37521. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37522. import { Camera } from "babylonjs/Cameras/camera";
  37523. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37524. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37525. import { Collider } from "babylonjs/Collisions/collider";
  37526. /**
  37527. * This represents an orbital type of camera.
  37528. *
  37529. * 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.
  37530. * 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.
  37531. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37532. */
  37533. export class ArcRotateCamera extends TargetCamera {
  37534. /**
  37535. * Defines the rotation angle of the camera along the longitudinal axis.
  37536. */
  37537. alpha: number;
  37538. /**
  37539. * Defines the rotation angle of the camera along the latitudinal axis.
  37540. */
  37541. beta: number;
  37542. /**
  37543. * Defines the radius of the camera from it s target point.
  37544. */
  37545. radius: number;
  37546. protected _target: Vector3;
  37547. protected _targetHost: Nullable<AbstractMesh>;
  37548. /**
  37549. * Defines the target point of the camera.
  37550. * The camera looks towards it form the radius distance.
  37551. */
  37552. target: Vector3;
  37553. /**
  37554. * Define the current local position of the camera in the scene
  37555. */
  37556. position: Vector3;
  37557. protected _upVector: Vector3;
  37558. protected _upToYMatrix: Matrix;
  37559. protected _YToUpMatrix: Matrix;
  37560. /**
  37561. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37562. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37563. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37564. */
  37565. upVector: Vector3;
  37566. /**
  37567. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37568. */
  37569. setMatUp(): void;
  37570. /**
  37571. * Current inertia value on the longitudinal axis.
  37572. * The bigger this number the longer it will take for the camera to stop.
  37573. */
  37574. inertialAlphaOffset: number;
  37575. /**
  37576. * Current inertia value on the latitudinal axis.
  37577. * The bigger this number the longer it will take for the camera to stop.
  37578. */
  37579. inertialBetaOffset: number;
  37580. /**
  37581. * Current inertia value on the radius axis.
  37582. * The bigger this number the longer it will take for the camera to stop.
  37583. */
  37584. inertialRadiusOffset: number;
  37585. /**
  37586. * Minimum allowed angle on the longitudinal axis.
  37587. * This can help limiting how the Camera is able to move in the scene.
  37588. */
  37589. lowerAlphaLimit: Nullable<number>;
  37590. /**
  37591. * Maximum allowed angle on the longitudinal axis.
  37592. * This can help limiting how the Camera is able to move in the scene.
  37593. */
  37594. upperAlphaLimit: Nullable<number>;
  37595. /**
  37596. * Minimum allowed angle on the latitudinal axis.
  37597. * This can help limiting how the Camera is able to move in the scene.
  37598. */
  37599. lowerBetaLimit: number;
  37600. /**
  37601. * Maximum allowed angle on the latitudinal axis.
  37602. * This can help limiting how the Camera is able to move in the scene.
  37603. */
  37604. upperBetaLimit: number;
  37605. /**
  37606. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37607. * This can help limiting how the Camera is able to move in the scene.
  37608. */
  37609. lowerRadiusLimit: Nullable<number>;
  37610. /**
  37611. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37612. * This can help limiting how the Camera is able to move in the scene.
  37613. */
  37614. upperRadiusLimit: Nullable<number>;
  37615. /**
  37616. * Defines the current inertia value used during panning of the camera along the X axis.
  37617. */
  37618. inertialPanningX: number;
  37619. /**
  37620. * Defines the current inertia value used during panning of the camera along the Y axis.
  37621. */
  37622. inertialPanningY: number;
  37623. /**
  37624. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37625. * Basically if your fingers moves away from more than this distance you will be considered
  37626. * in pinch mode.
  37627. */
  37628. pinchToPanMaxDistance: number;
  37629. /**
  37630. * Defines the maximum distance the camera can pan.
  37631. * This could help keeping the cammera always in your scene.
  37632. */
  37633. panningDistanceLimit: Nullable<number>;
  37634. /**
  37635. * Defines the target of the camera before paning.
  37636. */
  37637. panningOriginTarget: Vector3;
  37638. /**
  37639. * Defines the value of the inertia used during panning.
  37640. * 0 would mean stop inertia and one would mean no decelleration at all.
  37641. */
  37642. panningInertia: number;
  37643. /**
  37644. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37645. */
  37646. angularSensibilityX: number;
  37647. /**
  37648. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37649. */
  37650. angularSensibilityY: number;
  37651. /**
  37652. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37653. */
  37654. pinchPrecision: number;
  37655. /**
  37656. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37657. * It will be used instead of pinchDeltaPrecision if different from 0.
  37658. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37659. */
  37660. pinchDeltaPercentage: number;
  37661. /**
  37662. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37663. */
  37664. panningSensibility: number;
  37665. /**
  37666. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37667. */
  37668. keysUp: number[];
  37669. /**
  37670. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37671. */
  37672. keysDown: number[];
  37673. /**
  37674. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37675. */
  37676. keysLeft: number[];
  37677. /**
  37678. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37679. */
  37680. keysRight: number[];
  37681. /**
  37682. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37683. */
  37684. wheelPrecision: number;
  37685. /**
  37686. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37687. * It will be used instead of pinchDeltaPrecision if different from 0.
  37688. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37689. */
  37690. wheelDeltaPercentage: number;
  37691. /**
  37692. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37693. */
  37694. zoomOnFactor: number;
  37695. /**
  37696. * Defines a screen offset for the camera position.
  37697. */
  37698. targetScreenOffset: Vector2;
  37699. /**
  37700. * Allows the camera to be completely reversed.
  37701. * If false the camera can not arrive upside down.
  37702. */
  37703. allowUpsideDown: boolean;
  37704. /**
  37705. * Define if double tap/click is used to restore the previously saved state of the camera.
  37706. */
  37707. useInputToRestoreState: boolean;
  37708. /** @hidden */
  37709. _viewMatrix: Matrix;
  37710. /** @hidden */
  37711. _useCtrlForPanning: boolean;
  37712. /** @hidden */
  37713. _panningMouseButton: number;
  37714. /**
  37715. * Defines the input associated to the camera.
  37716. */
  37717. inputs: ArcRotateCameraInputsManager;
  37718. /** @hidden */
  37719. _reset: () => void;
  37720. /**
  37721. * Defines the allowed panning axis.
  37722. */
  37723. panningAxis: Vector3;
  37724. protected _localDirection: Vector3;
  37725. protected _transformedDirection: Vector3;
  37726. private _bouncingBehavior;
  37727. /**
  37728. * Gets the bouncing behavior of the camera if it has been enabled.
  37729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37730. */
  37731. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37732. /**
  37733. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37734. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37735. */
  37736. useBouncingBehavior: boolean;
  37737. private _framingBehavior;
  37738. /**
  37739. * Gets the framing behavior of the camera if it has been enabled.
  37740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37741. */
  37742. readonly framingBehavior: Nullable<FramingBehavior>;
  37743. /**
  37744. * Defines if the framing behavior of the camera is enabled on the camera.
  37745. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37746. */
  37747. useFramingBehavior: boolean;
  37748. private _autoRotationBehavior;
  37749. /**
  37750. * Gets the auto rotation behavior of the camera if it has been enabled.
  37751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37752. */
  37753. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37754. /**
  37755. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37756. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37757. */
  37758. useAutoRotationBehavior: boolean;
  37759. /**
  37760. * Observable triggered when the mesh target has been changed on the camera.
  37761. */
  37762. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37763. /**
  37764. * Event raised when the camera is colliding with a mesh.
  37765. */
  37766. onCollide: (collidedMesh: AbstractMesh) => void;
  37767. /**
  37768. * Defines whether the camera should check collision with the objects oh the scene.
  37769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37770. */
  37771. checkCollisions: boolean;
  37772. /**
  37773. * Defines the collision radius of the camera.
  37774. * This simulates a sphere around the camera.
  37775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37776. */
  37777. collisionRadius: Vector3;
  37778. protected _collider: Collider;
  37779. protected _previousPosition: Vector3;
  37780. protected _collisionVelocity: Vector3;
  37781. protected _newPosition: Vector3;
  37782. protected _previousAlpha: number;
  37783. protected _previousBeta: number;
  37784. protected _previousRadius: number;
  37785. protected _collisionTriggered: boolean;
  37786. protected _targetBoundingCenter: Nullable<Vector3>;
  37787. private _computationVector;
  37788. /**
  37789. * Instantiates a new ArcRotateCamera in a given scene
  37790. * @param name Defines the name of the camera
  37791. * @param alpha Defines the camera rotation along the logitudinal axis
  37792. * @param beta Defines the camera rotation along the latitudinal axis
  37793. * @param radius Defines the camera distance from its target
  37794. * @param target Defines the camera target
  37795. * @param scene Defines the scene the camera belongs to
  37796. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37797. */
  37798. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37799. /** @hidden */
  37800. _initCache(): void;
  37801. /** @hidden */
  37802. _updateCache(ignoreParentClass?: boolean): void;
  37803. protected _getTargetPosition(): Vector3;
  37804. private _storedAlpha;
  37805. private _storedBeta;
  37806. private _storedRadius;
  37807. private _storedTarget;
  37808. private _storedTargetScreenOffset;
  37809. /**
  37810. * Stores the current state of the camera (alpha, beta, radius and target)
  37811. * @returns the camera itself
  37812. */
  37813. storeState(): Camera;
  37814. /**
  37815. * @hidden
  37816. * Restored camera state. You must call storeState() first
  37817. */
  37818. _restoreStateValues(): boolean;
  37819. /** @hidden */
  37820. _isSynchronizedViewMatrix(): boolean;
  37821. /**
  37822. * Attached controls to the current camera.
  37823. * @param element Defines the element the controls should be listened from
  37824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37825. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37826. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37827. */
  37828. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37829. /**
  37830. * Detach the current controls from the camera.
  37831. * The camera will stop reacting to inputs.
  37832. * @param element Defines the element to stop listening the inputs from
  37833. */
  37834. detachControl(element: HTMLElement): void;
  37835. /** @hidden */
  37836. _checkInputs(): void;
  37837. protected _checkLimits(): void;
  37838. /**
  37839. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37840. */
  37841. rebuildAnglesAndRadius(): void;
  37842. /**
  37843. * Use a position to define the current camera related information like alpha, beta and radius
  37844. * @param position Defines the position to set the camera at
  37845. */
  37846. setPosition(position: Vector3): void;
  37847. /**
  37848. * Defines the target the camera should look at.
  37849. * This will automatically adapt alpha beta and radius to fit within the new target.
  37850. * @param target Defines the new target as a Vector or a mesh
  37851. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37852. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37853. */
  37854. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37855. /** @hidden */
  37856. _getViewMatrix(): Matrix;
  37857. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37858. /**
  37859. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37860. * @param meshes Defines the mesh to zoom on
  37861. * @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)
  37862. */
  37863. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37864. /**
  37865. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37866. * The target will be changed but the radius
  37867. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37868. * @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)
  37869. */
  37870. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37871. min: Vector3;
  37872. max: Vector3;
  37873. distance: number;
  37874. }, doNotUpdateMaxZ?: boolean): void;
  37875. /**
  37876. * @override
  37877. * Override Camera.createRigCamera
  37878. */
  37879. createRigCamera(name: string, cameraIndex: number): Camera;
  37880. /**
  37881. * @hidden
  37882. * @override
  37883. * Override Camera._updateRigCameras
  37884. */
  37885. _updateRigCameras(): void;
  37886. /**
  37887. * Destroy the camera and release the current resources hold by it.
  37888. */
  37889. dispose(): void;
  37890. /**
  37891. * Gets the current object class name.
  37892. * @return the class name
  37893. */
  37894. getClassName(): string;
  37895. }
  37896. }
  37897. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37898. import { Behavior } from "babylonjs/Behaviors/behavior";
  37899. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37900. /**
  37901. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37903. */
  37904. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37905. /**
  37906. * Gets the name of the behavior.
  37907. */
  37908. readonly name: string;
  37909. private _zoomStopsAnimation;
  37910. private _idleRotationSpeed;
  37911. private _idleRotationWaitTime;
  37912. private _idleRotationSpinupTime;
  37913. /**
  37914. * Sets the flag that indicates if user zooming should stop animation.
  37915. */
  37916. /**
  37917. * Gets the flag that indicates if user zooming should stop animation.
  37918. */
  37919. zoomStopsAnimation: boolean;
  37920. /**
  37921. * Sets the default speed at which the camera rotates around the model.
  37922. */
  37923. /**
  37924. * Gets the default speed at which the camera rotates around the model.
  37925. */
  37926. idleRotationSpeed: number;
  37927. /**
  37928. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37929. */
  37930. /**
  37931. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37932. */
  37933. idleRotationWaitTime: number;
  37934. /**
  37935. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37936. */
  37937. /**
  37938. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37939. */
  37940. idleRotationSpinupTime: number;
  37941. /**
  37942. * Gets a value indicating if the camera is currently rotating because of this behavior
  37943. */
  37944. readonly rotationInProgress: boolean;
  37945. private _onPrePointerObservableObserver;
  37946. private _onAfterCheckInputsObserver;
  37947. private _attachedCamera;
  37948. private _isPointerDown;
  37949. private _lastFrameTime;
  37950. private _lastInteractionTime;
  37951. private _cameraRotationSpeed;
  37952. /**
  37953. * Initializes the behavior.
  37954. */
  37955. init(): void;
  37956. /**
  37957. * Attaches the behavior to its arc rotate camera.
  37958. * @param camera Defines the camera to attach the behavior to
  37959. */
  37960. attach(camera: ArcRotateCamera): void;
  37961. /**
  37962. * Detaches the behavior from its current arc rotate camera.
  37963. */
  37964. detach(): void;
  37965. /**
  37966. * Returns true if user is scrolling.
  37967. * @return true if user is scrolling.
  37968. */
  37969. private _userIsZooming;
  37970. private _lastFrameRadius;
  37971. private _shouldAnimationStopForInteraction;
  37972. /**
  37973. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37974. */
  37975. private _applyUserInteraction;
  37976. private _userIsMoving;
  37977. }
  37978. }
  37979. declare module "babylonjs/Behaviors/Cameras/index" {
  37980. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37981. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37982. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37983. }
  37984. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37985. import { Mesh } from "babylonjs/Meshes/mesh";
  37986. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37987. import { Behavior } from "babylonjs/Behaviors/behavior";
  37988. /**
  37989. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37990. */
  37991. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37992. private ui;
  37993. /**
  37994. * The name of the behavior
  37995. */
  37996. name: string;
  37997. /**
  37998. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37999. */
  38000. distanceAwayFromFace: number;
  38001. /**
  38002. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38003. */
  38004. distanceAwayFromBottomOfFace: number;
  38005. private _faceVectors;
  38006. private _target;
  38007. private _scene;
  38008. private _onRenderObserver;
  38009. private _tmpMatrix;
  38010. private _tmpVector;
  38011. /**
  38012. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38013. * @param ui The transform node that should be attched to the mesh
  38014. */
  38015. constructor(ui: TransformNode);
  38016. /**
  38017. * Initializes the behavior
  38018. */
  38019. init(): void;
  38020. private _closestFace;
  38021. private _zeroVector;
  38022. private _lookAtTmpMatrix;
  38023. private _lookAtToRef;
  38024. /**
  38025. * Attaches the AttachToBoxBehavior to the passed in mesh
  38026. * @param target The mesh that the specified node will be attached to
  38027. */
  38028. attach(target: Mesh): void;
  38029. /**
  38030. * Detaches the behavior from the mesh
  38031. */
  38032. detach(): void;
  38033. }
  38034. }
  38035. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38036. import { Behavior } from "babylonjs/Behaviors/behavior";
  38037. import { Mesh } from "babylonjs/Meshes/mesh";
  38038. /**
  38039. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38040. */
  38041. export class FadeInOutBehavior implements Behavior<Mesh> {
  38042. /**
  38043. * Time in milliseconds to delay before fading in (Default: 0)
  38044. */
  38045. delay: number;
  38046. /**
  38047. * Time in milliseconds for the mesh to fade in (Default: 300)
  38048. */
  38049. fadeInTime: number;
  38050. private _millisecondsPerFrame;
  38051. private _hovered;
  38052. private _hoverValue;
  38053. private _ownerNode;
  38054. /**
  38055. * Instatiates the FadeInOutBehavior
  38056. */
  38057. constructor();
  38058. /**
  38059. * The name of the behavior
  38060. */
  38061. readonly name: string;
  38062. /**
  38063. * Initializes the behavior
  38064. */
  38065. init(): void;
  38066. /**
  38067. * Attaches the fade behavior on the passed in mesh
  38068. * @param ownerNode The mesh that will be faded in/out once attached
  38069. */
  38070. attach(ownerNode: Mesh): void;
  38071. /**
  38072. * Detaches the behavior from the mesh
  38073. */
  38074. detach(): void;
  38075. /**
  38076. * Triggers the mesh to begin fading in or out
  38077. * @param value if the object should fade in or out (true to fade in)
  38078. */
  38079. fadeIn(value: boolean): void;
  38080. private _update;
  38081. private _setAllVisibility;
  38082. }
  38083. }
  38084. declare module "babylonjs/Misc/pivotTools" {
  38085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38086. /**
  38087. * Class containing a set of static utilities functions for managing Pivots
  38088. * @hidden
  38089. */
  38090. export class PivotTools {
  38091. private static _PivotCached;
  38092. private static _OldPivotPoint;
  38093. private static _PivotTranslation;
  38094. private static _PivotTmpVector;
  38095. /** @hidden */
  38096. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38097. /** @hidden */
  38098. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38099. }
  38100. }
  38101. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38102. import { Scene } from "babylonjs/scene";
  38103. import { Vector4 } from "babylonjs/Maths/math.vector";
  38104. import { Mesh } from "babylonjs/Meshes/mesh";
  38105. import { Nullable } from "babylonjs/types";
  38106. import { Plane } from "babylonjs/Maths/math.plane";
  38107. /**
  38108. * Class containing static functions to help procedurally build meshes
  38109. */
  38110. export class PlaneBuilder {
  38111. /**
  38112. * Creates a plane mesh
  38113. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38114. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38115. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38119. * @param name defines the name of the mesh
  38120. * @param options defines the options used to create the mesh
  38121. * @param scene defines the hosting scene
  38122. * @returns the plane mesh
  38123. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38124. */
  38125. static CreatePlane(name: string, options: {
  38126. size?: number;
  38127. width?: number;
  38128. height?: number;
  38129. sideOrientation?: number;
  38130. frontUVs?: Vector4;
  38131. backUVs?: Vector4;
  38132. updatable?: boolean;
  38133. sourcePlane?: Plane;
  38134. }, scene?: Nullable<Scene>): Mesh;
  38135. }
  38136. }
  38137. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38138. import { Behavior } from "babylonjs/Behaviors/behavior";
  38139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38140. import { Observable } from "babylonjs/Misc/observable";
  38141. import { Vector3 } from "babylonjs/Maths/math.vector";
  38142. import { Ray } from "babylonjs/Culling/ray";
  38143. import "babylonjs/Meshes/Builders/planeBuilder";
  38144. /**
  38145. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38146. */
  38147. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38148. private static _AnyMouseID;
  38149. /**
  38150. * Abstract mesh the behavior is set on
  38151. */
  38152. attachedNode: AbstractMesh;
  38153. private _dragPlane;
  38154. private _scene;
  38155. private _pointerObserver;
  38156. private _beforeRenderObserver;
  38157. private static _planeScene;
  38158. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38159. /**
  38160. * 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)
  38161. */
  38162. maxDragAngle: number;
  38163. /**
  38164. * @hidden
  38165. */
  38166. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38167. /**
  38168. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38169. */
  38170. currentDraggingPointerID: number;
  38171. /**
  38172. * The last position where the pointer hit the drag plane in world space
  38173. */
  38174. lastDragPosition: Vector3;
  38175. /**
  38176. * If the behavior is currently in a dragging state
  38177. */
  38178. dragging: boolean;
  38179. /**
  38180. * 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)
  38181. */
  38182. dragDeltaRatio: number;
  38183. /**
  38184. * If the drag plane orientation should be updated during the dragging (Default: true)
  38185. */
  38186. updateDragPlane: boolean;
  38187. private _debugMode;
  38188. private _moving;
  38189. /**
  38190. * Fires each time the attached mesh is dragged with the pointer
  38191. * * delta between last drag position and current drag position in world space
  38192. * * dragDistance along the drag axis
  38193. * * dragPlaneNormal normal of the current drag plane used during the drag
  38194. * * dragPlanePoint in world space where the drag intersects the drag plane
  38195. */
  38196. onDragObservable: Observable<{
  38197. delta: Vector3;
  38198. dragPlanePoint: Vector3;
  38199. dragPlaneNormal: Vector3;
  38200. dragDistance: number;
  38201. pointerId: number;
  38202. }>;
  38203. /**
  38204. * Fires each time a drag begins (eg. mouse down on mesh)
  38205. */
  38206. onDragStartObservable: Observable<{
  38207. dragPlanePoint: Vector3;
  38208. pointerId: number;
  38209. }>;
  38210. /**
  38211. * Fires each time a drag ends (eg. mouse release after drag)
  38212. */
  38213. onDragEndObservable: Observable<{
  38214. dragPlanePoint: Vector3;
  38215. pointerId: number;
  38216. }>;
  38217. /**
  38218. * If the attached mesh should be moved when dragged
  38219. */
  38220. moveAttached: boolean;
  38221. /**
  38222. * If the drag behavior will react to drag events (Default: true)
  38223. */
  38224. enabled: boolean;
  38225. /**
  38226. * If pointer events should start and release the drag (Default: true)
  38227. */
  38228. startAndReleaseDragOnPointerEvents: boolean;
  38229. /**
  38230. * If camera controls should be detached during the drag
  38231. */
  38232. detachCameraControls: boolean;
  38233. /**
  38234. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38235. */
  38236. useObjectOrienationForDragging: boolean;
  38237. private _options;
  38238. /**
  38239. * Creates a pointer drag behavior that can be attached to a mesh
  38240. * @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)
  38241. */
  38242. constructor(options?: {
  38243. dragAxis?: Vector3;
  38244. dragPlaneNormal?: Vector3;
  38245. });
  38246. /**
  38247. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38248. */
  38249. validateDrag: (targetPosition: Vector3) => boolean;
  38250. /**
  38251. * The name of the behavior
  38252. */
  38253. readonly name: string;
  38254. /**
  38255. * Initializes the behavior
  38256. */
  38257. init(): void;
  38258. private _tmpVector;
  38259. private _alternatePickedPoint;
  38260. private _worldDragAxis;
  38261. private _targetPosition;
  38262. private _attachedElement;
  38263. /**
  38264. * Attaches the drag behavior the passed in mesh
  38265. * @param ownerNode The mesh that will be dragged around once attached
  38266. * @param predicate Predicate to use for pick filtering
  38267. */
  38268. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38269. /**
  38270. * Force relase the drag action by code.
  38271. */
  38272. releaseDrag(): void;
  38273. private _startDragRay;
  38274. private _lastPointerRay;
  38275. /**
  38276. * Simulates the start of a pointer drag event on the behavior
  38277. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38278. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38279. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38280. */
  38281. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38282. private _startDrag;
  38283. private _dragDelta;
  38284. private _moveDrag;
  38285. private _pickWithRayOnDragPlane;
  38286. private _pointA;
  38287. private _pointB;
  38288. private _pointC;
  38289. private _lineA;
  38290. private _lineB;
  38291. private _localAxis;
  38292. private _lookAt;
  38293. private _updateDragPlanePosition;
  38294. /**
  38295. * Detaches the behavior from the mesh
  38296. */
  38297. detach(): void;
  38298. }
  38299. }
  38300. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38301. import { Mesh } from "babylonjs/Meshes/mesh";
  38302. import { Behavior } from "babylonjs/Behaviors/behavior";
  38303. /**
  38304. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38305. */
  38306. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38307. private _dragBehaviorA;
  38308. private _dragBehaviorB;
  38309. private _startDistance;
  38310. private _initialScale;
  38311. private _targetScale;
  38312. private _ownerNode;
  38313. private _sceneRenderObserver;
  38314. /**
  38315. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38316. */
  38317. constructor();
  38318. /**
  38319. * The name of the behavior
  38320. */
  38321. readonly name: string;
  38322. /**
  38323. * Initializes the behavior
  38324. */
  38325. init(): void;
  38326. private _getCurrentDistance;
  38327. /**
  38328. * Attaches the scale behavior the passed in mesh
  38329. * @param ownerNode The mesh that will be scaled around once attached
  38330. */
  38331. attach(ownerNode: Mesh): void;
  38332. /**
  38333. * Detaches the behavior from the mesh
  38334. */
  38335. detach(): void;
  38336. }
  38337. }
  38338. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38339. import { Behavior } from "babylonjs/Behaviors/behavior";
  38340. import { Mesh } from "babylonjs/Meshes/mesh";
  38341. import { Observable } from "babylonjs/Misc/observable";
  38342. /**
  38343. * 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
  38344. */
  38345. export class SixDofDragBehavior implements Behavior<Mesh> {
  38346. private static _virtualScene;
  38347. private _ownerNode;
  38348. private _sceneRenderObserver;
  38349. private _scene;
  38350. private _targetPosition;
  38351. private _virtualOriginMesh;
  38352. private _virtualDragMesh;
  38353. private _pointerObserver;
  38354. private _moving;
  38355. private _startingOrientation;
  38356. /**
  38357. * 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)
  38358. */
  38359. private zDragFactor;
  38360. /**
  38361. * If the object should rotate to face the drag origin
  38362. */
  38363. rotateDraggedObject: boolean;
  38364. /**
  38365. * If the behavior is currently in a dragging state
  38366. */
  38367. dragging: boolean;
  38368. /**
  38369. * 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)
  38370. */
  38371. dragDeltaRatio: number;
  38372. /**
  38373. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38374. */
  38375. currentDraggingPointerID: number;
  38376. /**
  38377. * If camera controls should be detached during the drag
  38378. */
  38379. detachCameraControls: boolean;
  38380. /**
  38381. * Fires each time a drag starts
  38382. */
  38383. onDragStartObservable: Observable<{}>;
  38384. /**
  38385. * Fires each time a drag ends (eg. mouse release after drag)
  38386. */
  38387. onDragEndObservable: Observable<{}>;
  38388. /**
  38389. * 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
  38390. */
  38391. constructor();
  38392. /**
  38393. * The name of the behavior
  38394. */
  38395. readonly name: string;
  38396. /**
  38397. * Initializes the behavior
  38398. */
  38399. init(): void;
  38400. /**
  38401. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38402. */
  38403. private readonly _pointerCamera;
  38404. /**
  38405. * Attaches the scale behavior the passed in mesh
  38406. * @param ownerNode The mesh that will be scaled around once attached
  38407. */
  38408. attach(ownerNode: Mesh): void;
  38409. /**
  38410. * Detaches the behavior from the mesh
  38411. */
  38412. detach(): void;
  38413. }
  38414. }
  38415. declare module "babylonjs/Behaviors/Meshes/index" {
  38416. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38417. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38418. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38419. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38420. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38421. }
  38422. declare module "babylonjs/Behaviors/index" {
  38423. export * from "babylonjs/Behaviors/behavior";
  38424. export * from "babylonjs/Behaviors/Cameras/index";
  38425. export * from "babylonjs/Behaviors/Meshes/index";
  38426. }
  38427. declare module "babylonjs/Bones/boneIKController" {
  38428. import { Bone } from "babylonjs/Bones/bone";
  38429. import { Vector3 } from "babylonjs/Maths/math.vector";
  38430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38431. import { Nullable } from "babylonjs/types";
  38432. /**
  38433. * Class used to apply inverse kinematics to bones
  38434. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38435. */
  38436. export class BoneIKController {
  38437. private static _tmpVecs;
  38438. private static _tmpQuat;
  38439. private static _tmpMats;
  38440. /**
  38441. * Gets or sets the target mesh
  38442. */
  38443. targetMesh: AbstractMesh;
  38444. /** Gets or sets the mesh used as pole */
  38445. poleTargetMesh: AbstractMesh;
  38446. /**
  38447. * Gets or sets the bone used as pole
  38448. */
  38449. poleTargetBone: Nullable<Bone>;
  38450. /**
  38451. * Gets or sets the target position
  38452. */
  38453. targetPosition: Vector3;
  38454. /**
  38455. * Gets or sets the pole target position
  38456. */
  38457. poleTargetPosition: Vector3;
  38458. /**
  38459. * Gets or sets the pole target local offset
  38460. */
  38461. poleTargetLocalOffset: Vector3;
  38462. /**
  38463. * Gets or sets the pole angle
  38464. */
  38465. poleAngle: number;
  38466. /**
  38467. * Gets or sets the mesh associated with the controller
  38468. */
  38469. mesh: AbstractMesh;
  38470. /**
  38471. * 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)
  38472. */
  38473. slerpAmount: number;
  38474. private _bone1Quat;
  38475. private _bone1Mat;
  38476. private _bone2Ang;
  38477. private _bone1;
  38478. private _bone2;
  38479. private _bone1Length;
  38480. private _bone2Length;
  38481. private _maxAngle;
  38482. private _maxReach;
  38483. private _rightHandedSystem;
  38484. private _bendAxis;
  38485. private _slerping;
  38486. private _adjustRoll;
  38487. /**
  38488. * Gets or sets maximum allowed angle
  38489. */
  38490. maxAngle: number;
  38491. /**
  38492. * Creates a new BoneIKController
  38493. * @param mesh defines the mesh to control
  38494. * @param bone defines the bone to control
  38495. * @param options defines options to set up the controller
  38496. */
  38497. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38498. targetMesh?: AbstractMesh;
  38499. poleTargetMesh?: AbstractMesh;
  38500. poleTargetBone?: Bone;
  38501. poleTargetLocalOffset?: Vector3;
  38502. poleAngle?: number;
  38503. bendAxis?: Vector3;
  38504. maxAngle?: number;
  38505. slerpAmount?: number;
  38506. });
  38507. private _setMaxAngle;
  38508. /**
  38509. * Force the controller to update the bones
  38510. */
  38511. update(): void;
  38512. }
  38513. }
  38514. declare module "babylonjs/Bones/boneLookController" {
  38515. import { Vector3 } from "babylonjs/Maths/math.vector";
  38516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38517. import { Bone } from "babylonjs/Bones/bone";
  38518. import { Space } from "babylonjs/Maths/math.axis";
  38519. /**
  38520. * Class used to make a bone look toward a point in space
  38521. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38522. */
  38523. export class BoneLookController {
  38524. private static _tmpVecs;
  38525. private static _tmpQuat;
  38526. private static _tmpMats;
  38527. /**
  38528. * The target Vector3 that the bone will look at
  38529. */
  38530. target: Vector3;
  38531. /**
  38532. * The mesh that the bone is attached to
  38533. */
  38534. mesh: AbstractMesh;
  38535. /**
  38536. * The bone that will be looking to the target
  38537. */
  38538. bone: Bone;
  38539. /**
  38540. * The up axis of the coordinate system that is used when the bone is rotated
  38541. */
  38542. upAxis: Vector3;
  38543. /**
  38544. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38545. */
  38546. upAxisSpace: Space;
  38547. /**
  38548. * Used to make an adjustment to the yaw of the bone
  38549. */
  38550. adjustYaw: number;
  38551. /**
  38552. * Used to make an adjustment to the pitch of the bone
  38553. */
  38554. adjustPitch: number;
  38555. /**
  38556. * Used to make an adjustment to the roll of the bone
  38557. */
  38558. adjustRoll: number;
  38559. /**
  38560. * 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)
  38561. */
  38562. slerpAmount: number;
  38563. private _minYaw;
  38564. private _maxYaw;
  38565. private _minPitch;
  38566. private _maxPitch;
  38567. private _minYawSin;
  38568. private _minYawCos;
  38569. private _maxYawSin;
  38570. private _maxYawCos;
  38571. private _midYawConstraint;
  38572. private _minPitchTan;
  38573. private _maxPitchTan;
  38574. private _boneQuat;
  38575. private _slerping;
  38576. private _transformYawPitch;
  38577. private _transformYawPitchInv;
  38578. private _firstFrameSkipped;
  38579. private _yawRange;
  38580. private _fowardAxis;
  38581. /**
  38582. * Gets or sets the minimum yaw angle that the bone can look to
  38583. */
  38584. minYaw: number;
  38585. /**
  38586. * Gets or sets the maximum yaw angle that the bone can look to
  38587. */
  38588. maxYaw: number;
  38589. /**
  38590. * Gets or sets the minimum pitch angle that the bone can look to
  38591. */
  38592. minPitch: number;
  38593. /**
  38594. * Gets or sets the maximum pitch angle that the bone can look to
  38595. */
  38596. maxPitch: number;
  38597. /**
  38598. * Create a BoneLookController
  38599. * @param mesh the mesh that the bone belongs to
  38600. * @param bone the bone that will be looking to the target
  38601. * @param target the target Vector3 to look at
  38602. * @param options optional settings:
  38603. * * maxYaw: the maximum angle the bone will yaw to
  38604. * * minYaw: the minimum angle the bone will yaw to
  38605. * * maxPitch: the maximum angle the bone will pitch to
  38606. * * minPitch: the minimum angle the bone will yaw to
  38607. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38608. * * upAxis: the up axis of the coordinate system
  38609. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38610. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38611. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38612. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38613. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38614. * * adjustRoll: used to make an adjustment to the roll of the bone
  38615. **/
  38616. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38617. maxYaw?: number;
  38618. minYaw?: number;
  38619. maxPitch?: number;
  38620. minPitch?: number;
  38621. slerpAmount?: number;
  38622. upAxis?: Vector3;
  38623. upAxisSpace?: Space;
  38624. yawAxis?: Vector3;
  38625. pitchAxis?: Vector3;
  38626. adjustYaw?: number;
  38627. adjustPitch?: number;
  38628. adjustRoll?: number;
  38629. });
  38630. /**
  38631. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38632. */
  38633. update(): void;
  38634. private _getAngleDiff;
  38635. private _getAngleBetween;
  38636. private _isAngleBetween;
  38637. }
  38638. }
  38639. declare module "babylonjs/Bones/index" {
  38640. export * from "babylonjs/Bones/bone";
  38641. export * from "babylonjs/Bones/boneIKController";
  38642. export * from "babylonjs/Bones/boneLookController";
  38643. export * from "babylonjs/Bones/skeleton";
  38644. }
  38645. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38646. import { Nullable } from "babylonjs/types";
  38647. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38648. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38649. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38650. /**
  38651. * Manage the gamepad inputs to control an arc rotate camera.
  38652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38653. */
  38654. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38655. /**
  38656. * Defines the camera the input is attached to.
  38657. */
  38658. camera: ArcRotateCamera;
  38659. /**
  38660. * Defines the gamepad the input is gathering event from.
  38661. */
  38662. gamepad: Nullable<Gamepad>;
  38663. /**
  38664. * Defines the gamepad rotation sensiblity.
  38665. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38666. */
  38667. gamepadRotationSensibility: number;
  38668. /**
  38669. * Defines the gamepad move sensiblity.
  38670. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38671. */
  38672. gamepadMoveSensibility: number;
  38673. private _yAxisScale;
  38674. /**
  38675. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38676. */
  38677. invertYAxis: boolean;
  38678. private _onGamepadConnectedObserver;
  38679. private _onGamepadDisconnectedObserver;
  38680. /**
  38681. * Attach the input controls to a specific dom element to get the input from.
  38682. * @param element Defines the element the controls should be listened from
  38683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38684. */
  38685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38686. /**
  38687. * Detach the current controls from the specified dom element.
  38688. * @param element Defines the element to stop listening the inputs from
  38689. */
  38690. detachControl(element: Nullable<HTMLElement>): void;
  38691. /**
  38692. * Update the current camera state depending on the inputs that have been used this frame.
  38693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38694. */
  38695. checkInputs(): void;
  38696. /**
  38697. * Gets the class name of the current intput.
  38698. * @returns the class name
  38699. */
  38700. getClassName(): string;
  38701. /**
  38702. * Get the friendly name associated with the input class.
  38703. * @returns the input friendly name
  38704. */
  38705. getSimpleName(): string;
  38706. }
  38707. }
  38708. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38709. import { Nullable } from "babylonjs/types";
  38710. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38711. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38712. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38713. interface ArcRotateCameraInputsManager {
  38714. /**
  38715. * Add orientation input support to the input manager.
  38716. * @returns the current input manager
  38717. */
  38718. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38719. }
  38720. }
  38721. /**
  38722. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38724. */
  38725. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38726. /**
  38727. * Defines the camera the input is attached to.
  38728. */
  38729. camera: ArcRotateCamera;
  38730. /**
  38731. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38732. */
  38733. alphaCorrection: number;
  38734. /**
  38735. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38736. */
  38737. gammaCorrection: number;
  38738. private _alpha;
  38739. private _gamma;
  38740. private _dirty;
  38741. private _deviceOrientationHandler;
  38742. /**
  38743. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38744. */
  38745. constructor();
  38746. /**
  38747. * Attach the input controls to a specific dom element to get the input from.
  38748. * @param element Defines the element the controls should be listened from
  38749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38750. */
  38751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38752. /** @hidden */
  38753. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38754. /**
  38755. * Update the current camera state depending on the inputs that have been used this frame.
  38756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38757. */
  38758. checkInputs(): void;
  38759. /**
  38760. * Detach the current controls from the specified dom element.
  38761. * @param element Defines the element to stop listening the inputs from
  38762. */
  38763. detachControl(element: Nullable<HTMLElement>): void;
  38764. /**
  38765. * Gets the class name of the current intput.
  38766. * @returns the class name
  38767. */
  38768. getClassName(): string;
  38769. /**
  38770. * Get the friendly name associated with the input class.
  38771. * @returns the input friendly name
  38772. */
  38773. getSimpleName(): string;
  38774. }
  38775. }
  38776. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38777. import { Nullable } from "babylonjs/types";
  38778. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38779. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38780. /**
  38781. * Listen to mouse events to control the camera.
  38782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38783. */
  38784. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38785. /**
  38786. * Defines the camera the input is attached to.
  38787. */
  38788. camera: FlyCamera;
  38789. /**
  38790. * Defines if touch is enabled. (Default is true.)
  38791. */
  38792. touchEnabled: boolean;
  38793. /**
  38794. * Defines the buttons associated with the input to handle camera rotation.
  38795. */
  38796. buttons: number[];
  38797. /**
  38798. * Assign buttons for Yaw control.
  38799. */
  38800. buttonsYaw: number[];
  38801. /**
  38802. * Assign buttons for Pitch control.
  38803. */
  38804. buttonsPitch: number[];
  38805. /**
  38806. * Assign buttons for Roll control.
  38807. */
  38808. buttonsRoll: number[];
  38809. /**
  38810. * Detect if any button is being pressed while mouse is moved.
  38811. * -1 = Mouse locked.
  38812. * 0 = Left button.
  38813. * 1 = Middle Button.
  38814. * 2 = Right Button.
  38815. */
  38816. activeButton: number;
  38817. /**
  38818. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38819. * Higher values reduce its sensitivity.
  38820. */
  38821. angularSensibility: number;
  38822. private _mousemoveCallback;
  38823. private _observer;
  38824. private _rollObserver;
  38825. private previousPosition;
  38826. private noPreventDefault;
  38827. private element;
  38828. /**
  38829. * Listen to mouse events to control the camera.
  38830. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38832. */
  38833. constructor(touchEnabled?: boolean);
  38834. /**
  38835. * Attach the mouse control to the HTML DOM element.
  38836. * @param element Defines the element that listens to the input events.
  38837. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38838. */
  38839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38840. /**
  38841. * Detach the current controls from the specified dom element.
  38842. * @param element Defines the element to stop listening the inputs from
  38843. */
  38844. detachControl(element: Nullable<HTMLElement>): void;
  38845. /**
  38846. * Gets the class name of the current input.
  38847. * @returns the class name.
  38848. */
  38849. getClassName(): string;
  38850. /**
  38851. * Get the friendly name associated with the input class.
  38852. * @returns the input's friendly name.
  38853. */
  38854. getSimpleName(): string;
  38855. private _pointerInput;
  38856. private _onMouseMove;
  38857. /**
  38858. * Rotate camera by mouse offset.
  38859. */
  38860. private rotateCamera;
  38861. }
  38862. }
  38863. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38864. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38865. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38866. /**
  38867. * Default Inputs manager for the FlyCamera.
  38868. * It groups all the default supported inputs for ease of use.
  38869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38870. */
  38871. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38872. /**
  38873. * Instantiates a new FlyCameraInputsManager.
  38874. * @param camera Defines the camera the inputs belong to.
  38875. */
  38876. constructor(camera: FlyCamera);
  38877. /**
  38878. * Add keyboard input support to the input manager.
  38879. * @returns the new FlyCameraKeyboardMoveInput().
  38880. */
  38881. addKeyboard(): FlyCameraInputsManager;
  38882. /**
  38883. * Add mouse input support to the input manager.
  38884. * @param touchEnabled Enable touch screen support.
  38885. * @returns the new FlyCameraMouseInput().
  38886. */
  38887. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38888. }
  38889. }
  38890. declare module "babylonjs/Cameras/flyCamera" {
  38891. import { Scene } from "babylonjs/scene";
  38892. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38894. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38895. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38896. /**
  38897. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38898. * such as in a 3D Space Shooter or a Flight Simulator.
  38899. */
  38900. export class FlyCamera extends TargetCamera {
  38901. /**
  38902. * Define the collision ellipsoid of the camera.
  38903. * This is helpful for simulating a camera body, like a player's body.
  38904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38905. */
  38906. ellipsoid: Vector3;
  38907. /**
  38908. * Define an offset for the position of the ellipsoid around the camera.
  38909. * This can be helpful if the camera is attached away from the player's body center,
  38910. * such as at its head.
  38911. */
  38912. ellipsoidOffset: Vector3;
  38913. /**
  38914. * Enable or disable collisions of the camera with the rest of the scene objects.
  38915. */
  38916. checkCollisions: boolean;
  38917. /**
  38918. * Enable or disable gravity on the camera.
  38919. */
  38920. applyGravity: boolean;
  38921. /**
  38922. * Define the current direction the camera is moving to.
  38923. */
  38924. cameraDirection: Vector3;
  38925. /**
  38926. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38927. * This overrides and empties cameraRotation.
  38928. */
  38929. rotationQuaternion: Quaternion;
  38930. /**
  38931. * Track Roll to maintain the wanted Rolling when looking around.
  38932. */
  38933. _trackRoll: number;
  38934. /**
  38935. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38936. */
  38937. rollCorrect: number;
  38938. /**
  38939. * Mimic a banked turn, Rolling the camera when Yawing.
  38940. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38941. */
  38942. bankedTurn: boolean;
  38943. /**
  38944. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38945. */
  38946. bankedTurnLimit: number;
  38947. /**
  38948. * Value of 0 disables the banked Roll.
  38949. * Value of 1 is equal to the Yaw angle in radians.
  38950. */
  38951. bankedTurnMultiplier: number;
  38952. /**
  38953. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38954. */
  38955. inputs: FlyCameraInputsManager;
  38956. /**
  38957. * Gets the input sensibility for mouse input.
  38958. * Higher values reduce sensitivity.
  38959. */
  38960. /**
  38961. * Sets the input sensibility for a mouse input.
  38962. * Higher values reduce sensitivity.
  38963. */
  38964. angularSensibility: number;
  38965. /**
  38966. * Get the keys for camera movement forward.
  38967. */
  38968. /**
  38969. * Set the keys for camera movement forward.
  38970. */
  38971. keysForward: number[];
  38972. /**
  38973. * Get the keys for camera movement backward.
  38974. */
  38975. keysBackward: number[];
  38976. /**
  38977. * Get the keys for camera movement up.
  38978. */
  38979. /**
  38980. * Set the keys for camera movement up.
  38981. */
  38982. keysUp: number[];
  38983. /**
  38984. * Get the keys for camera movement down.
  38985. */
  38986. /**
  38987. * Set the keys for camera movement down.
  38988. */
  38989. keysDown: number[];
  38990. /**
  38991. * Get the keys for camera movement left.
  38992. */
  38993. /**
  38994. * Set the keys for camera movement left.
  38995. */
  38996. keysLeft: number[];
  38997. /**
  38998. * Set the keys for camera movement right.
  38999. */
  39000. /**
  39001. * Set the keys for camera movement right.
  39002. */
  39003. keysRight: number[];
  39004. /**
  39005. * Event raised when the camera collides with a mesh in the scene.
  39006. */
  39007. onCollide: (collidedMesh: AbstractMesh) => void;
  39008. private _collider;
  39009. private _needMoveForGravity;
  39010. private _oldPosition;
  39011. private _diffPosition;
  39012. private _newPosition;
  39013. /** @hidden */
  39014. _localDirection: Vector3;
  39015. /** @hidden */
  39016. _transformedDirection: Vector3;
  39017. /**
  39018. * Instantiates a FlyCamera.
  39019. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39020. * such as in a 3D Space Shooter or a Flight Simulator.
  39021. * @param name Define the name of the camera in the scene.
  39022. * @param position Define the starting position of the camera in the scene.
  39023. * @param scene Define the scene the camera belongs to.
  39024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39025. */
  39026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39027. /**
  39028. * Attach a control to the HTML DOM element.
  39029. * @param element Defines the element that listens to the input events.
  39030. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39031. */
  39032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39033. /**
  39034. * Detach a control from the HTML DOM element.
  39035. * The camera will stop reacting to that input.
  39036. * @param element Defines the element that listens to the input events.
  39037. */
  39038. detachControl(element: HTMLElement): void;
  39039. private _collisionMask;
  39040. /**
  39041. * Get the mask that the camera ignores in collision events.
  39042. */
  39043. /**
  39044. * Set the mask that the camera ignores in collision events.
  39045. */
  39046. collisionMask: number;
  39047. /** @hidden */
  39048. _collideWithWorld(displacement: Vector3): void;
  39049. /** @hidden */
  39050. private _onCollisionPositionChange;
  39051. /** @hidden */
  39052. _checkInputs(): void;
  39053. /** @hidden */
  39054. _decideIfNeedsToMove(): boolean;
  39055. /** @hidden */
  39056. _updatePosition(): void;
  39057. /**
  39058. * Restore the Roll to its target value at the rate specified.
  39059. * @param rate - Higher means slower restoring.
  39060. * @hidden
  39061. */
  39062. restoreRoll(rate: number): void;
  39063. /**
  39064. * Destroy the camera and release the current resources held by it.
  39065. */
  39066. dispose(): void;
  39067. /**
  39068. * Get the current object class name.
  39069. * @returns the class name.
  39070. */
  39071. getClassName(): string;
  39072. }
  39073. }
  39074. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39075. import { Nullable } from "babylonjs/types";
  39076. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39077. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39078. /**
  39079. * Listen to keyboard events to control the camera.
  39080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39081. */
  39082. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39083. /**
  39084. * Defines the camera the input is attached to.
  39085. */
  39086. camera: FlyCamera;
  39087. /**
  39088. * The list of keyboard keys used to control the forward move of the camera.
  39089. */
  39090. keysForward: number[];
  39091. /**
  39092. * The list of keyboard keys used to control the backward move of the camera.
  39093. */
  39094. keysBackward: number[];
  39095. /**
  39096. * The list of keyboard keys used to control the forward move of the camera.
  39097. */
  39098. keysUp: number[];
  39099. /**
  39100. * The list of keyboard keys used to control the backward move of the camera.
  39101. */
  39102. keysDown: number[];
  39103. /**
  39104. * The list of keyboard keys used to control the right strafe move of the camera.
  39105. */
  39106. keysRight: number[];
  39107. /**
  39108. * The list of keyboard keys used to control the left strafe move of the camera.
  39109. */
  39110. keysLeft: number[];
  39111. private _keys;
  39112. private _onCanvasBlurObserver;
  39113. private _onKeyboardObserver;
  39114. private _engine;
  39115. private _scene;
  39116. /**
  39117. * Attach the input controls to a specific dom element to get the input from.
  39118. * @param element Defines the element the controls should be listened from
  39119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39120. */
  39121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39122. /**
  39123. * Detach the current controls from the specified dom element.
  39124. * @param element Defines the element to stop listening the inputs from
  39125. */
  39126. detachControl(element: Nullable<HTMLElement>): void;
  39127. /**
  39128. * Gets the class name of the current intput.
  39129. * @returns the class name
  39130. */
  39131. getClassName(): string;
  39132. /** @hidden */
  39133. _onLostFocus(e: FocusEvent): void;
  39134. /**
  39135. * Get the friendly name associated with the input class.
  39136. * @returns the input friendly name
  39137. */
  39138. getSimpleName(): string;
  39139. /**
  39140. * Update the current camera state depending on the inputs that have been used this frame.
  39141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39142. */
  39143. checkInputs(): void;
  39144. }
  39145. }
  39146. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39147. import { Nullable } from "babylonjs/types";
  39148. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39149. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39150. /**
  39151. * Manage the mouse wheel inputs to control a follow camera.
  39152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39153. */
  39154. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39155. /**
  39156. * Defines the camera the input is attached to.
  39157. */
  39158. camera: FollowCamera;
  39159. /**
  39160. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39161. */
  39162. axisControlRadius: boolean;
  39163. /**
  39164. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39165. */
  39166. axisControlHeight: boolean;
  39167. /**
  39168. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39169. */
  39170. axisControlRotation: boolean;
  39171. /**
  39172. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39173. * relation to mouseWheel events.
  39174. */
  39175. wheelPrecision: number;
  39176. /**
  39177. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39178. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39179. */
  39180. wheelDeltaPercentage: number;
  39181. private _wheel;
  39182. private _observer;
  39183. /**
  39184. * Attach the input controls to a specific dom element to get the input from.
  39185. * @param element Defines the element the controls should be listened from
  39186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39187. */
  39188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39189. /**
  39190. * Detach the current controls from the specified dom element.
  39191. * @param element Defines the element to stop listening the inputs from
  39192. */
  39193. detachControl(element: Nullable<HTMLElement>): void;
  39194. /**
  39195. * Gets the class name of the current intput.
  39196. * @returns the class name
  39197. */
  39198. getClassName(): string;
  39199. /**
  39200. * Get the friendly name associated with the input class.
  39201. * @returns the input friendly name
  39202. */
  39203. getSimpleName(): string;
  39204. }
  39205. }
  39206. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39207. import { Nullable } from "babylonjs/types";
  39208. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39209. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39210. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39211. /**
  39212. * Manage the pointers inputs to control an follow camera.
  39213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39214. */
  39215. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39216. /**
  39217. * Defines the camera the input is attached to.
  39218. */
  39219. camera: FollowCamera;
  39220. /**
  39221. * Gets the class name of the current input.
  39222. * @returns the class name
  39223. */
  39224. getClassName(): string;
  39225. /**
  39226. * Defines the pointer angular sensibility along the X axis or how fast is
  39227. * the camera rotating.
  39228. * A negative number will reverse the axis direction.
  39229. */
  39230. angularSensibilityX: number;
  39231. /**
  39232. * Defines the pointer angular sensibility along the Y axis or how fast is
  39233. * the camera rotating.
  39234. * A negative number will reverse the axis direction.
  39235. */
  39236. angularSensibilityY: number;
  39237. /**
  39238. * Defines the pointer pinch precision or how fast is the camera zooming.
  39239. * A negative number will reverse the axis direction.
  39240. */
  39241. pinchPrecision: number;
  39242. /**
  39243. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39244. * from 0.
  39245. * It defines the percentage of current camera.radius to use as delta when
  39246. * pinch zoom is used.
  39247. */
  39248. pinchDeltaPercentage: number;
  39249. /**
  39250. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39251. */
  39252. axisXControlRadius: boolean;
  39253. /**
  39254. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39255. */
  39256. axisXControlHeight: boolean;
  39257. /**
  39258. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39259. */
  39260. axisXControlRotation: boolean;
  39261. /**
  39262. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39263. */
  39264. axisYControlRadius: boolean;
  39265. /**
  39266. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39267. */
  39268. axisYControlHeight: boolean;
  39269. /**
  39270. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39271. */
  39272. axisYControlRotation: boolean;
  39273. /**
  39274. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39275. */
  39276. axisPinchControlRadius: boolean;
  39277. /**
  39278. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39279. */
  39280. axisPinchControlHeight: boolean;
  39281. /**
  39282. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39283. */
  39284. axisPinchControlRotation: boolean;
  39285. /**
  39286. * Log error messages if basic misconfiguration has occurred.
  39287. */
  39288. warningEnable: boolean;
  39289. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39290. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39291. private _warningCounter;
  39292. private _warning;
  39293. }
  39294. }
  39295. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39296. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39297. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39298. /**
  39299. * Default Inputs manager for the FollowCamera.
  39300. * It groups all the default supported inputs for ease of use.
  39301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39302. */
  39303. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39304. /**
  39305. * Instantiates a new FollowCameraInputsManager.
  39306. * @param camera Defines the camera the inputs belong to
  39307. */
  39308. constructor(camera: FollowCamera);
  39309. /**
  39310. * Add keyboard input support to the input manager.
  39311. * @returns the current input manager
  39312. */
  39313. addKeyboard(): FollowCameraInputsManager;
  39314. /**
  39315. * Add mouse wheel input support to the input manager.
  39316. * @returns the current input manager
  39317. */
  39318. addMouseWheel(): FollowCameraInputsManager;
  39319. /**
  39320. * Add pointers input support to the input manager.
  39321. * @returns the current input manager
  39322. */
  39323. addPointers(): FollowCameraInputsManager;
  39324. /**
  39325. * Add orientation input support to the input manager.
  39326. * @returns the current input manager
  39327. */
  39328. addVRDeviceOrientation(): FollowCameraInputsManager;
  39329. }
  39330. }
  39331. declare module "babylonjs/Cameras/followCamera" {
  39332. import { Nullable } from "babylonjs/types";
  39333. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39334. import { Scene } from "babylonjs/scene";
  39335. import { Vector3 } from "babylonjs/Maths/math.vector";
  39336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39337. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39338. /**
  39339. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39340. * an arc rotate version arcFollowCamera are available.
  39341. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39342. */
  39343. export class FollowCamera extends TargetCamera {
  39344. /**
  39345. * Distance the follow camera should follow an object at
  39346. */
  39347. radius: number;
  39348. /**
  39349. * Minimum allowed distance of the camera to the axis of rotation
  39350. * (The camera can not get closer).
  39351. * This can help limiting how the Camera is able to move in the scene.
  39352. */
  39353. lowerRadiusLimit: Nullable<number>;
  39354. /**
  39355. * Maximum allowed distance of the camera to the axis of rotation
  39356. * (The camera can not get further).
  39357. * This can help limiting how the Camera is able to move in the scene.
  39358. */
  39359. upperRadiusLimit: Nullable<number>;
  39360. /**
  39361. * Define a rotation offset between the camera and the object it follows
  39362. */
  39363. rotationOffset: number;
  39364. /**
  39365. * Minimum allowed angle to camera position relative to target object.
  39366. * This can help limiting how the Camera is able to move in the scene.
  39367. */
  39368. lowerRotationOffsetLimit: Nullable<number>;
  39369. /**
  39370. * Maximum allowed angle to camera position relative to target object.
  39371. * This can help limiting how the Camera is able to move in the scene.
  39372. */
  39373. upperRotationOffsetLimit: Nullable<number>;
  39374. /**
  39375. * Define a height offset between the camera and the object it follows.
  39376. * It can help following an object from the top (like a car chaing a plane)
  39377. */
  39378. heightOffset: number;
  39379. /**
  39380. * Minimum allowed height of camera position relative to target object.
  39381. * This can help limiting how the Camera is able to move in the scene.
  39382. */
  39383. lowerHeightOffsetLimit: Nullable<number>;
  39384. /**
  39385. * Maximum allowed height of camera position relative to target object.
  39386. * This can help limiting how the Camera is able to move in the scene.
  39387. */
  39388. upperHeightOffsetLimit: Nullable<number>;
  39389. /**
  39390. * Define how fast the camera can accelerate to follow it s target.
  39391. */
  39392. cameraAcceleration: number;
  39393. /**
  39394. * Define the speed limit of the camera following an object.
  39395. */
  39396. maxCameraSpeed: number;
  39397. /**
  39398. * Define the target of the camera.
  39399. */
  39400. lockedTarget: Nullable<AbstractMesh>;
  39401. /**
  39402. * Defines the input associated with the camera.
  39403. */
  39404. inputs: FollowCameraInputsManager;
  39405. /**
  39406. * Instantiates the follow camera.
  39407. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39408. * @param name Define the name of the camera in the scene
  39409. * @param position Define the position of the camera
  39410. * @param scene Define the scene the camera belong to
  39411. * @param lockedTarget Define the target of the camera
  39412. */
  39413. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39414. private _follow;
  39415. /**
  39416. * Attached controls to the current camera.
  39417. * @param element Defines the element the controls should be listened from
  39418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39419. */
  39420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39421. /**
  39422. * Detach the current controls from the camera.
  39423. * The camera will stop reacting to inputs.
  39424. * @param element Defines the element to stop listening the inputs from
  39425. */
  39426. detachControl(element: HTMLElement): void;
  39427. /** @hidden */
  39428. _checkInputs(): void;
  39429. private _checkLimits;
  39430. /**
  39431. * Gets the camera class name.
  39432. * @returns the class name
  39433. */
  39434. getClassName(): string;
  39435. }
  39436. /**
  39437. * Arc Rotate version of the follow camera.
  39438. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39439. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39440. */
  39441. export class ArcFollowCamera extends TargetCamera {
  39442. /** The longitudinal angle of the camera */
  39443. alpha: number;
  39444. /** The latitudinal angle of the camera */
  39445. beta: number;
  39446. /** The radius of the camera from its target */
  39447. radius: number;
  39448. /** Define the camera target (the messh it should follow) */
  39449. target: Nullable<AbstractMesh>;
  39450. private _cartesianCoordinates;
  39451. /**
  39452. * Instantiates a new ArcFollowCamera
  39453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39454. * @param name Define the name of the camera
  39455. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39456. * @param beta Define the rotation angle of the camera around the elevation axis
  39457. * @param radius Define the radius of the camera from its target point
  39458. * @param target Define the target of the camera
  39459. * @param scene Define the scene the camera belongs to
  39460. */
  39461. constructor(name: string,
  39462. /** The longitudinal angle of the camera */
  39463. alpha: number,
  39464. /** The latitudinal angle of the camera */
  39465. beta: number,
  39466. /** The radius of the camera from its target */
  39467. radius: number,
  39468. /** Define the camera target (the messh it should follow) */
  39469. target: Nullable<AbstractMesh>, scene: Scene);
  39470. private _follow;
  39471. /** @hidden */
  39472. _checkInputs(): void;
  39473. /**
  39474. * Returns the class name of the object.
  39475. * It is mostly used internally for serialization purposes.
  39476. */
  39477. getClassName(): string;
  39478. }
  39479. }
  39480. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39482. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39483. import { Nullable } from "babylonjs/types";
  39484. /**
  39485. * Manage the keyboard inputs to control the movement of a follow camera.
  39486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39487. */
  39488. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39489. /**
  39490. * Defines the camera the input is attached to.
  39491. */
  39492. camera: FollowCamera;
  39493. /**
  39494. * Defines the list of key codes associated with the up action (increase heightOffset)
  39495. */
  39496. keysHeightOffsetIncr: number[];
  39497. /**
  39498. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39499. */
  39500. keysHeightOffsetDecr: number[];
  39501. /**
  39502. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39503. */
  39504. keysHeightOffsetModifierAlt: boolean;
  39505. /**
  39506. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39507. */
  39508. keysHeightOffsetModifierCtrl: boolean;
  39509. /**
  39510. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39511. */
  39512. keysHeightOffsetModifierShift: boolean;
  39513. /**
  39514. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39515. */
  39516. keysRotationOffsetIncr: number[];
  39517. /**
  39518. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39519. */
  39520. keysRotationOffsetDecr: number[];
  39521. /**
  39522. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39523. */
  39524. keysRotationOffsetModifierAlt: boolean;
  39525. /**
  39526. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39527. */
  39528. keysRotationOffsetModifierCtrl: boolean;
  39529. /**
  39530. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39531. */
  39532. keysRotationOffsetModifierShift: boolean;
  39533. /**
  39534. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39535. */
  39536. keysRadiusIncr: number[];
  39537. /**
  39538. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39539. */
  39540. keysRadiusDecr: number[];
  39541. /**
  39542. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39543. */
  39544. keysRadiusModifierAlt: boolean;
  39545. /**
  39546. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39547. */
  39548. keysRadiusModifierCtrl: boolean;
  39549. /**
  39550. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39551. */
  39552. keysRadiusModifierShift: boolean;
  39553. /**
  39554. * Defines the rate of change of heightOffset.
  39555. */
  39556. heightSensibility: number;
  39557. /**
  39558. * Defines the rate of change of rotationOffset.
  39559. */
  39560. rotationSensibility: number;
  39561. /**
  39562. * Defines the rate of change of radius.
  39563. */
  39564. radiusSensibility: number;
  39565. private _keys;
  39566. private _ctrlPressed;
  39567. private _altPressed;
  39568. private _shiftPressed;
  39569. private _onCanvasBlurObserver;
  39570. private _onKeyboardObserver;
  39571. private _engine;
  39572. private _scene;
  39573. /**
  39574. * Attach the input controls to a specific dom element to get the input from.
  39575. * @param element Defines the element the controls should be listened from
  39576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39577. */
  39578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39579. /**
  39580. * Detach the current controls from the specified dom element.
  39581. * @param element Defines the element to stop listening the inputs from
  39582. */
  39583. detachControl(element: Nullable<HTMLElement>): void;
  39584. /**
  39585. * Update the current camera state depending on the inputs that have been used this frame.
  39586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39587. */
  39588. checkInputs(): void;
  39589. /**
  39590. * Gets the class name of the current input.
  39591. * @returns the class name
  39592. */
  39593. getClassName(): string;
  39594. /**
  39595. * Get the friendly name associated with the input class.
  39596. * @returns the input friendly name
  39597. */
  39598. getSimpleName(): string;
  39599. /**
  39600. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39601. * allow modification of the heightOffset value.
  39602. */
  39603. private _modifierHeightOffset;
  39604. /**
  39605. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39606. * allow modification of the rotationOffset value.
  39607. */
  39608. private _modifierRotationOffset;
  39609. /**
  39610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39611. * allow modification of the radius value.
  39612. */
  39613. private _modifierRadius;
  39614. }
  39615. }
  39616. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39617. import { Nullable } from "babylonjs/types";
  39618. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39619. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39620. import { Observable } from "babylonjs/Misc/observable";
  39621. module "babylonjs/Cameras/freeCameraInputsManager" {
  39622. interface FreeCameraInputsManager {
  39623. /**
  39624. * @hidden
  39625. */
  39626. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39627. /**
  39628. * Add orientation input support to the input manager.
  39629. * @returns the current input manager
  39630. */
  39631. addDeviceOrientation(): FreeCameraInputsManager;
  39632. }
  39633. }
  39634. /**
  39635. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39636. * Screen rotation is taken into account.
  39637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39638. */
  39639. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39640. private _camera;
  39641. private _screenOrientationAngle;
  39642. private _constantTranform;
  39643. private _screenQuaternion;
  39644. private _alpha;
  39645. private _beta;
  39646. private _gamma;
  39647. /**
  39648. * Can be used to detect if a device orientation sensor is availible on a device
  39649. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39650. * @returns a promise that will resolve on orientation change
  39651. */
  39652. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39653. /**
  39654. * @hidden
  39655. */
  39656. _onDeviceOrientationChangedObservable: Observable<void>;
  39657. /**
  39658. * Instantiates a new input
  39659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39660. */
  39661. constructor();
  39662. /**
  39663. * Define the camera controlled by the input.
  39664. */
  39665. camera: FreeCamera;
  39666. /**
  39667. * Attach the input controls to a specific dom element to get the input from.
  39668. * @param element Defines the element the controls should be listened from
  39669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39670. */
  39671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39672. private _orientationChanged;
  39673. private _deviceOrientation;
  39674. /**
  39675. * Detach the current controls from the specified dom element.
  39676. * @param element Defines the element to stop listening the inputs from
  39677. */
  39678. detachControl(element: Nullable<HTMLElement>): void;
  39679. /**
  39680. * Update the current camera state depending on the inputs that have been used this frame.
  39681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39682. */
  39683. checkInputs(): void;
  39684. /**
  39685. * Gets the class name of the current intput.
  39686. * @returns the class name
  39687. */
  39688. getClassName(): string;
  39689. /**
  39690. * Get the friendly name associated with the input class.
  39691. * @returns the input friendly name
  39692. */
  39693. getSimpleName(): string;
  39694. }
  39695. }
  39696. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39697. import { Nullable } from "babylonjs/types";
  39698. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39699. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39700. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39701. /**
  39702. * Manage the gamepad inputs to control a free camera.
  39703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39704. */
  39705. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39706. /**
  39707. * Define the camera the input is attached to.
  39708. */
  39709. camera: FreeCamera;
  39710. /**
  39711. * Define the Gamepad controlling the input
  39712. */
  39713. gamepad: Nullable<Gamepad>;
  39714. /**
  39715. * Defines the gamepad rotation sensiblity.
  39716. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39717. */
  39718. gamepadAngularSensibility: number;
  39719. /**
  39720. * Defines the gamepad move sensiblity.
  39721. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39722. */
  39723. gamepadMoveSensibility: number;
  39724. private _yAxisScale;
  39725. /**
  39726. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39727. */
  39728. invertYAxis: boolean;
  39729. private _onGamepadConnectedObserver;
  39730. private _onGamepadDisconnectedObserver;
  39731. private _cameraTransform;
  39732. private _deltaTransform;
  39733. private _vector3;
  39734. private _vector2;
  39735. /**
  39736. * Attach the input controls to a specific dom element to get the input from.
  39737. * @param element Defines the element the controls should be listened from
  39738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39739. */
  39740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39741. /**
  39742. * Detach the current controls from the specified dom element.
  39743. * @param element Defines the element to stop listening the inputs from
  39744. */
  39745. detachControl(element: Nullable<HTMLElement>): void;
  39746. /**
  39747. * Update the current camera state depending on the inputs that have been used this frame.
  39748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39749. */
  39750. checkInputs(): void;
  39751. /**
  39752. * Gets the class name of the current intput.
  39753. * @returns the class name
  39754. */
  39755. getClassName(): string;
  39756. /**
  39757. * Get the friendly name associated with the input class.
  39758. * @returns the input friendly name
  39759. */
  39760. getSimpleName(): string;
  39761. }
  39762. }
  39763. declare module "babylonjs/Misc/virtualJoystick" {
  39764. import { Nullable } from "babylonjs/types";
  39765. import { Vector3 } from "babylonjs/Maths/math.vector";
  39766. /**
  39767. * Defines the potential axis of a Joystick
  39768. */
  39769. export enum JoystickAxis {
  39770. /** X axis */
  39771. X = 0,
  39772. /** Y axis */
  39773. Y = 1,
  39774. /** Z axis */
  39775. Z = 2
  39776. }
  39777. /**
  39778. * Class used to define virtual joystick (used in touch mode)
  39779. */
  39780. export class VirtualJoystick {
  39781. /**
  39782. * Gets or sets a boolean indicating that left and right values must be inverted
  39783. */
  39784. reverseLeftRight: boolean;
  39785. /**
  39786. * Gets or sets a boolean indicating that up and down values must be inverted
  39787. */
  39788. reverseUpDown: boolean;
  39789. /**
  39790. * Gets the offset value for the position (ie. the change of the position value)
  39791. */
  39792. deltaPosition: Vector3;
  39793. /**
  39794. * Gets a boolean indicating if the virtual joystick was pressed
  39795. */
  39796. pressed: boolean;
  39797. /**
  39798. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39799. */
  39800. static Canvas: Nullable<HTMLCanvasElement>;
  39801. private static _globalJoystickIndex;
  39802. private static vjCanvasContext;
  39803. private static vjCanvasWidth;
  39804. private static vjCanvasHeight;
  39805. private static halfWidth;
  39806. private _action;
  39807. private _axisTargetedByLeftAndRight;
  39808. private _axisTargetedByUpAndDown;
  39809. private _joystickSensibility;
  39810. private _inversedSensibility;
  39811. private _joystickPointerID;
  39812. private _joystickColor;
  39813. private _joystickPointerPos;
  39814. private _joystickPreviousPointerPos;
  39815. private _joystickPointerStartPos;
  39816. private _deltaJoystickVector;
  39817. private _leftJoystick;
  39818. private _touches;
  39819. private _onPointerDownHandlerRef;
  39820. private _onPointerMoveHandlerRef;
  39821. private _onPointerUpHandlerRef;
  39822. private _onResize;
  39823. /**
  39824. * Creates a new virtual joystick
  39825. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39826. */
  39827. constructor(leftJoystick?: boolean);
  39828. /**
  39829. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39830. * @param newJoystickSensibility defines the new sensibility
  39831. */
  39832. setJoystickSensibility(newJoystickSensibility: number): void;
  39833. private _onPointerDown;
  39834. private _onPointerMove;
  39835. private _onPointerUp;
  39836. /**
  39837. * Change the color of the virtual joystick
  39838. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39839. */
  39840. setJoystickColor(newColor: string): void;
  39841. /**
  39842. * Defines a callback to call when the joystick is touched
  39843. * @param action defines the callback
  39844. */
  39845. setActionOnTouch(action: () => any): void;
  39846. /**
  39847. * Defines which axis you'd like to control for left & right
  39848. * @param axis defines the axis to use
  39849. */
  39850. setAxisForLeftRight(axis: JoystickAxis): void;
  39851. /**
  39852. * Defines which axis you'd like to control for up & down
  39853. * @param axis defines the axis to use
  39854. */
  39855. setAxisForUpDown(axis: JoystickAxis): void;
  39856. private _drawVirtualJoystick;
  39857. /**
  39858. * Release internal HTML canvas
  39859. */
  39860. releaseCanvas(): void;
  39861. }
  39862. }
  39863. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39864. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39865. import { Nullable } from "babylonjs/types";
  39866. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39867. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39868. module "babylonjs/Cameras/freeCameraInputsManager" {
  39869. interface FreeCameraInputsManager {
  39870. /**
  39871. * Add virtual joystick input support to the input manager.
  39872. * @returns the current input manager
  39873. */
  39874. addVirtualJoystick(): FreeCameraInputsManager;
  39875. }
  39876. }
  39877. /**
  39878. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39880. */
  39881. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39882. /**
  39883. * Defines the camera the input is attached to.
  39884. */
  39885. camera: FreeCamera;
  39886. private _leftjoystick;
  39887. private _rightjoystick;
  39888. /**
  39889. * Gets the left stick of the virtual joystick.
  39890. * @returns The virtual Joystick
  39891. */
  39892. getLeftJoystick(): VirtualJoystick;
  39893. /**
  39894. * Gets the right stick of the virtual joystick.
  39895. * @returns The virtual Joystick
  39896. */
  39897. getRightJoystick(): VirtualJoystick;
  39898. /**
  39899. * Update the current camera state depending on the inputs that have been used this frame.
  39900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39901. */
  39902. checkInputs(): void;
  39903. /**
  39904. * Attach the input controls to a specific dom element to get the input from.
  39905. * @param element Defines the element the controls should be listened from
  39906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39907. */
  39908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39909. /**
  39910. * Detach the current controls from the specified dom element.
  39911. * @param element Defines the element to stop listening the inputs from
  39912. */
  39913. detachControl(element: Nullable<HTMLElement>): void;
  39914. /**
  39915. * Gets the class name of the current intput.
  39916. * @returns the class name
  39917. */
  39918. getClassName(): string;
  39919. /**
  39920. * Get the friendly name associated with the input class.
  39921. * @returns the input friendly name
  39922. */
  39923. getSimpleName(): string;
  39924. }
  39925. }
  39926. declare module "babylonjs/Cameras/Inputs/index" {
  39927. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39928. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39929. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39930. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39931. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39932. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39933. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39934. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39935. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39936. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39937. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39938. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39939. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39940. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39941. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39942. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39943. }
  39944. declare module "babylonjs/Cameras/touchCamera" {
  39945. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39946. import { Scene } from "babylonjs/scene";
  39947. import { Vector3 } from "babylonjs/Maths/math.vector";
  39948. /**
  39949. * This represents a FPS type of camera controlled by touch.
  39950. * This is like a universal camera minus the Gamepad controls.
  39951. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39952. */
  39953. export class TouchCamera extends FreeCamera {
  39954. /**
  39955. * Defines the touch sensibility for rotation.
  39956. * The higher the faster.
  39957. */
  39958. touchAngularSensibility: number;
  39959. /**
  39960. * Defines the touch sensibility for move.
  39961. * The higher the faster.
  39962. */
  39963. touchMoveSensibility: number;
  39964. /**
  39965. * Instantiates a new touch camera.
  39966. * This represents a FPS type of camera controlled by touch.
  39967. * This is like a universal camera minus the Gamepad controls.
  39968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39969. * @param name Define the name of the camera in the scene
  39970. * @param position Define the start position of the camera in the scene
  39971. * @param scene Define the scene the camera belongs to
  39972. */
  39973. constructor(name: string, position: Vector3, scene: Scene);
  39974. /**
  39975. * Gets the current object class name.
  39976. * @return the class name
  39977. */
  39978. getClassName(): string;
  39979. /** @hidden */
  39980. _setupInputs(): void;
  39981. }
  39982. }
  39983. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39984. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39985. import { Scene } from "babylonjs/scene";
  39986. import { Vector3 } from "babylonjs/Maths/math.vector";
  39987. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39988. import { Axis } from "babylonjs/Maths/math.axis";
  39989. /**
  39990. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39991. * being tilted forward or back and left or right.
  39992. */
  39993. export class DeviceOrientationCamera extends FreeCamera {
  39994. private _initialQuaternion;
  39995. private _quaternionCache;
  39996. private _tmpDragQuaternion;
  39997. private _disablePointerInputWhenUsingDeviceOrientation;
  39998. /**
  39999. * Creates a new device orientation camera
  40000. * @param name The name of the camera
  40001. * @param position The start position camera
  40002. * @param scene The scene the camera belongs to
  40003. */
  40004. constructor(name: string, position: Vector3, scene: Scene);
  40005. /**
  40006. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40007. */
  40008. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40009. private _dragFactor;
  40010. /**
  40011. * Enabled turning on the y axis when the orientation sensor is active
  40012. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40013. */
  40014. enableHorizontalDragging(dragFactor?: number): void;
  40015. /**
  40016. * Gets the current instance class name ("DeviceOrientationCamera").
  40017. * This helps avoiding instanceof at run time.
  40018. * @returns the class name
  40019. */
  40020. getClassName(): string;
  40021. /**
  40022. * @hidden
  40023. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40024. */
  40025. _checkInputs(): void;
  40026. /**
  40027. * Reset the camera to its default orientation on the specified axis only.
  40028. * @param axis The axis to reset
  40029. */
  40030. resetToCurrentRotation(axis?: Axis): void;
  40031. }
  40032. }
  40033. declare module "babylonjs/Gamepads/xboxGamepad" {
  40034. import { Observable } from "babylonjs/Misc/observable";
  40035. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40036. /**
  40037. * Defines supported buttons for XBox360 compatible gamepads
  40038. */
  40039. export enum Xbox360Button {
  40040. /** A */
  40041. A = 0,
  40042. /** B */
  40043. B = 1,
  40044. /** X */
  40045. X = 2,
  40046. /** Y */
  40047. Y = 3,
  40048. /** Start */
  40049. Start = 4,
  40050. /** Back */
  40051. Back = 5,
  40052. /** Left button */
  40053. LB = 6,
  40054. /** Right button */
  40055. RB = 7,
  40056. /** Left stick */
  40057. LeftStick = 8,
  40058. /** Right stick */
  40059. RightStick = 9
  40060. }
  40061. /** Defines values for XBox360 DPad */
  40062. export enum Xbox360Dpad {
  40063. /** Up */
  40064. Up = 0,
  40065. /** Down */
  40066. Down = 1,
  40067. /** Left */
  40068. Left = 2,
  40069. /** Right */
  40070. Right = 3
  40071. }
  40072. /**
  40073. * Defines a XBox360 gamepad
  40074. */
  40075. export class Xbox360Pad extends Gamepad {
  40076. private _leftTrigger;
  40077. private _rightTrigger;
  40078. private _onlefttriggerchanged;
  40079. private _onrighttriggerchanged;
  40080. private _onbuttondown;
  40081. private _onbuttonup;
  40082. private _ondpaddown;
  40083. private _ondpadup;
  40084. /** Observable raised when a button is pressed */
  40085. onButtonDownObservable: Observable<Xbox360Button>;
  40086. /** Observable raised when a button is released */
  40087. onButtonUpObservable: Observable<Xbox360Button>;
  40088. /** Observable raised when a pad is pressed */
  40089. onPadDownObservable: Observable<Xbox360Dpad>;
  40090. /** Observable raised when a pad is released */
  40091. onPadUpObservable: Observable<Xbox360Dpad>;
  40092. private _buttonA;
  40093. private _buttonB;
  40094. private _buttonX;
  40095. private _buttonY;
  40096. private _buttonBack;
  40097. private _buttonStart;
  40098. private _buttonLB;
  40099. private _buttonRB;
  40100. private _buttonLeftStick;
  40101. private _buttonRightStick;
  40102. private _dPadUp;
  40103. private _dPadDown;
  40104. private _dPadLeft;
  40105. private _dPadRight;
  40106. private _isXboxOnePad;
  40107. /**
  40108. * Creates a new XBox360 gamepad object
  40109. * @param id defines the id of this gamepad
  40110. * @param index defines its index
  40111. * @param gamepad defines the internal HTML gamepad object
  40112. * @param xboxOne defines if it is a XBox One gamepad
  40113. */
  40114. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40115. /**
  40116. * Defines the callback to call when left trigger is pressed
  40117. * @param callback defines the callback to use
  40118. */
  40119. onlefttriggerchanged(callback: (value: number) => void): void;
  40120. /**
  40121. * Defines the callback to call when right trigger is pressed
  40122. * @param callback defines the callback to use
  40123. */
  40124. onrighttriggerchanged(callback: (value: number) => void): void;
  40125. /**
  40126. * Gets the left trigger value
  40127. */
  40128. /**
  40129. * Sets the left trigger value
  40130. */
  40131. leftTrigger: number;
  40132. /**
  40133. * Gets the right trigger value
  40134. */
  40135. /**
  40136. * Sets the right trigger value
  40137. */
  40138. rightTrigger: number;
  40139. /**
  40140. * Defines the callback to call when a button is pressed
  40141. * @param callback defines the callback to use
  40142. */
  40143. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40144. /**
  40145. * Defines the callback to call when a button is released
  40146. * @param callback defines the callback to use
  40147. */
  40148. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40149. /**
  40150. * Defines the callback to call when a pad is pressed
  40151. * @param callback defines the callback to use
  40152. */
  40153. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40154. /**
  40155. * Defines the callback to call when a pad is released
  40156. * @param callback defines the callback to use
  40157. */
  40158. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40159. private _setButtonValue;
  40160. private _setDPadValue;
  40161. /**
  40162. * Gets the value of the `A` button
  40163. */
  40164. /**
  40165. * Sets the value of the `A` button
  40166. */
  40167. buttonA: number;
  40168. /**
  40169. * Gets the value of the `B` button
  40170. */
  40171. /**
  40172. * Sets the value of the `B` button
  40173. */
  40174. buttonB: number;
  40175. /**
  40176. * Gets the value of the `X` button
  40177. */
  40178. /**
  40179. * Sets the value of the `X` button
  40180. */
  40181. buttonX: number;
  40182. /**
  40183. * Gets the value of the `Y` button
  40184. */
  40185. /**
  40186. * Sets the value of the `Y` button
  40187. */
  40188. buttonY: number;
  40189. /**
  40190. * Gets the value of the `Start` button
  40191. */
  40192. /**
  40193. * Sets the value of the `Start` button
  40194. */
  40195. buttonStart: number;
  40196. /**
  40197. * Gets the value of the `Back` button
  40198. */
  40199. /**
  40200. * Sets the value of the `Back` button
  40201. */
  40202. buttonBack: number;
  40203. /**
  40204. * Gets the value of the `Left` button
  40205. */
  40206. /**
  40207. * Sets the value of the `Left` button
  40208. */
  40209. buttonLB: number;
  40210. /**
  40211. * Gets the value of the `Right` button
  40212. */
  40213. /**
  40214. * Sets the value of the `Right` button
  40215. */
  40216. buttonRB: number;
  40217. /**
  40218. * Gets the value of the Left joystick
  40219. */
  40220. /**
  40221. * Sets the value of the Left joystick
  40222. */
  40223. buttonLeftStick: number;
  40224. /**
  40225. * Gets the value of the Right joystick
  40226. */
  40227. /**
  40228. * Sets the value of the Right joystick
  40229. */
  40230. buttonRightStick: number;
  40231. /**
  40232. * Gets the value of D-pad up
  40233. */
  40234. /**
  40235. * Sets the value of D-pad up
  40236. */
  40237. dPadUp: number;
  40238. /**
  40239. * Gets the value of D-pad down
  40240. */
  40241. /**
  40242. * Sets the value of D-pad down
  40243. */
  40244. dPadDown: number;
  40245. /**
  40246. * Gets the value of D-pad left
  40247. */
  40248. /**
  40249. * Sets the value of D-pad left
  40250. */
  40251. dPadLeft: number;
  40252. /**
  40253. * Gets the value of D-pad right
  40254. */
  40255. /**
  40256. * Sets the value of D-pad right
  40257. */
  40258. dPadRight: number;
  40259. /**
  40260. * Force the gamepad to synchronize with device values
  40261. */
  40262. update(): void;
  40263. /**
  40264. * Disposes the gamepad
  40265. */
  40266. dispose(): void;
  40267. }
  40268. }
  40269. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40270. import { Observable } from "babylonjs/Misc/observable";
  40271. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40272. /**
  40273. * Defines supported buttons for DualShock compatible gamepads
  40274. */
  40275. export enum DualShockButton {
  40276. /** Cross */
  40277. Cross = 0,
  40278. /** Circle */
  40279. Circle = 1,
  40280. /** Square */
  40281. Square = 2,
  40282. /** Triangle */
  40283. Triangle = 3,
  40284. /** Options */
  40285. Options = 4,
  40286. /** Share */
  40287. Share = 5,
  40288. /** L1 */
  40289. L1 = 6,
  40290. /** R1 */
  40291. R1 = 7,
  40292. /** Left stick */
  40293. LeftStick = 8,
  40294. /** Right stick */
  40295. RightStick = 9
  40296. }
  40297. /** Defines values for DualShock DPad */
  40298. export enum DualShockDpad {
  40299. /** Up */
  40300. Up = 0,
  40301. /** Down */
  40302. Down = 1,
  40303. /** Left */
  40304. Left = 2,
  40305. /** Right */
  40306. Right = 3
  40307. }
  40308. /**
  40309. * Defines a DualShock gamepad
  40310. */
  40311. export class DualShockPad extends Gamepad {
  40312. private _leftTrigger;
  40313. private _rightTrigger;
  40314. private _onlefttriggerchanged;
  40315. private _onrighttriggerchanged;
  40316. private _onbuttondown;
  40317. private _onbuttonup;
  40318. private _ondpaddown;
  40319. private _ondpadup;
  40320. /** Observable raised when a button is pressed */
  40321. onButtonDownObservable: Observable<DualShockButton>;
  40322. /** Observable raised when a button is released */
  40323. onButtonUpObservable: Observable<DualShockButton>;
  40324. /** Observable raised when a pad is pressed */
  40325. onPadDownObservable: Observable<DualShockDpad>;
  40326. /** Observable raised when a pad is released */
  40327. onPadUpObservable: Observable<DualShockDpad>;
  40328. private _buttonCross;
  40329. private _buttonCircle;
  40330. private _buttonSquare;
  40331. private _buttonTriangle;
  40332. private _buttonShare;
  40333. private _buttonOptions;
  40334. private _buttonL1;
  40335. private _buttonR1;
  40336. private _buttonLeftStick;
  40337. private _buttonRightStick;
  40338. private _dPadUp;
  40339. private _dPadDown;
  40340. private _dPadLeft;
  40341. private _dPadRight;
  40342. /**
  40343. * Creates a new DualShock gamepad object
  40344. * @param id defines the id of this gamepad
  40345. * @param index defines its index
  40346. * @param gamepad defines the internal HTML gamepad object
  40347. */
  40348. constructor(id: string, index: number, gamepad: any);
  40349. /**
  40350. * Defines the callback to call when left trigger is pressed
  40351. * @param callback defines the callback to use
  40352. */
  40353. onlefttriggerchanged(callback: (value: number) => void): void;
  40354. /**
  40355. * Defines the callback to call when right trigger is pressed
  40356. * @param callback defines the callback to use
  40357. */
  40358. onrighttriggerchanged(callback: (value: number) => void): void;
  40359. /**
  40360. * Gets the left trigger value
  40361. */
  40362. /**
  40363. * Sets the left trigger value
  40364. */
  40365. leftTrigger: number;
  40366. /**
  40367. * Gets the right trigger value
  40368. */
  40369. /**
  40370. * Sets the right trigger value
  40371. */
  40372. rightTrigger: number;
  40373. /**
  40374. * Defines the callback to call when a button is pressed
  40375. * @param callback defines the callback to use
  40376. */
  40377. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40378. /**
  40379. * Defines the callback to call when a button is released
  40380. * @param callback defines the callback to use
  40381. */
  40382. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40383. /**
  40384. * Defines the callback to call when a pad is pressed
  40385. * @param callback defines the callback to use
  40386. */
  40387. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40388. /**
  40389. * Defines the callback to call when a pad is released
  40390. * @param callback defines the callback to use
  40391. */
  40392. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40393. private _setButtonValue;
  40394. private _setDPadValue;
  40395. /**
  40396. * Gets the value of the `Cross` button
  40397. */
  40398. /**
  40399. * Sets the value of the `Cross` button
  40400. */
  40401. buttonCross: number;
  40402. /**
  40403. * Gets the value of the `Circle` button
  40404. */
  40405. /**
  40406. * Sets the value of the `Circle` button
  40407. */
  40408. buttonCircle: number;
  40409. /**
  40410. * Gets the value of the `Square` button
  40411. */
  40412. /**
  40413. * Sets the value of the `Square` button
  40414. */
  40415. buttonSquare: number;
  40416. /**
  40417. * Gets the value of the `Triangle` button
  40418. */
  40419. /**
  40420. * Sets the value of the `Triangle` button
  40421. */
  40422. buttonTriangle: number;
  40423. /**
  40424. * Gets the value of the `Options` button
  40425. */
  40426. /**
  40427. * Sets the value of the `Options` button
  40428. */
  40429. buttonOptions: number;
  40430. /**
  40431. * Gets the value of the `Share` button
  40432. */
  40433. /**
  40434. * Sets the value of the `Share` button
  40435. */
  40436. buttonShare: number;
  40437. /**
  40438. * Gets the value of the `L1` button
  40439. */
  40440. /**
  40441. * Sets the value of the `L1` button
  40442. */
  40443. buttonL1: number;
  40444. /**
  40445. * Gets the value of the `R1` button
  40446. */
  40447. /**
  40448. * Sets the value of the `R1` button
  40449. */
  40450. buttonR1: number;
  40451. /**
  40452. * Gets the value of the Left joystick
  40453. */
  40454. /**
  40455. * Sets the value of the Left joystick
  40456. */
  40457. buttonLeftStick: number;
  40458. /**
  40459. * Gets the value of the Right joystick
  40460. */
  40461. /**
  40462. * Sets the value of the Right joystick
  40463. */
  40464. buttonRightStick: number;
  40465. /**
  40466. * Gets the value of D-pad up
  40467. */
  40468. /**
  40469. * Sets the value of D-pad up
  40470. */
  40471. dPadUp: number;
  40472. /**
  40473. * Gets the value of D-pad down
  40474. */
  40475. /**
  40476. * Sets the value of D-pad down
  40477. */
  40478. dPadDown: number;
  40479. /**
  40480. * Gets the value of D-pad left
  40481. */
  40482. /**
  40483. * Sets the value of D-pad left
  40484. */
  40485. dPadLeft: number;
  40486. /**
  40487. * Gets the value of D-pad right
  40488. */
  40489. /**
  40490. * Sets the value of D-pad right
  40491. */
  40492. dPadRight: number;
  40493. /**
  40494. * Force the gamepad to synchronize with device values
  40495. */
  40496. update(): void;
  40497. /**
  40498. * Disposes the gamepad
  40499. */
  40500. dispose(): void;
  40501. }
  40502. }
  40503. declare module "babylonjs/Gamepads/gamepadManager" {
  40504. import { Observable } from "babylonjs/Misc/observable";
  40505. import { Nullable } from "babylonjs/types";
  40506. import { Scene } from "babylonjs/scene";
  40507. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40508. /**
  40509. * Manager for handling gamepads
  40510. */
  40511. export class GamepadManager {
  40512. private _scene?;
  40513. private _babylonGamepads;
  40514. private _oneGamepadConnected;
  40515. /** @hidden */
  40516. _isMonitoring: boolean;
  40517. private _gamepadEventSupported;
  40518. private _gamepadSupport;
  40519. /**
  40520. * observable to be triggered when the gamepad controller has been connected
  40521. */
  40522. onGamepadConnectedObservable: Observable<Gamepad>;
  40523. /**
  40524. * observable to be triggered when the gamepad controller has been disconnected
  40525. */
  40526. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40527. private _onGamepadConnectedEvent;
  40528. private _onGamepadDisconnectedEvent;
  40529. /**
  40530. * Initializes the gamepad manager
  40531. * @param _scene BabylonJS scene
  40532. */
  40533. constructor(_scene?: Scene | undefined);
  40534. /**
  40535. * The gamepads in the game pad manager
  40536. */
  40537. readonly gamepads: Gamepad[];
  40538. /**
  40539. * Get the gamepad controllers based on type
  40540. * @param type The type of gamepad controller
  40541. * @returns Nullable gamepad
  40542. */
  40543. getGamepadByType(type?: number): Nullable<Gamepad>;
  40544. /**
  40545. * Disposes the gamepad manager
  40546. */
  40547. dispose(): void;
  40548. private _addNewGamepad;
  40549. private _startMonitoringGamepads;
  40550. private _stopMonitoringGamepads;
  40551. /** @hidden */
  40552. _checkGamepadsStatus(): void;
  40553. private _updateGamepadObjects;
  40554. }
  40555. }
  40556. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40557. import { Nullable } from "babylonjs/types";
  40558. import { Scene } from "babylonjs/scene";
  40559. import { ISceneComponent } from "babylonjs/sceneComponent";
  40560. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40561. module "babylonjs/scene" {
  40562. interface Scene {
  40563. /** @hidden */
  40564. _gamepadManager: Nullable<GamepadManager>;
  40565. /**
  40566. * Gets the gamepad manager associated with the scene
  40567. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40568. */
  40569. gamepadManager: GamepadManager;
  40570. }
  40571. }
  40572. module "babylonjs/Cameras/freeCameraInputsManager" {
  40573. /**
  40574. * Interface representing a free camera inputs manager
  40575. */
  40576. interface FreeCameraInputsManager {
  40577. /**
  40578. * Adds gamepad input support to the FreeCameraInputsManager.
  40579. * @returns the FreeCameraInputsManager
  40580. */
  40581. addGamepad(): FreeCameraInputsManager;
  40582. }
  40583. }
  40584. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40585. /**
  40586. * Interface representing an arc rotate camera inputs manager
  40587. */
  40588. interface ArcRotateCameraInputsManager {
  40589. /**
  40590. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40591. * @returns the camera inputs manager
  40592. */
  40593. addGamepad(): ArcRotateCameraInputsManager;
  40594. }
  40595. }
  40596. /**
  40597. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40598. */
  40599. export class GamepadSystemSceneComponent implements ISceneComponent {
  40600. /**
  40601. * The component name helpfull to identify the component in the list of scene components.
  40602. */
  40603. readonly name: string;
  40604. /**
  40605. * The scene the component belongs to.
  40606. */
  40607. scene: Scene;
  40608. /**
  40609. * Creates a new instance of the component for the given scene
  40610. * @param scene Defines the scene to register the component in
  40611. */
  40612. constructor(scene: Scene);
  40613. /**
  40614. * Registers the component in a given scene
  40615. */
  40616. register(): void;
  40617. /**
  40618. * Rebuilds the elements related to this component in case of
  40619. * context lost for instance.
  40620. */
  40621. rebuild(): void;
  40622. /**
  40623. * Disposes the component and the associated ressources
  40624. */
  40625. dispose(): void;
  40626. private _beforeCameraUpdate;
  40627. }
  40628. }
  40629. declare module "babylonjs/Cameras/universalCamera" {
  40630. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40631. import { Scene } from "babylonjs/scene";
  40632. import { Vector3 } from "babylonjs/Maths/math.vector";
  40633. import "babylonjs/Gamepads/gamepadSceneComponent";
  40634. /**
  40635. * 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,
  40636. * which still works and will still be found in many Playgrounds.
  40637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40638. */
  40639. export class UniversalCamera extends TouchCamera {
  40640. /**
  40641. * Defines the gamepad rotation sensiblity.
  40642. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40643. */
  40644. gamepadAngularSensibility: number;
  40645. /**
  40646. * Defines the gamepad move sensiblity.
  40647. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40648. */
  40649. gamepadMoveSensibility: number;
  40650. /**
  40651. * 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,
  40652. * which still works and will still be found in many Playgrounds.
  40653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40654. * @param name Define the name of the camera in the scene
  40655. * @param position Define the start position of the camera in the scene
  40656. * @param scene Define the scene the camera belongs to
  40657. */
  40658. constructor(name: string, position: Vector3, scene: Scene);
  40659. /**
  40660. * Gets the current object class name.
  40661. * @return the class name
  40662. */
  40663. getClassName(): string;
  40664. }
  40665. }
  40666. declare module "babylonjs/Cameras/gamepadCamera" {
  40667. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40668. import { Scene } from "babylonjs/scene";
  40669. import { Vector3 } from "babylonjs/Maths/math.vector";
  40670. /**
  40671. * This represents a FPS type of camera. This is only here for back compat purpose.
  40672. * Please use the UniversalCamera instead as both are identical.
  40673. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40674. */
  40675. export class GamepadCamera extends UniversalCamera {
  40676. /**
  40677. * Instantiates a new Gamepad Camera
  40678. * This represents a FPS type of camera. This is only here for back compat purpose.
  40679. * Please use the UniversalCamera instead as both are identical.
  40680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40681. * @param name Define the name of the camera in the scene
  40682. * @param position Define the start position of the camera in the scene
  40683. * @param scene Define the scene the camera belongs to
  40684. */
  40685. constructor(name: string, position: Vector3, scene: Scene);
  40686. /**
  40687. * Gets the current object class name.
  40688. * @return the class name
  40689. */
  40690. getClassName(): string;
  40691. }
  40692. }
  40693. declare module "babylonjs/Shaders/pass.fragment" {
  40694. /** @hidden */
  40695. export var passPixelShader: {
  40696. name: string;
  40697. shader: string;
  40698. };
  40699. }
  40700. declare module "babylonjs/Shaders/passCube.fragment" {
  40701. /** @hidden */
  40702. export var passCubePixelShader: {
  40703. name: string;
  40704. shader: string;
  40705. };
  40706. }
  40707. declare module "babylonjs/PostProcesses/passPostProcess" {
  40708. import { Nullable } from "babylonjs/types";
  40709. import { Camera } from "babylonjs/Cameras/camera";
  40710. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40711. import { Engine } from "babylonjs/Engines/engine";
  40712. import "babylonjs/Shaders/pass.fragment";
  40713. import "babylonjs/Shaders/passCube.fragment";
  40714. /**
  40715. * PassPostProcess which produces an output the same as it's input
  40716. */
  40717. export class PassPostProcess extends PostProcess {
  40718. /**
  40719. * Creates the PassPostProcess
  40720. * @param name The name of the effect.
  40721. * @param options The required width/height ratio to downsize to before computing the render pass.
  40722. * @param camera The camera to apply the render pass to.
  40723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40724. * @param engine The engine which the post process will be applied. (default: current engine)
  40725. * @param reusable If the post process can be reused on the same frame. (default: false)
  40726. * @param textureType The type of texture to be used when performing the post processing.
  40727. * @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)
  40728. */
  40729. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40730. }
  40731. /**
  40732. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40733. */
  40734. export class PassCubePostProcess extends PostProcess {
  40735. private _face;
  40736. /**
  40737. * Gets or sets the cube face to display.
  40738. * * 0 is +X
  40739. * * 1 is -X
  40740. * * 2 is +Y
  40741. * * 3 is -Y
  40742. * * 4 is +Z
  40743. * * 5 is -Z
  40744. */
  40745. face: number;
  40746. /**
  40747. * Creates the PassCubePostProcess
  40748. * @param name The name of the effect.
  40749. * @param options The required width/height ratio to downsize to before computing the render pass.
  40750. * @param camera The camera to apply the render pass to.
  40751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40752. * @param engine The engine which the post process will be applied. (default: current engine)
  40753. * @param reusable If the post process can be reused on the same frame. (default: false)
  40754. * @param textureType The type of texture to be used when performing the post processing.
  40755. * @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)
  40756. */
  40757. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40758. }
  40759. }
  40760. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40761. /** @hidden */
  40762. export var anaglyphPixelShader: {
  40763. name: string;
  40764. shader: string;
  40765. };
  40766. }
  40767. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40768. import { Engine } from "babylonjs/Engines/engine";
  40769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40770. import { Camera } from "babylonjs/Cameras/camera";
  40771. import "babylonjs/Shaders/anaglyph.fragment";
  40772. /**
  40773. * Postprocess used to generate anaglyphic rendering
  40774. */
  40775. export class AnaglyphPostProcess extends PostProcess {
  40776. private _passedProcess;
  40777. /**
  40778. * Creates a new AnaglyphPostProcess
  40779. * @param name defines postprocess name
  40780. * @param options defines creation options or target ratio scale
  40781. * @param rigCameras defines cameras using this postprocess
  40782. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40783. * @param engine defines hosting engine
  40784. * @param reusable defines if the postprocess will be reused multiple times per frame
  40785. */
  40786. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40787. }
  40788. }
  40789. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40790. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40792. import { Scene } from "babylonjs/scene";
  40793. import { Vector3 } from "babylonjs/Maths/math.vector";
  40794. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40795. /**
  40796. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40797. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40798. */
  40799. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40800. /**
  40801. * Creates a new AnaglyphArcRotateCamera
  40802. * @param name defines camera name
  40803. * @param alpha defines alpha angle (in radians)
  40804. * @param beta defines beta angle (in radians)
  40805. * @param radius defines radius
  40806. * @param target defines camera target
  40807. * @param interaxialDistance defines distance between each color axis
  40808. * @param scene defines the hosting scene
  40809. */
  40810. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40811. /**
  40812. * Gets camera class name
  40813. * @returns AnaglyphArcRotateCamera
  40814. */
  40815. getClassName(): string;
  40816. }
  40817. }
  40818. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40819. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40820. import { Scene } from "babylonjs/scene";
  40821. import { Vector3 } from "babylonjs/Maths/math.vector";
  40822. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40823. /**
  40824. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40825. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40826. */
  40827. export class AnaglyphFreeCamera extends FreeCamera {
  40828. /**
  40829. * Creates a new AnaglyphFreeCamera
  40830. * @param name defines camera name
  40831. * @param position defines initial position
  40832. * @param interaxialDistance defines distance between each color axis
  40833. * @param scene defines the hosting scene
  40834. */
  40835. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40836. /**
  40837. * Gets camera class name
  40838. * @returns AnaglyphFreeCamera
  40839. */
  40840. getClassName(): string;
  40841. }
  40842. }
  40843. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40844. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40845. import { Scene } from "babylonjs/scene";
  40846. import { Vector3 } from "babylonjs/Maths/math.vector";
  40847. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40848. /**
  40849. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40850. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40851. */
  40852. export class AnaglyphGamepadCamera extends GamepadCamera {
  40853. /**
  40854. * Creates a new AnaglyphGamepadCamera
  40855. * @param name defines camera name
  40856. * @param position defines initial position
  40857. * @param interaxialDistance defines distance between each color axis
  40858. * @param scene defines the hosting scene
  40859. */
  40860. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40861. /**
  40862. * Gets camera class name
  40863. * @returns AnaglyphGamepadCamera
  40864. */
  40865. getClassName(): string;
  40866. }
  40867. }
  40868. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40869. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40870. import { Scene } from "babylonjs/scene";
  40871. import { Vector3 } from "babylonjs/Maths/math.vector";
  40872. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40873. /**
  40874. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40875. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40876. */
  40877. export class AnaglyphUniversalCamera extends UniversalCamera {
  40878. /**
  40879. * Creates a new AnaglyphUniversalCamera
  40880. * @param name defines camera name
  40881. * @param position defines initial position
  40882. * @param interaxialDistance defines distance between each color axis
  40883. * @param scene defines the hosting scene
  40884. */
  40885. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40886. /**
  40887. * Gets camera class name
  40888. * @returns AnaglyphUniversalCamera
  40889. */
  40890. getClassName(): string;
  40891. }
  40892. }
  40893. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40894. /** @hidden */
  40895. export var stereoscopicInterlacePixelShader: {
  40896. name: string;
  40897. shader: string;
  40898. };
  40899. }
  40900. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40901. import { Camera } from "babylonjs/Cameras/camera";
  40902. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40903. import { Engine } from "babylonjs/Engines/engine";
  40904. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40905. /**
  40906. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40907. */
  40908. export class StereoscopicInterlacePostProcess extends PostProcess {
  40909. private _stepSize;
  40910. private _passedProcess;
  40911. /**
  40912. * Initializes a StereoscopicInterlacePostProcess
  40913. * @param name The name of the effect.
  40914. * @param rigCameras The rig cameras to be appled to the post process
  40915. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40917. * @param engine The engine which the post process will be applied. (default: current engine)
  40918. * @param reusable If the post process can be reused on the same frame. (default: false)
  40919. */
  40920. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40921. }
  40922. }
  40923. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40924. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40925. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40926. import { Scene } from "babylonjs/scene";
  40927. import { Vector3 } from "babylonjs/Maths/math.vector";
  40928. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40929. /**
  40930. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40931. * @see http://doc.babylonjs.com/features/cameras
  40932. */
  40933. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40934. /**
  40935. * Creates a new StereoscopicArcRotateCamera
  40936. * @param name defines camera name
  40937. * @param alpha defines alpha angle (in radians)
  40938. * @param beta defines beta angle (in radians)
  40939. * @param radius defines radius
  40940. * @param target defines camera target
  40941. * @param interaxialDistance defines distance between each color axis
  40942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40943. * @param scene defines the hosting scene
  40944. */
  40945. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40946. /**
  40947. * Gets camera class name
  40948. * @returns StereoscopicArcRotateCamera
  40949. */
  40950. getClassName(): string;
  40951. }
  40952. }
  40953. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40954. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40955. import { Scene } from "babylonjs/scene";
  40956. import { Vector3 } from "babylonjs/Maths/math.vector";
  40957. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40958. /**
  40959. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40960. * @see http://doc.babylonjs.com/features/cameras
  40961. */
  40962. export class StereoscopicFreeCamera extends FreeCamera {
  40963. /**
  40964. * Creates a new StereoscopicFreeCamera
  40965. * @param name defines camera name
  40966. * @param position defines initial position
  40967. * @param interaxialDistance defines distance between each color axis
  40968. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40969. * @param scene defines the hosting scene
  40970. */
  40971. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40972. /**
  40973. * Gets camera class name
  40974. * @returns StereoscopicFreeCamera
  40975. */
  40976. getClassName(): string;
  40977. }
  40978. }
  40979. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40980. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40981. import { Scene } from "babylonjs/scene";
  40982. import { Vector3 } from "babylonjs/Maths/math.vector";
  40983. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40984. /**
  40985. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40986. * @see http://doc.babylonjs.com/features/cameras
  40987. */
  40988. export class StereoscopicGamepadCamera extends GamepadCamera {
  40989. /**
  40990. * Creates a new StereoscopicGamepadCamera
  40991. * @param name defines camera name
  40992. * @param position defines initial position
  40993. * @param interaxialDistance defines distance between each color axis
  40994. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40995. * @param scene defines the hosting scene
  40996. */
  40997. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40998. /**
  40999. * Gets camera class name
  41000. * @returns StereoscopicGamepadCamera
  41001. */
  41002. getClassName(): string;
  41003. }
  41004. }
  41005. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41006. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41007. import { Scene } from "babylonjs/scene";
  41008. import { Vector3 } from "babylonjs/Maths/math.vector";
  41009. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41010. /**
  41011. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41012. * @see http://doc.babylonjs.com/features/cameras
  41013. */
  41014. export class StereoscopicUniversalCamera extends UniversalCamera {
  41015. /**
  41016. * Creates a new StereoscopicUniversalCamera
  41017. * @param name defines camera name
  41018. * @param position defines initial position
  41019. * @param interaxialDistance defines distance between each color axis
  41020. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41021. * @param scene defines the hosting scene
  41022. */
  41023. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41024. /**
  41025. * Gets camera class name
  41026. * @returns StereoscopicUniversalCamera
  41027. */
  41028. getClassName(): string;
  41029. }
  41030. }
  41031. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41032. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41033. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41034. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41035. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41036. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41037. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41038. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41039. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41040. }
  41041. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41043. import { Scene } from "babylonjs/scene";
  41044. import { Vector3 } from "babylonjs/Maths/math.vector";
  41045. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41046. /**
  41047. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41048. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41049. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41050. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41051. */
  41052. export class VirtualJoysticksCamera extends FreeCamera {
  41053. /**
  41054. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41055. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41056. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41057. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41058. * @param name Define the name of the camera in the scene
  41059. * @param position Define the start position of the camera in the scene
  41060. * @param scene Define the scene the camera belongs to
  41061. */
  41062. constructor(name: string, position: Vector3, scene: Scene);
  41063. /**
  41064. * Gets the current object class name.
  41065. * @return the class name
  41066. */
  41067. getClassName(): string;
  41068. }
  41069. }
  41070. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41071. import { Matrix } from "babylonjs/Maths/math.vector";
  41072. /**
  41073. * This represents all the required metrics to create a VR camera.
  41074. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41075. */
  41076. export class VRCameraMetrics {
  41077. /**
  41078. * Define the horizontal resolution off the screen.
  41079. */
  41080. hResolution: number;
  41081. /**
  41082. * Define the vertical resolution off the screen.
  41083. */
  41084. vResolution: number;
  41085. /**
  41086. * Define the horizontal screen size.
  41087. */
  41088. hScreenSize: number;
  41089. /**
  41090. * Define the vertical screen size.
  41091. */
  41092. vScreenSize: number;
  41093. /**
  41094. * Define the vertical screen center position.
  41095. */
  41096. vScreenCenter: number;
  41097. /**
  41098. * Define the distance of the eyes to the screen.
  41099. */
  41100. eyeToScreenDistance: number;
  41101. /**
  41102. * Define the distance between both lenses
  41103. */
  41104. lensSeparationDistance: number;
  41105. /**
  41106. * Define the distance between both viewer's eyes.
  41107. */
  41108. interpupillaryDistance: number;
  41109. /**
  41110. * Define the distortion factor of the VR postprocess.
  41111. * Please, touch with care.
  41112. */
  41113. distortionK: number[];
  41114. /**
  41115. * Define the chromatic aberration correction factors for the VR post process.
  41116. */
  41117. chromaAbCorrection: number[];
  41118. /**
  41119. * Define the scale factor of the post process.
  41120. * The smaller the better but the slower.
  41121. */
  41122. postProcessScaleFactor: number;
  41123. /**
  41124. * Define an offset for the lens center.
  41125. */
  41126. lensCenterOffset: number;
  41127. /**
  41128. * Define if the current vr camera should compensate the distortion of the lense or not.
  41129. */
  41130. compensateDistortion: boolean;
  41131. /**
  41132. * Defines if multiview should be enabled when rendering (Default: false)
  41133. */
  41134. multiviewEnabled: boolean;
  41135. /**
  41136. * Gets the rendering aspect ratio based on the provided resolutions.
  41137. */
  41138. readonly aspectRatio: number;
  41139. /**
  41140. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41141. */
  41142. readonly aspectRatioFov: number;
  41143. /**
  41144. * @hidden
  41145. */
  41146. readonly leftHMatrix: Matrix;
  41147. /**
  41148. * @hidden
  41149. */
  41150. readonly rightHMatrix: Matrix;
  41151. /**
  41152. * @hidden
  41153. */
  41154. readonly leftPreViewMatrix: Matrix;
  41155. /**
  41156. * @hidden
  41157. */
  41158. readonly rightPreViewMatrix: Matrix;
  41159. /**
  41160. * Get the default VRMetrics based on the most generic setup.
  41161. * @returns the default vr metrics
  41162. */
  41163. static GetDefault(): VRCameraMetrics;
  41164. }
  41165. }
  41166. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41167. /** @hidden */
  41168. export var vrDistortionCorrectionPixelShader: {
  41169. name: string;
  41170. shader: string;
  41171. };
  41172. }
  41173. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41174. import { Camera } from "babylonjs/Cameras/camera";
  41175. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41176. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41177. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41178. /**
  41179. * VRDistortionCorrectionPostProcess used for mobile VR
  41180. */
  41181. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41182. private _isRightEye;
  41183. private _distortionFactors;
  41184. private _postProcessScaleFactor;
  41185. private _lensCenterOffset;
  41186. private _scaleIn;
  41187. private _scaleFactor;
  41188. private _lensCenter;
  41189. /**
  41190. * Initializes the VRDistortionCorrectionPostProcess
  41191. * @param name The name of the effect.
  41192. * @param camera The camera to apply the render pass to.
  41193. * @param isRightEye If this is for the right eye distortion
  41194. * @param vrMetrics All the required metrics for the VR camera
  41195. */
  41196. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41197. }
  41198. }
  41199. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41200. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41202. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41203. import { Scene } from "babylonjs/scene";
  41204. import { Vector3 } from "babylonjs/Maths/math.vector";
  41205. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41206. import "babylonjs/Cameras/RigModes/vrRigMode";
  41207. /**
  41208. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41209. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41210. */
  41211. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41212. /**
  41213. * Creates a new VRDeviceOrientationArcRotateCamera
  41214. * @param name defines camera name
  41215. * @param alpha defines the camera rotation along the logitudinal axis
  41216. * @param beta defines the camera rotation along the latitudinal axis
  41217. * @param radius defines the camera distance from its target
  41218. * @param target defines the camera target
  41219. * @param scene defines the scene the camera belongs to
  41220. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41221. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41222. */
  41223. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41224. /**
  41225. * Gets camera class name
  41226. * @returns VRDeviceOrientationArcRotateCamera
  41227. */
  41228. getClassName(): string;
  41229. }
  41230. }
  41231. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41232. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41233. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41234. import { Scene } from "babylonjs/scene";
  41235. import { Vector3 } from "babylonjs/Maths/math.vector";
  41236. import "babylonjs/Cameras/RigModes/vrRigMode";
  41237. /**
  41238. * Camera used to simulate VR rendering (based on FreeCamera)
  41239. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41240. */
  41241. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41242. /**
  41243. * Creates a new VRDeviceOrientationFreeCamera
  41244. * @param name defines camera name
  41245. * @param position defines the start position of the camera
  41246. * @param scene defines the scene the camera belongs to
  41247. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41248. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41249. */
  41250. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41251. /**
  41252. * Gets camera class name
  41253. * @returns VRDeviceOrientationFreeCamera
  41254. */
  41255. getClassName(): string;
  41256. }
  41257. }
  41258. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41259. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41260. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41261. import { Scene } from "babylonjs/scene";
  41262. import { Vector3 } from "babylonjs/Maths/math.vector";
  41263. import "babylonjs/Gamepads/gamepadSceneComponent";
  41264. /**
  41265. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41266. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41267. */
  41268. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41269. /**
  41270. * Creates a new VRDeviceOrientationGamepadCamera
  41271. * @param name defines camera name
  41272. * @param position defines the start position of the camera
  41273. * @param scene defines the scene the camera belongs to
  41274. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41275. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41276. */
  41277. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41278. /**
  41279. * Gets camera class name
  41280. * @returns VRDeviceOrientationGamepadCamera
  41281. */
  41282. getClassName(): string;
  41283. }
  41284. }
  41285. declare module "babylonjs/Materials/pushMaterial" {
  41286. import { Nullable } from "babylonjs/types";
  41287. import { Scene } from "babylonjs/scene";
  41288. import { Matrix } from "babylonjs/Maths/math.vector";
  41289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41290. import { Mesh } from "babylonjs/Meshes/mesh";
  41291. import { Material } from "babylonjs/Materials/material";
  41292. import { Effect } from "babylonjs/Materials/effect";
  41293. /**
  41294. * Base class of materials working in push mode in babylon JS
  41295. * @hidden
  41296. */
  41297. export class PushMaterial extends Material {
  41298. protected _activeEffect: Effect;
  41299. protected _normalMatrix: Matrix;
  41300. /**
  41301. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41302. * This means that the material can keep using a previous shader while a new one is being compiled.
  41303. * This is mostly used when shader parallel compilation is supported (true by default)
  41304. */
  41305. allowShaderHotSwapping: boolean;
  41306. constructor(name: string, scene: Scene);
  41307. getEffect(): Effect;
  41308. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41309. /**
  41310. * Binds the given world matrix to the active effect
  41311. *
  41312. * @param world the matrix to bind
  41313. */
  41314. bindOnlyWorldMatrix(world: Matrix): void;
  41315. /**
  41316. * Binds the given normal matrix to the active effect
  41317. *
  41318. * @param normalMatrix the matrix to bind
  41319. */
  41320. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41321. bind(world: Matrix, mesh?: Mesh): void;
  41322. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41323. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41324. }
  41325. }
  41326. declare module "babylonjs/Materials/materialFlags" {
  41327. /**
  41328. * This groups all the flags used to control the materials channel.
  41329. */
  41330. export class MaterialFlags {
  41331. private static _DiffuseTextureEnabled;
  41332. /**
  41333. * Are diffuse textures enabled in the application.
  41334. */
  41335. static DiffuseTextureEnabled: boolean;
  41336. private static _AmbientTextureEnabled;
  41337. /**
  41338. * Are ambient textures enabled in the application.
  41339. */
  41340. static AmbientTextureEnabled: boolean;
  41341. private static _OpacityTextureEnabled;
  41342. /**
  41343. * Are opacity textures enabled in the application.
  41344. */
  41345. static OpacityTextureEnabled: boolean;
  41346. private static _ReflectionTextureEnabled;
  41347. /**
  41348. * Are reflection textures enabled in the application.
  41349. */
  41350. static ReflectionTextureEnabled: boolean;
  41351. private static _EmissiveTextureEnabled;
  41352. /**
  41353. * Are emissive textures enabled in the application.
  41354. */
  41355. static EmissiveTextureEnabled: boolean;
  41356. private static _SpecularTextureEnabled;
  41357. /**
  41358. * Are specular textures enabled in the application.
  41359. */
  41360. static SpecularTextureEnabled: boolean;
  41361. private static _BumpTextureEnabled;
  41362. /**
  41363. * Are bump textures enabled in the application.
  41364. */
  41365. static BumpTextureEnabled: boolean;
  41366. private static _LightmapTextureEnabled;
  41367. /**
  41368. * Are lightmap textures enabled in the application.
  41369. */
  41370. static LightmapTextureEnabled: boolean;
  41371. private static _RefractionTextureEnabled;
  41372. /**
  41373. * Are refraction textures enabled in the application.
  41374. */
  41375. static RefractionTextureEnabled: boolean;
  41376. private static _ColorGradingTextureEnabled;
  41377. /**
  41378. * Are color grading textures enabled in the application.
  41379. */
  41380. static ColorGradingTextureEnabled: boolean;
  41381. private static _FresnelEnabled;
  41382. /**
  41383. * Are fresnels enabled in the application.
  41384. */
  41385. static FresnelEnabled: boolean;
  41386. private static _ClearCoatTextureEnabled;
  41387. /**
  41388. * Are clear coat textures enabled in the application.
  41389. */
  41390. static ClearCoatTextureEnabled: boolean;
  41391. private static _ClearCoatBumpTextureEnabled;
  41392. /**
  41393. * Are clear coat bump textures enabled in the application.
  41394. */
  41395. static ClearCoatBumpTextureEnabled: boolean;
  41396. private static _ClearCoatTintTextureEnabled;
  41397. /**
  41398. * Are clear coat tint textures enabled in the application.
  41399. */
  41400. static ClearCoatTintTextureEnabled: boolean;
  41401. private static _SheenTextureEnabled;
  41402. /**
  41403. * Are sheen textures enabled in the application.
  41404. */
  41405. static SheenTextureEnabled: boolean;
  41406. private static _AnisotropicTextureEnabled;
  41407. /**
  41408. * Are anisotropic textures enabled in the application.
  41409. */
  41410. static AnisotropicTextureEnabled: boolean;
  41411. private static _ThicknessTextureEnabled;
  41412. /**
  41413. * Are thickness textures enabled in the application.
  41414. */
  41415. static ThicknessTextureEnabled: boolean;
  41416. }
  41417. }
  41418. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41419. /** @hidden */
  41420. export var defaultFragmentDeclaration: {
  41421. name: string;
  41422. shader: string;
  41423. };
  41424. }
  41425. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41426. /** @hidden */
  41427. export var defaultUboDeclaration: {
  41428. name: string;
  41429. shader: string;
  41430. };
  41431. }
  41432. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41433. /** @hidden */
  41434. export var lightFragmentDeclaration: {
  41435. name: string;
  41436. shader: string;
  41437. };
  41438. }
  41439. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41440. /** @hidden */
  41441. export var lightUboDeclaration: {
  41442. name: string;
  41443. shader: string;
  41444. };
  41445. }
  41446. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41447. /** @hidden */
  41448. export var lightsFragmentFunctions: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41454. /** @hidden */
  41455. export var shadowsFragmentFunctions: {
  41456. name: string;
  41457. shader: string;
  41458. };
  41459. }
  41460. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41461. /** @hidden */
  41462. export var fresnelFunction: {
  41463. name: string;
  41464. shader: string;
  41465. };
  41466. }
  41467. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41468. /** @hidden */
  41469. export var reflectionFunction: {
  41470. name: string;
  41471. shader: string;
  41472. };
  41473. }
  41474. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41475. /** @hidden */
  41476. export var bumpFragmentFunctions: {
  41477. name: string;
  41478. shader: string;
  41479. };
  41480. }
  41481. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41482. /** @hidden */
  41483. export var logDepthDeclaration: {
  41484. name: string;
  41485. shader: string;
  41486. };
  41487. }
  41488. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41489. /** @hidden */
  41490. export var bumpFragment: {
  41491. name: string;
  41492. shader: string;
  41493. };
  41494. }
  41495. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41496. /** @hidden */
  41497. export var depthPrePass: {
  41498. name: string;
  41499. shader: string;
  41500. };
  41501. }
  41502. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41503. /** @hidden */
  41504. export var lightFragment: {
  41505. name: string;
  41506. shader: string;
  41507. };
  41508. }
  41509. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41510. /** @hidden */
  41511. export var logDepthFragment: {
  41512. name: string;
  41513. shader: string;
  41514. };
  41515. }
  41516. declare module "babylonjs/Shaders/default.fragment" {
  41517. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41518. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41520. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41521. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41522. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41523. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41524. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41525. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41526. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41527. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41528. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41529. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41530. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41531. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41532. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41533. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41534. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41535. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41536. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41537. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41538. /** @hidden */
  41539. export var defaultPixelShader: {
  41540. name: string;
  41541. shader: string;
  41542. };
  41543. }
  41544. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41545. /** @hidden */
  41546. export var defaultVertexDeclaration: {
  41547. name: string;
  41548. shader: string;
  41549. };
  41550. }
  41551. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41552. /** @hidden */
  41553. export var bumpVertexDeclaration: {
  41554. name: string;
  41555. shader: string;
  41556. };
  41557. }
  41558. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41559. /** @hidden */
  41560. export var bumpVertex: {
  41561. name: string;
  41562. shader: string;
  41563. };
  41564. }
  41565. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41566. /** @hidden */
  41567. export var fogVertex: {
  41568. name: string;
  41569. shader: string;
  41570. };
  41571. }
  41572. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41573. /** @hidden */
  41574. export var shadowsVertex: {
  41575. name: string;
  41576. shader: string;
  41577. };
  41578. }
  41579. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41580. /** @hidden */
  41581. export var pointCloudVertex: {
  41582. name: string;
  41583. shader: string;
  41584. };
  41585. }
  41586. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41587. /** @hidden */
  41588. export var logDepthVertex: {
  41589. name: string;
  41590. shader: string;
  41591. };
  41592. }
  41593. declare module "babylonjs/Shaders/default.vertex" {
  41594. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41595. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41597. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41598. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41599. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41601. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41602. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41603. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41604. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41605. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41606. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41608. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41609. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41610. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41611. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41612. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41613. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41614. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41615. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41616. /** @hidden */
  41617. export var defaultVertexShader: {
  41618. name: string;
  41619. shader: string;
  41620. };
  41621. }
  41622. declare module "babylonjs/Materials/standardMaterial" {
  41623. import { SmartArray } from "babylonjs/Misc/smartArray";
  41624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41625. import { Nullable } from "babylonjs/types";
  41626. import { Scene } from "babylonjs/scene";
  41627. import { Matrix } from "babylonjs/Maths/math.vector";
  41628. import { Color3 } from "babylonjs/Maths/math.color";
  41629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41631. import { Mesh } from "babylonjs/Meshes/mesh";
  41632. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41633. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41634. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41635. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41636. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41638. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41639. import "babylonjs/Shaders/default.fragment";
  41640. import "babylonjs/Shaders/default.vertex";
  41641. /** @hidden */
  41642. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41643. MAINUV1: boolean;
  41644. MAINUV2: boolean;
  41645. DIFFUSE: boolean;
  41646. DIFFUSEDIRECTUV: number;
  41647. AMBIENT: boolean;
  41648. AMBIENTDIRECTUV: number;
  41649. OPACITY: boolean;
  41650. OPACITYDIRECTUV: number;
  41651. OPACITYRGB: boolean;
  41652. REFLECTION: boolean;
  41653. EMISSIVE: boolean;
  41654. EMISSIVEDIRECTUV: number;
  41655. SPECULAR: boolean;
  41656. SPECULARDIRECTUV: number;
  41657. BUMP: boolean;
  41658. BUMPDIRECTUV: number;
  41659. PARALLAX: boolean;
  41660. PARALLAXOCCLUSION: boolean;
  41661. SPECULAROVERALPHA: boolean;
  41662. CLIPPLANE: boolean;
  41663. CLIPPLANE2: boolean;
  41664. CLIPPLANE3: boolean;
  41665. CLIPPLANE4: boolean;
  41666. ALPHATEST: boolean;
  41667. DEPTHPREPASS: boolean;
  41668. ALPHAFROMDIFFUSE: boolean;
  41669. POINTSIZE: boolean;
  41670. FOG: boolean;
  41671. SPECULARTERM: boolean;
  41672. DIFFUSEFRESNEL: boolean;
  41673. OPACITYFRESNEL: boolean;
  41674. REFLECTIONFRESNEL: boolean;
  41675. REFRACTIONFRESNEL: boolean;
  41676. EMISSIVEFRESNEL: boolean;
  41677. FRESNEL: boolean;
  41678. NORMAL: boolean;
  41679. UV1: boolean;
  41680. UV2: boolean;
  41681. VERTEXCOLOR: boolean;
  41682. VERTEXALPHA: boolean;
  41683. NUM_BONE_INFLUENCERS: number;
  41684. BonesPerMesh: number;
  41685. BONETEXTURE: boolean;
  41686. INSTANCES: boolean;
  41687. GLOSSINESS: boolean;
  41688. ROUGHNESS: boolean;
  41689. EMISSIVEASILLUMINATION: boolean;
  41690. LINKEMISSIVEWITHDIFFUSE: boolean;
  41691. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41692. LIGHTMAP: boolean;
  41693. LIGHTMAPDIRECTUV: number;
  41694. OBJECTSPACE_NORMALMAP: boolean;
  41695. USELIGHTMAPASSHADOWMAP: boolean;
  41696. REFLECTIONMAP_3D: boolean;
  41697. REFLECTIONMAP_SPHERICAL: boolean;
  41698. REFLECTIONMAP_PLANAR: boolean;
  41699. REFLECTIONMAP_CUBIC: boolean;
  41700. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41701. REFLECTIONMAP_PROJECTION: boolean;
  41702. REFLECTIONMAP_SKYBOX: boolean;
  41703. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41704. REFLECTIONMAP_EXPLICIT: boolean;
  41705. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41706. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41707. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41708. INVERTCUBICMAP: boolean;
  41709. LOGARITHMICDEPTH: boolean;
  41710. REFRACTION: boolean;
  41711. REFRACTIONMAP_3D: boolean;
  41712. REFLECTIONOVERALPHA: boolean;
  41713. TWOSIDEDLIGHTING: boolean;
  41714. SHADOWFLOAT: boolean;
  41715. MORPHTARGETS: boolean;
  41716. MORPHTARGETS_NORMAL: boolean;
  41717. MORPHTARGETS_TANGENT: boolean;
  41718. MORPHTARGETS_UV: boolean;
  41719. NUM_MORPH_INFLUENCERS: number;
  41720. NONUNIFORMSCALING: boolean;
  41721. PREMULTIPLYALPHA: boolean;
  41722. IMAGEPROCESSING: boolean;
  41723. VIGNETTE: boolean;
  41724. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41725. VIGNETTEBLENDMODEOPAQUE: boolean;
  41726. TONEMAPPING: boolean;
  41727. TONEMAPPING_ACES: boolean;
  41728. CONTRAST: boolean;
  41729. COLORCURVES: boolean;
  41730. COLORGRADING: boolean;
  41731. COLORGRADING3D: boolean;
  41732. SAMPLER3DGREENDEPTH: boolean;
  41733. SAMPLER3DBGRMAP: boolean;
  41734. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41735. MULTIVIEW: boolean;
  41736. /**
  41737. * If the reflection texture on this material is in linear color space
  41738. * @hidden
  41739. */
  41740. IS_REFLECTION_LINEAR: boolean;
  41741. /**
  41742. * If the refraction texture on this material is in linear color space
  41743. * @hidden
  41744. */
  41745. IS_REFRACTION_LINEAR: boolean;
  41746. EXPOSURE: boolean;
  41747. constructor();
  41748. setReflectionMode(modeToEnable: string): void;
  41749. }
  41750. /**
  41751. * This is the default material used in Babylon. It is the best trade off between quality
  41752. * and performances.
  41753. * @see http://doc.babylonjs.com/babylon101/materials
  41754. */
  41755. export class StandardMaterial extends PushMaterial {
  41756. private _diffuseTexture;
  41757. /**
  41758. * The basic texture of the material as viewed under a light.
  41759. */
  41760. diffuseTexture: Nullable<BaseTexture>;
  41761. private _ambientTexture;
  41762. /**
  41763. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41764. */
  41765. ambientTexture: Nullable<BaseTexture>;
  41766. private _opacityTexture;
  41767. /**
  41768. * Define the transparency of the material from a texture.
  41769. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41770. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41771. */
  41772. opacityTexture: Nullable<BaseTexture>;
  41773. private _reflectionTexture;
  41774. /**
  41775. * Define the texture used to display the reflection.
  41776. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41777. */
  41778. reflectionTexture: Nullable<BaseTexture>;
  41779. private _emissiveTexture;
  41780. /**
  41781. * Define texture of the material as if self lit.
  41782. * This will be mixed in the final result even in the absence of light.
  41783. */
  41784. emissiveTexture: Nullable<BaseTexture>;
  41785. private _specularTexture;
  41786. /**
  41787. * Define how the color and intensity of the highlight given by the light in the material.
  41788. */
  41789. specularTexture: Nullable<BaseTexture>;
  41790. private _bumpTexture;
  41791. /**
  41792. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41793. * 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.
  41794. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41795. */
  41796. bumpTexture: Nullable<BaseTexture>;
  41797. private _lightmapTexture;
  41798. /**
  41799. * Complex lighting can be computationally expensive to compute at runtime.
  41800. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41801. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41802. */
  41803. lightmapTexture: Nullable<BaseTexture>;
  41804. private _refractionTexture;
  41805. /**
  41806. * Define the texture used to display the refraction.
  41807. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41808. */
  41809. refractionTexture: Nullable<BaseTexture>;
  41810. /**
  41811. * The color of the material lit by the environmental background lighting.
  41812. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41813. */
  41814. ambientColor: Color3;
  41815. /**
  41816. * The basic color of the material as viewed under a light.
  41817. */
  41818. diffuseColor: Color3;
  41819. /**
  41820. * Define how the color and intensity of the highlight given by the light in the material.
  41821. */
  41822. specularColor: Color3;
  41823. /**
  41824. * Define the color of the material as if self lit.
  41825. * This will be mixed in the final result even in the absence of light.
  41826. */
  41827. emissiveColor: Color3;
  41828. /**
  41829. * Defines how sharp are the highlights in the material.
  41830. * The bigger the value the sharper giving a more glossy feeling to the result.
  41831. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41832. */
  41833. specularPower: number;
  41834. private _useAlphaFromDiffuseTexture;
  41835. /**
  41836. * Does the transparency come from the diffuse texture alpha channel.
  41837. */
  41838. useAlphaFromDiffuseTexture: boolean;
  41839. private _useEmissiveAsIllumination;
  41840. /**
  41841. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41842. */
  41843. useEmissiveAsIllumination: boolean;
  41844. private _linkEmissiveWithDiffuse;
  41845. /**
  41846. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41847. * the emissive level when the final color is close to one.
  41848. */
  41849. linkEmissiveWithDiffuse: boolean;
  41850. private _useSpecularOverAlpha;
  41851. /**
  41852. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41853. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41854. */
  41855. useSpecularOverAlpha: boolean;
  41856. private _useReflectionOverAlpha;
  41857. /**
  41858. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41859. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41860. */
  41861. useReflectionOverAlpha: boolean;
  41862. private _disableLighting;
  41863. /**
  41864. * Does lights from the scene impacts this material.
  41865. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41866. */
  41867. disableLighting: boolean;
  41868. private _useObjectSpaceNormalMap;
  41869. /**
  41870. * Allows using an object space normal map (instead of tangent space).
  41871. */
  41872. useObjectSpaceNormalMap: boolean;
  41873. private _useParallax;
  41874. /**
  41875. * Is parallax enabled or not.
  41876. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41877. */
  41878. useParallax: boolean;
  41879. private _useParallaxOcclusion;
  41880. /**
  41881. * Is parallax occlusion enabled or not.
  41882. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41883. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41884. */
  41885. useParallaxOcclusion: boolean;
  41886. /**
  41887. * 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.
  41888. */
  41889. parallaxScaleBias: number;
  41890. private _roughness;
  41891. /**
  41892. * Helps to define how blurry the reflections should appears in the material.
  41893. */
  41894. roughness: number;
  41895. /**
  41896. * In case of refraction, define the value of the index of refraction.
  41897. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41898. */
  41899. indexOfRefraction: number;
  41900. /**
  41901. * Invert the refraction texture alongside the y axis.
  41902. * It can be useful with procedural textures or probe for instance.
  41903. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41904. */
  41905. invertRefractionY: boolean;
  41906. /**
  41907. * Defines the alpha limits in alpha test mode.
  41908. */
  41909. alphaCutOff: number;
  41910. private _useLightmapAsShadowmap;
  41911. /**
  41912. * In case of light mapping, define whether the map contains light or shadow informations.
  41913. */
  41914. useLightmapAsShadowmap: boolean;
  41915. private _diffuseFresnelParameters;
  41916. /**
  41917. * Define the diffuse fresnel parameters of the material.
  41918. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41919. */
  41920. diffuseFresnelParameters: FresnelParameters;
  41921. private _opacityFresnelParameters;
  41922. /**
  41923. * Define the opacity fresnel parameters of the material.
  41924. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41925. */
  41926. opacityFresnelParameters: FresnelParameters;
  41927. private _reflectionFresnelParameters;
  41928. /**
  41929. * Define the reflection fresnel parameters of the material.
  41930. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41931. */
  41932. reflectionFresnelParameters: FresnelParameters;
  41933. private _refractionFresnelParameters;
  41934. /**
  41935. * Define the refraction fresnel parameters of the material.
  41936. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41937. */
  41938. refractionFresnelParameters: FresnelParameters;
  41939. private _emissiveFresnelParameters;
  41940. /**
  41941. * Define the emissive fresnel parameters of the material.
  41942. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41943. */
  41944. emissiveFresnelParameters: FresnelParameters;
  41945. private _useReflectionFresnelFromSpecular;
  41946. /**
  41947. * If true automatically deducts the fresnels values from the material specularity.
  41948. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41949. */
  41950. useReflectionFresnelFromSpecular: boolean;
  41951. private _useGlossinessFromSpecularMapAlpha;
  41952. /**
  41953. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41954. */
  41955. useGlossinessFromSpecularMapAlpha: boolean;
  41956. private _maxSimultaneousLights;
  41957. /**
  41958. * Defines the maximum number of lights that can be used in the material
  41959. */
  41960. maxSimultaneousLights: number;
  41961. private _invertNormalMapX;
  41962. /**
  41963. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41964. */
  41965. invertNormalMapX: boolean;
  41966. private _invertNormalMapY;
  41967. /**
  41968. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41969. */
  41970. invertNormalMapY: boolean;
  41971. private _twoSidedLighting;
  41972. /**
  41973. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41974. */
  41975. twoSidedLighting: boolean;
  41976. /**
  41977. * Default configuration related to image processing available in the standard Material.
  41978. */
  41979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41980. /**
  41981. * Gets the image processing configuration used either in this material.
  41982. */
  41983. /**
  41984. * Sets the Default image processing configuration used either in the this material.
  41985. *
  41986. * If sets to null, the scene one is in use.
  41987. */
  41988. imageProcessingConfiguration: ImageProcessingConfiguration;
  41989. /**
  41990. * Keep track of the image processing observer to allow dispose and replace.
  41991. */
  41992. private _imageProcessingObserver;
  41993. /**
  41994. * Attaches a new image processing configuration to the Standard Material.
  41995. * @param configuration
  41996. */
  41997. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41998. /**
  41999. * Gets wether the color curves effect is enabled.
  42000. */
  42001. /**
  42002. * Sets wether the color curves effect is enabled.
  42003. */
  42004. cameraColorCurvesEnabled: boolean;
  42005. /**
  42006. * Gets wether the color grading effect is enabled.
  42007. */
  42008. /**
  42009. * Gets wether the color grading effect is enabled.
  42010. */
  42011. cameraColorGradingEnabled: boolean;
  42012. /**
  42013. * Gets wether tonemapping is enabled or not.
  42014. */
  42015. /**
  42016. * Sets wether tonemapping is enabled or not
  42017. */
  42018. cameraToneMappingEnabled: boolean;
  42019. /**
  42020. * The camera exposure used on this material.
  42021. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42022. * This corresponds to a photographic exposure.
  42023. */
  42024. /**
  42025. * The camera exposure used on this material.
  42026. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42027. * This corresponds to a photographic exposure.
  42028. */
  42029. cameraExposure: number;
  42030. /**
  42031. * Gets The camera contrast used on this material.
  42032. */
  42033. /**
  42034. * Sets The camera contrast used on this material.
  42035. */
  42036. cameraContrast: number;
  42037. /**
  42038. * Gets the Color Grading 2D Lookup Texture.
  42039. */
  42040. /**
  42041. * Sets the Color Grading 2D Lookup Texture.
  42042. */
  42043. cameraColorGradingTexture: Nullable<BaseTexture>;
  42044. /**
  42045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42047. * 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;
  42048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42049. */
  42050. /**
  42051. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42052. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42053. * 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;
  42054. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42055. */
  42056. cameraColorCurves: Nullable<ColorCurves>;
  42057. /**
  42058. * Custom callback helping to override the default shader used in the material.
  42059. */
  42060. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42061. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42062. protected _worldViewProjectionMatrix: Matrix;
  42063. protected _globalAmbientColor: Color3;
  42064. protected _useLogarithmicDepth: boolean;
  42065. protected _rebuildInParallel: boolean;
  42066. /**
  42067. * Instantiates a new standard material.
  42068. * This is the default material used in Babylon. It is the best trade off between quality
  42069. * and performances.
  42070. * @see http://doc.babylonjs.com/babylon101/materials
  42071. * @param name Define the name of the material in the scene
  42072. * @param scene Define the scene the material belong to
  42073. */
  42074. constructor(name: string, scene: Scene);
  42075. /**
  42076. * Gets a boolean indicating that current material needs to register RTT
  42077. */
  42078. readonly hasRenderTargetTextures: boolean;
  42079. /**
  42080. * Gets the current class name of the material e.g. "StandardMaterial"
  42081. * Mainly use in serialization.
  42082. * @returns the class name
  42083. */
  42084. getClassName(): string;
  42085. /**
  42086. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42087. * You can try switching to logarithmic depth.
  42088. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42089. */
  42090. useLogarithmicDepth: boolean;
  42091. /**
  42092. * Specifies if the material will require alpha blending
  42093. * @returns a boolean specifying if alpha blending is needed
  42094. */
  42095. needAlphaBlending(): boolean;
  42096. /**
  42097. * Specifies if this material should be rendered in alpha test mode
  42098. * @returns a boolean specifying if an alpha test is needed.
  42099. */
  42100. needAlphaTesting(): boolean;
  42101. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42102. /**
  42103. * Get the texture used for alpha test purpose.
  42104. * @returns the diffuse texture in case of the standard material.
  42105. */
  42106. getAlphaTestTexture(): Nullable<BaseTexture>;
  42107. /**
  42108. * Get if the submesh is ready to be used and all its information available.
  42109. * Child classes can use it to update shaders
  42110. * @param mesh defines the mesh to check
  42111. * @param subMesh defines which submesh to check
  42112. * @param useInstances specifies that instances should be used
  42113. * @returns a boolean indicating that the submesh is ready or not
  42114. */
  42115. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42116. /**
  42117. * Builds the material UBO layouts.
  42118. * Used internally during the effect preparation.
  42119. */
  42120. buildUniformLayout(): void;
  42121. /**
  42122. * Unbinds the material from the mesh
  42123. */
  42124. unbind(): void;
  42125. /**
  42126. * Binds the submesh to this material by preparing the effect and shader to draw
  42127. * @param world defines the world transformation matrix
  42128. * @param mesh defines the mesh containing the submesh
  42129. * @param subMesh defines the submesh to bind the material to
  42130. */
  42131. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42132. /**
  42133. * Get the list of animatables in the material.
  42134. * @returns the list of animatables object used in the material
  42135. */
  42136. getAnimatables(): IAnimatable[];
  42137. /**
  42138. * Gets the active textures from the material
  42139. * @returns an array of textures
  42140. */
  42141. getActiveTextures(): BaseTexture[];
  42142. /**
  42143. * Specifies if the material uses a texture
  42144. * @param texture defines the texture to check against the material
  42145. * @returns a boolean specifying if the material uses the texture
  42146. */
  42147. hasTexture(texture: BaseTexture): boolean;
  42148. /**
  42149. * Disposes the material
  42150. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42151. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42152. */
  42153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42154. /**
  42155. * Makes a duplicate of the material, and gives it a new name
  42156. * @param name defines the new name for the duplicated material
  42157. * @returns the cloned material
  42158. */
  42159. clone(name: string): StandardMaterial;
  42160. /**
  42161. * Serializes this material in a JSON representation
  42162. * @returns the serialized material object
  42163. */
  42164. serialize(): any;
  42165. /**
  42166. * Creates a standard material from parsed material data
  42167. * @param source defines the JSON representation of the material
  42168. * @param scene defines the hosting scene
  42169. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42170. * @returns a new standard material
  42171. */
  42172. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42173. /**
  42174. * Are diffuse textures enabled in the application.
  42175. */
  42176. static DiffuseTextureEnabled: boolean;
  42177. /**
  42178. * Are ambient textures enabled in the application.
  42179. */
  42180. static AmbientTextureEnabled: boolean;
  42181. /**
  42182. * Are opacity textures enabled in the application.
  42183. */
  42184. static OpacityTextureEnabled: boolean;
  42185. /**
  42186. * Are reflection textures enabled in the application.
  42187. */
  42188. static ReflectionTextureEnabled: boolean;
  42189. /**
  42190. * Are emissive textures enabled in the application.
  42191. */
  42192. static EmissiveTextureEnabled: boolean;
  42193. /**
  42194. * Are specular textures enabled in the application.
  42195. */
  42196. static SpecularTextureEnabled: boolean;
  42197. /**
  42198. * Are bump textures enabled in the application.
  42199. */
  42200. static BumpTextureEnabled: boolean;
  42201. /**
  42202. * Are lightmap textures enabled in the application.
  42203. */
  42204. static LightmapTextureEnabled: boolean;
  42205. /**
  42206. * Are refraction textures enabled in the application.
  42207. */
  42208. static RefractionTextureEnabled: boolean;
  42209. /**
  42210. * Are color grading textures enabled in the application.
  42211. */
  42212. static ColorGradingTextureEnabled: boolean;
  42213. /**
  42214. * Are fresnels enabled in the application.
  42215. */
  42216. static FresnelEnabled: boolean;
  42217. }
  42218. }
  42219. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42220. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42221. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42222. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42223. /** @hidden */
  42224. export var imageProcessingPixelShader: {
  42225. name: string;
  42226. shader: string;
  42227. };
  42228. }
  42229. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42230. import { Nullable } from "babylonjs/types";
  42231. import { Color4 } from "babylonjs/Maths/math.color";
  42232. import { Camera } from "babylonjs/Cameras/camera";
  42233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42234. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42235. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42237. import { Engine } from "babylonjs/Engines/engine";
  42238. import "babylonjs/Shaders/imageProcessing.fragment";
  42239. import "babylonjs/Shaders/postprocess.vertex";
  42240. /**
  42241. * ImageProcessingPostProcess
  42242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42243. */
  42244. export class ImageProcessingPostProcess extends PostProcess {
  42245. /**
  42246. * Default configuration related to image processing available in the PBR Material.
  42247. */
  42248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42249. /**
  42250. * Gets the image processing configuration used either in this material.
  42251. */
  42252. /**
  42253. * Sets the Default image processing configuration used either in the this material.
  42254. *
  42255. * If sets to null, the scene one is in use.
  42256. */
  42257. imageProcessingConfiguration: ImageProcessingConfiguration;
  42258. /**
  42259. * Keep track of the image processing observer to allow dispose and replace.
  42260. */
  42261. private _imageProcessingObserver;
  42262. /**
  42263. * Attaches a new image processing configuration to the PBR Material.
  42264. * @param configuration
  42265. */
  42266. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42267. /**
  42268. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42269. */
  42270. /**
  42271. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42272. */
  42273. colorCurves: Nullable<ColorCurves>;
  42274. /**
  42275. * Gets wether the color curves effect is enabled.
  42276. */
  42277. /**
  42278. * Sets wether the color curves effect is enabled.
  42279. */
  42280. colorCurvesEnabled: boolean;
  42281. /**
  42282. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42283. */
  42284. /**
  42285. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42286. */
  42287. colorGradingTexture: Nullable<BaseTexture>;
  42288. /**
  42289. * Gets wether the color grading effect is enabled.
  42290. */
  42291. /**
  42292. * Gets wether the color grading effect is enabled.
  42293. */
  42294. colorGradingEnabled: boolean;
  42295. /**
  42296. * Gets exposure used in the effect.
  42297. */
  42298. /**
  42299. * Sets exposure used in the effect.
  42300. */
  42301. exposure: number;
  42302. /**
  42303. * Gets wether tonemapping is enabled or not.
  42304. */
  42305. /**
  42306. * Sets wether tonemapping is enabled or not
  42307. */
  42308. toneMappingEnabled: boolean;
  42309. /**
  42310. * Gets the type of tone mapping effect.
  42311. */
  42312. /**
  42313. * Sets the type of tone mapping effect.
  42314. */
  42315. toneMappingType: number;
  42316. /**
  42317. * Gets contrast used in the effect.
  42318. */
  42319. /**
  42320. * Sets contrast used in the effect.
  42321. */
  42322. contrast: number;
  42323. /**
  42324. * Gets Vignette stretch size.
  42325. */
  42326. /**
  42327. * Sets Vignette stretch size.
  42328. */
  42329. vignetteStretch: number;
  42330. /**
  42331. * Gets Vignette centre X Offset.
  42332. */
  42333. /**
  42334. * Sets Vignette centre X Offset.
  42335. */
  42336. vignetteCentreX: number;
  42337. /**
  42338. * Gets Vignette centre Y Offset.
  42339. */
  42340. /**
  42341. * Sets Vignette centre Y Offset.
  42342. */
  42343. vignetteCentreY: number;
  42344. /**
  42345. * Gets Vignette weight or intensity of the vignette effect.
  42346. */
  42347. /**
  42348. * Sets Vignette weight or intensity of the vignette effect.
  42349. */
  42350. vignetteWeight: number;
  42351. /**
  42352. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42353. * if vignetteEnabled is set to true.
  42354. */
  42355. /**
  42356. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42357. * if vignetteEnabled is set to true.
  42358. */
  42359. vignetteColor: Color4;
  42360. /**
  42361. * Gets Camera field of view used by the Vignette effect.
  42362. */
  42363. /**
  42364. * Sets Camera field of view used by the Vignette effect.
  42365. */
  42366. vignetteCameraFov: number;
  42367. /**
  42368. * Gets the vignette blend mode allowing different kind of effect.
  42369. */
  42370. /**
  42371. * Sets the vignette blend mode allowing different kind of effect.
  42372. */
  42373. vignetteBlendMode: number;
  42374. /**
  42375. * Gets wether the vignette effect is enabled.
  42376. */
  42377. /**
  42378. * Sets wether the vignette effect is enabled.
  42379. */
  42380. vignetteEnabled: boolean;
  42381. private _fromLinearSpace;
  42382. /**
  42383. * Gets wether the input of the processing is in Gamma or Linear Space.
  42384. */
  42385. /**
  42386. * Sets wether the input of the processing is in Gamma or Linear Space.
  42387. */
  42388. fromLinearSpace: boolean;
  42389. /**
  42390. * Defines cache preventing GC.
  42391. */
  42392. private _defines;
  42393. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42394. /**
  42395. * "ImageProcessingPostProcess"
  42396. * @returns "ImageProcessingPostProcess"
  42397. */
  42398. getClassName(): string;
  42399. protected _updateParameters(): void;
  42400. dispose(camera?: Camera): void;
  42401. }
  42402. }
  42403. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42404. import { Scene } from "babylonjs/scene";
  42405. import { Color3 } from "babylonjs/Maths/math.color";
  42406. import { Mesh } from "babylonjs/Meshes/mesh";
  42407. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42408. import { Nullable } from "babylonjs/types";
  42409. /**
  42410. * Class containing static functions to help procedurally build meshes
  42411. */
  42412. export class GroundBuilder {
  42413. /**
  42414. * Creates a ground mesh
  42415. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42416. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42418. * @param name defines the name of the mesh
  42419. * @param options defines the options used to create the mesh
  42420. * @param scene defines the hosting scene
  42421. * @returns the ground mesh
  42422. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42423. */
  42424. static CreateGround(name: string, options: {
  42425. width?: number;
  42426. height?: number;
  42427. subdivisions?: number;
  42428. subdivisionsX?: number;
  42429. subdivisionsY?: number;
  42430. updatable?: boolean;
  42431. }, scene: any): Mesh;
  42432. /**
  42433. * Creates a tiled ground mesh
  42434. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42435. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42436. * * 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
  42437. * * 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
  42438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42439. * @param name defines the name of the mesh
  42440. * @param options defines the options used to create the mesh
  42441. * @param scene defines the hosting scene
  42442. * @returns the tiled ground mesh
  42443. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42444. */
  42445. static CreateTiledGround(name: string, options: {
  42446. xmin: number;
  42447. zmin: number;
  42448. xmax: number;
  42449. zmax: number;
  42450. subdivisions?: {
  42451. w: number;
  42452. h: number;
  42453. };
  42454. precision?: {
  42455. w: number;
  42456. h: number;
  42457. };
  42458. updatable?: boolean;
  42459. }, scene?: Nullable<Scene>): Mesh;
  42460. /**
  42461. * Creates a ground mesh from a height map
  42462. * * The parameter `url` sets the URL of the height map image resource.
  42463. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42464. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42465. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42466. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42467. * * 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.
  42468. * * 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).
  42469. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42471. * @param name defines the name of the mesh
  42472. * @param url defines the url to the height map
  42473. * @param options defines the options used to create the mesh
  42474. * @param scene defines the hosting scene
  42475. * @returns the ground mesh
  42476. * @see https://doc.babylonjs.com/babylon101/height_map
  42477. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42478. */
  42479. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42480. width?: number;
  42481. height?: number;
  42482. subdivisions?: number;
  42483. minHeight?: number;
  42484. maxHeight?: number;
  42485. colorFilter?: Color3;
  42486. alphaFilter?: number;
  42487. updatable?: boolean;
  42488. onReady?: (mesh: GroundMesh) => void;
  42489. }, scene?: Nullable<Scene>): GroundMesh;
  42490. }
  42491. }
  42492. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42493. import { Vector4 } from "babylonjs/Maths/math.vector";
  42494. import { Mesh } from "babylonjs/Meshes/mesh";
  42495. /**
  42496. * Class containing static functions to help procedurally build meshes
  42497. */
  42498. export class TorusBuilder {
  42499. /**
  42500. * Creates a torus mesh
  42501. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42502. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42503. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42507. * @param name defines the name of the mesh
  42508. * @param options defines the options used to create the mesh
  42509. * @param scene defines the hosting scene
  42510. * @returns the torus mesh
  42511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42512. */
  42513. static CreateTorus(name: string, options: {
  42514. diameter?: number;
  42515. thickness?: number;
  42516. tessellation?: number;
  42517. updatable?: boolean;
  42518. sideOrientation?: number;
  42519. frontUVs?: Vector4;
  42520. backUVs?: Vector4;
  42521. }, scene: any): Mesh;
  42522. }
  42523. }
  42524. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42525. import { Vector4 } from "babylonjs/Maths/math.vector";
  42526. import { Color4 } from "babylonjs/Maths/math.color";
  42527. import { Mesh } from "babylonjs/Meshes/mesh";
  42528. /**
  42529. * Class containing static functions to help procedurally build meshes
  42530. */
  42531. export class CylinderBuilder {
  42532. /**
  42533. * Creates a cylinder or a cone mesh
  42534. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42535. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42536. * * 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.
  42537. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42538. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42539. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42540. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42541. * * 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).
  42542. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42543. * * 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).
  42544. * * 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
  42545. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42546. * * 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
  42547. * * 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.
  42548. * * If `enclose` is false, a ring surface is one element.
  42549. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42550. * * 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
  42551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42554. * @param name defines the name of the mesh
  42555. * @param options defines the options used to create the mesh
  42556. * @param scene defines the hosting scene
  42557. * @returns the cylinder mesh
  42558. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42559. */
  42560. static CreateCylinder(name: string, options: {
  42561. height?: number;
  42562. diameterTop?: number;
  42563. diameterBottom?: number;
  42564. diameter?: number;
  42565. tessellation?: number;
  42566. subdivisions?: number;
  42567. arc?: number;
  42568. faceColors?: Color4[];
  42569. faceUV?: Vector4[];
  42570. updatable?: boolean;
  42571. hasRings?: boolean;
  42572. enclose?: boolean;
  42573. cap?: number;
  42574. sideOrientation?: number;
  42575. frontUVs?: Vector4;
  42576. backUVs?: Vector4;
  42577. }, scene: any): Mesh;
  42578. }
  42579. }
  42580. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42581. import { Observable } from "babylonjs/Misc/observable";
  42582. import { Nullable } from "babylonjs/types";
  42583. import { Camera } from "babylonjs/Cameras/camera";
  42584. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42585. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42586. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42587. import { Scene } from "babylonjs/scene";
  42588. import { Vector3 } from "babylonjs/Maths/math.vector";
  42589. import { Color3 } from "babylonjs/Maths/math.color";
  42590. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42592. import { Mesh } from "babylonjs/Meshes/mesh";
  42593. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42594. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42595. import "babylonjs/Meshes/Builders/groundBuilder";
  42596. import "babylonjs/Meshes/Builders/torusBuilder";
  42597. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42598. import "babylonjs/Gamepads/gamepadSceneComponent";
  42599. import "babylonjs/Animations/animatable";
  42600. /**
  42601. * Options to modify the vr teleportation behavior.
  42602. */
  42603. export interface VRTeleportationOptions {
  42604. /**
  42605. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42606. */
  42607. floorMeshName?: string;
  42608. /**
  42609. * A list of meshes to be used as the teleportation floor. (default: empty)
  42610. */
  42611. floorMeshes?: Mesh[];
  42612. }
  42613. /**
  42614. * Options to modify the vr experience helper's behavior.
  42615. */
  42616. export interface VRExperienceHelperOptions extends WebVROptions {
  42617. /**
  42618. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42619. */
  42620. createDeviceOrientationCamera?: boolean;
  42621. /**
  42622. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42623. */
  42624. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42625. /**
  42626. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42627. */
  42628. laserToggle?: boolean;
  42629. /**
  42630. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42631. */
  42632. floorMeshes?: Mesh[];
  42633. /**
  42634. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42635. */
  42636. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42637. }
  42638. /**
  42639. * Event containing information after VR has been entered
  42640. */
  42641. export class OnAfterEnteringVRObservableEvent {
  42642. /**
  42643. * If entering vr was successful
  42644. */
  42645. success: boolean;
  42646. }
  42647. /**
  42648. * Helps to quickly add VR support to an existing scene.
  42649. * See http://doc.babylonjs.com/how_to/webvr_helper
  42650. */
  42651. export class VRExperienceHelper {
  42652. /** Options to modify the vr experience helper's behavior. */
  42653. webVROptions: VRExperienceHelperOptions;
  42654. private _scene;
  42655. private _position;
  42656. private _btnVR;
  42657. private _btnVRDisplayed;
  42658. private _webVRsupported;
  42659. private _webVRready;
  42660. private _webVRrequesting;
  42661. private _webVRpresenting;
  42662. private _hasEnteredVR;
  42663. private _fullscreenVRpresenting;
  42664. private _canvas;
  42665. private _webVRCamera;
  42666. private _vrDeviceOrientationCamera;
  42667. private _deviceOrientationCamera;
  42668. private _existingCamera;
  42669. private _onKeyDown;
  42670. private _onVrDisplayPresentChange;
  42671. private _onVRDisplayChanged;
  42672. private _onVRRequestPresentStart;
  42673. private _onVRRequestPresentComplete;
  42674. /**
  42675. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42676. */
  42677. enableGazeEvenWhenNoPointerLock: boolean;
  42678. /**
  42679. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42680. */
  42681. exitVROnDoubleTap: boolean;
  42682. /**
  42683. * Observable raised right before entering VR.
  42684. */
  42685. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42686. /**
  42687. * Observable raised when entering VR has completed.
  42688. */
  42689. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42690. /**
  42691. * Observable raised when exiting VR.
  42692. */
  42693. onExitingVRObservable: Observable<VRExperienceHelper>;
  42694. /**
  42695. * Observable raised when controller mesh is loaded.
  42696. */
  42697. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42698. /** Return this.onEnteringVRObservable
  42699. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42700. */
  42701. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42702. /** Return this.onExitingVRObservable
  42703. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42704. */
  42705. readonly onExitingVR: Observable<VRExperienceHelper>;
  42706. /** Return this.onControllerMeshLoadedObservable
  42707. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42708. */
  42709. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42710. private _rayLength;
  42711. private _useCustomVRButton;
  42712. private _teleportationRequested;
  42713. private _teleportActive;
  42714. private _floorMeshName;
  42715. private _floorMeshesCollection;
  42716. private _rotationAllowed;
  42717. private _teleportBackwardsVector;
  42718. private _teleportationTarget;
  42719. private _isDefaultTeleportationTarget;
  42720. private _postProcessMove;
  42721. private _teleportationFillColor;
  42722. private _teleportationBorderColor;
  42723. private _rotationAngle;
  42724. private _haloCenter;
  42725. private _cameraGazer;
  42726. private _padSensibilityUp;
  42727. private _padSensibilityDown;
  42728. private _leftController;
  42729. private _rightController;
  42730. /**
  42731. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42732. */
  42733. onNewMeshSelected: Observable<AbstractMesh>;
  42734. /**
  42735. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42736. * This observable will provide the mesh and the controller used to select the mesh
  42737. */
  42738. onMeshSelectedWithController: Observable<{
  42739. mesh: AbstractMesh;
  42740. controller: WebVRController;
  42741. }>;
  42742. /**
  42743. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42744. */
  42745. onNewMeshPicked: Observable<PickingInfo>;
  42746. private _circleEase;
  42747. /**
  42748. * Observable raised before camera teleportation
  42749. */
  42750. onBeforeCameraTeleport: Observable<Vector3>;
  42751. /**
  42752. * Observable raised after camera teleportation
  42753. */
  42754. onAfterCameraTeleport: Observable<Vector3>;
  42755. /**
  42756. * Observable raised when current selected mesh gets unselected
  42757. */
  42758. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42759. private _raySelectionPredicate;
  42760. /**
  42761. * To be optionaly changed by user to define custom ray selection
  42762. */
  42763. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42764. /**
  42765. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42766. */
  42767. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42768. /**
  42769. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42770. */
  42771. teleportationEnabled: boolean;
  42772. private _defaultHeight;
  42773. private _teleportationInitialized;
  42774. private _interactionsEnabled;
  42775. private _interactionsRequested;
  42776. private _displayGaze;
  42777. private _displayLaserPointer;
  42778. /**
  42779. * The mesh used to display where the user is going to teleport.
  42780. */
  42781. /**
  42782. * Sets the mesh to be used to display where the user is going to teleport.
  42783. */
  42784. teleportationTarget: Mesh;
  42785. /**
  42786. * 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
  42787. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42788. * See http://doc.babylonjs.com/resources/baking_transformations
  42789. */
  42790. gazeTrackerMesh: Mesh;
  42791. /**
  42792. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42793. */
  42794. updateGazeTrackerScale: boolean;
  42795. /**
  42796. * If the gaze trackers color should be updated when selecting meshes
  42797. */
  42798. updateGazeTrackerColor: boolean;
  42799. /**
  42800. * If the controller laser color should be updated when selecting meshes
  42801. */
  42802. updateControllerLaserColor: boolean;
  42803. /**
  42804. * The gaze tracking mesh corresponding to the left controller
  42805. */
  42806. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42807. /**
  42808. * The gaze tracking mesh corresponding to the right controller
  42809. */
  42810. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42811. /**
  42812. * If the ray of the gaze should be displayed.
  42813. */
  42814. /**
  42815. * Sets if the ray of the gaze should be displayed.
  42816. */
  42817. displayGaze: boolean;
  42818. /**
  42819. * If the ray of the LaserPointer should be displayed.
  42820. */
  42821. /**
  42822. * Sets if the ray of the LaserPointer should be displayed.
  42823. */
  42824. displayLaserPointer: boolean;
  42825. /**
  42826. * The deviceOrientationCamera used as the camera when not in VR.
  42827. */
  42828. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42829. /**
  42830. * Based on the current WebVR support, returns the current VR camera used.
  42831. */
  42832. readonly currentVRCamera: Nullable<Camera>;
  42833. /**
  42834. * The webVRCamera which is used when in VR.
  42835. */
  42836. readonly webVRCamera: WebVRFreeCamera;
  42837. /**
  42838. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42839. */
  42840. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42841. /**
  42842. * The html button that is used to trigger entering into VR.
  42843. */
  42844. readonly vrButton: Nullable<HTMLButtonElement>;
  42845. private readonly _teleportationRequestInitiated;
  42846. /**
  42847. * Defines wether or not Pointer lock should be requested when switching to
  42848. * full screen.
  42849. */
  42850. requestPointerLockOnFullScreen: boolean;
  42851. /**
  42852. * Instantiates a VRExperienceHelper.
  42853. * Helps to quickly add VR support to an existing scene.
  42854. * @param scene The scene the VRExperienceHelper belongs to.
  42855. * @param webVROptions Options to modify the vr experience helper's behavior.
  42856. */
  42857. constructor(scene: Scene,
  42858. /** Options to modify the vr experience helper's behavior. */
  42859. webVROptions?: VRExperienceHelperOptions);
  42860. private _onDefaultMeshLoaded;
  42861. private _onResize;
  42862. private _onFullscreenChange;
  42863. /**
  42864. * Gets a value indicating if we are currently in VR mode.
  42865. */
  42866. readonly isInVRMode: boolean;
  42867. private onVrDisplayPresentChange;
  42868. private onVRDisplayChanged;
  42869. private moveButtonToBottomRight;
  42870. private displayVRButton;
  42871. private updateButtonVisibility;
  42872. private _cachedAngularSensibility;
  42873. /**
  42874. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42875. * Otherwise, will use the fullscreen API.
  42876. */
  42877. enterVR(): void;
  42878. /**
  42879. * Attempt to exit VR, or fullscreen.
  42880. */
  42881. exitVR(): void;
  42882. /**
  42883. * The position of the vr experience helper.
  42884. */
  42885. /**
  42886. * Sets the position of the vr experience helper.
  42887. */
  42888. position: Vector3;
  42889. /**
  42890. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42891. */
  42892. enableInteractions(): void;
  42893. private readonly _noControllerIsActive;
  42894. private beforeRender;
  42895. private _isTeleportationFloor;
  42896. /**
  42897. * Adds a floor mesh to be used for teleportation.
  42898. * @param floorMesh the mesh to be used for teleportation.
  42899. */
  42900. addFloorMesh(floorMesh: Mesh): void;
  42901. /**
  42902. * Removes a floor mesh from being used for teleportation.
  42903. * @param floorMesh the mesh to be removed.
  42904. */
  42905. removeFloorMesh(floorMesh: Mesh): void;
  42906. /**
  42907. * Enables interactions and teleportation using the VR controllers and gaze.
  42908. * @param vrTeleportationOptions options to modify teleportation behavior.
  42909. */
  42910. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42911. private _onNewGamepadConnected;
  42912. private _tryEnableInteractionOnController;
  42913. private _onNewGamepadDisconnected;
  42914. private _enableInteractionOnController;
  42915. private _checkTeleportWithRay;
  42916. private _checkRotate;
  42917. private _checkTeleportBackwards;
  42918. private _enableTeleportationOnController;
  42919. private _createTeleportationCircles;
  42920. private _displayTeleportationTarget;
  42921. private _hideTeleportationTarget;
  42922. private _rotateCamera;
  42923. private _moveTeleportationSelectorTo;
  42924. private _workingVector;
  42925. private _workingQuaternion;
  42926. private _workingMatrix;
  42927. /**
  42928. * Teleports the users feet to the desired location
  42929. * @param location The location where the user's feet should be placed
  42930. */
  42931. teleportCamera(location: Vector3): void;
  42932. private _convertNormalToDirectionOfRay;
  42933. private _castRayAndSelectObject;
  42934. private _notifySelectedMeshUnselected;
  42935. /**
  42936. * Sets the color of the laser ray from the vr controllers.
  42937. * @param color new color for the ray.
  42938. */
  42939. changeLaserColor(color: Color3): void;
  42940. /**
  42941. * Sets the color of the ray from the vr headsets gaze.
  42942. * @param color new color for the ray.
  42943. */
  42944. changeGazeColor(color: Color3): void;
  42945. /**
  42946. * Exits VR and disposes of the vr experience helper
  42947. */
  42948. dispose(): void;
  42949. /**
  42950. * Gets the name of the VRExperienceHelper class
  42951. * @returns "VRExperienceHelper"
  42952. */
  42953. getClassName(): string;
  42954. }
  42955. }
  42956. declare module "babylonjs/Cameras/VR/index" {
  42957. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42958. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42959. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42960. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42961. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42962. export * from "babylonjs/Cameras/VR/webVRCamera";
  42963. }
  42964. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { Nullable } from "babylonjs/types";
  42967. import { IDisposable, Scene } from "babylonjs/scene";
  42968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42969. /**
  42970. * Manages an XRSession to work with Babylon's engine
  42971. * @see https://doc.babylonjs.com/how_to/webxr
  42972. */
  42973. export class WebXRSessionManager implements IDisposable {
  42974. private scene;
  42975. /**
  42976. * Fires every time a new xrFrame arrives which can be used to update the camera
  42977. */
  42978. onXRFrameObservable: Observable<any>;
  42979. /**
  42980. * Fires when the xr session is ended either by the device or manually done
  42981. */
  42982. onXRSessionEnded: Observable<any>;
  42983. /**
  42984. * Underlying xr session
  42985. */
  42986. session: XRSession;
  42987. /**
  42988. * Type of reference space used when creating the session
  42989. */
  42990. referenceSpace: XRReferenceSpace;
  42991. /** @hidden */
  42992. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42993. /**
  42994. * Current XR frame
  42995. */
  42996. currentFrame: Nullable<XRFrame>;
  42997. private _xrNavigator;
  42998. private baseLayer;
  42999. /**
  43000. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43001. * @param scene The scene which the session should be created for
  43002. */
  43003. constructor(scene: Scene);
  43004. /**
  43005. * Initializes the manager
  43006. * After initialization enterXR can be called to start an XR session
  43007. * @returns Promise which resolves after it is initialized
  43008. */
  43009. initializeAsync(): Promise<void>;
  43010. /**
  43011. * Initializes an xr session
  43012. * @param xrSessionMode mode to initialize
  43013. * @returns a promise which will resolve once the session has been initialized
  43014. */
  43015. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  43016. /**
  43017. * Sets the reference space on the xr session
  43018. * @param referenceSpace space to set
  43019. * @returns a promise that will resolve once the reference space has been set
  43020. */
  43021. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43022. /**
  43023. * Updates the render state of the session
  43024. * @param state state to set
  43025. * @returns a promise that resolves once the render state has been updated
  43026. */
  43027. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43028. /**
  43029. * Starts rendering to the xr layer
  43030. * @returns a promise that will resolve once rendering has started
  43031. */
  43032. startRenderingToXRAsync(): Promise<void>;
  43033. /**
  43034. * Stops the xrSession and restores the renderloop
  43035. * @returns Promise which resolves after it exits XR
  43036. */
  43037. exitXRAsync(): Promise<unknown>;
  43038. /**
  43039. * Checks if a session would be supported for the creation options specified
  43040. * @param sessionMode session mode to check if supported eg. immersive-vr
  43041. * @returns true if supported
  43042. */
  43043. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43044. /**
  43045. * @hidden
  43046. * Converts the render layer of xrSession to a render target
  43047. * @param session session to create render target for
  43048. * @param scene scene the new render target should be created for
  43049. */
  43050. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43051. /**
  43052. * Disposes of the session manager
  43053. */
  43054. dispose(): void;
  43055. }
  43056. }
  43057. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43058. import { Scene } from "babylonjs/scene";
  43059. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43060. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43061. /**
  43062. * WebXR Camera which holds the views for the xrSession
  43063. * @see https://doc.babylonjs.com/how_to/webxr
  43064. */
  43065. export class WebXRCamera extends FreeCamera {
  43066. private static _TmpMatrix;
  43067. /**
  43068. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43069. * @param name the name of the camera
  43070. * @param scene the scene to add the camera to
  43071. */
  43072. constructor(name: string, scene: Scene);
  43073. private _updateNumberOfRigCameras;
  43074. /** @hidden */
  43075. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43076. /**
  43077. * Updates the cameras position from the current pose information of the XR session
  43078. * @param xrSessionManager the session containing pose information
  43079. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43080. */
  43081. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43082. }
  43083. }
  43084. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43085. import { Nullable } from "babylonjs/types";
  43086. import { IDisposable } from "babylonjs/scene";
  43087. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43088. /**
  43089. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43090. */
  43091. export class WebXRManagedOutputCanvas implements IDisposable {
  43092. private helper;
  43093. private _canvas;
  43094. /**
  43095. * xrpresent context of the canvas which can be used to display/mirror xr content
  43096. */
  43097. canvasContext: WebGLRenderingContext;
  43098. /**
  43099. * xr layer for the canvas
  43100. */
  43101. xrLayer: Nullable<XRWebGLLayer>;
  43102. /**
  43103. * Initializes the xr layer for the session
  43104. * @param xrSession xr session
  43105. * @returns a promise that will resolve once the XR Layer has been created
  43106. */
  43107. initializeXRLayerAsync(xrSession: any): any;
  43108. /**
  43109. * Initializes the canvas to be added/removed upon entering/exiting xr
  43110. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43111. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43112. */
  43113. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43114. /**
  43115. * Disposes of the object
  43116. */
  43117. dispose(): void;
  43118. private _setManagedOutputCanvas;
  43119. private _addCanvas;
  43120. private _removeCanvas;
  43121. }
  43122. }
  43123. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43124. import { Observable } from "babylonjs/Misc/observable";
  43125. import { IDisposable, Scene } from "babylonjs/scene";
  43126. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43128. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43129. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43130. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43131. /**
  43132. * States of the webXR experience
  43133. */
  43134. export enum WebXRState {
  43135. /**
  43136. * Transitioning to being in XR mode
  43137. */
  43138. ENTERING_XR = 0,
  43139. /**
  43140. * Transitioning to non XR mode
  43141. */
  43142. EXITING_XR = 1,
  43143. /**
  43144. * In XR mode and presenting
  43145. */
  43146. IN_XR = 2,
  43147. /**
  43148. * Not entered XR mode
  43149. */
  43150. NOT_IN_XR = 3
  43151. }
  43152. /**
  43153. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43154. * @see https://doc.babylonjs.com/how_to/webxr
  43155. */
  43156. export class WebXRExperienceHelper implements IDisposable {
  43157. private scene;
  43158. /**
  43159. * 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
  43160. */
  43161. container: AbstractMesh;
  43162. /**
  43163. * Camera used to render xr content
  43164. */
  43165. camera: WebXRCamera;
  43166. /**
  43167. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43168. */
  43169. state: WebXRState;
  43170. private _setState;
  43171. private static _TmpVector;
  43172. /**
  43173. * Fires when the state of the experience helper has changed
  43174. */
  43175. onStateChangedObservable: Observable<WebXRState>;
  43176. /** Session manager used to keep track of xr session */
  43177. sessionManager: WebXRSessionManager;
  43178. private _nonVRCamera;
  43179. private _originalSceneAutoClear;
  43180. private _supported;
  43181. /**
  43182. * Creates the experience helper
  43183. * @param scene the scene to attach the experience helper to
  43184. * @returns a promise for the experience helper
  43185. */
  43186. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43187. /**
  43188. * Creates a WebXRExperienceHelper
  43189. * @param scene The scene the helper should be created in
  43190. */
  43191. private constructor();
  43192. /**
  43193. * Exits XR mode and returns the scene to its original state
  43194. * @returns promise that resolves after xr mode has exited
  43195. */
  43196. exitXRAsync(): Promise<unknown>;
  43197. /**
  43198. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43199. * @param sessionCreationOptions options for the XR session
  43200. * @param referenceSpaceType frame of reference of the XR session
  43201. * @param outputCanvas the output canvas that will be used to enter XR mode
  43202. * @returns promise that resolves after xr mode has entered
  43203. */
  43204. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43205. /**
  43206. * Updates the global position of the camera by moving the camera's container
  43207. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43208. * @param position The desired global position of the camera
  43209. */
  43210. setPositionOfCameraUsingContainer(position: Vector3): void;
  43211. /**
  43212. * Rotates the xr camera by rotating the camera's container around the camera's position
  43213. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43214. * @param rotation the desired quaternion rotation to apply to the camera
  43215. */
  43216. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43217. /**
  43218. * Disposes of the experience helper
  43219. */
  43220. dispose(): void;
  43221. }
  43222. }
  43223. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43224. import { Nullable } from "babylonjs/types";
  43225. import { Observable } from "babylonjs/Misc/observable";
  43226. import { IDisposable, Scene } from "babylonjs/scene";
  43227. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43228. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43229. /**
  43230. * Button which can be used to enter a different mode of XR
  43231. */
  43232. export class WebXREnterExitUIButton {
  43233. /** button element */
  43234. element: HTMLElement;
  43235. /** XR initialization options for the button */
  43236. sessionMode: XRSessionMode;
  43237. /** Reference space type */
  43238. referenceSpaceType: XRReferenceSpaceType;
  43239. /**
  43240. * Creates a WebXREnterExitUIButton
  43241. * @param element button element
  43242. * @param sessionMode XR initialization session mode
  43243. * @param referenceSpaceType the type of reference space to be used
  43244. */
  43245. constructor(
  43246. /** button element */
  43247. element: HTMLElement,
  43248. /** XR initialization options for the button */
  43249. sessionMode: XRSessionMode,
  43250. /** Reference space type */
  43251. referenceSpaceType: XRReferenceSpaceType);
  43252. /**
  43253. * Overwritable function which can be used to update the button's visuals when the state changes
  43254. * @param activeButton the current active button in the UI
  43255. */
  43256. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43257. }
  43258. /**
  43259. * Options to create the webXR UI
  43260. */
  43261. export class WebXREnterExitUIOptions {
  43262. /**
  43263. * Context to enter xr with
  43264. */
  43265. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43266. /**
  43267. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43268. */
  43269. customButtons?: Array<WebXREnterExitUIButton>;
  43270. }
  43271. /**
  43272. * UI to allow the user to enter/exit XR mode
  43273. */
  43274. export class WebXREnterExitUI implements IDisposable {
  43275. private scene;
  43276. private _overlay;
  43277. private _buttons;
  43278. private _activeButton;
  43279. /**
  43280. * Fired every time the active button is changed.
  43281. *
  43282. * When xr is entered via a button that launches xr that button will be the callback parameter
  43283. *
  43284. * When exiting xr the callback parameter will be null)
  43285. */
  43286. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43287. /**
  43288. * Creates UI to allow the user to enter/exit XR mode
  43289. * @param scene the scene to add the ui to
  43290. * @param helper the xr experience helper to enter/exit xr with
  43291. * @param options options to configure the UI
  43292. * @returns the created ui
  43293. */
  43294. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43295. private constructor();
  43296. private _updateButtons;
  43297. /**
  43298. * Disposes of the object
  43299. */
  43300. dispose(): void;
  43301. }
  43302. }
  43303. declare module "babylonjs/Cameras/XR/webXRController" {
  43304. import { Nullable } from "babylonjs/types";
  43305. import { Observable } from "babylonjs/Misc/observable";
  43306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43307. import { Ray } from "babylonjs/Culling/ray";
  43308. import { Scene } from "babylonjs/scene";
  43309. /**
  43310. * Represents an XR input
  43311. */
  43312. export class WebXRController {
  43313. private scene;
  43314. /** The underlying input source for the controller */
  43315. inputSource: XRInputSource;
  43316. private parentContainer;
  43317. /**
  43318. * 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
  43319. */
  43320. grip?: AbstractMesh;
  43321. /**
  43322. * Pointer which can be used to select objects or attach a visible laser to
  43323. */
  43324. pointer: AbstractMesh;
  43325. /**
  43326. * Event that fires when the controller is removed/disposed
  43327. */
  43328. onDisposeObservable: Observable<{}>;
  43329. private _tmpMatrix;
  43330. private _tmpQuaternion;
  43331. private _tmpVector;
  43332. /**
  43333. * Creates the controller
  43334. * @see https://doc.babylonjs.com/how_to/webxr
  43335. * @param scene the scene which the controller should be associated to
  43336. * @param inputSource the underlying input source for the controller
  43337. * @param parentContainer parent that the controller meshes should be children of
  43338. */
  43339. constructor(scene: Scene,
  43340. /** The underlying input source for the controller */
  43341. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43342. /**
  43343. * Updates the controller pose based on the given XRFrame
  43344. * @param xrFrame xr frame to update the pose with
  43345. * @param referenceSpace reference space to use
  43346. */
  43347. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43348. /**
  43349. * Gets a world space ray coming from the controller
  43350. * @param result the resulting ray
  43351. */
  43352. getWorldPointerRayToRef(result: Ray): void;
  43353. /**
  43354. * Disposes of the object
  43355. */
  43356. dispose(): void;
  43357. }
  43358. }
  43359. declare module "babylonjs/Cameras/XR/webXRInput" {
  43360. import { Observable } from "babylonjs/Misc/observable";
  43361. import { IDisposable } from "babylonjs/scene";
  43362. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43363. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43364. /**
  43365. * XR input used to track XR inputs such as controllers/rays
  43366. */
  43367. export class WebXRInput implements IDisposable {
  43368. /**
  43369. * Base experience the input listens to
  43370. */
  43371. baseExperience: WebXRExperienceHelper;
  43372. /**
  43373. * XR controllers being tracked
  43374. */
  43375. controllers: Array<WebXRController>;
  43376. private _frameObserver;
  43377. private _stateObserver;
  43378. /**
  43379. * Event when a controller has been connected/added
  43380. */
  43381. onControllerAddedObservable: Observable<WebXRController>;
  43382. /**
  43383. * Event when a controller has been removed/disconnected
  43384. */
  43385. onControllerRemovedObservable: Observable<WebXRController>;
  43386. /**
  43387. * Initializes the WebXRInput
  43388. * @param baseExperience experience helper which the input should be created for
  43389. */
  43390. constructor(
  43391. /**
  43392. * Base experience the input listens to
  43393. */
  43394. baseExperience: WebXRExperienceHelper);
  43395. private _onInputSourcesChange;
  43396. private _addAndRemoveControllers;
  43397. /**
  43398. * Disposes of the object
  43399. */
  43400. dispose(): void;
  43401. }
  43402. }
  43403. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43405. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43406. /**
  43407. * Enables teleportation
  43408. */
  43409. export class WebXRControllerTeleportation {
  43410. private _teleportationFillColor;
  43411. private _teleportationBorderColor;
  43412. private _tmpRay;
  43413. private _tmpVector;
  43414. /**
  43415. * Creates a WebXRControllerTeleportation
  43416. * @param input input manager to add teleportation to
  43417. * @param floorMeshes floormeshes which can be teleported to
  43418. */
  43419. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43420. }
  43421. }
  43422. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43423. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43424. /**
  43425. * Handles pointer input automatically for the pointer of XR controllers
  43426. */
  43427. export class WebXRControllerPointerSelection {
  43428. private static _idCounter;
  43429. private _tmpRay;
  43430. /**
  43431. * Creates a WebXRControllerPointerSelection
  43432. * @param input input manager to setup pointer selection
  43433. */
  43434. constructor(input: WebXRInput);
  43435. private _convertNormalToDirectionOfRay;
  43436. private _updatePointerDistance;
  43437. }
  43438. }
  43439. declare module "babylonjs/Loading/sceneLoader" {
  43440. import { Observable } from "babylonjs/Misc/observable";
  43441. import { Nullable } from "babylonjs/types";
  43442. import { Scene } from "babylonjs/scene";
  43443. import { Engine } from "babylonjs/Engines/engine";
  43444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43445. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43446. import { AssetContainer } from "babylonjs/assetContainer";
  43447. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43448. import { Skeleton } from "babylonjs/Bones/skeleton";
  43449. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43450. import { WebRequest } from "babylonjs/Misc/webRequest";
  43451. /**
  43452. * Class used to represent data loading progression
  43453. */
  43454. export class SceneLoaderProgressEvent {
  43455. /** defines if data length to load can be evaluated */
  43456. readonly lengthComputable: boolean;
  43457. /** defines the loaded data length */
  43458. readonly loaded: number;
  43459. /** defines the data length to load */
  43460. readonly total: number;
  43461. /**
  43462. * Create a new progress event
  43463. * @param lengthComputable defines if data length to load can be evaluated
  43464. * @param loaded defines the loaded data length
  43465. * @param total defines the data length to load
  43466. */
  43467. constructor(
  43468. /** defines if data length to load can be evaluated */
  43469. lengthComputable: boolean,
  43470. /** defines the loaded data length */
  43471. loaded: number,
  43472. /** defines the data length to load */
  43473. total: number);
  43474. /**
  43475. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43476. * @param event defines the source event
  43477. * @returns a new SceneLoaderProgressEvent
  43478. */
  43479. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43480. }
  43481. /**
  43482. * Interface used by SceneLoader plugins to define supported file extensions
  43483. */
  43484. export interface ISceneLoaderPluginExtensions {
  43485. /**
  43486. * Defines the list of supported extensions
  43487. */
  43488. [extension: string]: {
  43489. isBinary: boolean;
  43490. };
  43491. }
  43492. /**
  43493. * Interface used by SceneLoader plugin factory
  43494. */
  43495. export interface ISceneLoaderPluginFactory {
  43496. /**
  43497. * Defines the name of the factory
  43498. */
  43499. name: string;
  43500. /**
  43501. * Function called to create a new plugin
  43502. * @return the new plugin
  43503. */
  43504. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43505. /**
  43506. * The callback that returns true if the data can be directly loaded.
  43507. * @param data string containing the file data
  43508. * @returns if the data can be loaded directly
  43509. */
  43510. canDirectLoad?(data: string): boolean;
  43511. }
  43512. /**
  43513. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43514. */
  43515. export interface ISceneLoaderPluginBase {
  43516. /**
  43517. * The friendly name of this plugin.
  43518. */
  43519. name: string;
  43520. /**
  43521. * The file extensions supported by this plugin.
  43522. */
  43523. extensions: string | ISceneLoaderPluginExtensions;
  43524. /**
  43525. * The callback called when loading from a url.
  43526. * @param scene scene loading this url
  43527. * @param url url to load
  43528. * @param onSuccess callback called when the file successfully loads
  43529. * @param onProgress callback called while file is loading (if the server supports this mode)
  43530. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43531. * @param onError callback called when the file fails to load
  43532. * @returns a file request object
  43533. */
  43534. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43535. /**
  43536. * The callback called when loading from a file object.
  43537. * @param scene scene loading this file
  43538. * @param file defines the file to load
  43539. * @param onSuccess defines the callback to call when data is loaded
  43540. * @param onProgress defines the callback to call during loading process
  43541. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43542. * @param onError defines the callback to call when an error occurs
  43543. * @returns a file request object
  43544. */
  43545. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43546. /**
  43547. * The callback that returns true if the data can be directly loaded.
  43548. * @param data string containing the file data
  43549. * @returns if the data can be loaded directly
  43550. */
  43551. canDirectLoad?(data: string): boolean;
  43552. /**
  43553. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43554. * @param scene scene loading this data
  43555. * @param data string containing the data
  43556. * @returns data to pass to the plugin
  43557. */
  43558. directLoad?(scene: Scene, data: string): any;
  43559. /**
  43560. * The callback that allows custom handling of the root url based on the response url.
  43561. * @param rootUrl the original root url
  43562. * @param responseURL the response url if available
  43563. * @returns the new root url
  43564. */
  43565. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43566. }
  43567. /**
  43568. * Interface used to define a SceneLoader plugin
  43569. */
  43570. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43571. /**
  43572. * Import meshes into a scene.
  43573. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43574. * @param scene The scene to import into
  43575. * @param data The data to import
  43576. * @param rootUrl The root url for scene and resources
  43577. * @param meshes The meshes array to import into
  43578. * @param particleSystems The particle systems array to import into
  43579. * @param skeletons The skeletons array to import into
  43580. * @param onError The callback when import fails
  43581. * @returns True if successful or false otherwise
  43582. */
  43583. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43584. /**
  43585. * Load into a scene.
  43586. * @param scene The scene to load into
  43587. * @param data The data to import
  43588. * @param rootUrl The root url for scene and resources
  43589. * @param onError The callback when import fails
  43590. * @returns True if successful or false otherwise
  43591. */
  43592. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43593. /**
  43594. * Load into an asset container.
  43595. * @param scene The scene to load into
  43596. * @param data The data to import
  43597. * @param rootUrl The root url for scene and resources
  43598. * @param onError The callback when import fails
  43599. * @returns The loaded asset container
  43600. */
  43601. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43602. }
  43603. /**
  43604. * Interface used to define an async SceneLoader plugin
  43605. */
  43606. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43607. /**
  43608. * Import meshes into a scene.
  43609. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43610. * @param scene The scene to import into
  43611. * @param data The data to import
  43612. * @param rootUrl The root url for scene and resources
  43613. * @param onProgress The callback when the load progresses
  43614. * @param fileName Defines the name of the file to load
  43615. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43616. */
  43617. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43618. meshes: AbstractMesh[];
  43619. particleSystems: IParticleSystem[];
  43620. skeletons: Skeleton[];
  43621. animationGroups: AnimationGroup[];
  43622. }>;
  43623. /**
  43624. * Load into a scene.
  43625. * @param scene The scene to load into
  43626. * @param data The data to import
  43627. * @param rootUrl The root url for scene and resources
  43628. * @param onProgress The callback when the load progresses
  43629. * @param fileName Defines the name of the file to load
  43630. * @returns Nothing
  43631. */
  43632. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43633. /**
  43634. * Load into an asset container.
  43635. * @param scene The scene to load into
  43636. * @param data The data to import
  43637. * @param rootUrl The root url for scene and resources
  43638. * @param onProgress The callback when the load progresses
  43639. * @param fileName Defines the name of the file to load
  43640. * @returns The loaded asset container
  43641. */
  43642. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43643. }
  43644. /**
  43645. * Class used to load scene from various file formats using registered plugins
  43646. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43647. */
  43648. export class SceneLoader {
  43649. /**
  43650. * No logging while loading
  43651. */
  43652. static readonly NO_LOGGING: number;
  43653. /**
  43654. * Minimal logging while loading
  43655. */
  43656. static readonly MINIMAL_LOGGING: number;
  43657. /**
  43658. * Summary logging while loading
  43659. */
  43660. static readonly SUMMARY_LOGGING: number;
  43661. /**
  43662. * Detailled logging while loading
  43663. */
  43664. static readonly DETAILED_LOGGING: number;
  43665. /**
  43666. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43667. */
  43668. static ForceFullSceneLoadingForIncremental: boolean;
  43669. /**
  43670. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43671. */
  43672. static ShowLoadingScreen: boolean;
  43673. /**
  43674. * Defines the current logging level (while loading the scene)
  43675. * @ignorenaming
  43676. */
  43677. static loggingLevel: number;
  43678. /**
  43679. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43680. */
  43681. static CleanBoneMatrixWeights: boolean;
  43682. /**
  43683. * Event raised when a plugin is used to load a scene
  43684. */
  43685. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43686. private static _registeredPlugins;
  43687. private static _getDefaultPlugin;
  43688. private static _getPluginForExtension;
  43689. private static _getPluginForDirectLoad;
  43690. private static _getPluginForFilename;
  43691. private static _getDirectLoad;
  43692. private static _loadData;
  43693. private static _getFileInfo;
  43694. /**
  43695. * Gets a plugin that can load the given extension
  43696. * @param extension defines the extension to load
  43697. * @returns a plugin or null if none works
  43698. */
  43699. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43700. /**
  43701. * Gets a boolean indicating that the given extension can be loaded
  43702. * @param extension defines the extension to load
  43703. * @returns true if the extension is supported
  43704. */
  43705. static IsPluginForExtensionAvailable(extension: string): boolean;
  43706. /**
  43707. * Adds a new plugin to the list of registered plugins
  43708. * @param plugin defines the plugin to add
  43709. */
  43710. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43711. /**
  43712. * Import meshes into a scene
  43713. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43714. * @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)
  43715. * @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)
  43716. * @param scene the instance of BABYLON.Scene to append to
  43717. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43718. * @param onProgress a callback with a progress event for each file being loaded
  43719. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43720. * @param pluginExtension the extension used to determine the plugin
  43721. * @returns The loaded plugin
  43722. */
  43723. 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>;
  43724. /**
  43725. * Import meshes into a scene
  43726. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43727. * @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)
  43728. * @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)
  43729. * @param scene the instance of BABYLON.Scene to append to
  43730. * @param onProgress a callback with a progress event for each file being loaded
  43731. * @param pluginExtension the extension used to determine the plugin
  43732. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43733. */
  43734. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43735. meshes: AbstractMesh[];
  43736. particleSystems: IParticleSystem[];
  43737. skeletons: Skeleton[];
  43738. animationGroups: AnimationGroup[];
  43739. }>;
  43740. /**
  43741. * Load a scene
  43742. * @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)
  43743. * @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)
  43744. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43745. * @param onSuccess a callback with the scene when import succeeds
  43746. * @param onProgress a callback with a progress event for each file being loaded
  43747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43748. * @param pluginExtension the extension used to determine the plugin
  43749. * @returns The loaded plugin
  43750. */
  43751. 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>;
  43752. /**
  43753. * Load a scene
  43754. * @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)
  43755. * @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)
  43756. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43757. * @param onProgress a callback with a progress event for each file being loaded
  43758. * @param pluginExtension the extension used to determine the plugin
  43759. * @returns The loaded scene
  43760. */
  43761. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43762. /**
  43763. * Append a scene
  43764. * @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)
  43765. * @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)
  43766. * @param scene is the instance of BABYLON.Scene to append to
  43767. * @param onSuccess a callback with the scene when import succeeds
  43768. * @param onProgress a callback with a progress event for each file being loaded
  43769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43770. * @param pluginExtension the extension used to determine the plugin
  43771. * @returns The loaded plugin
  43772. */
  43773. 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>;
  43774. /**
  43775. * Append a scene
  43776. * @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)
  43777. * @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)
  43778. * @param scene is the instance of BABYLON.Scene to append to
  43779. * @param onProgress a callback with a progress event for each file being loaded
  43780. * @param pluginExtension the extension used to determine the plugin
  43781. * @returns The given scene
  43782. */
  43783. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43784. /**
  43785. * Load a scene into an asset container
  43786. * @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)
  43787. * @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)
  43788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43789. * @param onSuccess a callback with the scene when import succeeds
  43790. * @param onProgress a callback with a progress event for each file being loaded
  43791. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43792. * @param pluginExtension the extension used to determine the plugin
  43793. * @returns The loaded plugin
  43794. */
  43795. 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>;
  43796. /**
  43797. * Load a scene into an asset container
  43798. * @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)
  43799. * @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)
  43800. * @param scene is the instance of Scene to append to
  43801. * @param onProgress a callback with a progress event for each file being loaded
  43802. * @param pluginExtension the extension used to determine the plugin
  43803. * @returns The loaded asset container
  43804. */
  43805. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43806. }
  43807. }
  43808. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43809. import { Scene } from "babylonjs/scene";
  43810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43811. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43812. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43813. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43814. /**
  43815. * Generic Controller
  43816. */
  43817. export class GenericController extends WebVRController {
  43818. /**
  43819. * Base Url for the controller model.
  43820. */
  43821. static readonly MODEL_BASE_URL: string;
  43822. /**
  43823. * File name for the controller model.
  43824. */
  43825. static readonly MODEL_FILENAME: string;
  43826. /**
  43827. * Creates a new GenericController from a gamepad
  43828. * @param vrGamepad the gamepad that the controller should be created from
  43829. */
  43830. constructor(vrGamepad: any);
  43831. /**
  43832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43833. * @param scene scene in which to add meshes
  43834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43835. */
  43836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43837. /**
  43838. * Called once for each button that changed state since the last frame
  43839. * @param buttonIdx Which button index changed
  43840. * @param state New state of the button
  43841. * @param changes Which properties on the state changed since last frame
  43842. */
  43843. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43844. }
  43845. }
  43846. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43847. import { Observable } from "babylonjs/Misc/observable";
  43848. import { Scene } from "babylonjs/scene";
  43849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43850. import { Ray } from "babylonjs/Culling/ray";
  43851. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43852. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43853. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43854. /**
  43855. * Defines the WindowsMotionController object that the state of the windows motion controller
  43856. */
  43857. export class WindowsMotionController extends WebVRController {
  43858. /**
  43859. * The base url used to load the left and right controller models
  43860. */
  43861. static MODEL_BASE_URL: string;
  43862. /**
  43863. * The name of the left controller model file
  43864. */
  43865. static MODEL_LEFT_FILENAME: string;
  43866. /**
  43867. * The name of the right controller model file
  43868. */
  43869. static MODEL_RIGHT_FILENAME: string;
  43870. /**
  43871. * The controller name prefix for this controller type
  43872. */
  43873. static readonly GAMEPAD_ID_PREFIX: string;
  43874. /**
  43875. * The controller id pattern for this controller type
  43876. */
  43877. private static readonly GAMEPAD_ID_PATTERN;
  43878. private _loadedMeshInfo;
  43879. private readonly _mapping;
  43880. /**
  43881. * Fired when the trackpad on this controller is clicked
  43882. */
  43883. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43884. /**
  43885. * Fired when the trackpad on this controller is modified
  43886. */
  43887. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43888. /**
  43889. * The current x and y values of this controller's trackpad
  43890. */
  43891. trackpad: StickValues;
  43892. /**
  43893. * Creates a new WindowsMotionController from a gamepad
  43894. * @param vrGamepad the gamepad that the controller should be created from
  43895. */
  43896. constructor(vrGamepad: any);
  43897. /**
  43898. * Fired when the trigger on this controller is modified
  43899. */
  43900. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Fired when the menu button on this controller is modified
  43903. */
  43904. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43905. /**
  43906. * Fired when the grip button on this controller is modified
  43907. */
  43908. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43909. /**
  43910. * Fired when the thumbstick button on this controller is modified
  43911. */
  43912. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43913. /**
  43914. * Fired when the touchpad button on this controller is modified
  43915. */
  43916. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43917. /**
  43918. * Fired when the touchpad values on this controller are modified
  43919. */
  43920. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43921. private _updateTrackpad;
  43922. /**
  43923. * Called once per frame by the engine.
  43924. */
  43925. update(): void;
  43926. /**
  43927. * Called once for each button that changed state since the last frame
  43928. * @param buttonIdx Which button index changed
  43929. * @param state New state of the button
  43930. * @param changes Which properties on the state changed since last frame
  43931. */
  43932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43933. /**
  43934. * Moves the buttons on the controller mesh based on their current state
  43935. * @param buttonName the name of the button to move
  43936. * @param buttonValue the value of the button which determines the buttons new position
  43937. */
  43938. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43939. /**
  43940. * Moves the axis on the controller mesh based on its current state
  43941. * @param axis the index of the axis
  43942. * @param axisValue the value of the axis which determines the meshes new position
  43943. * @hidden
  43944. */
  43945. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43946. /**
  43947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43948. * @param scene scene in which to add meshes
  43949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43950. */
  43951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43952. /**
  43953. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43954. * can be transformed by button presses and axes values, based on this._mapping.
  43955. *
  43956. * @param scene scene in which the meshes exist
  43957. * @param meshes list of meshes that make up the controller model to process
  43958. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43959. */
  43960. private processModel;
  43961. private createMeshInfo;
  43962. /**
  43963. * Gets the ray of the controller in the direction the controller is pointing
  43964. * @param length the length the resulting ray should be
  43965. * @returns a ray in the direction the controller is pointing
  43966. */
  43967. getForwardRay(length?: number): Ray;
  43968. /**
  43969. * Disposes of the controller
  43970. */
  43971. dispose(): void;
  43972. }
  43973. }
  43974. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43975. import { Observable } from "babylonjs/Misc/observable";
  43976. import { Scene } from "babylonjs/scene";
  43977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43978. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43979. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43980. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43981. /**
  43982. * Oculus Touch Controller
  43983. */
  43984. export class OculusTouchController extends WebVRController {
  43985. /**
  43986. * Base Url for the controller model.
  43987. */
  43988. static MODEL_BASE_URL: string;
  43989. /**
  43990. * File name for the left controller model.
  43991. */
  43992. static MODEL_LEFT_FILENAME: string;
  43993. /**
  43994. * File name for the right controller model.
  43995. */
  43996. static MODEL_RIGHT_FILENAME: string;
  43997. /**
  43998. * Base Url for the Quest controller model.
  43999. */
  44000. static QUEST_MODEL_BASE_URL: string;
  44001. /**
  44002. * @hidden
  44003. * If the controllers are running on a device that needs the updated Quest controller models
  44004. */
  44005. static _IsQuest: boolean;
  44006. /**
  44007. * Fired when the secondary trigger on this controller is modified
  44008. */
  44009. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44010. /**
  44011. * Fired when the thumb rest on this controller is modified
  44012. */
  44013. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44014. /**
  44015. * Creates a new OculusTouchController from a gamepad
  44016. * @param vrGamepad the gamepad that the controller should be created from
  44017. */
  44018. constructor(vrGamepad: any);
  44019. /**
  44020. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44021. * @param scene scene in which to add meshes
  44022. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44023. */
  44024. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44025. /**
  44026. * Fired when the A button on this controller is modified
  44027. */
  44028. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44029. /**
  44030. * Fired when the B button on this controller is modified
  44031. */
  44032. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44033. /**
  44034. * Fired when the X button on this controller is modified
  44035. */
  44036. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44037. /**
  44038. * Fired when the Y button on this controller is modified
  44039. */
  44040. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44041. /**
  44042. * Called once for each button that changed state since the last frame
  44043. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44044. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44045. * 2) secondary trigger (same)
  44046. * 3) A (right) X (left), touch, pressed = value
  44047. * 4) B / Y
  44048. * 5) thumb rest
  44049. * @param buttonIdx Which button index changed
  44050. * @param state New state of the button
  44051. * @param changes Which properties on the state changed since last frame
  44052. */
  44053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44054. }
  44055. }
  44056. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44057. import { Scene } from "babylonjs/scene";
  44058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44059. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44060. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44061. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44062. import { Observable } from "babylonjs/Misc/observable";
  44063. /**
  44064. * Vive Controller
  44065. */
  44066. export class ViveController extends WebVRController {
  44067. /**
  44068. * Base Url for the controller model.
  44069. */
  44070. static MODEL_BASE_URL: string;
  44071. /**
  44072. * File name for the controller model.
  44073. */
  44074. static MODEL_FILENAME: string;
  44075. /**
  44076. * Creates a new ViveController from a gamepad
  44077. * @param vrGamepad the gamepad that the controller should be created from
  44078. */
  44079. constructor(vrGamepad: any);
  44080. /**
  44081. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44082. * @param scene scene in which to add meshes
  44083. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44084. */
  44085. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44086. /**
  44087. * Fired when the left button on this controller is modified
  44088. */
  44089. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44090. /**
  44091. * Fired when the right button on this controller is modified
  44092. */
  44093. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44094. /**
  44095. * Fired when the menu button on this controller is modified
  44096. */
  44097. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44098. /**
  44099. * Called once for each button that changed state since the last frame
  44100. * Vive mapping:
  44101. * 0: touchpad
  44102. * 1: trigger
  44103. * 2: left AND right buttons
  44104. * 3: menu button
  44105. * @param buttonIdx Which button index changed
  44106. * @param state New state of the button
  44107. * @param changes Which properties on the state changed since last frame
  44108. */
  44109. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44110. }
  44111. }
  44112. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44113. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44114. /**
  44115. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44116. */
  44117. export class WebXRControllerModelLoader {
  44118. /**
  44119. * Creates the WebXRControllerModelLoader
  44120. * @param input xr input that creates the controllers
  44121. */
  44122. constructor(input: WebXRInput);
  44123. }
  44124. }
  44125. declare module "babylonjs/Cameras/XR/index" {
  44126. export * from "babylonjs/Cameras/XR/webXRCamera";
  44127. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44128. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44129. export * from "babylonjs/Cameras/XR/webXRInput";
  44130. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44131. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44132. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44133. export * from "babylonjs/Cameras/XR/webXRController";
  44134. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44135. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44136. }
  44137. declare module "babylonjs/Cameras/RigModes/index" {
  44138. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44139. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44140. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44141. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44142. }
  44143. declare module "babylonjs/Cameras/index" {
  44144. export * from "babylonjs/Cameras/Inputs/index";
  44145. export * from "babylonjs/Cameras/cameraInputsManager";
  44146. export * from "babylonjs/Cameras/camera";
  44147. export * from "babylonjs/Cameras/targetCamera";
  44148. export * from "babylonjs/Cameras/freeCamera";
  44149. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44150. export * from "babylonjs/Cameras/touchCamera";
  44151. export * from "babylonjs/Cameras/arcRotateCamera";
  44152. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44153. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44154. export * from "babylonjs/Cameras/flyCamera";
  44155. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44156. export * from "babylonjs/Cameras/followCamera";
  44157. export * from "babylonjs/Cameras/followCameraInputsManager";
  44158. export * from "babylonjs/Cameras/gamepadCamera";
  44159. export * from "babylonjs/Cameras/Stereoscopic/index";
  44160. export * from "babylonjs/Cameras/universalCamera";
  44161. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44162. export * from "babylonjs/Cameras/VR/index";
  44163. export * from "babylonjs/Cameras/XR/index";
  44164. export * from "babylonjs/Cameras/RigModes/index";
  44165. }
  44166. declare module "babylonjs/Collisions/index" {
  44167. export * from "babylonjs/Collisions/collider";
  44168. export * from "babylonjs/Collisions/collisionCoordinator";
  44169. export * from "babylonjs/Collisions/pickingInfo";
  44170. export * from "babylonjs/Collisions/intersectionInfo";
  44171. export * from "babylonjs/Collisions/meshCollisionData";
  44172. }
  44173. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44174. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44175. import { Vector3 } from "babylonjs/Maths/math.vector";
  44176. import { Ray } from "babylonjs/Culling/ray";
  44177. import { Plane } from "babylonjs/Maths/math.plane";
  44178. /**
  44179. * Contains an array of blocks representing the octree
  44180. */
  44181. export interface IOctreeContainer<T> {
  44182. /**
  44183. * Blocks within the octree
  44184. */
  44185. blocks: Array<OctreeBlock<T>>;
  44186. }
  44187. /**
  44188. * Class used to store a cell in an octree
  44189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44190. */
  44191. export class OctreeBlock<T> {
  44192. /**
  44193. * Gets the content of the current block
  44194. */
  44195. entries: T[];
  44196. /**
  44197. * Gets the list of block children
  44198. */
  44199. blocks: Array<OctreeBlock<T>>;
  44200. private _depth;
  44201. private _maxDepth;
  44202. private _capacity;
  44203. private _minPoint;
  44204. private _maxPoint;
  44205. private _boundingVectors;
  44206. private _creationFunc;
  44207. /**
  44208. * Creates a new block
  44209. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44210. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44211. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44212. * @param depth defines the current depth of this block in the octree
  44213. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44214. * @param creationFunc defines a callback to call when an element is added to the block
  44215. */
  44216. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44217. /**
  44218. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44219. */
  44220. readonly capacity: number;
  44221. /**
  44222. * Gets the minimum vector (in world space) of the block's bounding box
  44223. */
  44224. readonly minPoint: Vector3;
  44225. /**
  44226. * Gets the maximum vector (in world space) of the block's bounding box
  44227. */
  44228. readonly maxPoint: Vector3;
  44229. /**
  44230. * Add a new element to this block
  44231. * @param entry defines the element to add
  44232. */
  44233. addEntry(entry: T): void;
  44234. /**
  44235. * Remove an element from this block
  44236. * @param entry defines the element to remove
  44237. */
  44238. removeEntry(entry: T): void;
  44239. /**
  44240. * Add an array of elements to this block
  44241. * @param entries defines the array of elements to add
  44242. */
  44243. addEntries(entries: T[]): void;
  44244. /**
  44245. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44246. * @param frustumPlanes defines the frustum planes to test
  44247. * @param selection defines the array to store current content if selection is positive
  44248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44249. */
  44250. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44251. /**
  44252. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44253. * @param sphereCenter defines the bounding sphere center
  44254. * @param sphereRadius defines the bounding sphere radius
  44255. * @param selection defines the array to store current content if selection is positive
  44256. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44257. */
  44258. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44259. /**
  44260. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44261. * @param ray defines the ray to test with
  44262. * @param selection defines the array to store current content if selection is positive
  44263. */
  44264. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44265. /**
  44266. * Subdivide the content into child blocks (this block will then be empty)
  44267. */
  44268. createInnerBlocks(): void;
  44269. /**
  44270. * @hidden
  44271. */
  44272. 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;
  44273. }
  44274. }
  44275. declare module "babylonjs/Culling/Octrees/octree" {
  44276. import { SmartArray } from "babylonjs/Misc/smartArray";
  44277. import { Vector3 } from "babylonjs/Maths/math.vector";
  44278. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { Ray } from "babylonjs/Culling/ray";
  44281. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44282. import { Plane } from "babylonjs/Maths/math.plane";
  44283. /**
  44284. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44285. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44286. */
  44287. export class Octree<T> {
  44288. /** 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.) */
  44289. maxDepth: number;
  44290. /**
  44291. * Blocks within the octree containing objects
  44292. */
  44293. blocks: Array<OctreeBlock<T>>;
  44294. /**
  44295. * Content stored in the octree
  44296. */
  44297. dynamicContent: T[];
  44298. private _maxBlockCapacity;
  44299. private _selectionContent;
  44300. private _creationFunc;
  44301. /**
  44302. * Creates a octree
  44303. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44304. * @param creationFunc function to be used to instatiate the octree
  44305. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44306. * @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.)
  44307. */
  44308. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44309. /** 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.) */
  44310. maxDepth?: number);
  44311. /**
  44312. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44313. * @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);
  44314. * @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);
  44315. * @param entries meshes to be added to the octree blocks
  44316. */
  44317. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44318. /**
  44319. * Adds a mesh to the octree
  44320. * @param entry Mesh to add to the octree
  44321. */
  44322. addMesh(entry: T): void;
  44323. /**
  44324. * Remove an element from the octree
  44325. * @param entry defines the element to remove
  44326. */
  44327. removeMesh(entry: T): void;
  44328. /**
  44329. * Selects an array of meshes within the frustum
  44330. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44331. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44332. * @returns array of meshes within the frustum
  44333. */
  44334. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44335. /**
  44336. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44337. * @param sphereCenter defines the bounding sphere center
  44338. * @param sphereRadius defines the bounding sphere radius
  44339. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44340. * @returns an array of objects that intersect the sphere
  44341. */
  44342. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44343. /**
  44344. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44345. * @param ray defines the ray to test with
  44346. * @returns array of intersected objects
  44347. */
  44348. intersectsRay(ray: Ray): SmartArray<T>;
  44349. /**
  44350. * Adds a mesh into the octree block if it intersects the block
  44351. */
  44352. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44353. /**
  44354. * Adds a submesh into the octree block if it intersects the block
  44355. */
  44356. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44357. }
  44358. }
  44359. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44360. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44361. import { Scene } from "babylonjs/scene";
  44362. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44364. import { Ray } from "babylonjs/Culling/ray";
  44365. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44366. import { Collider } from "babylonjs/Collisions/collider";
  44367. module "babylonjs/scene" {
  44368. interface Scene {
  44369. /**
  44370. * @hidden
  44371. * Backing Filed
  44372. */
  44373. _selectionOctree: Octree<AbstractMesh>;
  44374. /**
  44375. * Gets the octree used to boost mesh selection (picking)
  44376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44377. */
  44378. selectionOctree: Octree<AbstractMesh>;
  44379. /**
  44380. * Creates or updates the octree used to boost selection (picking)
  44381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44382. * @param maxCapacity defines the maximum capacity per leaf
  44383. * @param maxDepth defines the maximum depth of the octree
  44384. * @returns an octree of AbstractMesh
  44385. */
  44386. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44387. }
  44388. }
  44389. module "babylonjs/Meshes/abstractMesh" {
  44390. interface AbstractMesh {
  44391. /**
  44392. * @hidden
  44393. * Backing Field
  44394. */
  44395. _submeshesOctree: Octree<SubMesh>;
  44396. /**
  44397. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44398. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44399. * @param maxCapacity defines the maximum size of each block (64 by default)
  44400. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44401. * @returns the new octree
  44402. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44404. */
  44405. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44406. }
  44407. }
  44408. /**
  44409. * Defines the octree scene component responsible to manage any octrees
  44410. * in a given scene.
  44411. */
  44412. export class OctreeSceneComponent {
  44413. /**
  44414. * The component name help to identify the component in the list of scene components.
  44415. */
  44416. readonly name: string;
  44417. /**
  44418. * The scene the component belongs to.
  44419. */
  44420. scene: Scene;
  44421. /**
  44422. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44423. */
  44424. readonly checksIsEnabled: boolean;
  44425. /**
  44426. * Creates a new instance of the component for the given scene
  44427. * @param scene Defines the scene to register the component in
  44428. */
  44429. constructor(scene: Scene);
  44430. /**
  44431. * Registers the component in a given scene
  44432. */
  44433. register(): void;
  44434. /**
  44435. * Return the list of active meshes
  44436. * @returns the list of active meshes
  44437. */
  44438. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44439. /**
  44440. * Return the list of active sub meshes
  44441. * @param mesh The mesh to get the candidates sub meshes from
  44442. * @returns the list of active sub meshes
  44443. */
  44444. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44445. private _tempRay;
  44446. /**
  44447. * Return the list of sub meshes intersecting with a given local ray
  44448. * @param mesh defines the mesh to find the submesh for
  44449. * @param localRay defines the ray in local space
  44450. * @returns the list of intersecting sub meshes
  44451. */
  44452. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44453. /**
  44454. * Return the list of sub meshes colliding with a collider
  44455. * @param mesh defines the mesh to find the submesh for
  44456. * @param collider defines the collider to evaluate the collision against
  44457. * @returns the list of colliding sub meshes
  44458. */
  44459. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44460. /**
  44461. * Rebuilds the elements related to this component in case of
  44462. * context lost for instance.
  44463. */
  44464. rebuild(): void;
  44465. /**
  44466. * Disposes the component and the associated ressources.
  44467. */
  44468. dispose(): void;
  44469. }
  44470. }
  44471. declare module "babylonjs/Culling/Octrees/index" {
  44472. export * from "babylonjs/Culling/Octrees/octree";
  44473. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44474. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44475. }
  44476. declare module "babylonjs/Culling/index" {
  44477. export * from "babylonjs/Culling/boundingBox";
  44478. export * from "babylonjs/Culling/boundingInfo";
  44479. export * from "babylonjs/Culling/boundingSphere";
  44480. export * from "babylonjs/Culling/Octrees/index";
  44481. export * from "babylonjs/Culling/ray";
  44482. }
  44483. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44484. import { IDisposable, Scene } from "babylonjs/scene";
  44485. import { Nullable } from "babylonjs/types";
  44486. import { Observable } from "babylonjs/Misc/observable";
  44487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44488. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44489. import { Camera } from "babylonjs/Cameras/camera";
  44490. /**
  44491. * Renders a layer on top of an existing scene
  44492. */
  44493. export class UtilityLayerRenderer implements IDisposable {
  44494. /** the original scene that will be rendered on top of */
  44495. originalScene: Scene;
  44496. private _pointerCaptures;
  44497. private _lastPointerEvents;
  44498. private static _DefaultUtilityLayer;
  44499. private static _DefaultKeepDepthUtilityLayer;
  44500. private _sharedGizmoLight;
  44501. private _renderCamera;
  44502. /**
  44503. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44504. * @returns the camera that is used when rendering the utility layer
  44505. */
  44506. getRenderCamera(): Nullable<Camera>;
  44507. /**
  44508. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44509. * @param cam the camera that should be used when rendering the utility layer
  44510. */
  44511. setRenderCamera(cam: Nullable<Camera>): void;
  44512. /**
  44513. * @hidden
  44514. * Light which used by gizmos to get light shading
  44515. */
  44516. _getSharedGizmoLight(): HemisphericLight;
  44517. /**
  44518. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44519. */
  44520. pickUtilitySceneFirst: boolean;
  44521. /**
  44522. * 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)
  44523. */
  44524. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44525. /**
  44526. * 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)
  44527. */
  44528. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44529. /**
  44530. * The scene that is rendered on top of the original scene
  44531. */
  44532. utilityLayerScene: Scene;
  44533. /**
  44534. * If the utility layer should automatically be rendered on top of existing scene
  44535. */
  44536. shouldRender: boolean;
  44537. /**
  44538. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44539. */
  44540. onlyCheckPointerDownEvents: boolean;
  44541. /**
  44542. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44543. */
  44544. processAllEvents: boolean;
  44545. /**
  44546. * Observable raised when the pointer move from the utility layer scene to the main scene
  44547. */
  44548. onPointerOutObservable: Observable<number>;
  44549. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44550. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44551. private _afterRenderObserver;
  44552. private _sceneDisposeObserver;
  44553. private _originalPointerObserver;
  44554. /**
  44555. * Instantiates a UtilityLayerRenderer
  44556. * @param originalScene the original scene that will be rendered on top of
  44557. * @param handleEvents boolean indicating if the utility layer should handle events
  44558. */
  44559. constructor(
  44560. /** the original scene that will be rendered on top of */
  44561. originalScene: Scene, handleEvents?: boolean);
  44562. private _notifyObservers;
  44563. /**
  44564. * Renders the utility layers scene on top of the original scene
  44565. */
  44566. render(): void;
  44567. /**
  44568. * Disposes of the renderer
  44569. */
  44570. dispose(): void;
  44571. private _updateCamera;
  44572. }
  44573. }
  44574. declare module "babylonjs/Gizmos/gizmo" {
  44575. import { Nullable } from "babylonjs/types";
  44576. import { IDisposable } from "babylonjs/scene";
  44577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44578. import { Mesh } from "babylonjs/Meshes/mesh";
  44579. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44580. /**
  44581. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44582. */
  44583. export class Gizmo implements IDisposable {
  44584. /** The utility layer the gizmo will be added to */
  44585. gizmoLayer: UtilityLayerRenderer;
  44586. /**
  44587. * The root mesh of the gizmo
  44588. */
  44589. _rootMesh: Mesh;
  44590. private _attachedMesh;
  44591. /**
  44592. * Ratio for the scale of the gizmo (Default: 1)
  44593. */
  44594. scaleRatio: number;
  44595. /**
  44596. * If a custom mesh has been set (Default: false)
  44597. */
  44598. protected _customMeshSet: boolean;
  44599. /**
  44600. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44601. * * When set, interactions will be enabled
  44602. */
  44603. attachedMesh: Nullable<AbstractMesh>;
  44604. /**
  44605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44606. * @param mesh The mesh to replace the default mesh of the gizmo
  44607. */
  44608. setCustomMesh(mesh: Mesh): void;
  44609. /**
  44610. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44611. */
  44612. updateGizmoRotationToMatchAttachedMesh: boolean;
  44613. /**
  44614. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44615. */
  44616. updateGizmoPositionToMatchAttachedMesh: boolean;
  44617. /**
  44618. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44619. */
  44620. updateScale: boolean;
  44621. protected _interactionsEnabled: boolean;
  44622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44623. private _beforeRenderObserver;
  44624. private _tempVector;
  44625. /**
  44626. * Creates a gizmo
  44627. * @param gizmoLayer The utility layer the gizmo will be added to
  44628. */
  44629. constructor(
  44630. /** The utility layer the gizmo will be added to */
  44631. gizmoLayer?: UtilityLayerRenderer);
  44632. /**
  44633. * Updates the gizmo to match the attached mesh's position/rotation
  44634. */
  44635. protected _update(): void;
  44636. /**
  44637. * Disposes of the gizmo
  44638. */
  44639. dispose(): void;
  44640. }
  44641. }
  44642. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44643. import { Observable } from "babylonjs/Misc/observable";
  44644. import { Nullable } from "babylonjs/types";
  44645. import { Vector3 } from "babylonjs/Maths/math.vector";
  44646. import { Color3 } from "babylonjs/Maths/math.color";
  44647. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44649. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44650. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44651. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44652. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44653. import { Scene } from "babylonjs/scene";
  44654. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44655. /**
  44656. * Single plane drag gizmo
  44657. */
  44658. export class PlaneDragGizmo extends Gizmo {
  44659. /**
  44660. * Drag behavior responsible for the gizmos dragging interactions
  44661. */
  44662. dragBehavior: PointerDragBehavior;
  44663. private _pointerObserver;
  44664. /**
  44665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44666. */
  44667. snapDistance: number;
  44668. /**
  44669. * Event that fires each time the gizmo snaps to a new location.
  44670. * * snapDistance is the the change in distance
  44671. */
  44672. onSnapObservable: Observable<{
  44673. snapDistance: number;
  44674. }>;
  44675. private _plane;
  44676. private _coloredMaterial;
  44677. private _hoverMaterial;
  44678. private _isEnabled;
  44679. private _parent;
  44680. /** @hidden */
  44681. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44682. /** @hidden */
  44683. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44684. /**
  44685. * Creates a PlaneDragGizmo
  44686. * @param gizmoLayer The utility layer the gizmo will be added to
  44687. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44688. * @param color The color of the gizmo
  44689. */
  44690. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44691. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44692. /**
  44693. * If the gizmo is enabled
  44694. */
  44695. isEnabled: boolean;
  44696. /**
  44697. * Disposes of the gizmo
  44698. */
  44699. dispose(): void;
  44700. }
  44701. }
  44702. declare module "babylonjs/Gizmos/positionGizmo" {
  44703. import { Observable } from "babylonjs/Misc/observable";
  44704. import { Nullable } from "babylonjs/types";
  44705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44706. import { Mesh } from "babylonjs/Meshes/mesh";
  44707. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44708. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44709. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44710. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44711. /**
  44712. * Gizmo that enables dragging a mesh along 3 axis
  44713. */
  44714. export class PositionGizmo extends Gizmo {
  44715. /**
  44716. * Internal gizmo used for interactions on the x axis
  44717. */
  44718. xGizmo: AxisDragGizmo;
  44719. /**
  44720. * Internal gizmo used for interactions on the y axis
  44721. */
  44722. yGizmo: AxisDragGizmo;
  44723. /**
  44724. * Internal gizmo used for interactions on the z axis
  44725. */
  44726. zGizmo: AxisDragGizmo;
  44727. /**
  44728. * Internal gizmo used for interactions on the yz plane
  44729. */
  44730. xPlaneGizmo: PlaneDragGizmo;
  44731. /**
  44732. * Internal gizmo used for interactions on the xz plane
  44733. */
  44734. yPlaneGizmo: PlaneDragGizmo;
  44735. /**
  44736. * Internal gizmo used for interactions on the xy plane
  44737. */
  44738. zPlaneGizmo: PlaneDragGizmo;
  44739. /**
  44740. * private variables
  44741. */
  44742. private _meshAttached;
  44743. private _updateGizmoRotationToMatchAttachedMesh;
  44744. private _snapDistance;
  44745. private _scaleRatio;
  44746. /** Fires an event when any of it's sub gizmos are dragged */
  44747. onDragStartObservable: Observable<unknown>;
  44748. /** Fires an event when any of it's sub gizmos are released from dragging */
  44749. onDragEndObservable: Observable<unknown>;
  44750. /**
  44751. * If set to true, planar drag is enabled
  44752. */
  44753. private _planarGizmoEnabled;
  44754. attachedMesh: Nullable<AbstractMesh>;
  44755. /**
  44756. * Creates a PositionGizmo
  44757. * @param gizmoLayer The utility layer the gizmo will be added to
  44758. */
  44759. constructor(gizmoLayer?: UtilityLayerRenderer);
  44760. /**
  44761. * If the planar drag gizmo is enabled
  44762. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44763. */
  44764. planarGizmoEnabled: boolean;
  44765. updateGizmoRotationToMatchAttachedMesh: boolean;
  44766. /**
  44767. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44768. */
  44769. snapDistance: number;
  44770. /**
  44771. * Ratio for the scale of the gizmo (Default: 1)
  44772. */
  44773. scaleRatio: number;
  44774. /**
  44775. * Disposes of the gizmo
  44776. */
  44777. dispose(): void;
  44778. /**
  44779. * CustomMeshes are not supported by this gizmo
  44780. * @param mesh The mesh to replace the default mesh of the gizmo
  44781. */
  44782. setCustomMesh(mesh: Mesh): void;
  44783. }
  44784. }
  44785. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44786. import { Observable } from "babylonjs/Misc/observable";
  44787. import { Nullable } from "babylonjs/types";
  44788. import { Vector3 } from "babylonjs/Maths/math.vector";
  44789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44791. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44792. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44793. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44794. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44795. import { Scene } from "babylonjs/scene";
  44796. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44797. import { Color3 } from "babylonjs/Maths/math.color";
  44798. /**
  44799. * Single axis drag gizmo
  44800. */
  44801. export class AxisDragGizmo extends Gizmo {
  44802. /**
  44803. * Drag behavior responsible for the gizmos dragging interactions
  44804. */
  44805. dragBehavior: PointerDragBehavior;
  44806. private _pointerObserver;
  44807. /**
  44808. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44809. */
  44810. snapDistance: number;
  44811. /**
  44812. * Event that fires each time the gizmo snaps to a new location.
  44813. * * snapDistance is the the change in distance
  44814. */
  44815. onSnapObservable: Observable<{
  44816. snapDistance: number;
  44817. }>;
  44818. private _isEnabled;
  44819. private _parent;
  44820. private _arrow;
  44821. private _coloredMaterial;
  44822. private _hoverMaterial;
  44823. /** @hidden */
  44824. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44825. /** @hidden */
  44826. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44827. /**
  44828. * Creates an AxisDragGizmo
  44829. * @param gizmoLayer The utility layer the gizmo will be added to
  44830. * @param dragAxis The axis which the gizmo will be able to drag on
  44831. * @param color The color of the gizmo
  44832. */
  44833. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44834. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44835. /**
  44836. * If the gizmo is enabled
  44837. */
  44838. isEnabled: boolean;
  44839. /**
  44840. * Disposes of the gizmo
  44841. */
  44842. dispose(): void;
  44843. }
  44844. }
  44845. declare module "babylonjs/Debug/axesViewer" {
  44846. import { Vector3 } from "babylonjs/Maths/math.vector";
  44847. import { Nullable } from "babylonjs/types";
  44848. import { Scene } from "babylonjs/scene";
  44849. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44850. /**
  44851. * The Axes viewer will show 3 axes in a specific point in space
  44852. */
  44853. export class AxesViewer {
  44854. private _xAxis;
  44855. private _yAxis;
  44856. private _zAxis;
  44857. private _scaleLinesFactor;
  44858. private _instanced;
  44859. /**
  44860. * Gets the hosting scene
  44861. */
  44862. scene: Scene;
  44863. /**
  44864. * Gets or sets a number used to scale line length
  44865. */
  44866. scaleLines: number;
  44867. /** Gets the node hierarchy used to render x-axis */
  44868. readonly xAxis: TransformNode;
  44869. /** Gets the node hierarchy used to render y-axis */
  44870. readonly yAxis: TransformNode;
  44871. /** Gets the node hierarchy used to render z-axis */
  44872. readonly zAxis: TransformNode;
  44873. /**
  44874. * Creates a new AxesViewer
  44875. * @param scene defines the hosting scene
  44876. * @param scaleLines defines a number used to scale line length (1 by default)
  44877. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44878. * @param xAxis defines the node hierarchy used to render the x-axis
  44879. * @param yAxis defines the node hierarchy used to render the y-axis
  44880. * @param zAxis defines the node hierarchy used to render the z-axis
  44881. */
  44882. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44883. /**
  44884. * Force the viewer to update
  44885. * @param position defines the position of the viewer
  44886. * @param xaxis defines the x axis of the viewer
  44887. * @param yaxis defines the y axis of the viewer
  44888. * @param zaxis defines the z axis of the viewer
  44889. */
  44890. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44891. /**
  44892. * Creates an instance of this axes viewer.
  44893. * @returns a new axes viewer with instanced meshes
  44894. */
  44895. createInstance(): AxesViewer;
  44896. /** Releases resources */
  44897. dispose(): void;
  44898. private static _SetRenderingGroupId;
  44899. }
  44900. }
  44901. declare module "babylonjs/Debug/boneAxesViewer" {
  44902. import { Nullable } from "babylonjs/types";
  44903. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44904. import { Vector3 } from "babylonjs/Maths/math.vector";
  44905. import { Mesh } from "babylonjs/Meshes/mesh";
  44906. import { Bone } from "babylonjs/Bones/bone";
  44907. import { Scene } from "babylonjs/scene";
  44908. /**
  44909. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44910. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44911. */
  44912. export class BoneAxesViewer extends AxesViewer {
  44913. /**
  44914. * Gets or sets the target mesh where to display the axes viewer
  44915. */
  44916. mesh: Nullable<Mesh>;
  44917. /**
  44918. * Gets or sets the target bone where to display the axes viewer
  44919. */
  44920. bone: Nullable<Bone>;
  44921. /** Gets current position */
  44922. pos: Vector3;
  44923. /** Gets direction of X axis */
  44924. xaxis: Vector3;
  44925. /** Gets direction of Y axis */
  44926. yaxis: Vector3;
  44927. /** Gets direction of Z axis */
  44928. zaxis: Vector3;
  44929. /**
  44930. * Creates a new BoneAxesViewer
  44931. * @param scene defines the hosting scene
  44932. * @param bone defines the target bone
  44933. * @param mesh defines the target mesh
  44934. * @param scaleLines defines a scaling factor for line length (1 by default)
  44935. */
  44936. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44937. /**
  44938. * Force the viewer to update
  44939. */
  44940. update(): void;
  44941. /** Releases resources */
  44942. dispose(): void;
  44943. }
  44944. }
  44945. declare module "babylonjs/Debug/debugLayer" {
  44946. import { Scene } from "babylonjs/scene";
  44947. /**
  44948. * Interface used to define scene explorer extensibility option
  44949. */
  44950. export interface IExplorerExtensibilityOption {
  44951. /**
  44952. * Define the option label
  44953. */
  44954. label: string;
  44955. /**
  44956. * Defines the action to execute on click
  44957. */
  44958. action: (entity: any) => void;
  44959. }
  44960. /**
  44961. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44962. */
  44963. export interface IExplorerExtensibilityGroup {
  44964. /**
  44965. * Defines a predicate to test if a given type mut be extended
  44966. */
  44967. predicate: (entity: any) => boolean;
  44968. /**
  44969. * Gets the list of options added to a type
  44970. */
  44971. entries: IExplorerExtensibilityOption[];
  44972. }
  44973. /**
  44974. * Interface used to define the options to use to create the Inspector
  44975. */
  44976. export interface IInspectorOptions {
  44977. /**
  44978. * Display in overlay mode (default: false)
  44979. */
  44980. overlay?: boolean;
  44981. /**
  44982. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44983. */
  44984. globalRoot?: HTMLElement;
  44985. /**
  44986. * Display the Scene explorer
  44987. */
  44988. showExplorer?: boolean;
  44989. /**
  44990. * Display the property inspector
  44991. */
  44992. showInspector?: boolean;
  44993. /**
  44994. * Display in embed mode (both panes on the right)
  44995. */
  44996. embedMode?: boolean;
  44997. /**
  44998. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44999. */
  45000. handleResize?: boolean;
  45001. /**
  45002. * Allow the panes to popup (default: true)
  45003. */
  45004. enablePopup?: boolean;
  45005. /**
  45006. * Allow the panes to be closed by users (default: true)
  45007. */
  45008. enableClose?: boolean;
  45009. /**
  45010. * Optional list of extensibility entries
  45011. */
  45012. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45013. /**
  45014. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45015. */
  45016. inspectorURL?: string;
  45017. }
  45018. module "babylonjs/scene" {
  45019. interface Scene {
  45020. /**
  45021. * @hidden
  45022. * Backing field
  45023. */
  45024. _debugLayer: DebugLayer;
  45025. /**
  45026. * Gets the debug layer (aka Inspector) associated with the scene
  45027. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45028. */
  45029. debugLayer: DebugLayer;
  45030. }
  45031. }
  45032. /**
  45033. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45034. * what is happening in your scene
  45035. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45036. */
  45037. export class DebugLayer {
  45038. /**
  45039. * Define the url to get the inspector script from.
  45040. * By default it uses the babylonjs CDN.
  45041. * @ignoreNaming
  45042. */
  45043. static InspectorURL: string;
  45044. private _scene;
  45045. private BJSINSPECTOR;
  45046. private _onPropertyChangedObservable?;
  45047. /**
  45048. * Observable triggered when a property is changed through the inspector.
  45049. */
  45050. readonly onPropertyChangedObservable: any;
  45051. /**
  45052. * Instantiates a new debug layer.
  45053. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45054. * what is happening in your scene
  45055. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45056. * @param scene Defines the scene to inspect
  45057. */
  45058. constructor(scene: Scene);
  45059. /** Creates the inspector window. */
  45060. private _createInspector;
  45061. /**
  45062. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45063. * @param entity defines the entity to select
  45064. * @param lineContainerTitle defines the specific block to highlight
  45065. */
  45066. select(entity: any, lineContainerTitle?: string): void;
  45067. /** Get the inspector from bundle or global */
  45068. private _getGlobalInspector;
  45069. /**
  45070. * Get if the inspector is visible or not.
  45071. * @returns true if visible otherwise, false
  45072. */
  45073. isVisible(): boolean;
  45074. /**
  45075. * Hide the inspector and close its window.
  45076. */
  45077. hide(): void;
  45078. /**
  45079. * Launch the debugLayer.
  45080. * @param config Define the configuration of the inspector
  45081. * @return a promise fulfilled when the debug layer is visible
  45082. */
  45083. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45084. }
  45085. }
  45086. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45087. import { Nullable } from "babylonjs/types";
  45088. import { Scene } from "babylonjs/scene";
  45089. import { Vector4 } from "babylonjs/Maths/math.vector";
  45090. import { Color4 } from "babylonjs/Maths/math.color";
  45091. import { Mesh } from "babylonjs/Meshes/mesh";
  45092. /**
  45093. * Class containing static functions to help procedurally build meshes
  45094. */
  45095. export class BoxBuilder {
  45096. /**
  45097. * Creates a box mesh
  45098. * * The parameter `size` sets the size (float) of each box side (default 1)
  45099. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45100. * * 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)
  45101. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45105. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45106. * @param name defines the name of the mesh
  45107. * @param options defines the options used to create the mesh
  45108. * @param scene defines the hosting scene
  45109. * @returns the box mesh
  45110. */
  45111. static CreateBox(name: string, options: {
  45112. size?: number;
  45113. width?: number;
  45114. height?: number;
  45115. depth?: number;
  45116. faceUV?: Vector4[];
  45117. faceColors?: Color4[];
  45118. sideOrientation?: number;
  45119. frontUVs?: Vector4;
  45120. backUVs?: Vector4;
  45121. wrap?: boolean;
  45122. topBaseAt?: number;
  45123. bottomBaseAt?: number;
  45124. updatable?: boolean;
  45125. }, scene?: Nullable<Scene>): Mesh;
  45126. }
  45127. }
  45128. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45129. import { Vector4 } from "babylonjs/Maths/math.vector";
  45130. import { Mesh } from "babylonjs/Meshes/mesh";
  45131. import { Scene } from "babylonjs/scene";
  45132. import { Nullable } from "babylonjs/types";
  45133. /**
  45134. * Class containing static functions to help procedurally build meshes
  45135. */
  45136. export class SphereBuilder {
  45137. /**
  45138. * Creates a sphere mesh
  45139. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45140. * * 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`)
  45141. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45142. * * 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
  45143. * * 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)
  45144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45147. * @param name defines the name of the mesh
  45148. * @param options defines the options used to create the mesh
  45149. * @param scene defines the hosting scene
  45150. * @returns the sphere mesh
  45151. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45152. */
  45153. static CreateSphere(name: string, options: {
  45154. segments?: number;
  45155. diameter?: number;
  45156. diameterX?: number;
  45157. diameterY?: number;
  45158. diameterZ?: number;
  45159. arc?: number;
  45160. slice?: number;
  45161. sideOrientation?: number;
  45162. frontUVs?: Vector4;
  45163. backUVs?: Vector4;
  45164. updatable?: boolean;
  45165. }, scene?: Nullable<Scene>): Mesh;
  45166. }
  45167. }
  45168. declare module "babylonjs/Debug/physicsViewer" {
  45169. import { Nullable } from "babylonjs/types";
  45170. import { Scene } from "babylonjs/scene";
  45171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45172. import { Mesh } from "babylonjs/Meshes/mesh";
  45173. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45174. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45175. /**
  45176. * Used to show the physics impostor around the specific mesh
  45177. */
  45178. export class PhysicsViewer {
  45179. /** @hidden */
  45180. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45181. /** @hidden */
  45182. protected _meshes: Array<Nullable<AbstractMesh>>;
  45183. /** @hidden */
  45184. protected _scene: Nullable<Scene>;
  45185. /** @hidden */
  45186. protected _numMeshes: number;
  45187. /** @hidden */
  45188. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45189. private _renderFunction;
  45190. private _utilityLayer;
  45191. private _debugBoxMesh;
  45192. private _debugSphereMesh;
  45193. private _debugCylinderMesh;
  45194. private _debugMaterial;
  45195. private _debugMeshMeshes;
  45196. /**
  45197. * Creates a new PhysicsViewer
  45198. * @param scene defines the hosting scene
  45199. */
  45200. constructor(scene: Scene);
  45201. /** @hidden */
  45202. protected _updateDebugMeshes(): void;
  45203. /**
  45204. * Renders a specified physic impostor
  45205. * @param impostor defines the impostor to render
  45206. * @param targetMesh defines the mesh represented by the impostor
  45207. * @returns the new debug mesh used to render the impostor
  45208. */
  45209. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45210. /**
  45211. * Hides a specified physic impostor
  45212. * @param impostor defines the impostor to hide
  45213. */
  45214. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45215. private _getDebugMaterial;
  45216. private _getDebugBoxMesh;
  45217. private _getDebugSphereMesh;
  45218. private _getDebugCylinderMesh;
  45219. private _getDebugMeshMesh;
  45220. private _getDebugMesh;
  45221. /** Releases all resources */
  45222. dispose(): void;
  45223. }
  45224. }
  45225. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45226. import { Vector3 } from "babylonjs/Maths/math.vector";
  45227. import { Color4 } from "babylonjs/Maths/math.color";
  45228. import { Nullable } from "babylonjs/types";
  45229. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45230. import { Scene } from "babylonjs/scene";
  45231. /**
  45232. * Class containing static functions to help procedurally build meshes
  45233. */
  45234. export class LinesBuilder {
  45235. /**
  45236. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45237. * * 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
  45238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45239. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45240. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45241. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45243. * * 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
  45244. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45247. * @param name defines the name of the new line system
  45248. * @param options defines the options used to create the line system
  45249. * @param scene defines the hosting scene
  45250. * @returns a new line system mesh
  45251. */
  45252. static CreateLineSystem(name: string, options: {
  45253. lines: Vector3[][];
  45254. updatable?: boolean;
  45255. instance?: Nullable<LinesMesh>;
  45256. colors?: Nullable<Color4[][]>;
  45257. useVertexAlpha?: boolean;
  45258. }, scene: Nullable<Scene>): LinesMesh;
  45259. /**
  45260. * Creates a line mesh
  45261. * 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
  45262. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45263. * * The parameter `points` is an array successive Vector3
  45264. * * 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
  45265. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45266. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45267. * * When updating an instance, remember that only point positions can change, not the number of points
  45268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45270. * @param name defines the name of the new line system
  45271. * @param options defines the options used to create the line system
  45272. * @param scene defines the hosting scene
  45273. * @returns a new line mesh
  45274. */
  45275. static CreateLines(name: string, options: {
  45276. points: Vector3[];
  45277. updatable?: boolean;
  45278. instance?: Nullable<LinesMesh>;
  45279. colors?: Color4[];
  45280. useVertexAlpha?: boolean;
  45281. }, scene?: Nullable<Scene>): LinesMesh;
  45282. /**
  45283. * Creates a dashed line mesh
  45284. * * 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
  45285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45286. * * The parameter `points` is an array successive Vector3
  45287. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45288. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45289. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45290. * * 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
  45291. * * When updating an instance, remember that only point positions can change, not the number of points
  45292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45293. * @param name defines the name of the mesh
  45294. * @param options defines the options used to create the mesh
  45295. * @param scene defines the hosting scene
  45296. * @returns the dashed line mesh
  45297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45298. */
  45299. static CreateDashedLines(name: string, options: {
  45300. points: Vector3[];
  45301. dashSize?: number;
  45302. gapSize?: number;
  45303. dashNb?: number;
  45304. updatable?: boolean;
  45305. instance?: LinesMesh;
  45306. }, scene?: Nullable<Scene>): LinesMesh;
  45307. }
  45308. }
  45309. declare module "babylonjs/Debug/rayHelper" {
  45310. import { Nullable } from "babylonjs/types";
  45311. import { Ray } from "babylonjs/Culling/ray";
  45312. import { Vector3 } from "babylonjs/Maths/math.vector";
  45313. import { Color3 } from "babylonjs/Maths/math.color";
  45314. import { Scene } from "babylonjs/scene";
  45315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45316. import "babylonjs/Meshes/Builders/linesBuilder";
  45317. /**
  45318. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45319. * in order to better appreciate the issue one might have.
  45320. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45321. */
  45322. export class RayHelper {
  45323. /**
  45324. * Defines the ray we are currently tryin to visualize.
  45325. */
  45326. ray: Nullable<Ray>;
  45327. private _renderPoints;
  45328. private _renderLine;
  45329. private _renderFunction;
  45330. private _scene;
  45331. private _updateToMeshFunction;
  45332. private _attachedToMesh;
  45333. private _meshSpaceDirection;
  45334. private _meshSpaceOrigin;
  45335. /**
  45336. * Helper function to create a colored helper in a scene in one line.
  45337. * @param ray Defines the ray we are currently tryin to visualize
  45338. * @param scene Defines the scene the ray is used in
  45339. * @param color Defines the color we want to see the ray in
  45340. * @returns The newly created ray helper.
  45341. */
  45342. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45343. /**
  45344. * Instantiate a new ray helper.
  45345. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45346. * in order to better appreciate the issue one might have.
  45347. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45348. * @param ray Defines the ray we are currently tryin to visualize
  45349. */
  45350. constructor(ray: Ray);
  45351. /**
  45352. * Shows the ray we are willing to debug.
  45353. * @param scene Defines the scene the ray needs to be rendered in
  45354. * @param color Defines the color the ray needs to be rendered in
  45355. */
  45356. show(scene: Scene, color?: Color3): void;
  45357. /**
  45358. * Hides the ray we are debugging.
  45359. */
  45360. hide(): void;
  45361. private _render;
  45362. /**
  45363. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45364. * @param mesh Defines the mesh we want the helper attached to
  45365. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45366. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45367. * @param length Defines the length of the ray
  45368. */
  45369. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45370. /**
  45371. * Detach the ray helper from the mesh it has previously been attached to.
  45372. */
  45373. detachFromMesh(): void;
  45374. private _updateToMesh;
  45375. /**
  45376. * Dispose the helper and release its associated resources.
  45377. */
  45378. dispose(): void;
  45379. }
  45380. }
  45381. declare module "babylonjs/Debug/skeletonViewer" {
  45382. import { Color3 } from "babylonjs/Maths/math.color";
  45383. import { Scene } from "babylonjs/scene";
  45384. import { Nullable } from "babylonjs/types";
  45385. import { Skeleton } from "babylonjs/Bones/skeleton";
  45386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45387. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45388. /**
  45389. * Class used to render a debug view of a given skeleton
  45390. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45391. */
  45392. export class SkeletonViewer {
  45393. /** defines the skeleton to render */
  45394. skeleton: Skeleton;
  45395. /** defines the mesh attached to the skeleton */
  45396. mesh: AbstractMesh;
  45397. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45398. autoUpdateBonesMatrices: boolean;
  45399. /** defines the rendering group id to use with the viewer */
  45400. renderingGroupId: number;
  45401. /** Gets or sets the color used to render the skeleton */
  45402. color: Color3;
  45403. private _scene;
  45404. private _debugLines;
  45405. private _debugMesh;
  45406. private _isEnabled;
  45407. private _renderFunction;
  45408. private _utilityLayer;
  45409. /**
  45410. * Returns the mesh used to render the bones
  45411. */
  45412. readonly debugMesh: Nullable<LinesMesh>;
  45413. /**
  45414. * Creates a new SkeletonViewer
  45415. * @param skeleton defines the skeleton to render
  45416. * @param mesh defines the mesh attached to the skeleton
  45417. * @param scene defines the hosting scene
  45418. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45419. * @param renderingGroupId defines the rendering group id to use with the viewer
  45420. */
  45421. constructor(
  45422. /** defines the skeleton to render */
  45423. skeleton: Skeleton,
  45424. /** defines the mesh attached to the skeleton */
  45425. mesh: AbstractMesh, scene: Scene,
  45426. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45427. autoUpdateBonesMatrices?: boolean,
  45428. /** defines the rendering group id to use with the viewer */
  45429. renderingGroupId?: number);
  45430. /** Gets or sets a boolean indicating if the viewer is enabled */
  45431. isEnabled: boolean;
  45432. private _getBonePosition;
  45433. private _getLinesForBonesWithLength;
  45434. private _getLinesForBonesNoLength;
  45435. /** Update the viewer to sync with current skeleton state */
  45436. update(): void;
  45437. /** Release associated resources */
  45438. dispose(): void;
  45439. }
  45440. }
  45441. declare module "babylonjs/Debug/index" {
  45442. export * from "babylonjs/Debug/axesViewer";
  45443. export * from "babylonjs/Debug/boneAxesViewer";
  45444. export * from "babylonjs/Debug/debugLayer";
  45445. export * from "babylonjs/Debug/physicsViewer";
  45446. export * from "babylonjs/Debug/rayHelper";
  45447. export * from "babylonjs/Debug/skeletonViewer";
  45448. }
  45449. declare module "babylonjs/Engines/nullEngine" {
  45450. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45451. import { Scene } from "babylonjs/scene";
  45452. import { Engine } from "babylonjs/Engines/engine";
  45453. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45454. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45456. import { Effect } from "babylonjs/Materials/effect";
  45457. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45458. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45459. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45460. /**
  45461. * Options to create the null engine
  45462. */
  45463. export class NullEngineOptions {
  45464. /**
  45465. * Render width (Default: 512)
  45466. */
  45467. renderWidth: number;
  45468. /**
  45469. * Render height (Default: 256)
  45470. */
  45471. renderHeight: number;
  45472. /**
  45473. * Texture size (Default: 512)
  45474. */
  45475. textureSize: number;
  45476. /**
  45477. * If delta time between frames should be constant
  45478. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45479. */
  45480. deterministicLockstep: boolean;
  45481. /**
  45482. * Maximum about of steps between frames (Default: 4)
  45483. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45484. */
  45485. lockstepMaxSteps: number;
  45486. }
  45487. /**
  45488. * The null engine class provides support for headless version of babylon.js.
  45489. * This can be used in server side scenario or for testing purposes
  45490. */
  45491. export class NullEngine extends Engine {
  45492. private _options;
  45493. /**
  45494. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45495. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45496. * @returns true if engine is in deterministic lock step mode
  45497. */
  45498. isDeterministicLockStep(): boolean;
  45499. /**
  45500. * Gets the max steps when engine is running in deterministic lock step
  45501. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45502. * @returns the max steps
  45503. */
  45504. getLockstepMaxSteps(): number;
  45505. /**
  45506. * Gets the current hardware scaling level.
  45507. * By default the hardware scaling level is computed from the window device ratio.
  45508. * 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.
  45509. * @returns a number indicating the current hardware scaling level
  45510. */
  45511. getHardwareScalingLevel(): number;
  45512. constructor(options?: NullEngineOptions);
  45513. /**
  45514. * Creates a vertex buffer
  45515. * @param vertices the data for the vertex buffer
  45516. * @returns the new WebGL static buffer
  45517. */
  45518. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45519. /**
  45520. * Creates a new index buffer
  45521. * @param indices defines the content of the index buffer
  45522. * @param updatable defines if the index buffer must be updatable
  45523. * @returns a new webGL buffer
  45524. */
  45525. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45526. /**
  45527. * Clear the current render buffer or the current render target (if any is set up)
  45528. * @param color defines the color to use
  45529. * @param backBuffer defines if the back buffer must be cleared
  45530. * @param depth defines if the depth buffer must be cleared
  45531. * @param stencil defines if the stencil buffer must be cleared
  45532. */
  45533. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45534. /**
  45535. * Gets the current render width
  45536. * @param useScreen defines if screen size must be used (or the current render target if any)
  45537. * @returns a number defining the current render width
  45538. */
  45539. getRenderWidth(useScreen?: boolean): number;
  45540. /**
  45541. * Gets the current render height
  45542. * @param useScreen defines if screen size must be used (or the current render target if any)
  45543. * @returns a number defining the current render height
  45544. */
  45545. getRenderHeight(useScreen?: boolean): number;
  45546. /**
  45547. * Set the WebGL's viewport
  45548. * @param viewport defines the viewport element to be used
  45549. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45550. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45551. */
  45552. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45554. /**
  45555. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45556. * @param pipelineContext defines the pipeline context to use
  45557. * @param uniformsNames defines the list of uniform names
  45558. * @returns an array of webGL uniform locations
  45559. */
  45560. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45561. /**
  45562. * Gets the lsit of active attributes for a given webGL program
  45563. * @param pipelineContext defines the pipeline context to use
  45564. * @param attributesNames defines the list of attribute names to get
  45565. * @returns an array of indices indicating the offset of each attribute
  45566. */
  45567. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45568. /**
  45569. * Binds an effect to the webGL context
  45570. * @param effect defines the effect to bind
  45571. */
  45572. bindSamplers(effect: Effect): void;
  45573. /**
  45574. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45575. * @param effect defines the effect to activate
  45576. */
  45577. enableEffect(effect: Effect): void;
  45578. /**
  45579. * Set various states to the webGL context
  45580. * @param culling defines backface culling state
  45581. * @param zOffset defines the value to apply to zOffset (0 by default)
  45582. * @param force defines if states must be applied even if cache is up to date
  45583. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45584. */
  45585. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45586. /**
  45587. * Set the value of an uniform to an array of int32
  45588. * @param uniform defines the webGL uniform location where to store the value
  45589. * @param array defines the array of int32 to store
  45590. */
  45591. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45592. /**
  45593. * Set the value of an uniform to an array of int32 (stored as vec2)
  45594. * @param uniform defines the webGL uniform location where to store the value
  45595. * @param array defines the array of int32 to store
  45596. */
  45597. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45598. /**
  45599. * Set the value of an uniform to an array of int32 (stored as vec3)
  45600. * @param uniform defines the webGL uniform location where to store the value
  45601. * @param array defines the array of int32 to store
  45602. */
  45603. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45604. /**
  45605. * Set the value of an uniform to an array of int32 (stored as vec4)
  45606. * @param uniform defines the webGL uniform location where to store the value
  45607. * @param array defines the array of int32 to store
  45608. */
  45609. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45610. /**
  45611. * Set the value of an uniform to an array of float32
  45612. * @param uniform defines the webGL uniform location where to store the value
  45613. * @param array defines the array of float32 to store
  45614. */
  45615. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45616. /**
  45617. * Set the value of an uniform to an array of float32 (stored as vec2)
  45618. * @param uniform defines the webGL uniform location where to store the value
  45619. * @param array defines the array of float32 to store
  45620. */
  45621. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45622. /**
  45623. * Set the value of an uniform to an array of float32 (stored as vec3)
  45624. * @param uniform defines the webGL uniform location where to store the value
  45625. * @param array defines the array of float32 to store
  45626. */
  45627. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45628. /**
  45629. * Set the value of an uniform to an array of float32 (stored as vec4)
  45630. * @param uniform defines the webGL uniform location where to store the value
  45631. * @param array defines the array of float32 to store
  45632. */
  45633. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45634. /**
  45635. * Set the value of an uniform to an array of number
  45636. * @param uniform defines the webGL uniform location where to store the value
  45637. * @param array defines the array of number to store
  45638. */
  45639. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45640. /**
  45641. * Set the value of an uniform to an array of number (stored as vec2)
  45642. * @param uniform defines the webGL uniform location where to store the value
  45643. * @param array defines the array of number to store
  45644. */
  45645. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45646. /**
  45647. * Set the value of an uniform to an array of number (stored as vec3)
  45648. * @param uniform defines the webGL uniform location where to store the value
  45649. * @param array defines the array of number to store
  45650. */
  45651. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45652. /**
  45653. * Set the value of an uniform to an array of number (stored as vec4)
  45654. * @param uniform defines the webGL uniform location where to store the value
  45655. * @param array defines the array of number to store
  45656. */
  45657. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45658. /**
  45659. * Set the value of an uniform to an array of float32 (stored as matrices)
  45660. * @param uniform defines the webGL uniform location where to store the value
  45661. * @param matrices defines the array of float32 to store
  45662. */
  45663. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45664. /**
  45665. * Set the value of an uniform to a matrix (3x3)
  45666. * @param uniform defines the webGL uniform location where to store the value
  45667. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45668. */
  45669. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45670. /**
  45671. * Set the value of an uniform to a matrix (2x2)
  45672. * @param uniform defines the webGL uniform location where to store the value
  45673. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45674. */
  45675. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45676. /**
  45677. * Set the value of an uniform to a number (float)
  45678. * @param uniform defines the webGL uniform location where to store the value
  45679. * @param value defines the float number to store
  45680. */
  45681. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45682. /**
  45683. * Set the value of an uniform to a vec2
  45684. * @param uniform defines the webGL uniform location where to store the value
  45685. * @param x defines the 1st component of the value
  45686. * @param y defines the 2nd component of the value
  45687. */
  45688. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45689. /**
  45690. * Set the value of an uniform to a vec3
  45691. * @param uniform defines the webGL uniform location where to store the value
  45692. * @param x defines the 1st component of the value
  45693. * @param y defines the 2nd component of the value
  45694. * @param z defines the 3rd component of the value
  45695. */
  45696. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45697. /**
  45698. * Set the value of an uniform to a boolean
  45699. * @param uniform defines the webGL uniform location where to store the value
  45700. * @param bool defines the boolean to store
  45701. */
  45702. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45703. /**
  45704. * Set the value of an uniform to a vec4
  45705. * @param uniform defines the webGL uniform location where to store the value
  45706. * @param x defines the 1st component of the value
  45707. * @param y defines the 2nd component of the value
  45708. * @param z defines the 3rd component of the value
  45709. * @param w defines the 4th component of the value
  45710. */
  45711. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45712. /**
  45713. * Sets the current alpha mode
  45714. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45715. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45716. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45717. */
  45718. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45719. /**
  45720. * Bind webGl buffers directly to the webGL context
  45721. * @param vertexBuffers defines the vertex buffer to bind
  45722. * @param indexBuffer defines the index buffer to bind
  45723. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45724. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45725. * @param effect defines the effect associated with the vertex buffer
  45726. */
  45727. bindBuffers(vertexBuffers: {
  45728. [key: string]: VertexBuffer;
  45729. }, indexBuffer: DataBuffer, effect: Effect): void;
  45730. /**
  45731. * Force the entire cache to be cleared
  45732. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45733. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45734. */
  45735. wipeCaches(bruteForce?: boolean): void;
  45736. /**
  45737. * Send a draw order
  45738. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45739. * @param indexStart defines the starting index
  45740. * @param indexCount defines the number of index to draw
  45741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45742. */
  45743. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45744. /**
  45745. * Draw a list of indexed primitives
  45746. * @param fillMode defines the primitive to use
  45747. * @param indexStart defines the starting index
  45748. * @param indexCount defines the number of index to draw
  45749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45750. */
  45751. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45752. /**
  45753. * Draw a list of unindexed primitives
  45754. * @param fillMode defines the primitive to use
  45755. * @param verticesStart defines the index of first vertex to draw
  45756. * @param verticesCount defines the count of vertices to draw
  45757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45758. */
  45759. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45760. /** @hidden */
  45761. _createTexture(): WebGLTexture;
  45762. /** @hidden */
  45763. _releaseTexture(texture: InternalTexture): void;
  45764. /**
  45765. * Usually called from Texture.ts.
  45766. * Passed information to create a WebGLTexture
  45767. * @param urlArg defines a value which contains one of the following:
  45768. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45769. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45770. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45772. * @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)
  45773. * @param scene needed for loading to the correct scene
  45774. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45775. * @param onLoad optional callback to be called upon successful completion
  45776. * @param onError optional callback to be called upon failure
  45777. * @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
  45778. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45779. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45780. * @param forcedExtension defines the extension to use to pick the right loader
  45781. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45782. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45783. */
  45784. 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;
  45785. /**
  45786. * Creates a new render target texture
  45787. * @param size defines the size of the texture
  45788. * @param options defines the options used to create the texture
  45789. * @returns a new render target texture stored in an InternalTexture
  45790. */
  45791. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45792. /**
  45793. * Update the sampling mode of a given texture
  45794. * @param samplingMode defines the required sampling mode
  45795. * @param texture defines the texture to update
  45796. */
  45797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45798. /**
  45799. * Binds the frame buffer to the specified texture.
  45800. * @param texture The texture to render to or null for the default canvas
  45801. * @param faceIndex The face of the texture to render to in case of cube texture
  45802. * @param requiredWidth The width of the target to render to
  45803. * @param requiredHeight The height of the target to render to
  45804. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45805. * @param depthStencilTexture The depth stencil texture to use to render
  45806. * @param lodLevel defines le lod level to bind to the frame buffer
  45807. */
  45808. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45809. /**
  45810. * Unbind the current render target texture from the webGL context
  45811. * @param texture defines the render target texture to unbind
  45812. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45813. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45814. */
  45815. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45816. /**
  45817. * Creates a dynamic vertex buffer
  45818. * @param vertices the data for the dynamic vertex buffer
  45819. * @returns the new WebGL dynamic buffer
  45820. */
  45821. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45822. /**
  45823. * Update the content of a dynamic texture
  45824. * @param texture defines the texture to update
  45825. * @param canvas defines the canvas containing the source
  45826. * @param invertY defines if data must be stored with Y axis inverted
  45827. * @param premulAlpha defines if alpha is stored as premultiplied
  45828. * @param format defines the format of the data
  45829. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45830. */
  45831. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45832. /**
  45833. * Gets a boolean indicating if all created effects are ready
  45834. * @returns true if all effects are ready
  45835. */
  45836. areAllEffectsReady(): boolean;
  45837. /**
  45838. * @hidden
  45839. * Get the current error code of the webGL context
  45840. * @returns the error code
  45841. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45842. */
  45843. getError(): number;
  45844. /** @hidden */
  45845. _getUnpackAlignement(): number;
  45846. /** @hidden */
  45847. _unpackFlipY(value: boolean): void;
  45848. /**
  45849. * Update a dynamic index buffer
  45850. * @param indexBuffer defines the target index buffer
  45851. * @param indices defines the data to update
  45852. * @param offset defines the offset in the target index buffer where update should start
  45853. */
  45854. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45855. /**
  45856. * Updates a dynamic vertex buffer.
  45857. * @param vertexBuffer the vertex buffer to update
  45858. * @param vertices the data used to update the vertex buffer
  45859. * @param byteOffset the byte offset of the data (optional)
  45860. * @param byteLength the byte length of the data (optional)
  45861. */
  45862. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45863. /** @hidden */
  45864. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45865. /** @hidden */
  45866. _bindTexture(channel: number, texture: InternalTexture): void;
  45867. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45868. /**
  45869. * 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
  45870. */
  45871. releaseEffects(): void;
  45872. displayLoadingUI(): void;
  45873. hideLoadingUI(): void;
  45874. /** @hidden */
  45875. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45876. /** @hidden */
  45877. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45878. /** @hidden */
  45879. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45880. /** @hidden */
  45881. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45882. }
  45883. }
  45884. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45885. import { Nullable, int } from "babylonjs/types";
  45886. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45887. /** @hidden */
  45888. export class _OcclusionDataStorage {
  45889. /** @hidden */
  45890. occlusionInternalRetryCounter: number;
  45891. /** @hidden */
  45892. isOcclusionQueryInProgress: boolean;
  45893. /** @hidden */
  45894. isOccluded: boolean;
  45895. /** @hidden */
  45896. occlusionRetryCount: number;
  45897. /** @hidden */
  45898. occlusionType: number;
  45899. /** @hidden */
  45900. occlusionQueryAlgorithmType: number;
  45901. }
  45902. module "babylonjs/Engines/engine" {
  45903. interface Engine {
  45904. /**
  45905. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45906. * @return the new query
  45907. */
  45908. createQuery(): WebGLQuery;
  45909. /**
  45910. * Delete and release a webGL query
  45911. * @param query defines the query to delete
  45912. * @return the current engine
  45913. */
  45914. deleteQuery(query: WebGLQuery): Engine;
  45915. /**
  45916. * Check if a given query has resolved and got its value
  45917. * @param query defines the query to check
  45918. * @returns true if the query got its value
  45919. */
  45920. isQueryResultAvailable(query: WebGLQuery): boolean;
  45921. /**
  45922. * Gets the value of a given query
  45923. * @param query defines the query to check
  45924. * @returns the value of the query
  45925. */
  45926. getQueryResult(query: WebGLQuery): number;
  45927. /**
  45928. * Initiates an occlusion query
  45929. * @param algorithmType defines the algorithm to use
  45930. * @param query defines the query to use
  45931. * @returns the current engine
  45932. * @see http://doc.babylonjs.com/features/occlusionquery
  45933. */
  45934. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45935. /**
  45936. * Ends an occlusion query
  45937. * @see http://doc.babylonjs.com/features/occlusionquery
  45938. * @param algorithmType defines the algorithm to use
  45939. * @returns the current engine
  45940. */
  45941. endOcclusionQuery(algorithmType: number): Engine;
  45942. /**
  45943. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45944. * Please note that only one query can be issued at a time
  45945. * @returns a time token used to track the time span
  45946. */
  45947. startTimeQuery(): Nullable<_TimeToken>;
  45948. /**
  45949. * Ends a time query
  45950. * @param token defines the token used to measure the time span
  45951. * @returns the time spent (in ns)
  45952. */
  45953. endTimeQuery(token: _TimeToken): int;
  45954. /** @hidden */
  45955. _currentNonTimestampToken: Nullable<_TimeToken>;
  45956. /** @hidden */
  45957. _createTimeQuery(): WebGLQuery;
  45958. /** @hidden */
  45959. _deleteTimeQuery(query: WebGLQuery): void;
  45960. /** @hidden */
  45961. _getGlAlgorithmType(algorithmType: number): number;
  45962. /** @hidden */
  45963. _getTimeQueryResult(query: WebGLQuery): any;
  45964. /** @hidden */
  45965. _getTimeQueryAvailability(query: WebGLQuery): any;
  45966. }
  45967. }
  45968. module "babylonjs/Meshes/abstractMesh" {
  45969. interface AbstractMesh {
  45970. /**
  45971. * Backing filed
  45972. * @hidden
  45973. */
  45974. __occlusionDataStorage: _OcclusionDataStorage;
  45975. /**
  45976. * Access property
  45977. * @hidden
  45978. */
  45979. _occlusionDataStorage: _OcclusionDataStorage;
  45980. /**
  45981. * 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.
  45982. * The default value is -1 which means don't break the query and wait till the result
  45983. * @see http://doc.babylonjs.com/features/occlusionquery
  45984. */
  45985. occlusionRetryCount: number;
  45986. /**
  45987. * 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:
  45988. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45989. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45990. * * 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.
  45991. * @see http://doc.babylonjs.com/features/occlusionquery
  45992. */
  45993. occlusionType: number;
  45994. /**
  45995. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45996. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45997. * * 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.
  45998. * @see http://doc.babylonjs.com/features/occlusionquery
  45999. */
  46000. occlusionQueryAlgorithmType: number;
  46001. /**
  46002. * 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
  46003. * @see http://doc.babylonjs.com/features/occlusionquery
  46004. */
  46005. isOccluded: boolean;
  46006. /**
  46007. * Flag to check the progress status of the query
  46008. * @see http://doc.babylonjs.com/features/occlusionquery
  46009. */
  46010. isOcclusionQueryInProgress: boolean;
  46011. }
  46012. }
  46013. }
  46014. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46015. import { Nullable } from "babylonjs/types";
  46016. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46017. /** @hidden */
  46018. export var _forceTransformFeedbackToBundle: boolean;
  46019. module "babylonjs/Engines/engine" {
  46020. interface Engine {
  46021. /**
  46022. * Creates a webGL transform feedback object
  46023. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46024. * @returns the webGL transform feedback object
  46025. */
  46026. createTransformFeedback(): WebGLTransformFeedback;
  46027. /**
  46028. * Delete a webGL transform feedback object
  46029. * @param value defines the webGL transform feedback object to delete
  46030. */
  46031. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46032. /**
  46033. * Bind a webGL transform feedback object to the webgl context
  46034. * @param value defines the webGL transform feedback object to bind
  46035. */
  46036. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46037. /**
  46038. * Begins a transform feedback operation
  46039. * @param usePoints defines if points or triangles must be used
  46040. */
  46041. beginTransformFeedback(usePoints: boolean): void;
  46042. /**
  46043. * Ends a transform feedback operation
  46044. */
  46045. endTransformFeedback(): void;
  46046. /**
  46047. * Specify the varyings to use with transform feedback
  46048. * @param program defines the associated webGL program
  46049. * @param value defines the list of strings representing the varying names
  46050. */
  46051. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46052. /**
  46053. * Bind a webGL buffer for a transform feedback operation
  46054. * @param value defines the webGL buffer to bind
  46055. */
  46056. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46057. }
  46058. }
  46059. }
  46060. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46061. import { Scene } from "babylonjs/scene";
  46062. import { Engine } from "babylonjs/Engines/engine";
  46063. import { Texture } from "babylonjs/Materials/Textures/texture";
  46064. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46065. import "babylonjs/Engines/Extensions/engine.multiRender";
  46066. /**
  46067. * Creation options of the multi render target texture.
  46068. */
  46069. export interface IMultiRenderTargetOptions {
  46070. /**
  46071. * Define if the texture needs to create mip maps after render.
  46072. */
  46073. generateMipMaps?: boolean;
  46074. /**
  46075. * Define the types of all the draw buffers we want to create
  46076. */
  46077. types?: number[];
  46078. /**
  46079. * Define the sampling modes of all the draw buffers we want to create
  46080. */
  46081. samplingModes?: number[];
  46082. /**
  46083. * Define if a depth buffer is required
  46084. */
  46085. generateDepthBuffer?: boolean;
  46086. /**
  46087. * Define if a stencil buffer is required
  46088. */
  46089. generateStencilBuffer?: boolean;
  46090. /**
  46091. * Define if a depth texture is required instead of a depth buffer
  46092. */
  46093. generateDepthTexture?: boolean;
  46094. /**
  46095. * Define the number of desired draw buffers
  46096. */
  46097. textureCount?: number;
  46098. /**
  46099. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46100. */
  46101. doNotChangeAspectRatio?: boolean;
  46102. /**
  46103. * Define the default type of the buffers we are creating
  46104. */
  46105. defaultType?: number;
  46106. }
  46107. /**
  46108. * A multi render target, like a render target provides the ability to render to a texture.
  46109. * Unlike the render target, it can render to several draw buffers in one draw.
  46110. * This is specially interesting in deferred rendering or for any effects requiring more than
  46111. * just one color from a single pass.
  46112. */
  46113. export class MultiRenderTarget extends RenderTargetTexture {
  46114. private _internalTextures;
  46115. private _textures;
  46116. private _multiRenderTargetOptions;
  46117. /**
  46118. * Get if draw buffers are currently supported by the used hardware and browser.
  46119. */
  46120. readonly isSupported: boolean;
  46121. /**
  46122. * Get the list of textures generated by the multi render target.
  46123. */
  46124. readonly textures: Texture[];
  46125. /**
  46126. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46127. */
  46128. readonly depthTexture: Texture;
  46129. /**
  46130. * Set the wrapping mode on U of all the textures we are rendering to.
  46131. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46132. */
  46133. wrapU: number;
  46134. /**
  46135. * Set the wrapping mode on V of all the textures we are rendering to.
  46136. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46137. */
  46138. wrapV: number;
  46139. /**
  46140. * Instantiate a new multi render target texture.
  46141. * A multi render target, like a render target provides the ability to render to a texture.
  46142. * Unlike the render target, it can render to several draw buffers in one draw.
  46143. * This is specially interesting in deferred rendering or for any effects requiring more than
  46144. * just one color from a single pass.
  46145. * @param name Define the name of the texture
  46146. * @param size Define the size of the buffers to render to
  46147. * @param count Define the number of target we are rendering into
  46148. * @param scene Define the scene the texture belongs to
  46149. * @param options Define the options used to create the multi render target
  46150. */
  46151. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46152. /** @hidden */
  46153. _rebuild(): void;
  46154. private _createInternalTextures;
  46155. private _createTextures;
  46156. /**
  46157. * Define the number of samples used if MSAA is enabled.
  46158. */
  46159. samples: number;
  46160. /**
  46161. * Resize all the textures in the multi render target.
  46162. * Be carrefull as it will recreate all the data in the new texture.
  46163. * @param size Define the new size
  46164. */
  46165. resize(size: any): void;
  46166. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46167. /**
  46168. * Dispose the render targets and their associated resources
  46169. */
  46170. dispose(): void;
  46171. /**
  46172. * Release all the underlying texture used as draw buffers.
  46173. */
  46174. releaseInternalTextures(): void;
  46175. }
  46176. }
  46177. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46178. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46179. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46180. import { Nullable } from "babylonjs/types";
  46181. module "babylonjs/Engines/thinEngine" {
  46182. interface ThinEngine {
  46183. /**
  46184. * Unbind a list of render target textures from the webGL context
  46185. * This is used only when drawBuffer extension or webGL2 are active
  46186. * @param textures defines the render target textures to unbind
  46187. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46188. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46189. */
  46190. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46191. /**
  46192. * Create a multi render target texture
  46193. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46194. * @param size defines the size of the texture
  46195. * @param options defines the creation options
  46196. * @returns the cube texture as an InternalTexture
  46197. */
  46198. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46199. /**
  46200. * Update the sample count for a given multiple render target texture
  46201. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46202. * @param textures defines the textures to update
  46203. * @param samples defines the sample count to set
  46204. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46205. */
  46206. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46207. }
  46208. }
  46209. }
  46210. declare module "babylonjs/Engines/Extensions/index" {
  46211. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46212. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46213. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46214. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46215. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46216. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46217. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46218. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46219. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46220. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46221. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46222. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46223. }
  46224. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46225. import { Nullable } from "babylonjs/types";
  46226. /**
  46227. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46228. */
  46229. export interface CubeMapInfo {
  46230. /**
  46231. * The pixel array for the front face.
  46232. * This is stored in format, left to right, up to down format.
  46233. */
  46234. front: Nullable<ArrayBufferView>;
  46235. /**
  46236. * The pixel array for the back face.
  46237. * This is stored in format, left to right, up to down format.
  46238. */
  46239. back: Nullable<ArrayBufferView>;
  46240. /**
  46241. * The pixel array for the left face.
  46242. * This is stored in format, left to right, up to down format.
  46243. */
  46244. left: Nullable<ArrayBufferView>;
  46245. /**
  46246. * The pixel array for the right face.
  46247. * This is stored in format, left to right, up to down format.
  46248. */
  46249. right: Nullable<ArrayBufferView>;
  46250. /**
  46251. * The pixel array for the up face.
  46252. * This is stored in format, left to right, up to down format.
  46253. */
  46254. up: Nullable<ArrayBufferView>;
  46255. /**
  46256. * The pixel array for the down face.
  46257. * This is stored in format, left to right, up to down format.
  46258. */
  46259. down: Nullable<ArrayBufferView>;
  46260. /**
  46261. * The size of the cubemap stored.
  46262. *
  46263. * Each faces will be size * size pixels.
  46264. */
  46265. size: number;
  46266. /**
  46267. * The format of the texture.
  46268. *
  46269. * RGBA, RGB.
  46270. */
  46271. format: number;
  46272. /**
  46273. * The type of the texture data.
  46274. *
  46275. * UNSIGNED_INT, FLOAT.
  46276. */
  46277. type: number;
  46278. /**
  46279. * Specifies whether the texture is in gamma space.
  46280. */
  46281. gammaSpace: boolean;
  46282. }
  46283. /**
  46284. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46285. */
  46286. export class PanoramaToCubeMapTools {
  46287. private static FACE_FRONT;
  46288. private static FACE_BACK;
  46289. private static FACE_RIGHT;
  46290. private static FACE_LEFT;
  46291. private static FACE_DOWN;
  46292. private static FACE_UP;
  46293. /**
  46294. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46295. *
  46296. * @param float32Array The source data.
  46297. * @param inputWidth The width of the input panorama.
  46298. * @param inputHeight The height of the input panorama.
  46299. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46300. * @return The cubemap data
  46301. */
  46302. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46303. private static CreateCubemapTexture;
  46304. private static CalcProjectionSpherical;
  46305. }
  46306. }
  46307. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46308. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46310. import { Nullable } from "babylonjs/types";
  46311. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46312. /**
  46313. * Helper class dealing with the extraction of spherical polynomial dataArray
  46314. * from a cube map.
  46315. */
  46316. export class CubeMapToSphericalPolynomialTools {
  46317. private static FileFaces;
  46318. /**
  46319. * Converts a texture to the according Spherical Polynomial data.
  46320. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46321. *
  46322. * @param texture The texture to extract the information from.
  46323. * @return The Spherical Polynomial data.
  46324. */
  46325. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46326. /**
  46327. * Converts a cubemap to the according Spherical Polynomial data.
  46328. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46329. *
  46330. * @param cubeInfo The Cube map to extract the information from.
  46331. * @return The Spherical Polynomial data.
  46332. */
  46333. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46334. }
  46335. }
  46336. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46337. import { Nullable } from "babylonjs/types";
  46338. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46339. module "babylonjs/Materials/Textures/baseTexture" {
  46340. interface BaseTexture {
  46341. /**
  46342. * Get the polynomial representation of the texture data.
  46343. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46344. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46345. */
  46346. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46347. }
  46348. }
  46349. }
  46350. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46351. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46352. /** @hidden */
  46353. export var rgbdEncodePixelShader: {
  46354. name: string;
  46355. shader: string;
  46356. };
  46357. }
  46358. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46359. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46360. /** @hidden */
  46361. export var rgbdDecodePixelShader: {
  46362. name: string;
  46363. shader: string;
  46364. };
  46365. }
  46366. declare module "babylonjs/Misc/environmentTextureTools" {
  46367. import { Nullable } from "babylonjs/types";
  46368. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46370. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46371. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46372. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46373. import "babylonjs/Shaders/rgbdEncode.fragment";
  46374. import "babylonjs/Shaders/rgbdDecode.fragment";
  46375. /**
  46376. * Raw texture data and descriptor sufficient for WebGL texture upload
  46377. */
  46378. export interface EnvironmentTextureInfo {
  46379. /**
  46380. * Version of the environment map
  46381. */
  46382. version: number;
  46383. /**
  46384. * Width of image
  46385. */
  46386. width: number;
  46387. /**
  46388. * Irradiance information stored in the file.
  46389. */
  46390. irradiance: any;
  46391. /**
  46392. * Specular information stored in the file.
  46393. */
  46394. specular: any;
  46395. }
  46396. /**
  46397. * Defines One Image in the file. It requires only the position in the file
  46398. * as well as the length.
  46399. */
  46400. interface BufferImageData {
  46401. /**
  46402. * Length of the image data.
  46403. */
  46404. length: number;
  46405. /**
  46406. * Position of the data from the null terminator delimiting the end of the JSON.
  46407. */
  46408. position: number;
  46409. }
  46410. /**
  46411. * Defines the specular data enclosed in the file.
  46412. * This corresponds to the version 1 of the data.
  46413. */
  46414. export interface EnvironmentTextureSpecularInfoV1 {
  46415. /**
  46416. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46417. */
  46418. specularDataPosition?: number;
  46419. /**
  46420. * This contains all the images data needed to reconstruct the cubemap.
  46421. */
  46422. mipmaps: Array<BufferImageData>;
  46423. /**
  46424. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46425. */
  46426. lodGenerationScale: number;
  46427. }
  46428. /**
  46429. * Sets of helpers addressing the serialization and deserialization of environment texture
  46430. * stored in a BabylonJS env file.
  46431. * Those files are usually stored as .env files.
  46432. */
  46433. export class EnvironmentTextureTools {
  46434. /**
  46435. * Magic number identifying the env file.
  46436. */
  46437. private static _MagicBytes;
  46438. /**
  46439. * Gets the environment info from an env file.
  46440. * @param data The array buffer containing the .env bytes.
  46441. * @returns the environment file info (the json header) if successfully parsed.
  46442. */
  46443. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46444. /**
  46445. * Creates an environment texture from a loaded cube texture.
  46446. * @param texture defines the cube texture to convert in env file
  46447. * @return a promise containing the environment data if succesfull.
  46448. */
  46449. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46450. /**
  46451. * Creates a JSON representation of the spherical data.
  46452. * @param texture defines the texture containing the polynomials
  46453. * @return the JSON representation of the spherical info
  46454. */
  46455. private static _CreateEnvTextureIrradiance;
  46456. /**
  46457. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46458. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46459. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46460. * @return the views described by info providing access to the underlying buffer
  46461. */
  46462. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46463. /**
  46464. * Uploads the texture info contained in the env file to the GPU.
  46465. * @param texture defines the internal texture to upload to
  46466. * @param arrayBuffer defines the buffer cotaining the data to load
  46467. * @param info defines the texture info retrieved through the GetEnvInfo method
  46468. * @returns a promise
  46469. */
  46470. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46471. private static _OnImageReadyAsync;
  46472. /**
  46473. * Uploads the levels of image data to the GPU.
  46474. * @param texture defines the internal texture to upload to
  46475. * @param imageData defines the array buffer views of image data [mipmap][face]
  46476. * @returns a promise
  46477. */
  46478. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46479. /**
  46480. * Uploads spherical polynomials information to the texture.
  46481. * @param texture defines the texture we are trying to upload the information to
  46482. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46483. */
  46484. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46485. /** @hidden */
  46486. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46487. }
  46488. }
  46489. declare module "babylonjs/Maths/math.vertexFormat" {
  46490. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46491. /**
  46492. * Contains position and normal vectors for a vertex
  46493. */
  46494. export class PositionNormalVertex {
  46495. /** the position of the vertex (defaut: 0,0,0) */
  46496. position: Vector3;
  46497. /** the normal of the vertex (defaut: 0,1,0) */
  46498. normal: Vector3;
  46499. /**
  46500. * Creates a PositionNormalVertex
  46501. * @param position the position of the vertex (defaut: 0,0,0)
  46502. * @param normal the normal of the vertex (defaut: 0,1,0)
  46503. */
  46504. constructor(
  46505. /** the position of the vertex (defaut: 0,0,0) */
  46506. position?: Vector3,
  46507. /** the normal of the vertex (defaut: 0,1,0) */
  46508. normal?: Vector3);
  46509. /**
  46510. * Clones the PositionNormalVertex
  46511. * @returns the cloned PositionNormalVertex
  46512. */
  46513. clone(): PositionNormalVertex;
  46514. }
  46515. /**
  46516. * Contains position, normal and uv vectors for a vertex
  46517. */
  46518. export class PositionNormalTextureVertex {
  46519. /** the position of the vertex (defaut: 0,0,0) */
  46520. position: Vector3;
  46521. /** the normal of the vertex (defaut: 0,1,0) */
  46522. normal: Vector3;
  46523. /** the uv of the vertex (default: 0,0) */
  46524. uv: Vector2;
  46525. /**
  46526. * Creates a PositionNormalTextureVertex
  46527. * @param position the position of the vertex (defaut: 0,0,0)
  46528. * @param normal the normal of the vertex (defaut: 0,1,0)
  46529. * @param uv the uv of the vertex (default: 0,0)
  46530. */
  46531. constructor(
  46532. /** the position of the vertex (defaut: 0,0,0) */
  46533. position?: Vector3,
  46534. /** the normal of the vertex (defaut: 0,1,0) */
  46535. normal?: Vector3,
  46536. /** the uv of the vertex (default: 0,0) */
  46537. uv?: Vector2);
  46538. /**
  46539. * Clones the PositionNormalTextureVertex
  46540. * @returns the cloned PositionNormalTextureVertex
  46541. */
  46542. clone(): PositionNormalTextureVertex;
  46543. }
  46544. }
  46545. declare module "babylonjs/Maths/math" {
  46546. export * from "babylonjs/Maths/math.axis";
  46547. export * from "babylonjs/Maths/math.color";
  46548. export * from "babylonjs/Maths/math.constants";
  46549. export * from "babylonjs/Maths/math.frustum";
  46550. export * from "babylonjs/Maths/math.path";
  46551. export * from "babylonjs/Maths/math.plane";
  46552. export * from "babylonjs/Maths/math.size";
  46553. export * from "babylonjs/Maths/math.vector";
  46554. export * from "babylonjs/Maths/math.vertexFormat";
  46555. export * from "babylonjs/Maths/math.viewport";
  46556. }
  46557. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46558. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46559. /** @hidden */
  46560. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46561. private _genericAttributeLocation;
  46562. private _varyingLocationCount;
  46563. private _varyingLocationMap;
  46564. private _replacements;
  46565. private _textureCount;
  46566. private _uniforms;
  46567. lineProcessor(line: string): string;
  46568. attributeProcessor(attribute: string): string;
  46569. varyingProcessor(varying: string, isFragment: boolean): string;
  46570. uniformProcessor(uniform: string): string;
  46571. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46572. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46573. }
  46574. }
  46575. declare module "babylonjs/Engines/nativeEngine" {
  46576. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46577. import { Engine } from "babylonjs/Engines/engine";
  46578. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46579. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46580. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46581. import { Effect } from "babylonjs/Materials/effect";
  46582. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46583. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46584. import { Scene } from "babylonjs/scene";
  46585. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46586. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46587. /**
  46588. * Container for accessors for natively-stored mesh data buffers.
  46589. */
  46590. class NativeDataBuffer extends DataBuffer {
  46591. /**
  46592. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46593. */
  46594. nativeIndexBuffer?: any;
  46595. /**
  46596. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46597. */
  46598. nativeVertexBuffer?: any;
  46599. }
  46600. /** @hidden */
  46601. export class NativeEngine extends Engine {
  46602. private readonly _native;
  46603. getHardwareScalingLevel(): number;
  46604. constructor();
  46605. /**
  46606. * Can be used to override the current requestAnimationFrame requester.
  46607. * @hidden
  46608. */
  46609. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46610. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46611. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46612. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46613. recordVertexArrayObject(vertexBuffers: {
  46614. [key: string]: VertexBuffer;
  46615. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46616. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46617. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46618. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46619. /**
  46620. * Draw a list of indexed primitives
  46621. * @param fillMode defines the primitive to use
  46622. * @param indexStart defines the starting index
  46623. * @param indexCount defines the number of index to draw
  46624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46625. */
  46626. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46627. /**
  46628. * Draw a list of unindexed primitives
  46629. * @param fillMode defines the primitive to use
  46630. * @param verticesStart defines the index of first vertex to draw
  46631. * @param verticesCount defines the count of vertices to draw
  46632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46633. */
  46634. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46635. createPipelineContext(): IPipelineContext;
  46636. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46637. /** @hidden */
  46638. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46639. /** @hidden */
  46640. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46641. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46642. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46643. protected _setProgram(program: WebGLProgram): void;
  46644. _releaseEffect(effect: Effect): void;
  46645. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46646. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46647. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46648. bindSamplers(effect: Effect): void;
  46649. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46650. getRenderWidth(useScreen?: boolean): number;
  46651. getRenderHeight(useScreen?: boolean): number;
  46652. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46653. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46654. /**
  46655. * Set the z offset to apply to current rendering
  46656. * @param value defines the offset to apply
  46657. */
  46658. setZOffset(value: number): void;
  46659. /**
  46660. * Gets the current value of the zOffset
  46661. * @returns the current zOffset state
  46662. */
  46663. getZOffset(): number;
  46664. /**
  46665. * Enable or disable depth buffering
  46666. * @param enable defines the state to set
  46667. */
  46668. setDepthBuffer(enable: boolean): void;
  46669. /**
  46670. * Gets a boolean indicating if depth writing is enabled
  46671. * @returns the current depth writing state
  46672. */
  46673. getDepthWrite(): boolean;
  46674. /**
  46675. * Enable or disable depth writing
  46676. * @param enable defines the state to set
  46677. */
  46678. setDepthWrite(enable: boolean): void;
  46679. /**
  46680. * Enable or disable color writing
  46681. * @param enable defines the state to set
  46682. */
  46683. setColorWrite(enable: boolean): void;
  46684. /**
  46685. * Gets a boolean indicating if color writing is enabled
  46686. * @returns the current color writing state
  46687. */
  46688. getColorWrite(): boolean;
  46689. /**
  46690. * Sets alpha constants used by some alpha blending modes
  46691. * @param r defines the red component
  46692. * @param g defines the green component
  46693. * @param b defines the blue component
  46694. * @param a defines the alpha component
  46695. */
  46696. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46697. /**
  46698. * Sets the current alpha mode
  46699. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46700. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46702. */
  46703. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46704. /**
  46705. * Gets the current alpha mode
  46706. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46707. * @returns the current alpha mode
  46708. */
  46709. getAlphaMode(): number;
  46710. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46711. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46712. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46713. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46714. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46715. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46716. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46717. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46718. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46719. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46720. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46721. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46722. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46723. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46724. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46725. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46726. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46727. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46728. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46729. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46730. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46731. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46732. wipeCaches(bruteForce?: boolean): void;
  46733. _createTexture(): WebGLTexture;
  46734. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46735. /**
  46736. * Usually called from BABYLON.Texture.ts.
  46737. * Passed information to create a WebGLTexture
  46738. * @param urlArg defines a value which contains one of the following:
  46739. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46740. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46741. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46742. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46743. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46744. * @param scene needed for loading to the correct scene
  46745. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46746. * @param onLoad optional callback to be called upon successful completion
  46747. * @param onError optional callback to be called upon failure
  46748. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46749. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46750. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46751. * @param forcedExtension defines the extension to use to pick the right loader
  46752. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46753. */
  46754. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46755. /**
  46756. * Creates a cube texture
  46757. * @param rootUrl defines the url where the files to load is located
  46758. * @param scene defines the current scene
  46759. * @param files defines the list of files to load (1 per face)
  46760. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46761. * @param onLoad defines an optional callback raised when the texture is loaded
  46762. * @param onError defines an optional callback raised if there is an issue to load the texture
  46763. * @param format defines the format of the data
  46764. * @param forcedExtension defines the extension to use to pick the right loader
  46765. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46766. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46767. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46768. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46769. * @returns the cube texture as an InternalTexture
  46770. */
  46771. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  46772. private _getSamplingFilter;
  46773. private static _GetNativeTextureFormat;
  46774. createRenderTargetTexture(size: number | {
  46775. width: number;
  46776. height: number;
  46777. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46778. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46779. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46780. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46781. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46782. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46783. /**
  46784. * Updates a dynamic vertex buffer.
  46785. * @param vertexBuffer the vertex buffer to update
  46786. * @param data the data used to update the vertex buffer
  46787. * @param byteOffset the byte offset of the data (optional)
  46788. * @param byteLength the byte length of the data (optional)
  46789. */
  46790. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46791. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46792. private _updateAnisotropicLevel;
  46793. private _getAddressMode;
  46794. /** @hidden */
  46795. _bindTexture(channel: number, texture: InternalTexture): void;
  46796. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46797. releaseEffects(): void;
  46798. /** @hidden */
  46799. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46800. /** @hidden */
  46801. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46802. /** @hidden */
  46803. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46804. /** @hidden */
  46805. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46806. }
  46807. }
  46808. declare module "babylonjs/Engines/index" {
  46809. export * from "babylonjs/Engines/constants";
  46810. export * from "babylonjs/Engines/engineCapabilities";
  46811. export * from "babylonjs/Engines/instancingAttributeInfo";
  46812. export * from "babylonjs/Engines/thinEngine";
  46813. export * from "babylonjs/Engines/engine";
  46814. export * from "babylonjs/Engines/engineStore";
  46815. export * from "babylonjs/Engines/nullEngine";
  46816. export * from "babylonjs/Engines/Extensions/index";
  46817. export * from "babylonjs/Engines/IPipelineContext";
  46818. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46819. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46820. export * from "babylonjs/Engines/nativeEngine";
  46821. }
  46822. declare module "babylonjs/Events/clipboardEvents" {
  46823. /**
  46824. * Gather the list of clipboard event types as constants.
  46825. */
  46826. export class ClipboardEventTypes {
  46827. /**
  46828. * The clipboard event is fired when a copy command is active (pressed).
  46829. */
  46830. static readonly COPY: number;
  46831. /**
  46832. * The clipboard event is fired when a cut command is active (pressed).
  46833. */
  46834. static readonly CUT: number;
  46835. /**
  46836. * The clipboard event is fired when a paste command is active (pressed).
  46837. */
  46838. static readonly PASTE: number;
  46839. }
  46840. /**
  46841. * This class is used to store clipboard related info for the onClipboardObservable event.
  46842. */
  46843. export class ClipboardInfo {
  46844. /**
  46845. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46846. */
  46847. type: number;
  46848. /**
  46849. * Defines the related dom event
  46850. */
  46851. event: ClipboardEvent;
  46852. /**
  46853. *Creates an instance of ClipboardInfo.
  46854. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46855. * @param event Defines the related dom event
  46856. */
  46857. constructor(
  46858. /**
  46859. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46860. */
  46861. type: number,
  46862. /**
  46863. * Defines the related dom event
  46864. */
  46865. event: ClipboardEvent);
  46866. /**
  46867. * Get the clipboard event's type from the keycode.
  46868. * @param keyCode Defines the keyCode for the current keyboard event.
  46869. * @return {number}
  46870. */
  46871. static GetTypeFromCharacter(keyCode: number): number;
  46872. }
  46873. }
  46874. declare module "babylonjs/Events/index" {
  46875. export * from "babylonjs/Events/keyboardEvents";
  46876. export * from "babylonjs/Events/pointerEvents";
  46877. export * from "babylonjs/Events/clipboardEvents";
  46878. }
  46879. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46880. import { Scene } from "babylonjs/scene";
  46881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46882. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46883. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46884. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46885. /**
  46886. * Google Daydream controller
  46887. */
  46888. export class DaydreamController extends WebVRController {
  46889. /**
  46890. * Base Url for the controller model.
  46891. */
  46892. static MODEL_BASE_URL: string;
  46893. /**
  46894. * File name for the controller model.
  46895. */
  46896. static MODEL_FILENAME: string;
  46897. /**
  46898. * Gamepad Id prefix used to identify Daydream Controller.
  46899. */
  46900. static readonly GAMEPAD_ID_PREFIX: string;
  46901. /**
  46902. * Creates a new DaydreamController from a gamepad
  46903. * @param vrGamepad the gamepad that the controller should be created from
  46904. */
  46905. constructor(vrGamepad: any);
  46906. /**
  46907. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46908. * @param scene scene in which to add meshes
  46909. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46910. */
  46911. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46912. /**
  46913. * Called once for each button that changed state since the last frame
  46914. * @param buttonIdx Which button index changed
  46915. * @param state New state of the button
  46916. * @param changes Which properties on the state changed since last frame
  46917. */
  46918. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46919. }
  46920. }
  46921. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46922. import { Scene } from "babylonjs/scene";
  46923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46924. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46925. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46926. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46927. /**
  46928. * Gear VR Controller
  46929. */
  46930. export class GearVRController extends WebVRController {
  46931. /**
  46932. * Base Url for the controller model.
  46933. */
  46934. static MODEL_BASE_URL: string;
  46935. /**
  46936. * File name for the controller model.
  46937. */
  46938. static MODEL_FILENAME: string;
  46939. /**
  46940. * Gamepad Id prefix used to identify this controller.
  46941. */
  46942. static readonly GAMEPAD_ID_PREFIX: string;
  46943. private readonly _buttonIndexToObservableNameMap;
  46944. /**
  46945. * Creates a new GearVRController from a gamepad
  46946. * @param vrGamepad the gamepad that the controller should be created from
  46947. */
  46948. constructor(vrGamepad: any);
  46949. /**
  46950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46951. * @param scene scene in which to add meshes
  46952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46953. */
  46954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46955. /**
  46956. * Called once for each button that changed state since the last frame
  46957. * @param buttonIdx Which button index changed
  46958. * @param state New state of the button
  46959. * @param changes Which properties on the state changed since last frame
  46960. */
  46961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46962. }
  46963. }
  46964. declare module "babylonjs/Gamepads/Controllers/index" {
  46965. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46966. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46967. export * from "babylonjs/Gamepads/Controllers/genericController";
  46968. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46969. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46970. export * from "babylonjs/Gamepads/Controllers/viveController";
  46971. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46972. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46973. }
  46974. declare module "babylonjs/Gamepads/index" {
  46975. export * from "babylonjs/Gamepads/Controllers/index";
  46976. export * from "babylonjs/Gamepads/gamepad";
  46977. export * from "babylonjs/Gamepads/gamepadManager";
  46978. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46979. export * from "babylonjs/Gamepads/xboxGamepad";
  46980. export * from "babylonjs/Gamepads/dualShockGamepad";
  46981. }
  46982. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46983. import { Scene } from "babylonjs/scene";
  46984. import { Vector4 } from "babylonjs/Maths/math.vector";
  46985. import { Color4 } from "babylonjs/Maths/math.color";
  46986. import { Mesh } from "babylonjs/Meshes/mesh";
  46987. import { Nullable } from "babylonjs/types";
  46988. /**
  46989. * Class containing static functions to help procedurally build meshes
  46990. */
  46991. export class PolyhedronBuilder {
  46992. /**
  46993. * Creates a polyhedron mesh
  46994. * * 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
  46995. * * The parameter `size` (positive float, default 1) sets the polygon size
  46996. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46997. * * 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`
  46998. * * 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
  46999. * * 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)`)
  47000. * * 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
  47001. * * 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
  47002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47005. * @param name defines the name of the mesh
  47006. * @param options defines the options used to create the mesh
  47007. * @param scene defines the hosting scene
  47008. * @returns the polyhedron mesh
  47009. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47010. */
  47011. static CreatePolyhedron(name: string, options: {
  47012. type?: number;
  47013. size?: number;
  47014. sizeX?: number;
  47015. sizeY?: number;
  47016. sizeZ?: number;
  47017. custom?: any;
  47018. faceUV?: Vector4[];
  47019. faceColors?: Color4[];
  47020. flat?: boolean;
  47021. updatable?: boolean;
  47022. sideOrientation?: number;
  47023. frontUVs?: Vector4;
  47024. backUVs?: Vector4;
  47025. }, scene?: Nullable<Scene>): Mesh;
  47026. }
  47027. }
  47028. declare module "babylonjs/Gizmos/scaleGizmo" {
  47029. import { Observable } from "babylonjs/Misc/observable";
  47030. import { Nullable } from "babylonjs/types";
  47031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47032. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47033. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47034. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47035. /**
  47036. * Gizmo that enables scaling a mesh along 3 axis
  47037. */
  47038. export class ScaleGizmo extends Gizmo {
  47039. /**
  47040. * Internal gizmo used for interactions on the x axis
  47041. */
  47042. xGizmo: AxisScaleGizmo;
  47043. /**
  47044. * Internal gizmo used for interactions on the y axis
  47045. */
  47046. yGizmo: AxisScaleGizmo;
  47047. /**
  47048. * Internal gizmo used for interactions on the z axis
  47049. */
  47050. zGizmo: AxisScaleGizmo;
  47051. /**
  47052. * Internal gizmo used to scale all axis equally
  47053. */
  47054. uniformScaleGizmo: AxisScaleGizmo;
  47055. private _meshAttached;
  47056. private _updateGizmoRotationToMatchAttachedMesh;
  47057. private _snapDistance;
  47058. private _scaleRatio;
  47059. private _uniformScalingMesh;
  47060. private _octahedron;
  47061. /** Fires an event when any of it's sub gizmos are dragged */
  47062. onDragStartObservable: Observable<unknown>;
  47063. /** Fires an event when any of it's sub gizmos are released from dragging */
  47064. onDragEndObservable: Observable<unknown>;
  47065. attachedMesh: Nullable<AbstractMesh>;
  47066. /**
  47067. * Creates a ScaleGizmo
  47068. * @param gizmoLayer The utility layer the gizmo will be added to
  47069. */
  47070. constructor(gizmoLayer?: UtilityLayerRenderer);
  47071. updateGizmoRotationToMatchAttachedMesh: boolean;
  47072. /**
  47073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47074. */
  47075. snapDistance: number;
  47076. /**
  47077. * Ratio for the scale of the gizmo (Default: 1)
  47078. */
  47079. scaleRatio: number;
  47080. /**
  47081. * Disposes of the gizmo
  47082. */
  47083. dispose(): void;
  47084. }
  47085. }
  47086. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47087. import { Observable } from "babylonjs/Misc/observable";
  47088. import { Nullable } from "babylonjs/types";
  47089. import { Vector3 } from "babylonjs/Maths/math.vector";
  47090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47091. import { Mesh } from "babylonjs/Meshes/mesh";
  47092. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47093. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47094. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47095. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47096. import { Color3 } from "babylonjs/Maths/math.color";
  47097. /**
  47098. * Single axis scale gizmo
  47099. */
  47100. export class AxisScaleGizmo extends Gizmo {
  47101. /**
  47102. * Drag behavior responsible for the gizmos dragging interactions
  47103. */
  47104. dragBehavior: PointerDragBehavior;
  47105. private _pointerObserver;
  47106. /**
  47107. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47108. */
  47109. snapDistance: number;
  47110. /**
  47111. * Event that fires each time the gizmo snaps to a new location.
  47112. * * snapDistance is the the change in distance
  47113. */
  47114. onSnapObservable: Observable<{
  47115. snapDistance: number;
  47116. }>;
  47117. /**
  47118. * If the scaling operation should be done on all axis (default: false)
  47119. */
  47120. uniformScaling: boolean;
  47121. private _isEnabled;
  47122. private _parent;
  47123. private _arrow;
  47124. private _coloredMaterial;
  47125. private _hoverMaterial;
  47126. /**
  47127. * Creates an AxisScaleGizmo
  47128. * @param gizmoLayer The utility layer the gizmo will be added to
  47129. * @param dragAxis The axis which the gizmo will be able to scale on
  47130. * @param color The color of the gizmo
  47131. */
  47132. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47133. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47134. /**
  47135. * If the gizmo is enabled
  47136. */
  47137. isEnabled: boolean;
  47138. /**
  47139. * Disposes of the gizmo
  47140. */
  47141. dispose(): void;
  47142. /**
  47143. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47144. * @param mesh The mesh to replace the default mesh of the gizmo
  47145. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47146. */
  47147. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47148. }
  47149. }
  47150. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47151. import { Observable } from "babylonjs/Misc/observable";
  47152. import { Nullable } from "babylonjs/types";
  47153. import { Vector3 } from "babylonjs/Maths/math.vector";
  47154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47155. import { Mesh } from "babylonjs/Meshes/mesh";
  47156. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47157. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47158. import { Color3 } from "babylonjs/Maths/math.color";
  47159. import "babylonjs/Meshes/Builders/boxBuilder";
  47160. /**
  47161. * Bounding box gizmo
  47162. */
  47163. export class BoundingBoxGizmo extends Gizmo {
  47164. private _lineBoundingBox;
  47165. private _rotateSpheresParent;
  47166. private _scaleBoxesParent;
  47167. private _boundingDimensions;
  47168. private _renderObserver;
  47169. private _pointerObserver;
  47170. private _scaleDragSpeed;
  47171. private _tmpQuaternion;
  47172. private _tmpVector;
  47173. private _tmpRotationMatrix;
  47174. /**
  47175. * 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)
  47176. */
  47177. ignoreChildren: boolean;
  47178. /**
  47179. * 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)
  47180. */
  47181. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47182. /**
  47183. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47184. */
  47185. rotationSphereSize: number;
  47186. /**
  47187. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47188. */
  47189. scaleBoxSize: number;
  47190. /**
  47191. * 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)
  47192. */
  47193. fixedDragMeshScreenSize: boolean;
  47194. /**
  47195. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47196. */
  47197. fixedDragMeshScreenSizeDistanceFactor: number;
  47198. /**
  47199. * Fired when a rotation sphere or scale box is dragged
  47200. */
  47201. onDragStartObservable: Observable<{}>;
  47202. /**
  47203. * Fired when a scale box is dragged
  47204. */
  47205. onScaleBoxDragObservable: Observable<{}>;
  47206. /**
  47207. * Fired when a scale box drag is ended
  47208. */
  47209. onScaleBoxDragEndObservable: Observable<{}>;
  47210. /**
  47211. * Fired when a rotation sphere is dragged
  47212. */
  47213. onRotationSphereDragObservable: Observable<{}>;
  47214. /**
  47215. * Fired when a rotation sphere drag is ended
  47216. */
  47217. onRotationSphereDragEndObservable: Observable<{}>;
  47218. /**
  47219. * 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)
  47220. */
  47221. scalePivot: Nullable<Vector3>;
  47222. /**
  47223. * Mesh used as a pivot to rotate the attached mesh
  47224. */
  47225. private _anchorMesh;
  47226. private _existingMeshScale;
  47227. private _dragMesh;
  47228. private pointerDragBehavior;
  47229. private coloredMaterial;
  47230. private hoverColoredMaterial;
  47231. /**
  47232. * Sets the color of the bounding box gizmo
  47233. * @param color the color to set
  47234. */
  47235. setColor(color: Color3): void;
  47236. /**
  47237. * Creates an BoundingBoxGizmo
  47238. * @param gizmoLayer The utility layer the gizmo will be added to
  47239. * @param color The color of the gizmo
  47240. */
  47241. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47243. private _selectNode;
  47244. /**
  47245. * Updates the bounding box information for the Gizmo
  47246. */
  47247. updateBoundingBox(): void;
  47248. private _updateRotationSpheres;
  47249. private _updateScaleBoxes;
  47250. /**
  47251. * Enables rotation on the specified axis and disables rotation on the others
  47252. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47253. */
  47254. setEnabledRotationAxis(axis: string): void;
  47255. /**
  47256. * Enables/disables scaling
  47257. * @param enable if scaling should be enabled
  47258. */
  47259. setEnabledScaling(enable: boolean): void;
  47260. private _updateDummy;
  47261. /**
  47262. * Enables a pointer drag behavior on the bounding box of the gizmo
  47263. */
  47264. enableDragBehavior(): void;
  47265. /**
  47266. * Disposes of the gizmo
  47267. */
  47268. dispose(): void;
  47269. /**
  47270. * 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)
  47271. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47272. * @returns the bounding box mesh with the passed in mesh as a child
  47273. */
  47274. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47275. /**
  47276. * CustomMeshes are not supported by this gizmo
  47277. * @param mesh The mesh to replace the default mesh of the gizmo
  47278. */
  47279. setCustomMesh(mesh: Mesh): void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47283. import { Observable } from "babylonjs/Misc/observable";
  47284. import { Nullable } from "babylonjs/types";
  47285. import { Vector3 } from "babylonjs/Maths/math.vector";
  47286. import { Color3 } from "babylonjs/Maths/math.color";
  47287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47288. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47289. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47290. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47291. import "babylonjs/Meshes/Builders/linesBuilder";
  47292. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47293. /**
  47294. * Single plane rotation gizmo
  47295. */
  47296. export class PlaneRotationGizmo extends Gizmo {
  47297. /**
  47298. * Drag behavior responsible for the gizmos dragging interactions
  47299. */
  47300. dragBehavior: PointerDragBehavior;
  47301. private _pointerObserver;
  47302. /**
  47303. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47304. */
  47305. snapDistance: number;
  47306. /**
  47307. * Event that fires each time the gizmo snaps to a new location.
  47308. * * snapDistance is the the change in distance
  47309. */
  47310. onSnapObservable: Observable<{
  47311. snapDistance: number;
  47312. }>;
  47313. private _isEnabled;
  47314. private _parent;
  47315. /**
  47316. * Creates a PlaneRotationGizmo
  47317. * @param gizmoLayer The utility layer the gizmo will be added to
  47318. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47319. * @param color The color of the gizmo
  47320. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47321. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47322. */
  47323. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47324. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47325. /**
  47326. * If the gizmo is enabled
  47327. */
  47328. isEnabled: boolean;
  47329. /**
  47330. * Disposes of the gizmo
  47331. */
  47332. dispose(): void;
  47333. }
  47334. }
  47335. declare module "babylonjs/Gizmos/rotationGizmo" {
  47336. import { Observable } from "babylonjs/Misc/observable";
  47337. import { Nullable } from "babylonjs/types";
  47338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47339. import { Mesh } from "babylonjs/Meshes/mesh";
  47340. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47341. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47342. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47343. /**
  47344. * Gizmo that enables rotating a mesh along 3 axis
  47345. */
  47346. export class RotationGizmo extends Gizmo {
  47347. /**
  47348. * Internal gizmo used for interactions on the x axis
  47349. */
  47350. xGizmo: PlaneRotationGizmo;
  47351. /**
  47352. * Internal gizmo used for interactions on the y axis
  47353. */
  47354. yGizmo: PlaneRotationGizmo;
  47355. /**
  47356. * Internal gizmo used for interactions on the z axis
  47357. */
  47358. zGizmo: PlaneRotationGizmo;
  47359. /** Fires an event when any of it's sub gizmos are dragged */
  47360. onDragStartObservable: Observable<unknown>;
  47361. /** Fires an event when any of it's sub gizmos are released from dragging */
  47362. onDragEndObservable: Observable<unknown>;
  47363. private _meshAttached;
  47364. attachedMesh: Nullable<AbstractMesh>;
  47365. /**
  47366. * Creates a RotationGizmo
  47367. * @param gizmoLayer The utility layer the gizmo will be added to
  47368. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47369. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47370. */
  47371. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47372. updateGizmoRotationToMatchAttachedMesh: boolean;
  47373. /**
  47374. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47375. */
  47376. snapDistance: number;
  47377. /**
  47378. * Ratio for the scale of the gizmo (Default: 1)
  47379. */
  47380. scaleRatio: number;
  47381. /**
  47382. * Disposes of the gizmo
  47383. */
  47384. dispose(): void;
  47385. /**
  47386. * CustomMeshes are not supported by this gizmo
  47387. * @param mesh The mesh to replace the default mesh of the gizmo
  47388. */
  47389. setCustomMesh(mesh: Mesh): void;
  47390. }
  47391. }
  47392. declare module "babylonjs/Gizmos/gizmoManager" {
  47393. import { Observable } from "babylonjs/Misc/observable";
  47394. import { Nullable } from "babylonjs/types";
  47395. import { Scene, IDisposable } from "babylonjs/scene";
  47396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47397. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47398. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47399. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47400. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47401. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47402. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47403. /**
  47404. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47405. */
  47406. export class GizmoManager implements IDisposable {
  47407. private scene;
  47408. /**
  47409. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47410. */
  47411. gizmos: {
  47412. positionGizmo: Nullable<PositionGizmo>;
  47413. rotationGizmo: Nullable<RotationGizmo>;
  47414. scaleGizmo: Nullable<ScaleGizmo>;
  47415. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47416. };
  47417. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47418. clearGizmoOnEmptyPointerEvent: boolean;
  47419. /** Fires an event when the manager is attached to a mesh */
  47420. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47421. private _gizmosEnabled;
  47422. private _pointerObserver;
  47423. private _attachedMesh;
  47424. private _boundingBoxColor;
  47425. private _defaultUtilityLayer;
  47426. private _defaultKeepDepthUtilityLayer;
  47427. /**
  47428. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47429. */
  47430. boundingBoxDragBehavior: SixDofDragBehavior;
  47431. /**
  47432. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47433. */
  47434. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47435. /**
  47436. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47437. */
  47438. usePointerToAttachGizmos: boolean;
  47439. /**
  47440. * Utility layer that the bounding box gizmo belongs to
  47441. */
  47442. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47443. /**
  47444. * Utility layer that all gizmos besides bounding box belong to
  47445. */
  47446. readonly utilityLayer: UtilityLayerRenderer;
  47447. /**
  47448. * Instatiates a gizmo manager
  47449. * @param scene the scene to overlay the gizmos on top of
  47450. */
  47451. constructor(scene: Scene);
  47452. /**
  47453. * Attaches a set of gizmos to the specified mesh
  47454. * @param mesh The mesh the gizmo's should be attached to
  47455. */
  47456. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47457. /**
  47458. * If the position gizmo is enabled
  47459. */
  47460. positionGizmoEnabled: boolean;
  47461. /**
  47462. * If the rotation gizmo is enabled
  47463. */
  47464. rotationGizmoEnabled: boolean;
  47465. /**
  47466. * If the scale gizmo is enabled
  47467. */
  47468. scaleGizmoEnabled: boolean;
  47469. /**
  47470. * If the boundingBox gizmo is enabled
  47471. */
  47472. boundingBoxGizmoEnabled: boolean;
  47473. /**
  47474. * Disposes of the gizmo manager
  47475. */
  47476. dispose(): void;
  47477. }
  47478. }
  47479. declare module "babylonjs/Lights/directionalLight" {
  47480. import { Camera } from "babylonjs/Cameras/camera";
  47481. import { Scene } from "babylonjs/scene";
  47482. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47484. import { Light } from "babylonjs/Lights/light";
  47485. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47486. import { Effect } from "babylonjs/Materials/effect";
  47487. /**
  47488. * A directional light is defined by a direction (what a surprise!).
  47489. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47490. * 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.
  47491. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47492. */
  47493. export class DirectionalLight extends ShadowLight {
  47494. private _shadowFrustumSize;
  47495. /**
  47496. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47497. */
  47498. /**
  47499. * Specifies a fix frustum size for the shadow generation.
  47500. */
  47501. shadowFrustumSize: number;
  47502. private _shadowOrthoScale;
  47503. /**
  47504. * Gets the shadow projection scale against the optimal computed one.
  47505. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47506. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47507. */
  47508. /**
  47509. * Sets the shadow projection scale against the optimal computed one.
  47510. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47511. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47512. */
  47513. shadowOrthoScale: number;
  47514. /**
  47515. * Automatically compute the projection matrix to best fit (including all the casters)
  47516. * on each frame.
  47517. */
  47518. autoUpdateExtends: boolean;
  47519. private _orthoLeft;
  47520. private _orthoRight;
  47521. private _orthoTop;
  47522. private _orthoBottom;
  47523. /**
  47524. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47525. * The directional light is emitted from everywhere in the given direction.
  47526. * It can cast shadows.
  47527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47528. * @param name The friendly name of the light
  47529. * @param direction The direction of the light
  47530. * @param scene The scene the light belongs to
  47531. */
  47532. constructor(name: string, direction: Vector3, scene: Scene);
  47533. /**
  47534. * Returns the string "DirectionalLight".
  47535. * @return The class name
  47536. */
  47537. getClassName(): string;
  47538. /**
  47539. * Returns the integer 1.
  47540. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47541. */
  47542. getTypeID(): number;
  47543. /**
  47544. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47545. * Returns the DirectionalLight Shadow projection matrix.
  47546. */
  47547. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47548. /**
  47549. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47550. * Returns the DirectionalLight Shadow projection matrix.
  47551. */
  47552. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47553. /**
  47554. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47555. * Returns the DirectionalLight Shadow projection matrix.
  47556. */
  47557. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47558. protected _buildUniformLayout(): void;
  47559. /**
  47560. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47561. * @param effect The effect to update
  47562. * @param lightIndex The index of the light in the effect to update
  47563. * @returns The directional light
  47564. */
  47565. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47566. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47567. /**
  47568. * Gets the minZ used for shadow according to both the scene and the light.
  47569. *
  47570. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47571. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47572. * @param activeCamera The camera we are returning the min for
  47573. * @returns the depth min z
  47574. */
  47575. getDepthMinZ(activeCamera: Camera): number;
  47576. /**
  47577. * Gets the maxZ used for shadow according to both the scene and the light.
  47578. *
  47579. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47580. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47581. * @param activeCamera The camera we are returning the max for
  47582. * @returns the depth max z
  47583. */
  47584. getDepthMaxZ(activeCamera: Camera): number;
  47585. /**
  47586. * Prepares the list of defines specific to the light type.
  47587. * @param defines the list of defines
  47588. * @param lightIndex defines the index of the light for the effect
  47589. */
  47590. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47591. }
  47592. }
  47593. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47594. import { Mesh } from "babylonjs/Meshes/mesh";
  47595. /**
  47596. * Class containing static functions to help procedurally build meshes
  47597. */
  47598. export class HemisphereBuilder {
  47599. /**
  47600. * Creates a hemisphere mesh
  47601. * @param name defines the name of the mesh
  47602. * @param options defines the options used to create the mesh
  47603. * @param scene defines the hosting scene
  47604. * @returns the hemisphere mesh
  47605. */
  47606. static CreateHemisphere(name: string, options: {
  47607. segments?: number;
  47608. diameter?: number;
  47609. sideOrientation?: number;
  47610. }, scene: any): Mesh;
  47611. }
  47612. }
  47613. declare module "babylonjs/Lights/spotLight" {
  47614. import { Nullable } from "babylonjs/types";
  47615. import { Scene } from "babylonjs/scene";
  47616. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47618. import { Effect } from "babylonjs/Materials/effect";
  47619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47620. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47621. /**
  47622. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47623. * These values define a cone of light starting from the position, emitting toward the direction.
  47624. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47625. * and the exponent defines the speed of the decay of the light with distance (reach).
  47626. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47627. */
  47628. export class SpotLight extends ShadowLight {
  47629. private _angle;
  47630. private _innerAngle;
  47631. private _cosHalfAngle;
  47632. private _lightAngleScale;
  47633. private _lightAngleOffset;
  47634. /**
  47635. * Gets the cone angle of the spot light in Radians.
  47636. */
  47637. /**
  47638. * Sets the cone angle of the spot light in Radians.
  47639. */
  47640. angle: number;
  47641. /**
  47642. * Only used in gltf falloff mode, this defines the angle where
  47643. * the directional falloff will start before cutting at angle which could be seen
  47644. * as outer angle.
  47645. */
  47646. /**
  47647. * Only used in gltf falloff mode, this defines the angle where
  47648. * the directional falloff will start before cutting at angle which could be seen
  47649. * as outer angle.
  47650. */
  47651. innerAngle: number;
  47652. private _shadowAngleScale;
  47653. /**
  47654. * Allows scaling the angle of the light for shadow generation only.
  47655. */
  47656. /**
  47657. * Allows scaling the angle of the light for shadow generation only.
  47658. */
  47659. shadowAngleScale: number;
  47660. /**
  47661. * The light decay speed with the distance from the emission spot.
  47662. */
  47663. exponent: number;
  47664. private _projectionTextureMatrix;
  47665. /**
  47666. * Allows reading the projecton texture
  47667. */
  47668. readonly projectionTextureMatrix: Matrix;
  47669. protected _projectionTextureLightNear: number;
  47670. /**
  47671. * Gets the near clip of the Spotlight for texture projection.
  47672. */
  47673. /**
  47674. * Sets the near clip of the Spotlight for texture projection.
  47675. */
  47676. projectionTextureLightNear: number;
  47677. protected _projectionTextureLightFar: number;
  47678. /**
  47679. * Gets the far clip of the Spotlight for texture projection.
  47680. */
  47681. /**
  47682. * Sets the far clip of the Spotlight for texture projection.
  47683. */
  47684. projectionTextureLightFar: number;
  47685. protected _projectionTextureUpDirection: Vector3;
  47686. /**
  47687. * Gets the Up vector of the Spotlight for texture projection.
  47688. */
  47689. /**
  47690. * Sets the Up vector of the Spotlight for texture projection.
  47691. */
  47692. projectionTextureUpDirection: Vector3;
  47693. private _projectionTexture;
  47694. /**
  47695. * Gets the projection texture of the light.
  47696. */
  47697. /**
  47698. * Sets the projection texture of the light.
  47699. */
  47700. projectionTexture: Nullable<BaseTexture>;
  47701. private _projectionTextureViewLightDirty;
  47702. private _projectionTextureProjectionLightDirty;
  47703. private _projectionTextureDirty;
  47704. private _projectionTextureViewTargetVector;
  47705. private _projectionTextureViewLightMatrix;
  47706. private _projectionTextureProjectionLightMatrix;
  47707. private _projectionTextureScalingMatrix;
  47708. /**
  47709. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47710. * It can cast shadows.
  47711. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47712. * @param name The light friendly name
  47713. * @param position The position of the spot light in the scene
  47714. * @param direction The direction of the light in the scene
  47715. * @param angle The cone angle of the light in Radians
  47716. * @param exponent The light decay speed with the distance from the emission spot
  47717. * @param scene The scene the lights belongs to
  47718. */
  47719. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47720. /**
  47721. * Returns the string "SpotLight".
  47722. * @returns the class name
  47723. */
  47724. getClassName(): string;
  47725. /**
  47726. * Returns the integer 2.
  47727. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47728. */
  47729. getTypeID(): number;
  47730. /**
  47731. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47732. */
  47733. protected _setDirection(value: Vector3): void;
  47734. /**
  47735. * Overrides the position setter to recompute the projection texture view light Matrix.
  47736. */
  47737. protected _setPosition(value: Vector3): void;
  47738. /**
  47739. * 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.
  47740. * Returns the SpotLight.
  47741. */
  47742. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47743. protected _computeProjectionTextureViewLightMatrix(): void;
  47744. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47745. /**
  47746. * Main function for light texture projection matrix computing.
  47747. */
  47748. protected _computeProjectionTextureMatrix(): void;
  47749. protected _buildUniformLayout(): void;
  47750. private _computeAngleValues;
  47751. /**
  47752. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47753. * @param effect The effect to update
  47754. * @param lightIndex The index of the light in the effect to update
  47755. * @returns The spot light
  47756. */
  47757. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47758. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47759. /**
  47760. * Disposes the light and the associated resources.
  47761. */
  47762. dispose(): void;
  47763. /**
  47764. * Prepares the list of defines specific to the light type.
  47765. * @param defines the list of defines
  47766. * @param lightIndex defines the index of the light for the effect
  47767. */
  47768. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47769. }
  47770. }
  47771. declare module "babylonjs/Gizmos/lightGizmo" {
  47772. import { Nullable } from "babylonjs/types";
  47773. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47774. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47775. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47776. import { Light } from "babylonjs/Lights/light";
  47777. /**
  47778. * Gizmo that enables viewing a light
  47779. */
  47780. export class LightGizmo extends Gizmo {
  47781. private _lightMesh;
  47782. private _material;
  47783. private cachedPosition;
  47784. private cachedForward;
  47785. /**
  47786. * Creates a LightGizmo
  47787. * @param gizmoLayer The utility layer the gizmo will be added to
  47788. */
  47789. constructor(gizmoLayer?: UtilityLayerRenderer);
  47790. private _light;
  47791. /**
  47792. * The light that the gizmo is attached to
  47793. */
  47794. light: Nullable<Light>;
  47795. /**
  47796. * Gets the material used to render the light gizmo
  47797. */
  47798. readonly material: StandardMaterial;
  47799. /**
  47800. * @hidden
  47801. * Updates the gizmo to match the attached mesh's position/rotation
  47802. */
  47803. protected _update(): void;
  47804. private static _Scale;
  47805. /**
  47806. * Creates the lines for a light mesh
  47807. */
  47808. private static _createLightLines;
  47809. /**
  47810. * Disposes of the light gizmo
  47811. */
  47812. dispose(): void;
  47813. private static _CreateHemisphericLightMesh;
  47814. private static _CreatePointLightMesh;
  47815. private static _CreateSpotLightMesh;
  47816. private static _CreateDirectionalLightMesh;
  47817. }
  47818. }
  47819. declare module "babylonjs/Gizmos/index" {
  47820. export * from "babylonjs/Gizmos/axisDragGizmo";
  47821. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47822. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47823. export * from "babylonjs/Gizmos/gizmo";
  47824. export * from "babylonjs/Gizmos/gizmoManager";
  47825. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47826. export * from "babylonjs/Gizmos/positionGizmo";
  47827. export * from "babylonjs/Gizmos/rotationGizmo";
  47828. export * from "babylonjs/Gizmos/scaleGizmo";
  47829. export * from "babylonjs/Gizmos/lightGizmo";
  47830. export * from "babylonjs/Gizmos/planeDragGizmo";
  47831. }
  47832. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47833. /** @hidden */
  47834. export var backgroundFragmentDeclaration: {
  47835. name: string;
  47836. shader: string;
  47837. };
  47838. }
  47839. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47840. /** @hidden */
  47841. export var backgroundUboDeclaration: {
  47842. name: string;
  47843. shader: string;
  47844. };
  47845. }
  47846. declare module "babylonjs/Shaders/background.fragment" {
  47847. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47848. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47849. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47850. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47851. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47852. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47853. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47854. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47855. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47856. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47857. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47858. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47859. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47860. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47861. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47862. /** @hidden */
  47863. export var backgroundPixelShader: {
  47864. name: string;
  47865. shader: string;
  47866. };
  47867. }
  47868. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47869. /** @hidden */
  47870. export var backgroundVertexDeclaration: {
  47871. name: string;
  47872. shader: string;
  47873. };
  47874. }
  47875. declare module "babylonjs/Shaders/background.vertex" {
  47876. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47877. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47878. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47879. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47880. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47881. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47882. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47883. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47884. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47885. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47886. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47887. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47888. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47889. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47890. /** @hidden */
  47891. export var backgroundVertexShader: {
  47892. name: string;
  47893. shader: string;
  47894. };
  47895. }
  47896. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47897. import { Nullable, int, float } from "babylonjs/types";
  47898. import { Scene } from "babylonjs/scene";
  47899. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47902. import { Mesh } from "babylonjs/Meshes/mesh";
  47903. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47904. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47905. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47907. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47908. import { Color3 } from "babylonjs/Maths/math.color";
  47909. import "babylonjs/Shaders/background.fragment";
  47910. import "babylonjs/Shaders/background.vertex";
  47911. /**
  47912. * Background material used to create an efficient environement around your scene.
  47913. */
  47914. export class BackgroundMaterial extends PushMaterial {
  47915. /**
  47916. * Standard reflectance value at parallel view angle.
  47917. */
  47918. static StandardReflectance0: number;
  47919. /**
  47920. * Standard reflectance value at grazing angle.
  47921. */
  47922. static StandardReflectance90: number;
  47923. protected _primaryColor: Color3;
  47924. /**
  47925. * Key light Color (multiply against the environement texture)
  47926. */
  47927. primaryColor: Color3;
  47928. protected __perceptualColor: Nullable<Color3>;
  47929. /**
  47930. * Experimental Internal Use Only.
  47931. *
  47932. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47933. * This acts as a helper to set the primary color to a more "human friendly" value.
  47934. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47935. * output color as close as possible from the chosen value.
  47936. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47937. * part of lighting setup.)
  47938. */
  47939. _perceptualColor: Nullable<Color3>;
  47940. protected _primaryColorShadowLevel: float;
  47941. /**
  47942. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47943. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47944. */
  47945. primaryColorShadowLevel: float;
  47946. protected _primaryColorHighlightLevel: float;
  47947. /**
  47948. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47949. * The primary color is used at the level chosen to define what the white area would look.
  47950. */
  47951. primaryColorHighlightLevel: float;
  47952. protected _reflectionTexture: Nullable<BaseTexture>;
  47953. /**
  47954. * Reflection Texture used in the material.
  47955. * Should be author in a specific way for the best result (refer to the documentation).
  47956. */
  47957. reflectionTexture: Nullable<BaseTexture>;
  47958. protected _reflectionBlur: float;
  47959. /**
  47960. * Reflection Texture level of blur.
  47961. *
  47962. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47963. * texture twice.
  47964. */
  47965. reflectionBlur: float;
  47966. protected _diffuseTexture: Nullable<BaseTexture>;
  47967. /**
  47968. * Diffuse Texture used in the material.
  47969. * Should be author in a specific way for the best result (refer to the documentation).
  47970. */
  47971. diffuseTexture: Nullable<BaseTexture>;
  47972. protected _shadowLights: Nullable<IShadowLight[]>;
  47973. /**
  47974. * Specify the list of lights casting shadow on the material.
  47975. * All scene shadow lights will be included if null.
  47976. */
  47977. shadowLights: Nullable<IShadowLight[]>;
  47978. protected _shadowLevel: float;
  47979. /**
  47980. * Helps adjusting the shadow to a softer level if required.
  47981. * 0 means black shadows and 1 means no shadows.
  47982. */
  47983. shadowLevel: float;
  47984. protected _sceneCenter: Vector3;
  47985. /**
  47986. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47987. * It is usually zero but might be interesting to modify according to your setup.
  47988. */
  47989. sceneCenter: Vector3;
  47990. protected _opacityFresnel: boolean;
  47991. /**
  47992. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47993. * This helps ensuring a nice transition when the camera goes under the ground.
  47994. */
  47995. opacityFresnel: boolean;
  47996. protected _reflectionFresnel: boolean;
  47997. /**
  47998. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47999. * This helps adding a mirror texture on the ground.
  48000. */
  48001. reflectionFresnel: boolean;
  48002. protected _reflectionFalloffDistance: number;
  48003. /**
  48004. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48005. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48006. */
  48007. reflectionFalloffDistance: number;
  48008. protected _reflectionAmount: number;
  48009. /**
  48010. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48011. */
  48012. reflectionAmount: number;
  48013. protected _reflectionReflectance0: number;
  48014. /**
  48015. * This specifies the weight of the reflection at grazing angle.
  48016. */
  48017. reflectionReflectance0: number;
  48018. protected _reflectionReflectance90: number;
  48019. /**
  48020. * This specifies the weight of the reflection at a perpendicular point of view.
  48021. */
  48022. reflectionReflectance90: number;
  48023. /**
  48024. * Sets the reflection reflectance fresnel values according to the default standard
  48025. * empirically know to work well :-)
  48026. */
  48027. reflectionStandardFresnelWeight: number;
  48028. protected _useRGBColor: boolean;
  48029. /**
  48030. * Helps to directly use the maps channels instead of their level.
  48031. */
  48032. useRGBColor: boolean;
  48033. protected _enableNoise: boolean;
  48034. /**
  48035. * This helps reducing the banding effect that could occur on the background.
  48036. */
  48037. enableNoise: boolean;
  48038. /**
  48039. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48040. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48041. * Recommended to be keep at 1.0 except for special cases.
  48042. */
  48043. fovMultiplier: number;
  48044. private _fovMultiplier;
  48045. /**
  48046. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48047. */
  48048. useEquirectangularFOV: boolean;
  48049. private _maxSimultaneousLights;
  48050. /**
  48051. * Number of Simultaneous lights allowed on the material.
  48052. */
  48053. maxSimultaneousLights: int;
  48054. /**
  48055. * Default configuration related to image processing available in the Background Material.
  48056. */
  48057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48058. /**
  48059. * Keep track of the image processing observer to allow dispose and replace.
  48060. */
  48061. private _imageProcessingObserver;
  48062. /**
  48063. * Attaches a new image processing configuration to the PBR Material.
  48064. * @param configuration (if null the scene configuration will be use)
  48065. */
  48066. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48067. /**
  48068. * Gets the image processing configuration used either in this material.
  48069. */
  48070. /**
  48071. * Sets the Default image processing configuration used either in the this material.
  48072. *
  48073. * If sets to null, the scene one is in use.
  48074. */
  48075. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48076. /**
  48077. * Gets wether the color curves effect is enabled.
  48078. */
  48079. /**
  48080. * Sets wether the color curves effect is enabled.
  48081. */
  48082. cameraColorCurvesEnabled: boolean;
  48083. /**
  48084. * Gets wether the color grading effect is enabled.
  48085. */
  48086. /**
  48087. * Gets wether the color grading effect is enabled.
  48088. */
  48089. cameraColorGradingEnabled: boolean;
  48090. /**
  48091. * Gets wether tonemapping is enabled or not.
  48092. */
  48093. /**
  48094. * Sets wether tonemapping is enabled or not
  48095. */
  48096. cameraToneMappingEnabled: boolean;
  48097. /**
  48098. * The camera exposure used on this material.
  48099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48100. * This corresponds to a photographic exposure.
  48101. */
  48102. /**
  48103. * The camera exposure used on this material.
  48104. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48105. * This corresponds to a photographic exposure.
  48106. */
  48107. cameraExposure: float;
  48108. /**
  48109. * Gets The camera contrast used on this material.
  48110. */
  48111. /**
  48112. * Sets The camera contrast used on this material.
  48113. */
  48114. cameraContrast: float;
  48115. /**
  48116. * Gets the Color Grading 2D Lookup Texture.
  48117. */
  48118. /**
  48119. * Sets the Color Grading 2D Lookup Texture.
  48120. */
  48121. cameraColorGradingTexture: Nullable<BaseTexture>;
  48122. /**
  48123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48125. * 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;
  48126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48127. */
  48128. /**
  48129. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48131. * 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;
  48132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48133. */
  48134. cameraColorCurves: Nullable<ColorCurves>;
  48135. /**
  48136. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48137. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48138. */
  48139. switchToBGR: boolean;
  48140. private _renderTargets;
  48141. private _reflectionControls;
  48142. private _white;
  48143. private _primaryShadowColor;
  48144. private _primaryHighlightColor;
  48145. /**
  48146. * Instantiates a Background Material in the given scene
  48147. * @param name The friendly name of the material
  48148. * @param scene The scene to add the material to
  48149. */
  48150. constructor(name: string, scene: Scene);
  48151. /**
  48152. * Gets a boolean indicating that current material needs to register RTT
  48153. */
  48154. readonly hasRenderTargetTextures: boolean;
  48155. /**
  48156. * The entire material has been created in order to prevent overdraw.
  48157. * @returns false
  48158. */
  48159. needAlphaTesting(): boolean;
  48160. /**
  48161. * The entire material has been created in order to prevent overdraw.
  48162. * @returns true if blending is enable
  48163. */
  48164. needAlphaBlending(): boolean;
  48165. /**
  48166. * Checks wether the material is ready to be rendered for a given mesh.
  48167. * @param mesh The mesh to render
  48168. * @param subMesh The submesh to check against
  48169. * @param useInstances Specify wether or not the material is used with instances
  48170. * @returns true if all the dependencies are ready (Textures, Effects...)
  48171. */
  48172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48173. /**
  48174. * Compute the primary color according to the chosen perceptual color.
  48175. */
  48176. private _computePrimaryColorFromPerceptualColor;
  48177. /**
  48178. * Compute the highlights and shadow colors according to their chosen levels.
  48179. */
  48180. private _computePrimaryColors;
  48181. /**
  48182. * Build the uniform buffer used in the material.
  48183. */
  48184. buildUniformLayout(): void;
  48185. /**
  48186. * Unbind the material.
  48187. */
  48188. unbind(): void;
  48189. /**
  48190. * Bind only the world matrix to the material.
  48191. * @param world The world matrix to bind.
  48192. */
  48193. bindOnlyWorldMatrix(world: Matrix): void;
  48194. /**
  48195. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48196. * @param world The world matrix to bind.
  48197. * @param subMesh The submesh to bind for.
  48198. */
  48199. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48200. /**
  48201. * Checks to see if a texture is used in the material.
  48202. * @param texture - Base texture to use.
  48203. * @returns - Boolean specifying if a texture is used in the material.
  48204. */
  48205. hasTexture(texture: BaseTexture): boolean;
  48206. /**
  48207. * Dispose the material.
  48208. * @param forceDisposeEffect Force disposal of the associated effect.
  48209. * @param forceDisposeTextures Force disposal of the associated textures.
  48210. */
  48211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48212. /**
  48213. * Clones the material.
  48214. * @param name The cloned name.
  48215. * @returns The cloned material.
  48216. */
  48217. clone(name: string): BackgroundMaterial;
  48218. /**
  48219. * Serializes the current material to its JSON representation.
  48220. * @returns The JSON representation.
  48221. */
  48222. serialize(): any;
  48223. /**
  48224. * Gets the class name of the material
  48225. * @returns "BackgroundMaterial"
  48226. */
  48227. getClassName(): string;
  48228. /**
  48229. * Parse a JSON input to create back a background material.
  48230. * @param source The JSON data to parse
  48231. * @param scene The scene to create the parsed material in
  48232. * @param rootUrl The root url of the assets the material depends upon
  48233. * @returns the instantiated BackgroundMaterial.
  48234. */
  48235. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48236. }
  48237. }
  48238. declare module "babylonjs/Helpers/environmentHelper" {
  48239. import { Observable } from "babylonjs/Misc/observable";
  48240. import { Nullable } from "babylonjs/types";
  48241. import { Scene } from "babylonjs/scene";
  48242. import { Vector3 } from "babylonjs/Maths/math.vector";
  48243. import { Color3 } from "babylonjs/Maths/math.color";
  48244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48245. import { Mesh } from "babylonjs/Meshes/mesh";
  48246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48247. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48248. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48249. import "babylonjs/Meshes/Builders/planeBuilder";
  48250. import "babylonjs/Meshes/Builders/boxBuilder";
  48251. /**
  48252. * Represents the different options available during the creation of
  48253. * a Environment helper.
  48254. *
  48255. * This can control the default ground, skybox and image processing setup of your scene.
  48256. */
  48257. export interface IEnvironmentHelperOptions {
  48258. /**
  48259. * Specifies wether or not to create a ground.
  48260. * True by default.
  48261. */
  48262. createGround: boolean;
  48263. /**
  48264. * Specifies the ground size.
  48265. * 15 by default.
  48266. */
  48267. groundSize: number;
  48268. /**
  48269. * The texture used on the ground for the main color.
  48270. * Comes from the BabylonJS CDN by default.
  48271. *
  48272. * Remarks: Can be either a texture or a url.
  48273. */
  48274. groundTexture: string | BaseTexture;
  48275. /**
  48276. * The color mixed in the ground texture by default.
  48277. * BabylonJS clearColor by default.
  48278. */
  48279. groundColor: Color3;
  48280. /**
  48281. * Specifies the ground opacity.
  48282. * 1 by default.
  48283. */
  48284. groundOpacity: number;
  48285. /**
  48286. * Enables the ground to receive shadows.
  48287. * True by default.
  48288. */
  48289. enableGroundShadow: boolean;
  48290. /**
  48291. * Helps preventing the shadow to be fully black on the ground.
  48292. * 0.5 by default.
  48293. */
  48294. groundShadowLevel: number;
  48295. /**
  48296. * Creates a mirror texture attach to the ground.
  48297. * false by default.
  48298. */
  48299. enableGroundMirror: boolean;
  48300. /**
  48301. * Specifies the ground mirror size ratio.
  48302. * 0.3 by default as the default kernel is 64.
  48303. */
  48304. groundMirrorSizeRatio: number;
  48305. /**
  48306. * Specifies the ground mirror blur kernel size.
  48307. * 64 by default.
  48308. */
  48309. groundMirrorBlurKernel: number;
  48310. /**
  48311. * Specifies the ground mirror visibility amount.
  48312. * 1 by default
  48313. */
  48314. groundMirrorAmount: number;
  48315. /**
  48316. * Specifies the ground mirror reflectance weight.
  48317. * This uses the standard weight of the background material to setup the fresnel effect
  48318. * of the mirror.
  48319. * 1 by default.
  48320. */
  48321. groundMirrorFresnelWeight: number;
  48322. /**
  48323. * Specifies the ground mirror Falloff distance.
  48324. * This can helps reducing the size of the reflection.
  48325. * 0 by Default.
  48326. */
  48327. groundMirrorFallOffDistance: number;
  48328. /**
  48329. * Specifies the ground mirror texture type.
  48330. * Unsigned Int by Default.
  48331. */
  48332. groundMirrorTextureType: number;
  48333. /**
  48334. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48335. * the shown objects.
  48336. */
  48337. groundYBias: number;
  48338. /**
  48339. * Specifies wether or not to create a skybox.
  48340. * True by default.
  48341. */
  48342. createSkybox: boolean;
  48343. /**
  48344. * Specifies the skybox size.
  48345. * 20 by default.
  48346. */
  48347. skyboxSize: number;
  48348. /**
  48349. * The texture used on the skybox for the main color.
  48350. * Comes from the BabylonJS CDN by default.
  48351. *
  48352. * Remarks: Can be either a texture or a url.
  48353. */
  48354. skyboxTexture: string | BaseTexture;
  48355. /**
  48356. * The color mixed in the skybox texture by default.
  48357. * BabylonJS clearColor by default.
  48358. */
  48359. skyboxColor: Color3;
  48360. /**
  48361. * The background rotation around the Y axis of the scene.
  48362. * This helps aligning the key lights of your scene with the background.
  48363. * 0 by default.
  48364. */
  48365. backgroundYRotation: number;
  48366. /**
  48367. * Compute automatically the size of the elements to best fit with the scene.
  48368. */
  48369. sizeAuto: boolean;
  48370. /**
  48371. * Default position of the rootMesh if autoSize is not true.
  48372. */
  48373. rootPosition: Vector3;
  48374. /**
  48375. * Sets up the image processing in the scene.
  48376. * true by default.
  48377. */
  48378. setupImageProcessing: boolean;
  48379. /**
  48380. * The texture used as your environment texture in the scene.
  48381. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48382. *
  48383. * Remarks: Can be either a texture or a url.
  48384. */
  48385. environmentTexture: string | BaseTexture;
  48386. /**
  48387. * The value of the exposure to apply to the scene.
  48388. * 0.6 by default if setupImageProcessing is true.
  48389. */
  48390. cameraExposure: number;
  48391. /**
  48392. * The value of the contrast to apply to the scene.
  48393. * 1.6 by default if setupImageProcessing is true.
  48394. */
  48395. cameraContrast: number;
  48396. /**
  48397. * Specifies wether or not tonemapping should be enabled in the scene.
  48398. * true by default if setupImageProcessing is true.
  48399. */
  48400. toneMappingEnabled: boolean;
  48401. }
  48402. /**
  48403. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48404. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48405. * It also helps with the default setup of your imageProcessing configuration.
  48406. */
  48407. export class EnvironmentHelper {
  48408. /**
  48409. * Default ground texture URL.
  48410. */
  48411. private static _groundTextureCDNUrl;
  48412. /**
  48413. * Default skybox texture URL.
  48414. */
  48415. private static _skyboxTextureCDNUrl;
  48416. /**
  48417. * Default environment texture URL.
  48418. */
  48419. private static _environmentTextureCDNUrl;
  48420. /**
  48421. * Creates the default options for the helper.
  48422. */
  48423. private static _getDefaultOptions;
  48424. private _rootMesh;
  48425. /**
  48426. * Gets the root mesh created by the helper.
  48427. */
  48428. readonly rootMesh: Mesh;
  48429. private _skybox;
  48430. /**
  48431. * Gets the skybox created by the helper.
  48432. */
  48433. readonly skybox: Nullable<Mesh>;
  48434. private _skyboxTexture;
  48435. /**
  48436. * Gets the skybox texture created by the helper.
  48437. */
  48438. readonly skyboxTexture: Nullable<BaseTexture>;
  48439. private _skyboxMaterial;
  48440. /**
  48441. * Gets the skybox material created by the helper.
  48442. */
  48443. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48444. private _ground;
  48445. /**
  48446. * Gets the ground mesh created by the helper.
  48447. */
  48448. readonly ground: Nullable<Mesh>;
  48449. private _groundTexture;
  48450. /**
  48451. * Gets the ground texture created by the helper.
  48452. */
  48453. readonly groundTexture: Nullable<BaseTexture>;
  48454. private _groundMirror;
  48455. /**
  48456. * Gets the ground mirror created by the helper.
  48457. */
  48458. readonly groundMirror: Nullable<MirrorTexture>;
  48459. /**
  48460. * Gets the ground mirror render list to helps pushing the meshes
  48461. * you wish in the ground reflection.
  48462. */
  48463. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48464. private _groundMaterial;
  48465. /**
  48466. * Gets the ground material created by the helper.
  48467. */
  48468. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48469. /**
  48470. * Stores the creation options.
  48471. */
  48472. private readonly _scene;
  48473. private _options;
  48474. /**
  48475. * This observable will be notified with any error during the creation of the environment,
  48476. * mainly texture creation errors.
  48477. */
  48478. onErrorObservable: Observable<{
  48479. message?: string;
  48480. exception?: any;
  48481. }>;
  48482. /**
  48483. * constructor
  48484. * @param options Defines the options we want to customize the helper
  48485. * @param scene The scene to add the material to
  48486. */
  48487. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48488. /**
  48489. * Updates the background according to the new options
  48490. * @param options
  48491. */
  48492. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48493. /**
  48494. * Sets the primary color of all the available elements.
  48495. * @param color the main color to affect to the ground and the background
  48496. */
  48497. setMainColor(color: Color3): void;
  48498. /**
  48499. * Setup the image processing according to the specified options.
  48500. */
  48501. private _setupImageProcessing;
  48502. /**
  48503. * Setup the environment texture according to the specified options.
  48504. */
  48505. private _setupEnvironmentTexture;
  48506. /**
  48507. * Setup the background according to the specified options.
  48508. */
  48509. private _setupBackground;
  48510. /**
  48511. * Get the scene sizes according to the setup.
  48512. */
  48513. private _getSceneSize;
  48514. /**
  48515. * Setup the ground according to the specified options.
  48516. */
  48517. private _setupGround;
  48518. /**
  48519. * Setup the ground material according to the specified options.
  48520. */
  48521. private _setupGroundMaterial;
  48522. /**
  48523. * Setup the ground diffuse texture according to the specified options.
  48524. */
  48525. private _setupGroundDiffuseTexture;
  48526. /**
  48527. * Setup the ground mirror texture according to the specified options.
  48528. */
  48529. private _setupGroundMirrorTexture;
  48530. /**
  48531. * Setup the ground to receive the mirror texture.
  48532. */
  48533. private _setupMirrorInGroundMaterial;
  48534. /**
  48535. * Setup the skybox according to the specified options.
  48536. */
  48537. private _setupSkybox;
  48538. /**
  48539. * Setup the skybox material according to the specified options.
  48540. */
  48541. private _setupSkyboxMaterial;
  48542. /**
  48543. * Setup the skybox reflection texture according to the specified options.
  48544. */
  48545. private _setupSkyboxReflectionTexture;
  48546. private _errorHandler;
  48547. /**
  48548. * Dispose all the elements created by the Helper.
  48549. */
  48550. dispose(): void;
  48551. }
  48552. }
  48553. declare module "babylonjs/Helpers/photoDome" {
  48554. import { Observable } from "babylonjs/Misc/observable";
  48555. import { Nullable } from "babylonjs/types";
  48556. import { Scene } from "babylonjs/scene";
  48557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48558. import { Mesh } from "babylonjs/Meshes/mesh";
  48559. import { Texture } from "babylonjs/Materials/Textures/texture";
  48560. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48561. import "babylonjs/Meshes/Builders/sphereBuilder";
  48562. /**
  48563. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48564. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48565. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48566. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48567. */
  48568. export class PhotoDome extends TransformNode {
  48569. /**
  48570. * Define the image as a Monoscopic panoramic 360 image.
  48571. */
  48572. static readonly MODE_MONOSCOPIC: number;
  48573. /**
  48574. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48575. */
  48576. static readonly MODE_TOPBOTTOM: number;
  48577. /**
  48578. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48579. */
  48580. static readonly MODE_SIDEBYSIDE: number;
  48581. private _useDirectMapping;
  48582. /**
  48583. * The texture being displayed on the sphere
  48584. */
  48585. protected _photoTexture: Texture;
  48586. /**
  48587. * Gets or sets the texture being displayed on the sphere
  48588. */
  48589. photoTexture: Texture;
  48590. /**
  48591. * Observable raised when an error occured while loading the 360 image
  48592. */
  48593. onLoadErrorObservable: Observable<string>;
  48594. /**
  48595. * The skybox material
  48596. */
  48597. protected _material: BackgroundMaterial;
  48598. /**
  48599. * The surface used for the skybox
  48600. */
  48601. protected _mesh: Mesh;
  48602. /**
  48603. * Gets the mesh used for the skybox.
  48604. */
  48605. readonly mesh: Mesh;
  48606. /**
  48607. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48608. * Also see the options.resolution property.
  48609. */
  48610. fovMultiplier: number;
  48611. private _imageMode;
  48612. /**
  48613. * Gets or set the current video mode for the video. It can be:
  48614. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48615. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48616. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48617. */
  48618. imageMode: number;
  48619. /**
  48620. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48621. * @param name Element's name, child elements will append suffixes for their own names.
  48622. * @param urlsOfPhoto defines the url of the photo to display
  48623. * @param options defines an object containing optional or exposed sub element properties
  48624. * @param onError defines a callback called when an error occured while loading the texture
  48625. */
  48626. constructor(name: string, urlOfPhoto: string, options: {
  48627. resolution?: number;
  48628. size?: number;
  48629. useDirectMapping?: boolean;
  48630. faceForward?: boolean;
  48631. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48632. private _onBeforeCameraRenderObserver;
  48633. private _changeImageMode;
  48634. /**
  48635. * Releases resources associated with this node.
  48636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48638. */
  48639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48640. }
  48641. }
  48642. declare module "babylonjs/Misc/rgbdTextureTools" {
  48643. import "babylonjs/Shaders/rgbdDecode.fragment";
  48644. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48645. import { Texture } from "babylonjs/Materials/Textures/texture";
  48646. /**
  48647. * Class used to host RGBD texture specific utilities
  48648. */
  48649. export class RGBDTextureTools {
  48650. /**
  48651. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48652. * @param texture the texture to expand.
  48653. */
  48654. static ExpandRGBDTexture(texture: Texture): void;
  48655. }
  48656. }
  48657. declare module "babylonjs/Misc/brdfTextureTools" {
  48658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48659. import { Scene } from "babylonjs/scene";
  48660. /**
  48661. * Class used to host texture specific utilities
  48662. */
  48663. export class BRDFTextureTools {
  48664. /**
  48665. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48666. * @param scene defines the hosting scene
  48667. * @returns the environment BRDF texture
  48668. */
  48669. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48670. private static _environmentBRDFBase64Texture;
  48671. }
  48672. }
  48673. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48674. import { Nullable } from "babylonjs/types";
  48675. import { Color3 } from "babylonjs/Maths/math.color";
  48676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48677. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48678. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48679. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48680. import { Engine } from "babylonjs/Engines/engine";
  48681. import { Scene } from "babylonjs/scene";
  48682. /**
  48683. * @hidden
  48684. */
  48685. export interface IMaterialClearCoatDefines {
  48686. CLEARCOAT: boolean;
  48687. CLEARCOAT_DEFAULTIOR: boolean;
  48688. CLEARCOAT_TEXTURE: boolean;
  48689. CLEARCOAT_TEXTUREDIRECTUV: number;
  48690. CLEARCOAT_BUMP: boolean;
  48691. CLEARCOAT_BUMPDIRECTUV: number;
  48692. CLEARCOAT_TINT: boolean;
  48693. CLEARCOAT_TINT_TEXTURE: boolean;
  48694. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48695. /** @hidden */
  48696. _areTexturesDirty: boolean;
  48697. }
  48698. /**
  48699. * Define the code related to the clear coat parameters of the pbr material.
  48700. */
  48701. export class PBRClearCoatConfiguration {
  48702. /**
  48703. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48704. * The default fits with a polyurethane material.
  48705. */
  48706. private static readonly _DefaultIndexOfRefraction;
  48707. private _isEnabled;
  48708. /**
  48709. * Defines if the clear coat is enabled in the material.
  48710. */
  48711. isEnabled: boolean;
  48712. /**
  48713. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48714. */
  48715. intensity: number;
  48716. /**
  48717. * Defines the clear coat layer roughness.
  48718. */
  48719. roughness: number;
  48720. private _indexOfRefraction;
  48721. /**
  48722. * Defines the index of refraction of the clear coat.
  48723. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48724. * The default fits with a polyurethane material.
  48725. * Changing the default value is more performance intensive.
  48726. */
  48727. indexOfRefraction: number;
  48728. private _texture;
  48729. /**
  48730. * Stores the clear coat values in a texture.
  48731. */
  48732. texture: Nullable<BaseTexture>;
  48733. private _bumpTexture;
  48734. /**
  48735. * Define the clear coat specific bump texture.
  48736. */
  48737. bumpTexture: Nullable<BaseTexture>;
  48738. private _isTintEnabled;
  48739. /**
  48740. * Defines if the clear coat tint is enabled in the material.
  48741. */
  48742. isTintEnabled: boolean;
  48743. /**
  48744. * Defines the clear coat tint of the material.
  48745. * This is only use if tint is enabled
  48746. */
  48747. tintColor: Color3;
  48748. /**
  48749. * Defines the distance at which the tint color should be found in the
  48750. * clear coat media.
  48751. * This is only use if tint is enabled
  48752. */
  48753. tintColorAtDistance: number;
  48754. /**
  48755. * Defines the clear coat layer thickness.
  48756. * This is only use if tint is enabled
  48757. */
  48758. tintThickness: number;
  48759. private _tintTexture;
  48760. /**
  48761. * Stores the clear tint values in a texture.
  48762. * rgb is tint
  48763. * a is a thickness factor
  48764. */
  48765. tintTexture: Nullable<BaseTexture>;
  48766. /** @hidden */
  48767. private _internalMarkAllSubMeshesAsTexturesDirty;
  48768. /** @hidden */
  48769. _markAllSubMeshesAsTexturesDirty(): void;
  48770. /**
  48771. * Instantiate a new istance of clear coat configuration.
  48772. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48773. */
  48774. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48775. /**
  48776. * Gets wehter the submesh is ready to be used or not.
  48777. * @param defines the list of "defines" to update.
  48778. * @param scene defines the scene the material belongs to.
  48779. * @param engine defines the engine the material belongs to.
  48780. * @param disableBumpMap defines wether the material disables bump or not.
  48781. * @returns - boolean indicating that the submesh is ready or not.
  48782. */
  48783. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48784. /**
  48785. * Checks to see if a texture is used in the material.
  48786. * @param defines the list of "defines" to update.
  48787. * @param scene defines the scene to the material belongs to.
  48788. */
  48789. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48790. /**
  48791. * Binds the material data.
  48792. * @param uniformBuffer defines the Uniform buffer to fill in.
  48793. * @param scene defines the scene the material belongs to.
  48794. * @param engine defines the engine the material belongs to.
  48795. * @param disableBumpMap defines wether the material disables bump or not.
  48796. * @param isFrozen defines wether the material is frozen or not.
  48797. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48798. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48799. */
  48800. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48801. /**
  48802. * Checks to see if a texture is used in the material.
  48803. * @param texture - Base texture to use.
  48804. * @returns - Boolean specifying if a texture is used in the material.
  48805. */
  48806. hasTexture(texture: BaseTexture): boolean;
  48807. /**
  48808. * Returns an array of the actively used textures.
  48809. * @param activeTextures Array of BaseTextures
  48810. */
  48811. getActiveTextures(activeTextures: BaseTexture[]): void;
  48812. /**
  48813. * Returns the animatable textures.
  48814. * @param animatables Array of animatable textures.
  48815. */
  48816. getAnimatables(animatables: IAnimatable[]): void;
  48817. /**
  48818. * Disposes the resources of the material.
  48819. * @param forceDisposeTextures - Forces the disposal of all textures.
  48820. */
  48821. dispose(forceDisposeTextures?: boolean): void;
  48822. /**
  48823. * Get the current class name of the texture useful for serialization or dynamic coding.
  48824. * @returns "PBRClearCoatConfiguration"
  48825. */
  48826. getClassName(): string;
  48827. /**
  48828. * Add fallbacks to the effect fallbacks list.
  48829. * @param defines defines the Base texture to use.
  48830. * @param fallbacks defines the current fallback list.
  48831. * @param currentRank defines the current fallback rank.
  48832. * @returns the new fallback rank.
  48833. */
  48834. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48835. /**
  48836. * Add the required uniforms to the current list.
  48837. * @param uniforms defines the current uniform list.
  48838. */
  48839. static AddUniforms(uniforms: string[]): void;
  48840. /**
  48841. * Add the required samplers to the current list.
  48842. * @param samplers defines the current sampler list.
  48843. */
  48844. static AddSamplers(samplers: string[]): void;
  48845. /**
  48846. * Add the required uniforms to the current buffer.
  48847. * @param uniformBuffer defines the current uniform buffer.
  48848. */
  48849. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48850. /**
  48851. * Makes a duplicate of the current configuration into another one.
  48852. * @param clearCoatConfiguration define the config where to copy the info
  48853. */
  48854. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48855. /**
  48856. * Serializes this clear coat configuration.
  48857. * @returns - An object with the serialized config.
  48858. */
  48859. serialize(): any;
  48860. /**
  48861. * Parses a anisotropy Configuration from a serialized object.
  48862. * @param source - Serialized object.
  48863. * @param scene Defines the scene we are parsing for
  48864. * @param rootUrl Defines the rootUrl to load from
  48865. */
  48866. parse(source: any, scene: Scene, rootUrl: string): void;
  48867. }
  48868. }
  48869. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48870. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48872. import { Vector2 } from "babylonjs/Maths/math.vector";
  48873. import { Scene } from "babylonjs/scene";
  48874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48875. import { Nullable } from "babylonjs/types";
  48876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48877. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48878. /**
  48879. * @hidden
  48880. */
  48881. export interface IMaterialAnisotropicDefines {
  48882. ANISOTROPIC: boolean;
  48883. ANISOTROPIC_TEXTURE: boolean;
  48884. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48885. MAINUV1: boolean;
  48886. _areTexturesDirty: boolean;
  48887. _needUVs: boolean;
  48888. }
  48889. /**
  48890. * Define the code related to the anisotropic parameters of the pbr material.
  48891. */
  48892. export class PBRAnisotropicConfiguration {
  48893. private _isEnabled;
  48894. /**
  48895. * Defines if the anisotropy is enabled in the material.
  48896. */
  48897. isEnabled: boolean;
  48898. /**
  48899. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48900. */
  48901. intensity: number;
  48902. /**
  48903. * Defines if the effect is along the tangents, bitangents or in between.
  48904. * By default, the effect is "strectching" the highlights along the tangents.
  48905. */
  48906. direction: Vector2;
  48907. private _texture;
  48908. /**
  48909. * Stores the anisotropy values in a texture.
  48910. * rg is direction (like normal from -1 to 1)
  48911. * b is a intensity
  48912. */
  48913. texture: Nullable<BaseTexture>;
  48914. /** @hidden */
  48915. private _internalMarkAllSubMeshesAsTexturesDirty;
  48916. /** @hidden */
  48917. _markAllSubMeshesAsTexturesDirty(): void;
  48918. /**
  48919. * Instantiate a new istance of anisotropy configuration.
  48920. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48921. */
  48922. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48923. /**
  48924. * Specifies that the submesh is ready to be used.
  48925. * @param defines the list of "defines" to update.
  48926. * @param scene defines the scene the material belongs to.
  48927. * @returns - boolean indicating that the submesh is ready or not.
  48928. */
  48929. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48930. /**
  48931. * Checks to see if a texture is used in the material.
  48932. * @param defines the list of "defines" to update.
  48933. * @param mesh the mesh we are preparing the defines for.
  48934. * @param scene defines the scene the material belongs to.
  48935. */
  48936. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48937. /**
  48938. * Binds the material data.
  48939. * @param uniformBuffer defines the Uniform buffer to fill in.
  48940. * @param scene defines the scene the material belongs to.
  48941. * @param isFrozen defines wether the material is frozen or not.
  48942. */
  48943. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48944. /**
  48945. * Checks to see if a texture is used in the material.
  48946. * @param texture - Base texture to use.
  48947. * @returns - Boolean specifying if a texture is used in the material.
  48948. */
  48949. hasTexture(texture: BaseTexture): boolean;
  48950. /**
  48951. * Returns an array of the actively used textures.
  48952. * @param activeTextures Array of BaseTextures
  48953. */
  48954. getActiveTextures(activeTextures: BaseTexture[]): void;
  48955. /**
  48956. * Returns the animatable textures.
  48957. * @param animatables Array of animatable textures.
  48958. */
  48959. getAnimatables(animatables: IAnimatable[]): void;
  48960. /**
  48961. * Disposes the resources of the material.
  48962. * @param forceDisposeTextures - Forces the disposal of all textures.
  48963. */
  48964. dispose(forceDisposeTextures?: boolean): void;
  48965. /**
  48966. * Get the current class name of the texture useful for serialization or dynamic coding.
  48967. * @returns "PBRAnisotropicConfiguration"
  48968. */
  48969. getClassName(): string;
  48970. /**
  48971. * Add fallbacks to the effect fallbacks list.
  48972. * @param defines defines the Base texture to use.
  48973. * @param fallbacks defines the current fallback list.
  48974. * @param currentRank defines the current fallback rank.
  48975. * @returns the new fallback rank.
  48976. */
  48977. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48978. /**
  48979. * Add the required uniforms to the current list.
  48980. * @param uniforms defines the current uniform list.
  48981. */
  48982. static AddUniforms(uniforms: string[]): void;
  48983. /**
  48984. * Add the required uniforms to the current buffer.
  48985. * @param uniformBuffer defines the current uniform buffer.
  48986. */
  48987. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48988. /**
  48989. * Add the required samplers to the current list.
  48990. * @param samplers defines the current sampler list.
  48991. */
  48992. static AddSamplers(samplers: string[]): void;
  48993. /**
  48994. * Makes a duplicate of the current configuration into another one.
  48995. * @param anisotropicConfiguration define the config where to copy the info
  48996. */
  48997. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48998. /**
  48999. * Serializes this anisotropy configuration.
  49000. * @returns - An object with the serialized config.
  49001. */
  49002. serialize(): any;
  49003. /**
  49004. * Parses a anisotropy Configuration from a serialized object.
  49005. * @param source - Serialized object.
  49006. * @param scene Defines the scene we are parsing for
  49007. * @param rootUrl Defines the rootUrl to load from
  49008. */
  49009. parse(source: any, scene: Scene, rootUrl: string): void;
  49010. }
  49011. }
  49012. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49013. import { Scene } from "babylonjs/scene";
  49014. /**
  49015. * @hidden
  49016. */
  49017. export interface IMaterialBRDFDefines {
  49018. BRDF_V_HEIGHT_CORRELATED: boolean;
  49019. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49020. SPHERICAL_HARMONICS: boolean;
  49021. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49022. /** @hidden */
  49023. _areMiscDirty: boolean;
  49024. }
  49025. /**
  49026. * Define the code related to the BRDF parameters of the pbr material.
  49027. */
  49028. export class PBRBRDFConfiguration {
  49029. /**
  49030. * Default value used for the energy conservation.
  49031. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49032. */
  49033. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49034. /**
  49035. * Default value used for the Smith Visibility Height Correlated mode.
  49036. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49037. */
  49038. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49039. /**
  49040. * Default value used for the IBL diffuse part.
  49041. * This can help switching back to the polynomials mode globally which is a tiny bit
  49042. * less GPU intensive at the drawback of a lower quality.
  49043. */
  49044. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49045. /**
  49046. * Default value used for activating energy conservation for the specular workflow.
  49047. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49048. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49049. */
  49050. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49051. private _useEnergyConservation;
  49052. /**
  49053. * Defines if the material uses energy conservation.
  49054. */
  49055. useEnergyConservation: boolean;
  49056. private _useSmithVisibilityHeightCorrelated;
  49057. /**
  49058. * LEGACY Mode set to false
  49059. * Defines if the material uses height smith correlated visibility term.
  49060. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49061. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49062. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49063. * Not relying on height correlated will also disable energy conservation.
  49064. */
  49065. useSmithVisibilityHeightCorrelated: boolean;
  49066. private _useSphericalHarmonics;
  49067. /**
  49068. * LEGACY Mode set to false
  49069. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49070. * diffuse part of the IBL.
  49071. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49072. * to the ground truth.
  49073. */
  49074. useSphericalHarmonics: boolean;
  49075. private _useSpecularGlossinessInputEnergyConservation;
  49076. /**
  49077. * Defines if the material uses energy conservation, when the specular workflow is active.
  49078. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49079. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49080. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49081. */
  49082. useSpecularGlossinessInputEnergyConservation: boolean;
  49083. /** @hidden */
  49084. private _internalMarkAllSubMeshesAsMiscDirty;
  49085. /** @hidden */
  49086. _markAllSubMeshesAsMiscDirty(): void;
  49087. /**
  49088. * Instantiate a new istance of clear coat configuration.
  49089. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49090. */
  49091. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49092. /**
  49093. * Checks to see if a texture is used in the material.
  49094. * @param defines the list of "defines" to update.
  49095. */
  49096. prepareDefines(defines: IMaterialBRDFDefines): void;
  49097. /**
  49098. * Get the current class name of the texture useful for serialization or dynamic coding.
  49099. * @returns "PBRClearCoatConfiguration"
  49100. */
  49101. getClassName(): string;
  49102. /**
  49103. * Makes a duplicate of the current configuration into another one.
  49104. * @param brdfConfiguration define the config where to copy the info
  49105. */
  49106. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49107. /**
  49108. * Serializes this BRDF configuration.
  49109. * @returns - An object with the serialized config.
  49110. */
  49111. serialize(): any;
  49112. /**
  49113. * Parses a anisotropy Configuration from a serialized object.
  49114. * @param source - Serialized object.
  49115. * @param scene Defines the scene we are parsing for
  49116. * @param rootUrl Defines the rootUrl to load from
  49117. */
  49118. parse(source: any, scene: Scene, rootUrl: string): void;
  49119. }
  49120. }
  49121. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49122. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49123. import { Color3 } from "babylonjs/Maths/math.color";
  49124. import { Scene } from "babylonjs/scene";
  49125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49126. import { Nullable } from "babylonjs/types";
  49127. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49128. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49129. /**
  49130. * @hidden
  49131. */
  49132. export interface IMaterialSheenDefines {
  49133. SHEEN: boolean;
  49134. SHEEN_TEXTURE: boolean;
  49135. SHEEN_TEXTUREDIRECTUV: number;
  49136. SHEEN_LINKWITHALBEDO: boolean;
  49137. /** @hidden */
  49138. _areTexturesDirty: boolean;
  49139. }
  49140. /**
  49141. * Define the code related to the Sheen parameters of the pbr material.
  49142. */
  49143. export class PBRSheenConfiguration {
  49144. private _isEnabled;
  49145. /**
  49146. * Defines if the material uses sheen.
  49147. */
  49148. isEnabled: boolean;
  49149. private _linkSheenWithAlbedo;
  49150. /**
  49151. * Defines if the sheen is linked to the sheen color.
  49152. */
  49153. linkSheenWithAlbedo: boolean;
  49154. /**
  49155. * Defines the sheen intensity.
  49156. */
  49157. intensity: number;
  49158. /**
  49159. * Defines the sheen color.
  49160. */
  49161. color: Color3;
  49162. private _texture;
  49163. /**
  49164. * Stores the sheen tint values in a texture.
  49165. * rgb is tint
  49166. * a is a intensity
  49167. */
  49168. texture: Nullable<BaseTexture>;
  49169. /** @hidden */
  49170. private _internalMarkAllSubMeshesAsTexturesDirty;
  49171. /** @hidden */
  49172. _markAllSubMeshesAsTexturesDirty(): void;
  49173. /**
  49174. * Instantiate a new istance of clear coat configuration.
  49175. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49176. */
  49177. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49178. /**
  49179. * Specifies that the submesh is ready to be used.
  49180. * @param defines the list of "defines" to update.
  49181. * @param scene defines the scene the material belongs to.
  49182. * @returns - boolean indicating that the submesh is ready or not.
  49183. */
  49184. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49185. /**
  49186. * Checks to see if a texture is used in the material.
  49187. * @param defines the list of "defines" to update.
  49188. * @param scene defines the scene the material belongs to.
  49189. */
  49190. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49191. /**
  49192. * Binds the material data.
  49193. * @param uniformBuffer defines the Uniform buffer to fill in.
  49194. * @param scene defines the scene the material belongs to.
  49195. * @param isFrozen defines wether the material is frozen or not.
  49196. */
  49197. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49198. /**
  49199. * Checks to see if a texture is used in the material.
  49200. * @param texture - Base texture to use.
  49201. * @returns - Boolean specifying if a texture is used in the material.
  49202. */
  49203. hasTexture(texture: BaseTexture): boolean;
  49204. /**
  49205. * Returns an array of the actively used textures.
  49206. * @param activeTextures Array of BaseTextures
  49207. */
  49208. getActiveTextures(activeTextures: BaseTexture[]): void;
  49209. /**
  49210. * Returns the animatable textures.
  49211. * @param animatables Array of animatable textures.
  49212. */
  49213. getAnimatables(animatables: IAnimatable[]): void;
  49214. /**
  49215. * Disposes the resources of the material.
  49216. * @param forceDisposeTextures - Forces the disposal of all textures.
  49217. */
  49218. dispose(forceDisposeTextures?: boolean): void;
  49219. /**
  49220. * Get the current class name of the texture useful for serialization or dynamic coding.
  49221. * @returns "PBRSheenConfiguration"
  49222. */
  49223. getClassName(): string;
  49224. /**
  49225. * Add fallbacks to the effect fallbacks list.
  49226. * @param defines defines the Base texture to use.
  49227. * @param fallbacks defines the current fallback list.
  49228. * @param currentRank defines the current fallback rank.
  49229. * @returns the new fallback rank.
  49230. */
  49231. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49232. /**
  49233. * Add the required uniforms to the current list.
  49234. * @param uniforms defines the current uniform list.
  49235. */
  49236. static AddUniforms(uniforms: string[]): void;
  49237. /**
  49238. * Add the required uniforms to the current buffer.
  49239. * @param uniformBuffer defines the current uniform buffer.
  49240. */
  49241. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49242. /**
  49243. * Add the required samplers to the current list.
  49244. * @param samplers defines the current sampler list.
  49245. */
  49246. static AddSamplers(samplers: string[]): void;
  49247. /**
  49248. * Makes a duplicate of the current configuration into another one.
  49249. * @param sheenConfiguration define the config where to copy the info
  49250. */
  49251. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49252. /**
  49253. * Serializes this BRDF configuration.
  49254. * @returns - An object with the serialized config.
  49255. */
  49256. serialize(): any;
  49257. /**
  49258. * Parses a anisotropy Configuration from a serialized object.
  49259. * @param source - Serialized object.
  49260. * @param scene Defines the scene we are parsing for
  49261. * @param rootUrl Defines the rootUrl to load from
  49262. */
  49263. parse(source: any, scene: Scene, rootUrl: string): void;
  49264. }
  49265. }
  49266. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49267. import { Nullable } from "babylonjs/types";
  49268. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49269. import { Color3 } from "babylonjs/Maths/math.color";
  49270. import { SmartArray } from "babylonjs/Misc/smartArray";
  49271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49273. import { Effect } from "babylonjs/Materials/effect";
  49274. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49275. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49276. import { Engine } from "babylonjs/Engines/engine";
  49277. import { Scene } from "babylonjs/scene";
  49278. /**
  49279. * @hidden
  49280. */
  49281. export interface IMaterialSubSurfaceDefines {
  49282. SUBSURFACE: boolean;
  49283. SS_REFRACTION: boolean;
  49284. SS_TRANSLUCENCY: boolean;
  49285. SS_SCATERRING: boolean;
  49286. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49287. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49288. SS_REFRACTIONMAP_3D: boolean;
  49289. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49290. SS_LODINREFRACTIONALPHA: boolean;
  49291. SS_GAMMAREFRACTION: boolean;
  49292. SS_RGBDREFRACTION: boolean;
  49293. SS_LINEARSPECULARREFRACTION: boolean;
  49294. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49295. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49296. /** @hidden */
  49297. _areTexturesDirty: boolean;
  49298. }
  49299. /**
  49300. * Define the code related to the sub surface parameters of the pbr material.
  49301. */
  49302. export class PBRSubSurfaceConfiguration {
  49303. private _isRefractionEnabled;
  49304. /**
  49305. * Defines if the refraction is enabled in the material.
  49306. */
  49307. isRefractionEnabled: boolean;
  49308. private _isTranslucencyEnabled;
  49309. /**
  49310. * Defines if the translucency is enabled in the material.
  49311. */
  49312. isTranslucencyEnabled: boolean;
  49313. private _isScatteringEnabled;
  49314. /**
  49315. * Defines the refraction intensity of the material.
  49316. * The refraction when enabled replaces the Diffuse part of the material.
  49317. * The intensity helps transitionning between diffuse and refraction.
  49318. */
  49319. refractionIntensity: number;
  49320. /**
  49321. * Defines the translucency intensity of the material.
  49322. * When translucency has been enabled, this defines how much of the "translucency"
  49323. * is addded to the diffuse part of the material.
  49324. */
  49325. translucencyIntensity: number;
  49326. /**
  49327. * Defines the scattering intensity of the material.
  49328. * When scattering has been enabled, this defines how much of the "scattered light"
  49329. * is addded to the diffuse part of the material.
  49330. */
  49331. scatteringIntensity: number;
  49332. private _thicknessTexture;
  49333. /**
  49334. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49335. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49336. * 0 would mean minimumThickness
  49337. * 1 would mean maximumThickness
  49338. * The other channels might be use as a mask to vary the different effects intensity.
  49339. */
  49340. thicknessTexture: Nullable<BaseTexture>;
  49341. private _refractionTexture;
  49342. /**
  49343. * Defines the texture to use for refraction.
  49344. */
  49345. refractionTexture: Nullable<BaseTexture>;
  49346. private _indexOfRefraction;
  49347. /**
  49348. * Defines the index of refraction used in the material.
  49349. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49350. */
  49351. indexOfRefraction: number;
  49352. private _invertRefractionY;
  49353. /**
  49354. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49355. */
  49356. invertRefractionY: boolean;
  49357. private _linkRefractionWithTransparency;
  49358. /**
  49359. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49360. * Materials half opaque for instance using refraction could benefit from this control.
  49361. */
  49362. linkRefractionWithTransparency: boolean;
  49363. /**
  49364. * Defines the minimum thickness stored in the thickness map.
  49365. * If no thickness map is defined, this value will be used to simulate thickness.
  49366. */
  49367. minimumThickness: number;
  49368. /**
  49369. * Defines the maximum thickness stored in the thickness map.
  49370. */
  49371. maximumThickness: number;
  49372. /**
  49373. * Defines the volume tint of the material.
  49374. * This is used for both translucency and scattering.
  49375. */
  49376. tintColor: Color3;
  49377. /**
  49378. * Defines the distance at which the tint color should be found in the media.
  49379. * This is used for refraction only.
  49380. */
  49381. tintColorAtDistance: number;
  49382. /**
  49383. * Defines how far each channel transmit through the media.
  49384. * It is defined as a color to simplify it selection.
  49385. */
  49386. diffusionDistance: Color3;
  49387. private _useMaskFromThicknessTexture;
  49388. /**
  49389. * Stores the intensity of the different subsurface effects in the thickness texture.
  49390. * * the green channel is the translucency intensity.
  49391. * * the blue channel is the scattering intensity.
  49392. * * the alpha channel is the refraction intensity.
  49393. */
  49394. useMaskFromThicknessTexture: boolean;
  49395. /** @hidden */
  49396. private _internalMarkAllSubMeshesAsTexturesDirty;
  49397. /** @hidden */
  49398. _markAllSubMeshesAsTexturesDirty(): void;
  49399. /**
  49400. * Instantiate a new istance of sub surface configuration.
  49401. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49402. */
  49403. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49404. /**
  49405. * Gets wehter the submesh is ready to be used or not.
  49406. * @param defines the list of "defines" to update.
  49407. * @param scene defines the scene the material belongs to.
  49408. * @returns - boolean indicating that the submesh is ready or not.
  49409. */
  49410. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49411. /**
  49412. * Checks to see if a texture is used in the material.
  49413. * @param defines the list of "defines" to update.
  49414. * @param scene defines the scene to the material belongs to.
  49415. */
  49416. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49417. /**
  49418. * Binds the material data.
  49419. * @param uniformBuffer defines the Uniform buffer to fill in.
  49420. * @param scene defines the scene the material belongs to.
  49421. * @param engine defines the engine the material belongs to.
  49422. * @param isFrozen defines wether the material is frozen or not.
  49423. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49424. */
  49425. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49426. /**
  49427. * Unbinds the material from the mesh.
  49428. * @param activeEffect defines the effect that should be unbound from.
  49429. * @returns true if unbound, otherwise false
  49430. */
  49431. unbind(activeEffect: Effect): boolean;
  49432. /**
  49433. * Returns the texture used for refraction or null if none is used.
  49434. * @param scene defines the scene the material belongs to.
  49435. * @returns - Refraction texture if present. If no refraction texture and refraction
  49436. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49437. */
  49438. private _getRefractionTexture;
  49439. /**
  49440. * Returns true if alpha blending should be disabled.
  49441. */
  49442. readonly disableAlphaBlending: boolean;
  49443. /**
  49444. * Fills the list of render target textures.
  49445. * @param renderTargets the list of render targets to update
  49446. */
  49447. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49448. /**
  49449. * Checks to see if a texture is used in the material.
  49450. * @param texture - Base texture to use.
  49451. * @returns - Boolean specifying if a texture is used in the material.
  49452. */
  49453. hasTexture(texture: BaseTexture): boolean;
  49454. /**
  49455. * Gets a boolean indicating that current material needs to register RTT
  49456. * @returns true if this uses a render target otherwise false.
  49457. */
  49458. hasRenderTargetTextures(): boolean;
  49459. /**
  49460. * Returns an array of the actively used textures.
  49461. * @param activeTextures Array of BaseTextures
  49462. */
  49463. getActiveTextures(activeTextures: BaseTexture[]): void;
  49464. /**
  49465. * Returns the animatable textures.
  49466. * @param animatables Array of animatable textures.
  49467. */
  49468. getAnimatables(animatables: IAnimatable[]): void;
  49469. /**
  49470. * Disposes the resources of the material.
  49471. * @param forceDisposeTextures - Forces the disposal of all textures.
  49472. */
  49473. dispose(forceDisposeTextures?: boolean): void;
  49474. /**
  49475. * Get the current class name of the texture useful for serialization or dynamic coding.
  49476. * @returns "PBRSubSurfaceConfiguration"
  49477. */
  49478. getClassName(): string;
  49479. /**
  49480. * Add fallbacks to the effect fallbacks list.
  49481. * @param defines defines the Base texture to use.
  49482. * @param fallbacks defines the current fallback list.
  49483. * @param currentRank defines the current fallback rank.
  49484. * @returns the new fallback rank.
  49485. */
  49486. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49487. /**
  49488. * Add the required uniforms to the current list.
  49489. * @param uniforms defines the current uniform list.
  49490. */
  49491. static AddUniforms(uniforms: string[]): void;
  49492. /**
  49493. * Add the required samplers to the current list.
  49494. * @param samplers defines the current sampler list.
  49495. */
  49496. static AddSamplers(samplers: string[]): void;
  49497. /**
  49498. * Add the required uniforms to the current buffer.
  49499. * @param uniformBuffer defines the current uniform buffer.
  49500. */
  49501. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49502. /**
  49503. * Makes a duplicate of the current configuration into another one.
  49504. * @param configuration define the config where to copy the info
  49505. */
  49506. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49507. /**
  49508. * Serializes this Sub Surface configuration.
  49509. * @returns - An object with the serialized config.
  49510. */
  49511. serialize(): any;
  49512. /**
  49513. * Parses a anisotropy Configuration from a serialized object.
  49514. * @param source - Serialized object.
  49515. * @param scene Defines the scene we are parsing for
  49516. * @param rootUrl Defines the rootUrl to load from
  49517. */
  49518. parse(source: any, scene: Scene, rootUrl: string): void;
  49519. }
  49520. }
  49521. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49522. /** @hidden */
  49523. export var pbrFragmentDeclaration: {
  49524. name: string;
  49525. shader: string;
  49526. };
  49527. }
  49528. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49529. /** @hidden */
  49530. export var pbrUboDeclaration: {
  49531. name: string;
  49532. shader: string;
  49533. };
  49534. }
  49535. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49536. /** @hidden */
  49537. export var pbrFragmentExtraDeclaration: {
  49538. name: string;
  49539. shader: string;
  49540. };
  49541. }
  49542. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49543. /** @hidden */
  49544. export var pbrFragmentSamplersDeclaration: {
  49545. name: string;
  49546. shader: string;
  49547. };
  49548. }
  49549. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49550. /** @hidden */
  49551. export var pbrHelperFunctions: {
  49552. name: string;
  49553. shader: string;
  49554. };
  49555. }
  49556. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49557. /** @hidden */
  49558. export var harmonicsFunctions: {
  49559. name: string;
  49560. shader: string;
  49561. };
  49562. }
  49563. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49564. /** @hidden */
  49565. export var pbrDirectLightingSetupFunctions: {
  49566. name: string;
  49567. shader: string;
  49568. };
  49569. }
  49570. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49571. /** @hidden */
  49572. export var pbrDirectLightingFalloffFunctions: {
  49573. name: string;
  49574. shader: string;
  49575. };
  49576. }
  49577. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49578. /** @hidden */
  49579. export var pbrBRDFFunctions: {
  49580. name: string;
  49581. shader: string;
  49582. };
  49583. }
  49584. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49585. /** @hidden */
  49586. export var pbrDirectLightingFunctions: {
  49587. name: string;
  49588. shader: string;
  49589. };
  49590. }
  49591. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49592. /** @hidden */
  49593. export var pbrIBLFunctions: {
  49594. name: string;
  49595. shader: string;
  49596. };
  49597. }
  49598. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49599. /** @hidden */
  49600. export var pbrDebug: {
  49601. name: string;
  49602. shader: string;
  49603. };
  49604. }
  49605. declare module "babylonjs/Shaders/pbr.fragment" {
  49606. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49607. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49608. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49609. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49610. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49611. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49612. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49613. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49614. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49616. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49617. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49618. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49619. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49620. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49621. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49622. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49623. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49624. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49625. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49626. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49627. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49628. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49629. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49630. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49631. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49632. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49633. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49634. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49635. /** @hidden */
  49636. export var pbrPixelShader: {
  49637. name: string;
  49638. shader: string;
  49639. };
  49640. }
  49641. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49642. /** @hidden */
  49643. export var pbrVertexDeclaration: {
  49644. name: string;
  49645. shader: string;
  49646. };
  49647. }
  49648. declare module "babylonjs/Shaders/pbr.vertex" {
  49649. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49650. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49651. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49652. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49653. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49654. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49655. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49656. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49657. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49658. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49659. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49660. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49661. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49662. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49663. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49664. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49665. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49666. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49667. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49668. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49669. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49670. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49671. /** @hidden */
  49672. export var pbrVertexShader: {
  49673. name: string;
  49674. shader: string;
  49675. };
  49676. }
  49677. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49678. import { Nullable } from "babylonjs/types";
  49679. import { Scene } from "babylonjs/scene";
  49680. import { Matrix } from "babylonjs/Maths/math.vector";
  49681. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49683. import { Mesh } from "babylonjs/Meshes/mesh";
  49684. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49685. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49686. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49687. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49688. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49689. import { Color3 } from "babylonjs/Maths/math.color";
  49690. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49691. import { Material } from "babylonjs/Materials/material";
  49692. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49693. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49695. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49696. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49697. import "babylonjs/Shaders/pbr.fragment";
  49698. import "babylonjs/Shaders/pbr.vertex";
  49699. /**
  49700. * Manages the defines for the PBR Material.
  49701. * @hidden
  49702. */
  49703. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49704. PBR: boolean;
  49705. MAINUV1: boolean;
  49706. MAINUV2: boolean;
  49707. UV1: boolean;
  49708. UV2: boolean;
  49709. ALBEDO: boolean;
  49710. ALBEDODIRECTUV: number;
  49711. VERTEXCOLOR: boolean;
  49712. AMBIENT: boolean;
  49713. AMBIENTDIRECTUV: number;
  49714. AMBIENTINGRAYSCALE: boolean;
  49715. OPACITY: boolean;
  49716. VERTEXALPHA: boolean;
  49717. OPACITYDIRECTUV: number;
  49718. OPACITYRGB: boolean;
  49719. ALPHATEST: boolean;
  49720. DEPTHPREPASS: boolean;
  49721. ALPHABLEND: boolean;
  49722. ALPHAFROMALBEDO: boolean;
  49723. ALPHATESTVALUE: string;
  49724. SPECULAROVERALPHA: boolean;
  49725. RADIANCEOVERALPHA: boolean;
  49726. ALPHAFRESNEL: boolean;
  49727. LINEARALPHAFRESNEL: boolean;
  49728. PREMULTIPLYALPHA: boolean;
  49729. EMISSIVE: boolean;
  49730. EMISSIVEDIRECTUV: number;
  49731. REFLECTIVITY: boolean;
  49732. REFLECTIVITYDIRECTUV: number;
  49733. SPECULARTERM: boolean;
  49734. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49735. MICROSURFACEAUTOMATIC: boolean;
  49736. LODBASEDMICROSFURACE: boolean;
  49737. MICROSURFACEMAP: boolean;
  49738. MICROSURFACEMAPDIRECTUV: number;
  49739. METALLICWORKFLOW: boolean;
  49740. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49741. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49742. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49743. AOSTOREINMETALMAPRED: boolean;
  49744. ENVIRONMENTBRDF: boolean;
  49745. ENVIRONMENTBRDF_RGBD: boolean;
  49746. NORMAL: boolean;
  49747. TANGENT: boolean;
  49748. BUMP: boolean;
  49749. BUMPDIRECTUV: number;
  49750. OBJECTSPACE_NORMALMAP: boolean;
  49751. PARALLAX: boolean;
  49752. PARALLAXOCCLUSION: boolean;
  49753. NORMALXYSCALE: boolean;
  49754. LIGHTMAP: boolean;
  49755. LIGHTMAPDIRECTUV: number;
  49756. USELIGHTMAPASSHADOWMAP: boolean;
  49757. GAMMALIGHTMAP: boolean;
  49758. RGBDLIGHTMAP: boolean;
  49759. REFLECTION: boolean;
  49760. REFLECTIONMAP_3D: boolean;
  49761. REFLECTIONMAP_SPHERICAL: boolean;
  49762. REFLECTIONMAP_PLANAR: boolean;
  49763. REFLECTIONMAP_CUBIC: boolean;
  49764. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49765. REFLECTIONMAP_PROJECTION: boolean;
  49766. REFLECTIONMAP_SKYBOX: boolean;
  49767. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49768. REFLECTIONMAP_EXPLICIT: boolean;
  49769. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49770. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49771. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49772. INVERTCUBICMAP: boolean;
  49773. USESPHERICALFROMREFLECTIONMAP: boolean;
  49774. USEIRRADIANCEMAP: boolean;
  49775. SPHERICAL_HARMONICS: boolean;
  49776. USESPHERICALINVERTEX: boolean;
  49777. REFLECTIONMAP_OPPOSITEZ: boolean;
  49778. LODINREFLECTIONALPHA: boolean;
  49779. GAMMAREFLECTION: boolean;
  49780. RGBDREFLECTION: boolean;
  49781. LINEARSPECULARREFLECTION: boolean;
  49782. RADIANCEOCCLUSION: boolean;
  49783. HORIZONOCCLUSION: boolean;
  49784. INSTANCES: boolean;
  49785. NUM_BONE_INFLUENCERS: number;
  49786. BonesPerMesh: number;
  49787. BONETEXTURE: boolean;
  49788. NONUNIFORMSCALING: boolean;
  49789. MORPHTARGETS: boolean;
  49790. MORPHTARGETS_NORMAL: boolean;
  49791. MORPHTARGETS_TANGENT: boolean;
  49792. MORPHTARGETS_UV: boolean;
  49793. NUM_MORPH_INFLUENCERS: number;
  49794. IMAGEPROCESSING: boolean;
  49795. VIGNETTE: boolean;
  49796. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49797. VIGNETTEBLENDMODEOPAQUE: boolean;
  49798. TONEMAPPING: boolean;
  49799. TONEMAPPING_ACES: boolean;
  49800. CONTRAST: boolean;
  49801. COLORCURVES: boolean;
  49802. COLORGRADING: boolean;
  49803. COLORGRADING3D: boolean;
  49804. SAMPLER3DGREENDEPTH: boolean;
  49805. SAMPLER3DBGRMAP: boolean;
  49806. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49807. EXPOSURE: boolean;
  49808. MULTIVIEW: boolean;
  49809. USEPHYSICALLIGHTFALLOFF: boolean;
  49810. USEGLTFLIGHTFALLOFF: boolean;
  49811. TWOSIDEDLIGHTING: boolean;
  49812. SHADOWFLOAT: boolean;
  49813. CLIPPLANE: boolean;
  49814. CLIPPLANE2: boolean;
  49815. CLIPPLANE3: boolean;
  49816. CLIPPLANE4: boolean;
  49817. POINTSIZE: boolean;
  49818. FOG: boolean;
  49819. LOGARITHMICDEPTH: boolean;
  49820. FORCENORMALFORWARD: boolean;
  49821. SPECULARAA: boolean;
  49822. CLEARCOAT: boolean;
  49823. CLEARCOAT_DEFAULTIOR: boolean;
  49824. CLEARCOAT_TEXTURE: boolean;
  49825. CLEARCOAT_TEXTUREDIRECTUV: number;
  49826. CLEARCOAT_BUMP: boolean;
  49827. CLEARCOAT_BUMPDIRECTUV: number;
  49828. CLEARCOAT_TINT: boolean;
  49829. CLEARCOAT_TINT_TEXTURE: boolean;
  49830. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49831. ANISOTROPIC: boolean;
  49832. ANISOTROPIC_TEXTURE: boolean;
  49833. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49834. BRDF_V_HEIGHT_CORRELATED: boolean;
  49835. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49836. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49837. SHEEN: boolean;
  49838. SHEEN_TEXTURE: boolean;
  49839. SHEEN_TEXTUREDIRECTUV: number;
  49840. SHEEN_LINKWITHALBEDO: boolean;
  49841. SUBSURFACE: boolean;
  49842. SS_REFRACTION: boolean;
  49843. SS_TRANSLUCENCY: boolean;
  49844. SS_SCATERRING: boolean;
  49845. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49846. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49847. SS_REFRACTIONMAP_3D: boolean;
  49848. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49849. SS_LODINREFRACTIONALPHA: boolean;
  49850. SS_GAMMAREFRACTION: boolean;
  49851. SS_RGBDREFRACTION: boolean;
  49852. SS_LINEARSPECULARREFRACTION: boolean;
  49853. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49854. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49855. UNLIT: boolean;
  49856. DEBUGMODE: number;
  49857. /**
  49858. * Initializes the PBR Material defines.
  49859. */
  49860. constructor();
  49861. /**
  49862. * Resets the PBR Material defines.
  49863. */
  49864. reset(): void;
  49865. }
  49866. /**
  49867. * The Physically based material base class of BJS.
  49868. *
  49869. * This offers the main features of a standard PBR material.
  49870. * For more information, please refer to the documentation :
  49871. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49872. */
  49873. export abstract class PBRBaseMaterial extends PushMaterial {
  49874. /**
  49875. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49876. */
  49877. static readonly PBRMATERIAL_OPAQUE: number;
  49878. /**
  49879. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49880. */
  49881. static readonly PBRMATERIAL_ALPHATEST: number;
  49882. /**
  49883. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49884. */
  49885. static readonly PBRMATERIAL_ALPHABLEND: number;
  49886. /**
  49887. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49888. * They are also discarded below the alpha cutoff threshold to improve performances.
  49889. */
  49890. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49891. /**
  49892. * Defines the default value of how much AO map is occluding the analytical lights
  49893. * (point spot...).
  49894. */
  49895. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49896. /**
  49897. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49898. */
  49899. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49900. /**
  49901. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49902. * to enhance interoperability with other engines.
  49903. */
  49904. static readonly LIGHTFALLOFF_GLTF: number;
  49905. /**
  49906. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49907. * to enhance interoperability with other materials.
  49908. */
  49909. static readonly LIGHTFALLOFF_STANDARD: number;
  49910. /**
  49911. * Intensity of the direct lights e.g. the four lights available in your scene.
  49912. * This impacts both the direct diffuse and specular highlights.
  49913. */
  49914. protected _directIntensity: number;
  49915. /**
  49916. * Intensity of the emissive part of the material.
  49917. * This helps controlling the emissive effect without modifying the emissive color.
  49918. */
  49919. protected _emissiveIntensity: number;
  49920. /**
  49921. * Intensity of the environment e.g. how much the environment will light the object
  49922. * either through harmonics for rough material or through the refelction for shiny ones.
  49923. */
  49924. protected _environmentIntensity: number;
  49925. /**
  49926. * This is a special control allowing the reduction of the specular highlights coming from the
  49927. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49928. */
  49929. protected _specularIntensity: number;
  49930. /**
  49931. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49932. */
  49933. private _lightingInfos;
  49934. /**
  49935. * Debug Control allowing disabling the bump map on this material.
  49936. */
  49937. protected _disableBumpMap: boolean;
  49938. /**
  49939. * AKA Diffuse Texture in standard nomenclature.
  49940. */
  49941. protected _albedoTexture: Nullable<BaseTexture>;
  49942. /**
  49943. * AKA Occlusion Texture in other nomenclature.
  49944. */
  49945. protected _ambientTexture: Nullable<BaseTexture>;
  49946. /**
  49947. * AKA Occlusion Texture Intensity in other nomenclature.
  49948. */
  49949. protected _ambientTextureStrength: number;
  49950. /**
  49951. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49952. * 1 means it completely occludes it
  49953. * 0 mean it has no impact
  49954. */
  49955. protected _ambientTextureImpactOnAnalyticalLights: number;
  49956. /**
  49957. * Stores the alpha values in a texture.
  49958. */
  49959. protected _opacityTexture: Nullable<BaseTexture>;
  49960. /**
  49961. * Stores the reflection values in a texture.
  49962. */
  49963. protected _reflectionTexture: Nullable<BaseTexture>;
  49964. /**
  49965. * Stores the emissive values in a texture.
  49966. */
  49967. protected _emissiveTexture: Nullable<BaseTexture>;
  49968. /**
  49969. * AKA Specular texture in other nomenclature.
  49970. */
  49971. protected _reflectivityTexture: Nullable<BaseTexture>;
  49972. /**
  49973. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49974. */
  49975. protected _metallicTexture: Nullable<BaseTexture>;
  49976. /**
  49977. * Specifies the metallic scalar of the metallic/roughness workflow.
  49978. * Can also be used to scale the metalness values of the metallic texture.
  49979. */
  49980. protected _metallic: Nullable<number>;
  49981. /**
  49982. * Specifies the roughness scalar of the metallic/roughness workflow.
  49983. * Can also be used to scale the roughness values of the metallic texture.
  49984. */
  49985. protected _roughness: Nullable<number>;
  49986. /**
  49987. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49988. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49989. */
  49990. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49991. /**
  49992. * Stores surface normal data used to displace a mesh in a texture.
  49993. */
  49994. protected _bumpTexture: Nullable<BaseTexture>;
  49995. /**
  49996. * Stores the pre-calculated light information of a mesh in a texture.
  49997. */
  49998. protected _lightmapTexture: Nullable<BaseTexture>;
  49999. /**
  50000. * The color of a material in ambient lighting.
  50001. */
  50002. protected _ambientColor: Color3;
  50003. /**
  50004. * AKA Diffuse Color in other nomenclature.
  50005. */
  50006. protected _albedoColor: Color3;
  50007. /**
  50008. * AKA Specular Color in other nomenclature.
  50009. */
  50010. protected _reflectivityColor: Color3;
  50011. /**
  50012. * The color applied when light is reflected from a material.
  50013. */
  50014. protected _reflectionColor: Color3;
  50015. /**
  50016. * The color applied when light is emitted from a material.
  50017. */
  50018. protected _emissiveColor: Color3;
  50019. /**
  50020. * AKA Glossiness in other nomenclature.
  50021. */
  50022. protected _microSurface: number;
  50023. /**
  50024. * Specifies that the material will use the light map as a show map.
  50025. */
  50026. protected _useLightmapAsShadowmap: boolean;
  50027. /**
  50028. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50029. * makes the reflect vector face the model (under horizon).
  50030. */
  50031. protected _useHorizonOcclusion: boolean;
  50032. /**
  50033. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50034. * too much the area relying on ambient texture to define their ambient occlusion.
  50035. */
  50036. protected _useRadianceOcclusion: boolean;
  50037. /**
  50038. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50039. */
  50040. protected _useAlphaFromAlbedoTexture: boolean;
  50041. /**
  50042. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50043. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50044. */
  50045. protected _useSpecularOverAlpha: boolean;
  50046. /**
  50047. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50048. */
  50049. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50050. /**
  50051. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50052. */
  50053. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50054. /**
  50055. * Specifies if the metallic texture contains the roughness information in its green channel.
  50056. */
  50057. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50058. /**
  50059. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50060. */
  50061. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50062. /**
  50063. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50064. */
  50065. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50066. /**
  50067. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50068. */
  50069. protected _useAmbientInGrayScale: boolean;
  50070. /**
  50071. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50072. * The material will try to infer what glossiness each pixel should be.
  50073. */
  50074. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50075. /**
  50076. * Defines the falloff type used in this material.
  50077. * It by default is Physical.
  50078. */
  50079. protected _lightFalloff: number;
  50080. /**
  50081. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50082. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50083. */
  50084. protected _useRadianceOverAlpha: boolean;
  50085. /**
  50086. * Allows using an object space normal map (instead of tangent space).
  50087. */
  50088. protected _useObjectSpaceNormalMap: boolean;
  50089. /**
  50090. * Allows using the bump map in parallax mode.
  50091. */
  50092. protected _useParallax: boolean;
  50093. /**
  50094. * Allows using the bump map in parallax occlusion mode.
  50095. */
  50096. protected _useParallaxOcclusion: boolean;
  50097. /**
  50098. * Controls the scale bias of the parallax mode.
  50099. */
  50100. protected _parallaxScaleBias: number;
  50101. /**
  50102. * If sets to true, disables all the lights affecting the material.
  50103. */
  50104. protected _disableLighting: boolean;
  50105. /**
  50106. * Number of Simultaneous lights allowed on the material.
  50107. */
  50108. protected _maxSimultaneousLights: number;
  50109. /**
  50110. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50111. */
  50112. protected _invertNormalMapX: boolean;
  50113. /**
  50114. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50115. */
  50116. protected _invertNormalMapY: boolean;
  50117. /**
  50118. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50119. */
  50120. protected _twoSidedLighting: boolean;
  50121. /**
  50122. * Defines the alpha limits in alpha test mode.
  50123. */
  50124. protected _alphaCutOff: number;
  50125. /**
  50126. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50127. */
  50128. protected _forceAlphaTest: boolean;
  50129. /**
  50130. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50131. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50132. */
  50133. protected _useAlphaFresnel: boolean;
  50134. /**
  50135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50136. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50137. */
  50138. protected _useLinearAlphaFresnel: boolean;
  50139. /**
  50140. * The transparency mode of the material.
  50141. */
  50142. protected _transparencyMode: Nullable<number>;
  50143. /**
  50144. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50145. * from cos thetav and roughness:
  50146. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50147. */
  50148. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50149. /**
  50150. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50151. */
  50152. protected _forceIrradianceInFragment: boolean;
  50153. /**
  50154. * Force normal to face away from face.
  50155. */
  50156. protected _forceNormalForward: boolean;
  50157. /**
  50158. * Enables specular anti aliasing in the PBR shader.
  50159. * It will both interacts on the Geometry for analytical and IBL lighting.
  50160. * It also prefilter the roughness map based on the bump values.
  50161. */
  50162. protected _enableSpecularAntiAliasing: boolean;
  50163. /**
  50164. * Default configuration related to image processing available in the PBR Material.
  50165. */
  50166. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50167. /**
  50168. * Keep track of the image processing observer to allow dispose and replace.
  50169. */
  50170. private _imageProcessingObserver;
  50171. /**
  50172. * Attaches a new image processing configuration to the PBR Material.
  50173. * @param configuration
  50174. */
  50175. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50176. /**
  50177. * Stores the available render targets.
  50178. */
  50179. private _renderTargets;
  50180. /**
  50181. * Sets the global ambient color for the material used in lighting calculations.
  50182. */
  50183. private _globalAmbientColor;
  50184. /**
  50185. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50186. */
  50187. private _useLogarithmicDepth;
  50188. /**
  50189. * If set to true, no lighting calculations will be applied.
  50190. */
  50191. private _unlit;
  50192. private _debugMode;
  50193. /**
  50194. * @hidden
  50195. * This is reserved for the inspector.
  50196. * Defines the material debug mode.
  50197. * It helps seeing only some components of the material while troubleshooting.
  50198. */
  50199. debugMode: number;
  50200. /**
  50201. * @hidden
  50202. * This is reserved for the inspector.
  50203. * Specify from where on screen the debug mode should start.
  50204. * The value goes from -1 (full screen) to 1 (not visible)
  50205. * It helps with side by side comparison against the final render
  50206. * This defaults to -1
  50207. */
  50208. private debugLimit;
  50209. /**
  50210. * @hidden
  50211. * This is reserved for the inspector.
  50212. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50213. * You can use the factor to better multiply the final value.
  50214. */
  50215. private debugFactor;
  50216. /**
  50217. * Defines the clear coat layer parameters for the material.
  50218. */
  50219. readonly clearCoat: PBRClearCoatConfiguration;
  50220. /**
  50221. * Defines the anisotropic parameters for the material.
  50222. */
  50223. readonly anisotropy: PBRAnisotropicConfiguration;
  50224. /**
  50225. * Defines the BRDF parameters for the material.
  50226. */
  50227. readonly brdf: PBRBRDFConfiguration;
  50228. /**
  50229. * Defines the Sheen parameters for the material.
  50230. */
  50231. readonly sheen: PBRSheenConfiguration;
  50232. /**
  50233. * Defines the SubSurface parameters for the material.
  50234. */
  50235. readonly subSurface: PBRSubSurfaceConfiguration;
  50236. /**
  50237. * Custom callback helping to override the default shader used in the material.
  50238. */
  50239. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50240. protected _rebuildInParallel: boolean;
  50241. /**
  50242. * Instantiates a new PBRMaterial instance.
  50243. *
  50244. * @param name The material name
  50245. * @param scene The scene the material will be use in.
  50246. */
  50247. constructor(name: string, scene: Scene);
  50248. /**
  50249. * Gets a boolean indicating that current material needs to register RTT
  50250. */
  50251. readonly hasRenderTargetTextures: boolean;
  50252. /**
  50253. * Gets the name of the material class.
  50254. */
  50255. getClassName(): string;
  50256. /**
  50257. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50258. */
  50259. /**
  50260. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50261. */
  50262. useLogarithmicDepth: boolean;
  50263. /**
  50264. * Gets the current transparency mode.
  50265. */
  50266. /**
  50267. * Sets the transparency mode of the material.
  50268. *
  50269. * | Value | Type | Description |
  50270. * | ----- | ----------------------------------- | ----------- |
  50271. * | 0 | OPAQUE | |
  50272. * | 1 | ALPHATEST | |
  50273. * | 2 | ALPHABLEND | |
  50274. * | 3 | ALPHATESTANDBLEND | |
  50275. *
  50276. */
  50277. transparencyMode: Nullable<number>;
  50278. /**
  50279. * Returns true if alpha blending should be disabled.
  50280. */
  50281. private readonly _disableAlphaBlending;
  50282. /**
  50283. * Specifies whether or not this material should be rendered in alpha blend mode.
  50284. */
  50285. needAlphaBlending(): boolean;
  50286. /**
  50287. * Specifies if the mesh will require alpha blending.
  50288. * @param mesh - BJS mesh.
  50289. */
  50290. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50291. /**
  50292. * Specifies whether or not this material should be rendered in alpha test mode.
  50293. */
  50294. needAlphaTesting(): boolean;
  50295. /**
  50296. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50297. */
  50298. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50299. /**
  50300. * Gets the texture used for the alpha test.
  50301. */
  50302. getAlphaTestTexture(): Nullable<BaseTexture>;
  50303. /**
  50304. * Specifies that the submesh is ready to be used.
  50305. * @param mesh - BJS mesh.
  50306. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50307. * @param useInstances - Specifies that instances should be used.
  50308. * @returns - boolean indicating that the submesh is ready or not.
  50309. */
  50310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50311. /**
  50312. * Specifies if the material uses metallic roughness workflow.
  50313. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50314. */
  50315. isMetallicWorkflow(): boolean;
  50316. private _prepareEffect;
  50317. private _prepareDefines;
  50318. /**
  50319. * Force shader compilation
  50320. */
  50321. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50322. clipPlane: boolean;
  50323. }>): void;
  50324. /**
  50325. * Initializes the uniform buffer layout for the shader.
  50326. */
  50327. buildUniformLayout(): void;
  50328. /**
  50329. * Unbinds the material from the mesh
  50330. */
  50331. unbind(): void;
  50332. /**
  50333. * Binds the submesh data.
  50334. * @param world - The world matrix.
  50335. * @param mesh - The BJS mesh.
  50336. * @param subMesh - A submesh of the BJS mesh.
  50337. */
  50338. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50339. /**
  50340. * Returns the animatable textures.
  50341. * @returns - Array of animatable textures.
  50342. */
  50343. getAnimatables(): IAnimatable[];
  50344. /**
  50345. * Returns the texture used for reflections.
  50346. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50347. */
  50348. private _getReflectionTexture;
  50349. /**
  50350. * Returns an array of the actively used textures.
  50351. * @returns - Array of BaseTextures
  50352. */
  50353. getActiveTextures(): BaseTexture[];
  50354. /**
  50355. * Checks to see if a texture is used in the material.
  50356. * @param texture - Base texture to use.
  50357. * @returns - Boolean specifying if a texture is used in the material.
  50358. */
  50359. hasTexture(texture: BaseTexture): boolean;
  50360. /**
  50361. * Disposes the resources of the material.
  50362. * @param forceDisposeEffect - Forces the disposal of effects.
  50363. * @param forceDisposeTextures - Forces the disposal of all textures.
  50364. */
  50365. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50366. }
  50367. }
  50368. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50369. import { Nullable } from "babylonjs/types";
  50370. import { Scene } from "babylonjs/scene";
  50371. import { Color3 } from "babylonjs/Maths/math.color";
  50372. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50373. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50375. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50376. /**
  50377. * The Physically based material of BJS.
  50378. *
  50379. * This offers the main features of a standard PBR material.
  50380. * For more information, please refer to the documentation :
  50381. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50382. */
  50383. export class PBRMaterial extends PBRBaseMaterial {
  50384. /**
  50385. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50386. */
  50387. static readonly PBRMATERIAL_OPAQUE: number;
  50388. /**
  50389. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50390. */
  50391. static readonly PBRMATERIAL_ALPHATEST: number;
  50392. /**
  50393. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50394. */
  50395. static readonly PBRMATERIAL_ALPHABLEND: number;
  50396. /**
  50397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50398. * They are also discarded below the alpha cutoff threshold to improve performances.
  50399. */
  50400. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50401. /**
  50402. * Defines the default value of how much AO map is occluding the analytical lights
  50403. * (point spot...).
  50404. */
  50405. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50406. /**
  50407. * Intensity of the direct lights e.g. the four lights available in your scene.
  50408. * This impacts both the direct diffuse and specular highlights.
  50409. */
  50410. directIntensity: number;
  50411. /**
  50412. * Intensity of the emissive part of the material.
  50413. * This helps controlling the emissive effect without modifying the emissive color.
  50414. */
  50415. emissiveIntensity: number;
  50416. /**
  50417. * Intensity of the environment e.g. how much the environment will light the object
  50418. * either through harmonics for rough material or through the refelction for shiny ones.
  50419. */
  50420. environmentIntensity: number;
  50421. /**
  50422. * This is a special control allowing the reduction of the specular highlights coming from the
  50423. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50424. */
  50425. specularIntensity: number;
  50426. /**
  50427. * Debug Control allowing disabling the bump map on this material.
  50428. */
  50429. disableBumpMap: boolean;
  50430. /**
  50431. * AKA Diffuse Texture in standard nomenclature.
  50432. */
  50433. albedoTexture: BaseTexture;
  50434. /**
  50435. * AKA Occlusion Texture in other nomenclature.
  50436. */
  50437. ambientTexture: BaseTexture;
  50438. /**
  50439. * AKA Occlusion Texture Intensity in other nomenclature.
  50440. */
  50441. ambientTextureStrength: number;
  50442. /**
  50443. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50444. * 1 means it completely occludes it
  50445. * 0 mean it has no impact
  50446. */
  50447. ambientTextureImpactOnAnalyticalLights: number;
  50448. /**
  50449. * Stores the alpha values in a texture.
  50450. */
  50451. opacityTexture: BaseTexture;
  50452. /**
  50453. * Stores the reflection values in a texture.
  50454. */
  50455. reflectionTexture: Nullable<BaseTexture>;
  50456. /**
  50457. * Stores the emissive values in a texture.
  50458. */
  50459. emissiveTexture: BaseTexture;
  50460. /**
  50461. * AKA Specular texture in other nomenclature.
  50462. */
  50463. reflectivityTexture: BaseTexture;
  50464. /**
  50465. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50466. */
  50467. metallicTexture: BaseTexture;
  50468. /**
  50469. * Specifies the metallic scalar of the metallic/roughness workflow.
  50470. * Can also be used to scale the metalness values of the metallic texture.
  50471. */
  50472. metallic: Nullable<number>;
  50473. /**
  50474. * Specifies the roughness scalar of the metallic/roughness workflow.
  50475. * Can also be used to scale the roughness values of the metallic texture.
  50476. */
  50477. roughness: Nullable<number>;
  50478. /**
  50479. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50480. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50481. */
  50482. microSurfaceTexture: BaseTexture;
  50483. /**
  50484. * Stores surface normal data used to displace a mesh in a texture.
  50485. */
  50486. bumpTexture: BaseTexture;
  50487. /**
  50488. * Stores the pre-calculated light information of a mesh in a texture.
  50489. */
  50490. lightmapTexture: BaseTexture;
  50491. /**
  50492. * Stores the refracted light information in a texture.
  50493. */
  50494. refractionTexture: Nullable<BaseTexture>;
  50495. /**
  50496. * The color of a material in ambient lighting.
  50497. */
  50498. ambientColor: Color3;
  50499. /**
  50500. * AKA Diffuse Color in other nomenclature.
  50501. */
  50502. albedoColor: Color3;
  50503. /**
  50504. * AKA Specular Color in other nomenclature.
  50505. */
  50506. reflectivityColor: Color3;
  50507. /**
  50508. * The color reflected from the material.
  50509. */
  50510. reflectionColor: Color3;
  50511. /**
  50512. * The color emitted from the material.
  50513. */
  50514. emissiveColor: Color3;
  50515. /**
  50516. * AKA Glossiness in other nomenclature.
  50517. */
  50518. microSurface: number;
  50519. /**
  50520. * source material index of refraction (IOR)' / 'destination material IOR.
  50521. */
  50522. indexOfRefraction: number;
  50523. /**
  50524. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50525. */
  50526. invertRefractionY: boolean;
  50527. /**
  50528. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50529. * Materials half opaque for instance using refraction could benefit from this control.
  50530. */
  50531. linkRefractionWithTransparency: boolean;
  50532. /**
  50533. * If true, the light map contains occlusion information instead of lighting info.
  50534. */
  50535. useLightmapAsShadowmap: boolean;
  50536. /**
  50537. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50538. */
  50539. useAlphaFromAlbedoTexture: boolean;
  50540. /**
  50541. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50542. */
  50543. forceAlphaTest: boolean;
  50544. /**
  50545. * Defines the alpha limits in alpha test mode.
  50546. */
  50547. alphaCutOff: number;
  50548. /**
  50549. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50550. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50551. */
  50552. useSpecularOverAlpha: boolean;
  50553. /**
  50554. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50555. */
  50556. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50557. /**
  50558. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50559. */
  50560. useRoughnessFromMetallicTextureAlpha: boolean;
  50561. /**
  50562. * Specifies if the metallic texture contains the roughness information in its green channel.
  50563. */
  50564. useRoughnessFromMetallicTextureGreen: boolean;
  50565. /**
  50566. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50567. */
  50568. useMetallnessFromMetallicTextureBlue: boolean;
  50569. /**
  50570. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50571. */
  50572. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50573. /**
  50574. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50575. */
  50576. useAmbientInGrayScale: boolean;
  50577. /**
  50578. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50579. * The material will try to infer what glossiness each pixel should be.
  50580. */
  50581. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50582. /**
  50583. * BJS is using an harcoded light falloff based on a manually sets up range.
  50584. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50585. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50586. */
  50587. /**
  50588. * BJS is using an harcoded light falloff based on a manually sets up range.
  50589. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50590. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50591. */
  50592. usePhysicalLightFalloff: boolean;
  50593. /**
  50594. * In order to support the falloff compatibility with gltf, a special mode has been added
  50595. * to reproduce the gltf light falloff.
  50596. */
  50597. /**
  50598. * In order to support the falloff compatibility with gltf, a special mode has been added
  50599. * to reproduce the gltf light falloff.
  50600. */
  50601. useGLTFLightFalloff: boolean;
  50602. /**
  50603. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50604. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50605. */
  50606. useRadianceOverAlpha: boolean;
  50607. /**
  50608. * Allows using an object space normal map (instead of tangent space).
  50609. */
  50610. useObjectSpaceNormalMap: boolean;
  50611. /**
  50612. * Allows using the bump map in parallax mode.
  50613. */
  50614. useParallax: boolean;
  50615. /**
  50616. * Allows using the bump map in parallax occlusion mode.
  50617. */
  50618. useParallaxOcclusion: boolean;
  50619. /**
  50620. * Controls the scale bias of the parallax mode.
  50621. */
  50622. parallaxScaleBias: number;
  50623. /**
  50624. * If sets to true, disables all the lights affecting the material.
  50625. */
  50626. disableLighting: boolean;
  50627. /**
  50628. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50629. */
  50630. forceIrradianceInFragment: boolean;
  50631. /**
  50632. * Number of Simultaneous lights allowed on the material.
  50633. */
  50634. maxSimultaneousLights: number;
  50635. /**
  50636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50637. */
  50638. invertNormalMapX: boolean;
  50639. /**
  50640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50641. */
  50642. invertNormalMapY: boolean;
  50643. /**
  50644. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50645. */
  50646. twoSidedLighting: boolean;
  50647. /**
  50648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50650. */
  50651. useAlphaFresnel: boolean;
  50652. /**
  50653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50655. */
  50656. useLinearAlphaFresnel: boolean;
  50657. /**
  50658. * Let user defines the brdf lookup texture used for IBL.
  50659. * A default 8bit version is embedded but you could point at :
  50660. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50661. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50662. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50663. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50664. */
  50665. environmentBRDFTexture: Nullable<BaseTexture>;
  50666. /**
  50667. * Force normal to face away from face.
  50668. */
  50669. forceNormalForward: boolean;
  50670. /**
  50671. * Enables specular anti aliasing in the PBR shader.
  50672. * It will both interacts on the Geometry for analytical and IBL lighting.
  50673. * It also prefilter the roughness map based on the bump values.
  50674. */
  50675. enableSpecularAntiAliasing: boolean;
  50676. /**
  50677. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50678. * makes the reflect vector face the model (under horizon).
  50679. */
  50680. useHorizonOcclusion: boolean;
  50681. /**
  50682. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50683. * too much the area relying on ambient texture to define their ambient occlusion.
  50684. */
  50685. useRadianceOcclusion: boolean;
  50686. /**
  50687. * If set to true, no lighting calculations will be applied.
  50688. */
  50689. unlit: boolean;
  50690. /**
  50691. * Gets the image processing configuration used either in this material.
  50692. */
  50693. /**
  50694. * Sets the Default image processing configuration used either in the this material.
  50695. *
  50696. * If sets to null, the scene one is in use.
  50697. */
  50698. imageProcessingConfiguration: ImageProcessingConfiguration;
  50699. /**
  50700. * Gets wether the color curves effect is enabled.
  50701. */
  50702. /**
  50703. * Sets wether the color curves effect is enabled.
  50704. */
  50705. cameraColorCurvesEnabled: boolean;
  50706. /**
  50707. * Gets wether the color grading effect is enabled.
  50708. */
  50709. /**
  50710. * Gets wether the color grading effect is enabled.
  50711. */
  50712. cameraColorGradingEnabled: boolean;
  50713. /**
  50714. * Gets wether tonemapping is enabled or not.
  50715. */
  50716. /**
  50717. * Sets wether tonemapping is enabled or not
  50718. */
  50719. cameraToneMappingEnabled: boolean;
  50720. /**
  50721. * The camera exposure used on this material.
  50722. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50723. * This corresponds to a photographic exposure.
  50724. */
  50725. /**
  50726. * The camera exposure used on this material.
  50727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50728. * This corresponds to a photographic exposure.
  50729. */
  50730. cameraExposure: number;
  50731. /**
  50732. * Gets The camera contrast used on this material.
  50733. */
  50734. /**
  50735. * Sets The camera contrast used on this material.
  50736. */
  50737. cameraContrast: number;
  50738. /**
  50739. * Gets the Color Grading 2D Lookup Texture.
  50740. */
  50741. /**
  50742. * Sets the Color Grading 2D Lookup Texture.
  50743. */
  50744. cameraColorGradingTexture: Nullable<BaseTexture>;
  50745. /**
  50746. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50747. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50748. * 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;
  50749. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50750. */
  50751. /**
  50752. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50753. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50754. * 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;
  50755. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50756. */
  50757. cameraColorCurves: Nullable<ColorCurves>;
  50758. /**
  50759. * Instantiates a new PBRMaterial instance.
  50760. *
  50761. * @param name The material name
  50762. * @param scene The scene the material will be use in.
  50763. */
  50764. constructor(name: string, scene: Scene);
  50765. /**
  50766. * Returns the name of this material class.
  50767. */
  50768. getClassName(): string;
  50769. /**
  50770. * Makes a duplicate of the current material.
  50771. * @param name - name to use for the new material.
  50772. */
  50773. clone(name: string): PBRMaterial;
  50774. /**
  50775. * Serializes this PBR Material.
  50776. * @returns - An object with the serialized material.
  50777. */
  50778. serialize(): any;
  50779. /**
  50780. * Parses a PBR Material from a serialized object.
  50781. * @param source - Serialized object.
  50782. * @param scene - BJS scene instance.
  50783. * @param rootUrl - url for the scene object
  50784. * @returns - PBRMaterial
  50785. */
  50786. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50787. }
  50788. }
  50789. declare module "babylonjs/Misc/dds" {
  50790. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50791. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50792. import { Nullable } from "babylonjs/types";
  50793. import { Scene } from "babylonjs/scene";
  50794. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50795. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50796. /**
  50797. * Direct draw surface info
  50798. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50799. */
  50800. export interface DDSInfo {
  50801. /**
  50802. * Width of the texture
  50803. */
  50804. width: number;
  50805. /**
  50806. * Width of the texture
  50807. */
  50808. height: number;
  50809. /**
  50810. * Number of Mipmaps for the texture
  50811. * @see https://en.wikipedia.org/wiki/Mipmap
  50812. */
  50813. mipmapCount: number;
  50814. /**
  50815. * If the textures format is a known fourCC format
  50816. * @see https://www.fourcc.org/
  50817. */
  50818. isFourCC: boolean;
  50819. /**
  50820. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50821. */
  50822. isRGB: boolean;
  50823. /**
  50824. * If the texture is a lumincance format
  50825. */
  50826. isLuminance: boolean;
  50827. /**
  50828. * If this is a cube texture
  50829. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50830. */
  50831. isCube: boolean;
  50832. /**
  50833. * If the texture is a compressed format eg. FOURCC_DXT1
  50834. */
  50835. isCompressed: boolean;
  50836. /**
  50837. * The dxgiFormat of the texture
  50838. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50839. */
  50840. dxgiFormat: number;
  50841. /**
  50842. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50843. */
  50844. textureType: number;
  50845. /**
  50846. * Sphericle polynomial created for the dds texture
  50847. */
  50848. sphericalPolynomial?: SphericalPolynomial;
  50849. }
  50850. /**
  50851. * Class used to provide DDS decompression tools
  50852. */
  50853. export class DDSTools {
  50854. /**
  50855. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50856. */
  50857. static StoreLODInAlphaChannel: boolean;
  50858. /**
  50859. * Gets DDS information from an array buffer
  50860. * @param arrayBuffer defines the array buffer to read data from
  50861. * @returns the DDS information
  50862. */
  50863. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50864. private static _FloatView;
  50865. private static _Int32View;
  50866. private static _ToHalfFloat;
  50867. private static _FromHalfFloat;
  50868. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50869. private static _GetHalfFloatRGBAArrayBuffer;
  50870. private static _GetFloatRGBAArrayBuffer;
  50871. private static _GetFloatAsUIntRGBAArrayBuffer;
  50872. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50873. private static _GetRGBAArrayBuffer;
  50874. private static _ExtractLongWordOrder;
  50875. private static _GetRGBArrayBuffer;
  50876. private static _GetLuminanceArrayBuffer;
  50877. /**
  50878. * Uploads DDS Levels to a Babylon Texture
  50879. * @hidden
  50880. */
  50881. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50882. }
  50883. module "babylonjs/Engines/thinEngine" {
  50884. interface ThinEngine {
  50885. /**
  50886. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50887. * @param rootUrl defines the url where the file to load is located
  50888. * @param scene defines the current scene
  50889. * @param lodScale defines scale to apply to the mip map selection
  50890. * @param lodOffset defines offset to apply to the mip map selection
  50891. * @param onLoad defines an optional callback raised when the texture is loaded
  50892. * @param onError defines an optional callback raised if there is an issue to load the texture
  50893. * @param format defines the format of the data
  50894. * @param forcedExtension defines the extension to use to pick the right loader
  50895. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50896. * @returns the cube texture as an InternalTexture
  50897. */
  50898. 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;
  50899. }
  50900. }
  50901. }
  50902. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50903. import { Nullable } from "babylonjs/types";
  50904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50905. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50906. /**
  50907. * Implementation of the DDS Texture Loader.
  50908. * @hidden
  50909. */
  50910. export class _DDSTextureLoader implements IInternalTextureLoader {
  50911. /**
  50912. * Defines wether the loader supports cascade loading the different faces.
  50913. */
  50914. readonly supportCascades: boolean;
  50915. /**
  50916. * This returns if the loader support the current file information.
  50917. * @param extension defines the file extension of the file being loaded
  50918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50919. * @param fallback defines the fallback internal texture if any
  50920. * @param isBase64 defines whether the texture is encoded as a base64
  50921. * @param isBuffer defines whether the texture data are stored as a buffer
  50922. * @returns true if the loader can load the specified file
  50923. */
  50924. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50925. /**
  50926. * Transform the url before loading if required.
  50927. * @param rootUrl the url of the texture
  50928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50929. * @returns the transformed texture
  50930. */
  50931. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50932. /**
  50933. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50934. * @param rootUrl the url of the texture
  50935. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50936. * @returns the fallback texture
  50937. */
  50938. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50939. /**
  50940. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50941. * @param data contains the texture data
  50942. * @param texture defines the BabylonJS internal texture
  50943. * @param createPolynomials will be true if polynomials have been requested
  50944. * @param onLoad defines the callback to trigger once the texture is ready
  50945. * @param onError defines the callback to trigger in case of error
  50946. */
  50947. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50948. /**
  50949. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50950. * @param data contains the texture data
  50951. * @param texture defines the BabylonJS internal texture
  50952. * @param callback defines the method to call once ready to upload
  50953. */
  50954. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50955. }
  50956. }
  50957. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50958. import { Nullable } from "babylonjs/types";
  50959. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50960. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50961. /**
  50962. * Implementation of the ENV Texture Loader.
  50963. * @hidden
  50964. */
  50965. export class _ENVTextureLoader implements IInternalTextureLoader {
  50966. /**
  50967. * Defines wether the loader supports cascade loading the different faces.
  50968. */
  50969. readonly supportCascades: boolean;
  50970. /**
  50971. * This returns if the loader support the current file information.
  50972. * @param extension defines the file extension of the file being loaded
  50973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50974. * @param fallback defines the fallback internal texture if any
  50975. * @param isBase64 defines whether the texture is encoded as a base64
  50976. * @param isBuffer defines whether the texture data are stored as a buffer
  50977. * @returns true if the loader can load the specified file
  50978. */
  50979. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50980. /**
  50981. * Transform the url before loading if required.
  50982. * @param rootUrl the url of the texture
  50983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50984. * @returns the transformed texture
  50985. */
  50986. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50987. /**
  50988. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50989. * @param rootUrl the url of the texture
  50990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50991. * @returns the fallback texture
  50992. */
  50993. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50994. /**
  50995. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50996. * @param data contains the texture data
  50997. * @param texture defines the BabylonJS internal texture
  50998. * @param createPolynomials will be true if polynomials have been requested
  50999. * @param onLoad defines the callback to trigger once the texture is ready
  51000. * @param onError defines the callback to trigger in case of error
  51001. */
  51002. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51003. /**
  51004. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51005. * @param data contains the texture data
  51006. * @param texture defines the BabylonJS internal texture
  51007. * @param callback defines the method to call once ready to upload
  51008. */
  51009. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51010. }
  51011. }
  51012. declare module "babylonjs/Misc/khronosTextureContainer" {
  51013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51014. /**
  51015. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51016. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51017. */
  51018. export class KhronosTextureContainer {
  51019. /** contents of the KTX container file */
  51020. arrayBuffer: any;
  51021. private static HEADER_LEN;
  51022. private static COMPRESSED_2D;
  51023. private static COMPRESSED_3D;
  51024. private static TEX_2D;
  51025. private static TEX_3D;
  51026. /**
  51027. * Gets the openGL type
  51028. */
  51029. glType: number;
  51030. /**
  51031. * Gets the openGL type size
  51032. */
  51033. glTypeSize: number;
  51034. /**
  51035. * Gets the openGL format
  51036. */
  51037. glFormat: number;
  51038. /**
  51039. * Gets the openGL internal format
  51040. */
  51041. glInternalFormat: number;
  51042. /**
  51043. * Gets the base internal format
  51044. */
  51045. glBaseInternalFormat: number;
  51046. /**
  51047. * Gets image width in pixel
  51048. */
  51049. pixelWidth: number;
  51050. /**
  51051. * Gets image height in pixel
  51052. */
  51053. pixelHeight: number;
  51054. /**
  51055. * Gets image depth in pixels
  51056. */
  51057. pixelDepth: number;
  51058. /**
  51059. * Gets the number of array elements
  51060. */
  51061. numberOfArrayElements: number;
  51062. /**
  51063. * Gets the number of faces
  51064. */
  51065. numberOfFaces: number;
  51066. /**
  51067. * Gets the number of mipmap levels
  51068. */
  51069. numberOfMipmapLevels: number;
  51070. /**
  51071. * Gets the bytes of key value data
  51072. */
  51073. bytesOfKeyValueData: number;
  51074. /**
  51075. * Gets the load type
  51076. */
  51077. loadType: number;
  51078. /**
  51079. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51080. */
  51081. isInvalid: boolean;
  51082. /**
  51083. * Creates a new KhronosTextureContainer
  51084. * @param arrayBuffer contents of the KTX container file
  51085. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51086. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51087. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51088. */
  51089. constructor(
  51090. /** contents of the KTX container file */
  51091. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51092. /**
  51093. * Uploads KTX content to a Babylon Texture.
  51094. * It is assumed that the texture has already been created & is currently bound
  51095. * @hidden
  51096. */
  51097. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51098. private _upload2DCompressedLevels;
  51099. }
  51100. }
  51101. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51102. import { Nullable } from "babylonjs/types";
  51103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51104. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51105. /**
  51106. * Implementation of the KTX Texture Loader.
  51107. * @hidden
  51108. */
  51109. export class _KTXTextureLoader implements IInternalTextureLoader {
  51110. /**
  51111. * Defines wether the loader supports cascade loading the different faces.
  51112. */
  51113. readonly supportCascades: boolean;
  51114. /**
  51115. * This returns if the loader support the current file information.
  51116. * @param extension defines the file extension of the file being loaded
  51117. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51118. * @param fallback defines the fallback internal texture if any
  51119. * @param isBase64 defines whether the texture is encoded as a base64
  51120. * @param isBuffer defines whether the texture data are stored as a buffer
  51121. * @returns true if the loader can load the specified file
  51122. */
  51123. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51124. /**
  51125. * Transform the url before loading if required.
  51126. * @param rootUrl the url of the texture
  51127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51128. * @returns the transformed texture
  51129. */
  51130. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51131. /**
  51132. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51133. * @param rootUrl the url of the texture
  51134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51135. * @returns the fallback texture
  51136. */
  51137. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51138. /**
  51139. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51140. * @param data contains the texture data
  51141. * @param texture defines the BabylonJS internal texture
  51142. * @param createPolynomials will be true if polynomials have been requested
  51143. * @param onLoad defines the callback to trigger once the texture is ready
  51144. * @param onError defines the callback to trigger in case of error
  51145. */
  51146. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51147. /**
  51148. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51149. * @param data contains the texture data
  51150. * @param texture defines the BabylonJS internal texture
  51151. * @param callback defines the method to call once ready to upload
  51152. */
  51153. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51154. }
  51155. }
  51156. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51157. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51158. import { Scene } from "babylonjs/scene";
  51159. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51160. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51161. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51162. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51163. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  51164. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51166. /**
  51167. * Options for the default xr helper
  51168. */
  51169. export class WebXRDefaultExperienceOptions {
  51170. /**
  51171. * Floor meshes that should be used for teleporting
  51172. */
  51173. floorMeshes: Array<AbstractMesh>;
  51174. }
  51175. /**
  51176. * Default experience which provides a similar setup to the previous webVRExperience
  51177. */
  51178. export class WebXRDefaultExperience {
  51179. /**
  51180. * Base experience
  51181. */
  51182. baseExperience: WebXRExperienceHelper;
  51183. /**
  51184. * Input experience extension
  51185. */
  51186. input: WebXRInput;
  51187. /**
  51188. * Loads the controller models
  51189. */
  51190. controllerModelLoader: WebXRControllerModelLoader;
  51191. /**
  51192. * Enables laser pointer and selection
  51193. */
  51194. pointerSelection: WebXRControllerPointerSelection;
  51195. /**
  51196. * Enables teleportation
  51197. */
  51198. teleportation: WebXRControllerTeleportation;
  51199. /**
  51200. * Enables ui for enetering/exiting xr
  51201. */
  51202. enterExitUI: WebXREnterExitUI;
  51203. /**
  51204. * Default output canvas xr should render to
  51205. */
  51206. outputCanvas: WebXRManagedOutputCanvas;
  51207. /**
  51208. * Creates the default xr experience
  51209. * @param scene scene
  51210. * @param options options for basic configuration
  51211. * @returns resulting WebXRDefaultExperience
  51212. */
  51213. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51214. private constructor();
  51215. /**
  51216. * DIsposes of the experience helper
  51217. */
  51218. dispose(): void;
  51219. }
  51220. }
  51221. declare module "babylonjs/Helpers/sceneHelpers" {
  51222. import { Nullable } from "babylonjs/types";
  51223. import { Mesh } from "babylonjs/Meshes/mesh";
  51224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51225. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51226. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51227. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51228. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51229. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51230. import "babylonjs/Meshes/Builders/boxBuilder";
  51231. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51232. /** @hidden */
  51233. export var _forceSceneHelpersToBundle: boolean;
  51234. module "babylonjs/scene" {
  51235. interface Scene {
  51236. /**
  51237. * Creates a default light for the scene.
  51238. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51239. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51240. */
  51241. createDefaultLight(replace?: boolean): void;
  51242. /**
  51243. * Creates a default camera for the scene.
  51244. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51245. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51246. * @param replace has default false, when true replaces the active camera in the scene
  51247. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51248. */
  51249. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51250. /**
  51251. * Creates a default camera and a default light.
  51252. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51253. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51254. * @param replace has the default false, when true replaces the active camera/light in the scene
  51255. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51256. */
  51257. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51258. /**
  51259. * Creates a new sky box
  51260. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51261. * @param environmentTexture defines the texture to use as environment texture
  51262. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51263. * @param scale defines the overall scale of the skybox
  51264. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51265. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51266. * @returns a new mesh holding the sky box
  51267. */
  51268. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51269. /**
  51270. * Creates a new environment
  51271. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51272. * @param options defines the options you can use to configure the environment
  51273. * @returns the new EnvironmentHelper
  51274. */
  51275. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51276. /**
  51277. * Creates a new VREXperienceHelper
  51278. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51279. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51280. * @returns a new VREXperienceHelper
  51281. */
  51282. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51283. /**
  51284. * Creates a new WebXRDefaultExperience
  51285. * @see http://doc.babylonjs.com/how_to/webxr
  51286. * @param options experience options
  51287. * @returns a promise for a new WebXRDefaultExperience
  51288. */
  51289. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51290. }
  51291. }
  51292. }
  51293. declare module "babylonjs/Helpers/videoDome" {
  51294. import { Scene } from "babylonjs/scene";
  51295. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51296. import { Mesh } from "babylonjs/Meshes/mesh";
  51297. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51298. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51299. import "babylonjs/Meshes/Builders/sphereBuilder";
  51300. /**
  51301. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51302. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51303. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51304. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51305. */
  51306. export class VideoDome extends TransformNode {
  51307. /**
  51308. * Define the video source as a Monoscopic panoramic 360 video.
  51309. */
  51310. static readonly MODE_MONOSCOPIC: number;
  51311. /**
  51312. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51313. */
  51314. static readonly MODE_TOPBOTTOM: number;
  51315. /**
  51316. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51317. */
  51318. static readonly MODE_SIDEBYSIDE: number;
  51319. private _halfDome;
  51320. private _useDirectMapping;
  51321. /**
  51322. * The video texture being displayed on the sphere
  51323. */
  51324. protected _videoTexture: VideoTexture;
  51325. /**
  51326. * Gets the video texture being displayed on the sphere
  51327. */
  51328. readonly videoTexture: VideoTexture;
  51329. /**
  51330. * The skybox material
  51331. */
  51332. protected _material: BackgroundMaterial;
  51333. /**
  51334. * The surface used for the skybox
  51335. */
  51336. protected _mesh: Mesh;
  51337. /**
  51338. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51339. */
  51340. private _halfDomeMask;
  51341. /**
  51342. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51343. * Also see the options.resolution property.
  51344. */
  51345. fovMultiplier: number;
  51346. private _videoMode;
  51347. /**
  51348. * Gets or set the current video mode for the video. It can be:
  51349. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51350. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51351. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51352. */
  51353. videoMode: number;
  51354. /**
  51355. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51356. *
  51357. */
  51358. /**
  51359. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51360. */
  51361. halfDome: boolean;
  51362. /**
  51363. * Oberserver used in Stereoscopic VR Mode.
  51364. */
  51365. private _onBeforeCameraRenderObserver;
  51366. /**
  51367. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51368. * @param name Element's name, child elements will append suffixes for their own names.
  51369. * @param urlsOrVideo defines the url(s) or the video element to use
  51370. * @param options An object containing optional or exposed sub element properties
  51371. */
  51372. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51373. resolution?: number;
  51374. clickToPlay?: boolean;
  51375. autoPlay?: boolean;
  51376. loop?: boolean;
  51377. size?: number;
  51378. poster?: string;
  51379. faceForward?: boolean;
  51380. useDirectMapping?: boolean;
  51381. halfDomeMode?: boolean;
  51382. }, scene: Scene);
  51383. private _changeVideoMode;
  51384. /**
  51385. * Releases resources associated with this node.
  51386. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51387. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51388. */
  51389. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51390. }
  51391. }
  51392. declare module "babylonjs/Helpers/index" {
  51393. export * from "babylonjs/Helpers/environmentHelper";
  51394. export * from "babylonjs/Helpers/photoDome";
  51395. export * from "babylonjs/Helpers/sceneHelpers";
  51396. export * from "babylonjs/Helpers/videoDome";
  51397. }
  51398. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51399. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51400. import { IDisposable } from "babylonjs/scene";
  51401. import { Engine } from "babylonjs/Engines/engine";
  51402. /**
  51403. * This class can be used to get instrumentation data from a Babylon engine
  51404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51405. */
  51406. export class EngineInstrumentation implements IDisposable {
  51407. /**
  51408. * Define the instrumented engine.
  51409. */
  51410. engine: Engine;
  51411. private _captureGPUFrameTime;
  51412. private _gpuFrameTimeToken;
  51413. private _gpuFrameTime;
  51414. private _captureShaderCompilationTime;
  51415. private _shaderCompilationTime;
  51416. private _onBeginFrameObserver;
  51417. private _onEndFrameObserver;
  51418. private _onBeforeShaderCompilationObserver;
  51419. private _onAfterShaderCompilationObserver;
  51420. /**
  51421. * Gets the perf counter used for GPU frame time
  51422. */
  51423. readonly gpuFrameTimeCounter: PerfCounter;
  51424. /**
  51425. * Gets the GPU frame time capture status
  51426. */
  51427. /**
  51428. * Enable or disable the GPU frame time capture
  51429. */
  51430. captureGPUFrameTime: boolean;
  51431. /**
  51432. * Gets the perf counter used for shader compilation time
  51433. */
  51434. readonly shaderCompilationTimeCounter: PerfCounter;
  51435. /**
  51436. * Gets the shader compilation time capture status
  51437. */
  51438. /**
  51439. * Enable or disable the shader compilation time capture
  51440. */
  51441. captureShaderCompilationTime: boolean;
  51442. /**
  51443. * Instantiates a new engine instrumentation.
  51444. * This class can be used to get instrumentation data from a Babylon engine
  51445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51446. * @param engine Defines the engine to instrument
  51447. */
  51448. constructor(
  51449. /**
  51450. * Define the instrumented engine.
  51451. */
  51452. engine: Engine);
  51453. /**
  51454. * Dispose and release associated resources.
  51455. */
  51456. dispose(): void;
  51457. }
  51458. }
  51459. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51460. import { Scene, IDisposable } from "babylonjs/scene";
  51461. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51462. /**
  51463. * This class can be used to get instrumentation data from a Babylon engine
  51464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51465. */
  51466. export class SceneInstrumentation implements IDisposable {
  51467. /**
  51468. * Defines the scene to instrument
  51469. */
  51470. scene: Scene;
  51471. private _captureActiveMeshesEvaluationTime;
  51472. private _activeMeshesEvaluationTime;
  51473. private _captureRenderTargetsRenderTime;
  51474. private _renderTargetsRenderTime;
  51475. private _captureFrameTime;
  51476. private _frameTime;
  51477. private _captureRenderTime;
  51478. private _renderTime;
  51479. private _captureInterFrameTime;
  51480. private _interFrameTime;
  51481. private _captureParticlesRenderTime;
  51482. private _particlesRenderTime;
  51483. private _captureSpritesRenderTime;
  51484. private _spritesRenderTime;
  51485. private _capturePhysicsTime;
  51486. private _physicsTime;
  51487. private _captureAnimationsTime;
  51488. private _animationsTime;
  51489. private _captureCameraRenderTime;
  51490. private _cameraRenderTime;
  51491. private _onBeforeActiveMeshesEvaluationObserver;
  51492. private _onAfterActiveMeshesEvaluationObserver;
  51493. private _onBeforeRenderTargetsRenderObserver;
  51494. private _onAfterRenderTargetsRenderObserver;
  51495. private _onAfterRenderObserver;
  51496. private _onBeforeDrawPhaseObserver;
  51497. private _onAfterDrawPhaseObserver;
  51498. private _onBeforeAnimationsObserver;
  51499. private _onBeforeParticlesRenderingObserver;
  51500. private _onAfterParticlesRenderingObserver;
  51501. private _onBeforeSpritesRenderingObserver;
  51502. private _onAfterSpritesRenderingObserver;
  51503. private _onBeforePhysicsObserver;
  51504. private _onAfterPhysicsObserver;
  51505. private _onAfterAnimationsObserver;
  51506. private _onBeforeCameraRenderObserver;
  51507. private _onAfterCameraRenderObserver;
  51508. /**
  51509. * Gets the perf counter used for active meshes evaluation time
  51510. */
  51511. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51512. /**
  51513. * Gets the active meshes evaluation time capture status
  51514. */
  51515. /**
  51516. * Enable or disable the active meshes evaluation time capture
  51517. */
  51518. captureActiveMeshesEvaluationTime: boolean;
  51519. /**
  51520. * Gets the perf counter used for render targets render time
  51521. */
  51522. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51523. /**
  51524. * Gets the render targets render time capture status
  51525. */
  51526. /**
  51527. * Enable or disable the render targets render time capture
  51528. */
  51529. captureRenderTargetsRenderTime: boolean;
  51530. /**
  51531. * Gets the perf counter used for particles render time
  51532. */
  51533. readonly particlesRenderTimeCounter: PerfCounter;
  51534. /**
  51535. * Gets the particles render time capture status
  51536. */
  51537. /**
  51538. * Enable or disable the particles render time capture
  51539. */
  51540. captureParticlesRenderTime: boolean;
  51541. /**
  51542. * Gets the perf counter used for sprites render time
  51543. */
  51544. readonly spritesRenderTimeCounter: PerfCounter;
  51545. /**
  51546. * Gets the sprites render time capture status
  51547. */
  51548. /**
  51549. * Enable or disable the sprites render time capture
  51550. */
  51551. captureSpritesRenderTime: boolean;
  51552. /**
  51553. * Gets the perf counter used for physics time
  51554. */
  51555. readonly physicsTimeCounter: PerfCounter;
  51556. /**
  51557. * Gets the physics time capture status
  51558. */
  51559. /**
  51560. * Enable or disable the physics time capture
  51561. */
  51562. capturePhysicsTime: boolean;
  51563. /**
  51564. * Gets the perf counter used for animations time
  51565. */
  51566. readonly animationsTimeCounter: PerfCounter;
  51567. /**
  51568. * Gets the animations time capture status
  51569. */
  51570. /**
  51571. * Enable or disable the animations time capture
  51572. */
  51573. captureAnimationsTime: boolean;
  51574. /**
  51575. * Gets the perf counter used for frame time capture
  51576. */
  51577. readonly frameTimeCounter: PerfCounter;
  51578. /**
  51579. * Gets the frame time capture status
  51580. */
  51581. /**
  51582. * Enable or disable the frame time capture
  51583. */
  51584. captureFrameTime: boolean;
  51585. /**
  51586. * Gets the perf counter used for inter-frames time capture
  51587. */
  51588. readonly interFrameTimeCounter: PerfCounter;
  51589. /**
  51590. * Gets the inter-frames time capture status
  51591. */
  51592. /**
  51593. * Enable or disable the inter-frames time capture
  51594. */
  51595. captureInterFrameTime: boolean;
  51596. /**
  51597. * Gets the perf counter used for render time capture
  51598. */
  51599. readonly renderTimeCounter: PerfCounter;
  51600. /**
  51601. * Gets the render time capture status
  51602. */
  51603. /**
  51604. * Enable or disable the render time capture
  51605. */
  51606. captureRenderTime: boolean;
  51607. /**
  51608. * Gets the perf counter used for camera render time capture
  51609. */
  51610. readonly cameraRenderTimeCounter: PerfCounter;
  51611. /**
  51612. * Gets the camera render time capture status
  51613. */
  51614. /**
  51615. * Enable or disable the camera render time capture
  51616. */
  51617. captureCameraRenderTime: boolean;
  51618. /**
  51619. * Gets the perf counter used for draw calls
  51620. */
  51621. readonly drawCallsCounter: PerfCounter;
  51622. /**
  51623. * Instantiates a new scene instrumentation.
  51624. * This class can be used to get instrumentation data from a Babylon engine
  51625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51626. * @param scene Defines the scene to instrument
  51627. */
  51628. constructor(
  51629. /**
  51630. * Defines the scene to instrument
  51631. */
  51632. scene: Scene);
  51633. /**
  51634. * Dispose and release associated resources.
  51635. */
  51636. dispose(): void;
  51637. }
  51638. }
  51639. declare module "babylonjs/Instrumentation/index" {
  51640. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51641. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51642. export * from "babylonjs/Instrumentation/timeToken";
  51643. }
  51644. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51645. /** @hidden */
  51646. export var glowMapGenerationPixelShader: {
  51647. name: string;
  51648. shader: string;
  51649. };
  51650. }
  51651. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51652. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51653. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51654. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51655. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51656. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51657. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51658. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51659. /** @hidden */
  51660. export var glowMapGenerationVertexShader: {
  51661. name: string;
  51662. shader: string;
  51663. };
  51664. }
  51665. declare module "babylonjs/Layers/effectLayer" {
  51666. import { Observable } from "babylonjs/Misc/observable";
  51667. import { Nullable } from "babylonjs/types";
  51668. import { Camera } from "babylonjs/Cameras/camera";
  51669. import { Scene } from "babylonjs/scene";
  51670. import { ISize } from "babylonjs/Maths/math.size";
  51671. import { Color4 } from "babylonjs/Maths/math.color";
  51672. import { Engine } from "babylonjs/Engines/engine";
  51673. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51675. import { Mesh } from "babylonjs/Meshes/mesh";
  51676. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51678. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51679. import { Effect } from "babylonjs/Materials/effect";
  51680. import { Material } from "babylonjs/Materials/material";
  51681. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51682. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51683. /**
  51684. * Effect layer options. This helps customizing the behaviour
  51685. * of the effect layer.
  51686. */
  51687. export interface IEffectLayerOptions {
  51688. /**
  51689. * Multiplication factor apply to the canvas size to compute the render target size
  51690. * used to generated the objects (the smaller the faster).
  51691. */
  51692. mainTextureRatio: number;
  51693. /**
  51694. * Enforces a fixed size texture to ensure effect stability across devices.
  51695. */
  51696. mainTextureFixedSize?: number;
  51697. /**
  51698. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51699. */
  51700. alphaBlendingMode: number;
  51701. /**
  51702. * The camera attached to the layer.
  51703. */
  51704. camera: Nullable<Camera>;
  51705. /**
  51706. * The rendering group to draw the layer in.
  51707. */
  51708. renderingGroupId: number;
  51709. }
  51710. /**
  51711. * The effect layer Helps adding post process effect blended with the main pass.
  51712. *
  51713. * This can be for instance use to generate glow or higlight effects on the scene.
  51714. *
  51715. * The effect layer class can not be used directly and is intented to inherited from to be
  51716. * customized per effects.
  51717. */
  51718. export abstract class EffectLayer {
  51719. private _vertexBuffers;
  51720. private _indexBuffer;
  51721. private _cachedDefines;
  51722. private _effectLayerMapGenerationEffect;
  51723. private _effectLayerOptions;
  51724. private _mergeEffect;
  51725. protected _scene: Scene;
  51726. protected _engine: Engine;
  51727. protected _maxSize: number;
  51728. protected _mainTextureDesiredSize: ISize;
  51729. protected _mainTexture: RenderTargetTexture;
  51730. protected _shouldRender: boolean;
  51731. protected _postProcesses: PostProcess[];
  51732. protected _textures: BaseTexture[];
  51733. protected _emissiveTextureAndColor: {
  51734. texture: Nullable<BaseTexture>;
  51735. color: Color4;
  51736. };
  51737. /**
  51738. * The name of the layer
  51739. */
  51740. name: string;
  51741. /**
  51742. * The clear color of the texture used to generate the glow map.
  51743. */
  51744. neutralColor: Color4;
  51745. /**
  51746. * Specifies wether the highlight layer is enabled or not.
  51747. */
  51748. isEnabled: boolean;
  51749. /**
  51750. * Gets the camera attached to the layer.
  51751. */
  51752. readonly camera: Nullable<Camera>;
  51753. /**
  51754. * Gets the rendering group id the layer should render in.
  51755. */
  51756. renderingGroupId: number;
  51757. /**
  51758. * An event triggered when the effect layer has been disposed.
  51759. */
  51760. onDisposeObservable: Observable<EffectLayer>;
  51761. /**
  51762. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51763. */
  51764. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51765. /**
  51766. * An event triggered when the generated texture is being merged in the scene.
  51767. */
  51768. onBeforeComposeObservable: Observable<EffectLayer>;
  51769. /**
  51770. * An event triggered when the generated texture has been merged in the scene.
  51771. */
  51772. onAfterComposeObservable: Observable<EffectLayer>;
  51773. /**
  51774. * An event triggered when the efffect layer changes its size.
  51775. */
  51776. onSizeChangedObservable: Observable<EffectLayer>;
  51777. /** @hidden */
  51778. static _SceneComponentInitialization: (scene: Scene) => void;
  51779. /**
  51780. * Instantiates a new effect Layer and references it in the scene.
  51781. * @param name The name of the layer
  51782. * @param scene The scene to use the layer in
  51783. */
  51784. constructor(
  51785. /** The Friendly of the effect in the scene */
  51786. name: string, scene: Scene);
  51787. /**
  51788. * Get the effect name of the layer.
  51789. * @return The effect name
  51790. */
  51791. abstract getEffectName(): string;
  51792. /**
  51793. * Checks for the readiness of the element composing the layer.
  51794. * @param subMesh the mesh to check for
  51795. * @param useInstances specify wether or not to use instances to render the mesh
  51796. * @return true if ready otherwise, false
  51797. */
  51798. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51799. /**
  51800. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51801. * @returns true if the effect requires stencil during the main canvas render pass.
  51802. */
  51803. abstract needStencil(): boolean;
  51804. /**
  51805. * Create the merge effect. This is the shader use to blit the information back
  51806. * to the main canvas at the end of the scene rendering.
  51807. * @returns The effect containing the shader used to merge the effect on the main canvas
  51808. */
  51809. protected abstract _createMergeEffect(): Effect;
  51810. /**
  51811. * Creates the render target textures and post processes used in the effect layer.
  51812. */
  51813. protected abstract _createTextureAndPostProcesses(): void;
  51814. /**
  51815. * Implementation specific of rendering the generating effect on the main canvas.
  51816. * @param effect The effect used to render through
  51817. */
  51818. protected abstract _internalRender(effect: Effect): void;
  51819. /**
  51820. * Sets the required values for both the emissive texture and and the main color.
  51821. */
  51822. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51823. /**
  51824. * Free any resources and references associated to a mesh.
  51825. * Internal use
  51826. * @param mesh The mesh to free.
  51827. */
  51828. abstract _disposeMesh(mesh: Mesh): void;
  51829. /**
  51830. * Serializes this layer (Glow or Highlight for example)
  51831. * @returns a serialized layer object
  51832. */
  51833. abstract serialize?(): any;
  51834. /**
  51835. * Initializes the effect layer with the required options.
  51836. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51837. */
  51838. protected _init(options: Partial<IEffectLayerOptions>): void;
  51839. /**
  51840. * Generates the index buffer of the full screen quad blending to the main canvas.
  51841. */
  51842. private _generateIndexBuffer;
  51843. /**
  51844. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51845. */
  51846. private _generateVertexBuffer;
  51847. /**
  51848. * Sets the main texture desired size which is the closest power of two
  51849. * of the engine canvas size.
  51850. */
  51851. private _setMainTextureSize;
  51852. /**
  51853. * Creates the main texture for the effect layer.
  51854. */
  51855. protected _createMainTexture(): void;
  51856. /**
  51857. * Adds specific effects defines.
  51858. * @param defines The defines to add specifics to.
  51859. */
  51860. protected _addCustomEffectDefines(defines: string[]): void;
  51861. /**
  51862. * Checks for the readiness of the element composing the layer.
  51863. * @param subMesh the mesh to check for
  51864. * @param useInstances specify wether or not to use instances to render the mesh
  51865. * @param emissiveTexture the associated emissive texture used to generate the glow
  51866. * @return true if ready otherwise, false
  51867. */
  51868. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51869. /**
  51870. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51871. */
  51872. render(): void;
  51873. /**
  51874. * Determine if a given mesh will be used in the current effect.
  51875. * @param mesh mesh to test
  51876. * @returns true if the mesh will be used
  51877. */
  51878. hasMesh(mesh: AbstractMesh): boolean;
  51879. /**
  51880. * Returns true if the layer contains information to display, otherwise false.
  51881. * @returns true if the glow layer should be rendered
  51882. */
  51883. shouldRender(): boolean;
  51884. /**
  51885. * Returns true if the mesh should render, otherwise false.
  51886. * @param mesh The mesh to render
  51887. * @returns true if it should render otherwise false
  51888. */
  51889. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51890. /**
  51891. * Returns true if the mesh can be rendered, otherwise false.
  51892. * @param mesh The mesh to render
  51893. * @param material The material used on the mesh
  51894. * @returns true if it can be rendered otherwise false
  51895. */
  51896. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51897. /**
  51898. * Returns true if the mesh should render, otherwise false.
  51899. * @param mesh The mesh to render
  51900. * @returns true if it should render otherwise false
  51901. */
  51902. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51903. /**
  51904. * Renders the submesh passed in parameter to the generation map.
  51905. */
  51906. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51907. /**
  51908. * Rebuild the required buffers.
  51909. * @hidden Internal use only.
  51910. */
  51911. _rebuild(): void;
  51912. /**
  51913. * Dispose only the render target textures and post process.
  51914. */
  51915. private _disposeTextureAndPostProcesses;
  51916. /**
  51917. * Dispose the highlight layer and free resources.
  51918. */
  51919. dispose(): void;
  51920. /**
  51921. * Gets the class name of the effect layer
  51922. * @returns the string with the class name of the effect layer
  51923. */
  51924. getClassName(): string;
  51925. /**
  51926. * Creates an effect layer from parsed effect layer data
  51927. * @param parsedEffectLayer defines effect layer data
  51928. * @param scene defines the current scene
  51929. * @param rootUrl defines the root URL containing the effect layer information
  51930. * @returns a parsed effect Layer
  51931. */
  51932. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51933. }
  51934. }
  51935. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51936. import { Scene } from "babylonjs/scene";
  51937. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51938. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51939. import { AbstractScene } from "babylonjs/abstractScene";
  51940. module "babylonjs/abstractScene" {
  51941. interface AbstractScene {
  51942. /**
  51943. * The list of effect layers (highlights/glow) added to the scene
  51944. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51945. * @see http://doc.babylonjs.com/how_to/glow_layer
  51946. */
  51947. effectLayers: Array<EffectLayer>;
  51948. /**
  51949. * Removes the given effect layer from this scene.
  51950. * @param toRemove defines the effect layer to remove
  51951. * @returns the index of the removed effect layer
  51952. */
  51953. removeEffectLayer(toRemove: EffectLayer): number;
  51954. /**
  51955. * Adds the given effect layer to this scene
  51956. * @param newEffectLayer defines the effect layer to add
  51957. */
  51958. addEffectLayer(newEffectLayer: EffectLayer): void;
  51959. }
  51960. }
  51961. /**
  51962. * Defines the layer scene component responsible to manage any effect layers
  51963. * in a given scene.
  51964. */
  51965. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51966. /**
  51967. * The component name helpfull to identify the component in the list of scene components.
  51968. */
  51969. readonly name: string;
  51970. /**
  51971. * The scene the component belongs to.
  51972. */
  51973. scene: Scene;
  51974. private _engine;
  51975. private _renderEffects;
  51976. private _needStencil;
  51977. private _previousStencilState;
  51978. /**
  51979. * Creates a new instance of the component for the given scene
  51980. * @param scene Defines the scene to register the component in
  51981. */
  51982. constructor(scene: Scene);
  51983. /**
  51984. * Registers the component in a given scene
  51985. */
  51986. register(): void;
  51987. /**
  51988. * Rebuilds the elements related to this component in case of
  51989. * context lost for instance.
  51990. */
  51991. rebuild(): void;
  51992. /**
  51993. * Serializes the component data to the specified json object
  51994. * @param serializationObject The object to serialize to
  51995. */
  51996. serialize(serializationObject: any): void;
  51997. /**
  51998. * Adds all the elements from the container to the scene
  51999. * @param container the container holding the elements
  52000. */
  52001. addFromContainer(container: AbstractScene): void;
  52002. /**
  52003. * Removes all the elements in the container from the scene
  52004. * @param container contains the elements to remove
  52005. * @param dispose if the removed element should be disposed (default: false)
  52006. */
  52007. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52008. /**
  52009. * Disposes the component and the associated ressources.
  52010. */
  52011. dispose(): void;
  52012. private _isReadyForMesh;
  52013. private _renderMainTexture;
  52014. private _setStencil;
  52015. private _setStencilBack;
  52016. private _draw;
  52017. private _drawCamera;
  52018. private _drawRenderingGroup;
  52019. }
  52020. }
  52021. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52022. /** @hidden */
  52023. export var glowMapMergePixelShader: {
  52024. name: string;
  52025. shader: string;
  52026. };
  52027. }
  52028. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52029. /** @hidden */
  52030. export var glowMapMergeVertexShader: {
  52031. name: string;
  52032. shader: string;
  52033. };
  52034. }
  52035. declare module "babylonjs/Layers/glowLayer" {
  52036. import { Nullable } from "babylonjs/types";
  52037. import { Camera } from "babylonjs/Cameras/camera";
  52038. import { Scene } from "babylonjs/scene";
  52039. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52041. import { Mesh } from "babylonjs/Meshes/mesh";
  52042. import { Texture } from "babylonjs/Materials/Textures/texture";
  52043. import { Effect } from "babylonjs/Materials/effect";
  52044. import { Material } from "babylonjs/Materials/material";
  52045. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52046. import { Color4 } from "babylonjs/Maths/math.color";
  52047. import "babylonjs/Shaders/glowMapMerge.fragment";
  52048. import "babylonjs/Shaders/glowMapMerge.vertex";
  52049. import "babylonjs/Layers/effectLayerSceneComponent";
  52050. module "babylonjs/abstractScene" {
  52051. interface AbstractScene {
  52052. /**
  52053. * Return a the first highlight layer of the scene with a given name.
  52054. * @param name The name of the highlight layer to look for.
  52055. * @return The highlight layer if found otherwise null.
  52056. */
  52057. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52058. }
  52059. }
  52060. /**
  52061. * Glow layer options. This helps customizing the behaviour
  52062. * of the glow layer.
  52063. */
  52064. export interface IGlowLayerOptions {
  52065. /**
  52066. * Multiplication factor apply to the canvas size to compute the render target size
  52067. * used to generated the glowing objects (the smaller the faster).
  52068. */
  52069. mainTextureRatio: number;
  52070. /**
  52071. * Enforces a fixed size texture to ensure resize independant blur.
  52072. */
  52073. mainTextureFixedSize?: number;
  52074. /**
  52075. * How big is the kernel of the blur texture.
  52076. */
  52077. blurKernelSize: number;
  52078. /**
  52079. * The camera attached to the layer.
  52080. */
  52081. camera: Nullable<Camera>;
  52082. /**
  52083. * Enable MSAA by chosing the number of samples.
  52084. */
  52085. mainTextureSamples?: number;
  52086. /**
  52087. * The rendering group to draw the layer in.
  52088. */
  52089. renderingGroupId: number;
  52090. }
  52091. /**
  52092. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52093. *
  52094. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52095. * glowy meshes to your scene.
  52096. *
  52097. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52098. */
  52099. export class GlowLayer extends EffectLayer {
  52100. /**
  52101. * Effect Name of the layer.
  52102. */
  52103. static readonly EffectName: string;
  52104. /**
  52105. * The default blur kernel size used for the glow.
  52106. */
  52107. static DefaultBlurKernelSize: number;
  52108. /**
  52109. * The default texture size ratio used for the glow.
  52110. */
  52111. static DefaultTextureRatio: number;
  52112. /**
  52113. * Sets the kernel size of the blur.
  52114. */
  52115. /**
  52116. * Gets the kernel size of the blur.
  52117. */
  52118. blurKernelSize: number;
  52119. /**
  52120. * Sets the glow intensity.
  52121. */
  52122. /**
  52123. * Gets the glow intensity.
  52124. */
  52125. intensity: number;
  52126. private _options;
  52127. private _intensity;
  52128. private _horizontalBlurPostprocess1;
  52129. private _verticalBlurPostprocess1;
  52130. private _horizontalBlurPostprocess2;
  52131. private _verticalBlurPostprocess2;
  52132. private _blurTexture1;
  52133. private _blurTexture2;
  52134. private _postProcesses1;
  52135. private _postProcesses2;
  52136. private _includedOnlyMeshes;
  52137. private _excludedMeshes;
  52138. /**
  52139. * Callback used to let the user override the color selection on a per mesh basis
  52140. */
  52141. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52142. /**
  52143. * Callback used to let the user override the texture selection on a per mesh basis
  52144. */
  52145. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52146. /**
  52147. * Instantiates a new glow Layer and references it to the scene.
  52148. * @param name The name of the layer
  52149. * @param scene The scene to use the layer in
  52150. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52151. */
  52152. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52153. /**
  52154. * Get the effect name of the layer.
  52155. * @return The effect name
  52156. */
  52157. getEffectName(): string;
  52158. /**
  52159. * Create the merge effect. This is the shader use to blit the information back
  52160. * to the main canvas at the end of the scene rendering.
  52161. */
  52162. protected _createMergeEffect(): Effect;
  52163. /**
  52164. * Creates the render target textures and post processes used in the glow layer.
  52165. */
  52166. protected _createTextureAndPostProcesses(): void;
  52167. /**
  52168. * Checks for the readiness of the element composing the layer.
  52169. * @param subMesh the mesh to check for
  52170. * @param useInstances specify wether or not to use instances to render the mesh
  52171. * @param emissiveTexture the associated emissive texture used to generate the glow
  52172. * @return true if ready otherwise, false
  52173. */
  52174. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52175. /**
  52176. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52177. */
  52178. needStencil(): boolean;
  52179. /**
  52180. * Returns true if the mesh can be rendered, otherwise false.
  52181. * @param mesh The mesh to render
  52182. * @param material The material used on the mesh
  52183. * @returns true if it can be rendered otherwise false
  52184. */
  52185. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52186. /**
  52187. * Implementation specific of rendering the generating effect on the main canvas.
  52188. * @param effect The effect used to render through
  52189. */
  52190. protected _internalRender(effect: Effect): void;
  52191. /**
  52192. * Sets the required values for both the emissive texture and and the main color.
  52193. */
  52194. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52195. /**
  52196. * Returns true if the mesh should render, otherwise false.
  52197. * @param mesh The mesh to render
  52198. * @returns true if it should render otherwise false
  52199. */
  52200. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52201. /**
  52202. * Adds specific effects defines.
  52203. * @param defines The defines to add specifics to.
  52204. */
  52205. protected _addCustomEffectDefines(defines: string[]): void;
  52206. /**
  52207. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52208. * @param mesh The mesh to exclude from the glow layer
  52209. */
  52210. addExcludedMesh(mesh: Mesh): void;
  52211. /**
  52212. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52213. * @param mesh The mesh to remove
  52214. */
  52215. removeExcludedMesh(mesh: Mesh): void;
  52216. /**
  52217. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52218. * @param mesh The mesh to include in the glow layer
  52219. */
  52220. addIncludedOnlyMesh(mesh: Mesh): void;
  52221. /**
  52222. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52223. * @param mesh The mesh to remove
  52224. */
  52225. removeIncludedOnlyMesh(mesh: Mesh): void;
  52226. /**
  52227. * Determine if a given mesh will be used in the glow layer
  52228. * @param mesh The mesh to test
  52229. * @returns true if the mesh will be highlighted by the current glow layer
  52230. */
  52231. hasMesh(mesh: AbstractMesh): boolean;
  52232. /**
  52233. * Free any resources and references associated to a mesh.
  52234. * Internal use
  52235. * @param mesh The mesh to free.
  52236. * @hidden
  52237. */
  52238. _disposeMesh(mesh: Mesh): void;
  52239. /**
  52240. * Gets the class name of the effect layer
  52241. * @returns the string with the class name of the effect layer
  52242. */
  52243. getClassName(): string;
  52244. /**
  52245. * Serializes this glow layer
  52246. * @returns a serialized glow layer object
  52247. */
  52248. serialize(): any;
  52249. /**
  52250. * Creates a Glow Layer from parsed glow layer data
  52251. * @param parsedGlowLayer defines glow layer data
  52252. * @param scene defines the current scene
  52253. * @param rootUrl defines the root URL containing the glow layer information
  52254. * @returns a parsed Glow Layer
  52255. */
  52256. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52257. }
  52258. }
  52259. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52260. /** @hidden */
  52261. export var glowBlurPostProcessPixelShader: {
  52262. name: string;
  52263. shader: string;
  52264. };
  52265. }
  52266. declare module "babylonjs/Layers/highlightLayer" {
  52267. import { Observable } from "babylonjs/Misc/observable";
  52268. import { Nullable } from "babylonjs/types";
  52269. import { Camera } from "babylonjs/Cameras/camera";
  52270. import { Scene } from "babylonjs/scene";
  52271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52273. import { Mesh } from "babylonjs/Meshes/mesh";
  52274. import { Effect } from "babylonjs/Materials/effect";
  52275. import { Material } from "babylonjs/Materials/material";
  52276. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52277. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52278. import "babylonjs/Shaders/glowMapMerge.fragment";
  52279. import "babylonjs/Shaders/glowMapMerge.vertex";
  52280. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52281. module "babylonjs/abstractScene" {
  52282. interface AbstractScene {
  52283. /**
  52284. * Return a the first highlight layer of the scene with a given name.
  52285. * @param name The name of the highlight layer to look for.
  52286. * @return The highlight layer if found otherwise null.
  52287. */
  52288. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52289. }
  52290. }
  52291. /**
  52292. * Highlight layer options. This helps customizing the behaviour
  52293. * of the highlight layer.
  52294. */
  52295. export interface IHighlightLayerOptions {
  52296. /**
  52297. * Multiplication factor apply to the canvas size to compute the render target size
  52298. * used to generated the glowing objects (the smaller the faster).
  52299. */
  52300. mainTextureRatio: number;
  52301. /**
  52302. * Enforces a fixed size texture to ensure resize independant blur.
  52303. */
  52304. mainTextureFixedSize?: number;
  52305. /**
  52306. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52307. * of the picture to blur (the smaller the faster).
  52308. */
  52309. blurTextureSizeRatio: number;
  52310. /**
  52311. * How big in texel of the blur texture is the vertical blur.
  52312. */
  52313. blurVerticalSize: number;
  52314. /**
  52315. * How big in texel of the blur texture is the horizontal blur.
  52316. */
  52317. blurHorizontalSize: number;
  52318. /**
  52319. * Alpha blending mode used to apply the blur. Default is combine.
  52320. */
  52321. alphaBlendingMode: number;
  52322. /**
  52323. * The camera attached to the layer.
  52324. */
  52325. camera: Nullable<Camera>;
  52326. /**
  52327. * Should we display highlight as a solid stroke?
  52328. */
  52329. isStroke?: boolean;
  52330. /**
  52331. * The rendering group to draw the layer in.
  52332. */
  52333. renderingGroupId: number;
  52334. }
  52335. /**
  52336. * The highlight layer Helps adding a glow effect around a mesh.
  52337. *
  52338. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52339. * glowy meshes to your scene.
  52340. *
  52341. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52342. */
  52343. export class HighlightLayer extends EffectLayer {
  52344. name: string;
  52345. /**
  52346. * Effect Name of the highlight layer.
  52347. */
  52348. static readonly EffectName: string;
  52349. /**
  52350. * The neutral color used during the preparation of the glow effect.
  52351. * This is black by default as the blend operation is a blend operation.
  52352. */
  52353. static NeutralColor: Color4;
  52354. /**
  52355. * Stencil value used for glowing meshes.
  52356. */
  52357. static GlowingMeshStencilReference: number;
  52358. /**
  52359. * Stencil value used for the other meshes in the scene.
  52360. */
  52361. static NormalMeshStencilReference: number;
  52362. /**
  52363. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52364. */
  52365. innerGlow: boolean;
  52366. /**
  52367. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52368. */
  52369. outerGlow: boolean;
  52370. /**
  52371. * Specifies the horizontal size of the blur.
  52372. */
  52373. /**
  52374. * Gets the horizontal size of the blur.
  52375. */
  52376. blurHorizontalSize: number;
  52377. /**
  52378. * Specifies the vertical size of the blur.
  52379. */
  52380. /**
  52381. * Gets the vertical size of the blur.
  52382. */
  52383. blurVerticalSize: number;
  52384. /**
  52385. * An event triggered when the highlight layer is being blurred.
  52386. */
  52387. onBeforeBlurObservable: Observable<HighlightLayer>;
  52388. /**
  52389. * An event triggered when the highlight layer has been blurred.
  52390. */
  52391. onAfterBlurObservable: Observable<HighlightLayer>;
  52392. private _instanceGlowingMeshStencilReference;
  52393. private _options;
  52394. private _downSamplePostprocess;
  52395. private _horizontalBlurPostprocess;
  52396. private _verticalBlurPostprocess;
  52397. private _blurTexture;
  52398. private _meshes;
  52399. private _excludedMeshes;
  52400. /**
  52401. * Instantiates a new highlight Layer and references it to the scene..
  52402. * @param name The name of the layer
  52403. * @param scene The scene to use the layer in
  52404. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52405. */
  52406. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52407. /**
  52408. * Get the effect name of the layer.
  52409. * @return The effect name
  52410. */
  52411. getEffectName(): string;
  52412. /**
  52413. * Create the merge effect. This is the shader use to blit the information back
  52414. * to the main canvas at the end of the scene rendering.
  52415. */
  52416. protected _createMergeEffect(): Effect;
  52417. /**
  52418. * Creates the render target textures and post processes used in the highlight layer.
  52419. */
  52420. protected _createTextureAndPostProcesses(): void;
  52421. /**
  52422. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52423. */
  52424. needStencil(): boolean;
  52425. /**
  52426. * Checks for the readiness of the element composing the layer.
  52427. * @param subMesh the mesh to check for
  52428. * @param useInstances specify wether or not to use instances to render the mesh
  52429. * @param emissiveTexture the associated emissive texture used to generate the glow
  52430. * @return true if ready otherwise, false
  52431. */
  52432. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52433. /**
  52434. * Implementation specific of rendering the generating effect on the main canvas.
  52435. * @param effect The effect used to render through
  52436. */
  52437. protected _internalRender(effect: Effect): void;
  52438. /**
  52439. * Returns true if the layer contains information to display, otherwise false.
  52440. */
  52441. shouldRender(): boolean;
  52442. /**
  52443. * Returns true if the mesh should render, otherwise false.
  52444. * @param mesh The mesh to render
  52445. * @returns true if it should render otherwise false
  52446. */
  52447. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52448. /**
  52449. * Sets the required values for both the emissive texture and and the main color.
  52450. */
  52451. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52452. /**
  52453. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52454. * @param mesh The mesh to exclude from the highlight layer
  52455. */
  52456. addExcludedMesh(mesh: Mesh): void;
  52457. /**
  52458. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52459. * @param mesh The mesh to highlight
  52460. */
  52461. removeExcludedMesh(mesh: Mesh): void;
  52462. /**
  52463. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52464. * @param mesh mesh to test
  52465. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52466. */
  52467. hasMesh(mesh: AbstractMesh): boolean;
  52468. /**
  52469. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52470. * @param mesh The mesh to highlight
  52471. * @param color The color of the highlight
  52472. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52473. */
  52474. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52475. /**
  52476. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52477. * @param mesh The mesh to highlight
  52478. */
  52479. removeMesh(mesh: Mesh): void;
  52480. /**
  52481. * Force the stencil to the normal expected value for none glowing parts
  52482. */
  52483. private _defaultStencilReference;
  52484. /**
  52485. * Free any resources and references associated to a mesh.
  52486. * Internal use
  52487. * @param mesh The mesh to free.
  52488. * @hidden
  52489. */
  52490. _disposeMesh(mesh: Mesh): void;
  52491. /**
  52492. * Dispose the highlight layer and free resources.
  52493. */
  52494. dispose(): void;
  52495. /**
  52496. * Gets the class name of the effect layer
  52497. * @returns the string with the class name of the effect layer
  52498. */
  52499. getClassName(): string;
  52500. /**
  52501. * Serializes this Highlight layer
  52502. * @returns a serialized Highlight layer object
  52503. */
  52504. serialize(): any;
  52505. /**
  52506. * Creates a Highlight layer from parsed Highlight layer data
  52507. * @param parsedHightlightLayer defines the Highlight layer data
  52508. * @param scene defines the current scene
  52509. * @param rootUrl defines the root URL containing the Highlight layer information
  52510. * @returns a parsed Highlight layer
  52511. */
  52512. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52513. }
  52514. }
  52515. declare module "babylonjs/Layers/layerSceneComponent" {
  52516. import { Scene } from "babylonjs/scene";
  52517. import { ISceneComponent } from "babylonjs/sceneComponent";
  52518. import { Layer } from "babylonjs/Layers/layer";
  52519. import { AbstractScene } from "babylonjs/abstractScene";
  52520. module "babylonjs/abstractScene" {
  52521. interface AbstractScene {
  52522. /**
  52523. * The list of layers (background and foreground) of the scene
  52524. */
  52525. layers: Array<Layer>;
  52526. }
  52527. }
  52528. /**
  52529. * Defines the layer scene component responsible to manage any layers
  52530. * in a given scene.
  52531. */
  52532. export class LayerSceneComponent implements ISceneComponent {
  52533. /**
  52534. * The component name helpfull to identify the component in the list of scene components.
  52535. */
  52536. readonly name: string;
  52537. /**
  52538. * The scene the component belongs to.
  52539. */
  52540. scene: Scene;
  52541. private _engine;
  52542. /**
  52543. * Creates a new instance of the component for the given scene
  52544. * @param scene Defines the scene to register the component in
  52545. */
  52546. constructor(scene: Scene);
  52547. /**
  52548. * Registers the component in a given scene
  52549. */
  52550. register(): void;
  52551. /**
  52552. * Rebuilds the elements related to this component in case of
  52553. * context lost for instance.
  52554. */
  52555. rebuild(): void;
  52556. /**
  52557. * Disposes the component and the associated ressources.
  52558. */
  52559. dispose(): void;
  52560. private _draw;
  52561. private _drawCameraPredicate;
  52562. private _drawCameraBackground;
  52563. private _drawCameraForeground;
  52564. private _drawRenderTargetPredicate;
  52565. private _drawRenderTargetBackground;
  52566. private _drawRenderTargetForeground;
  52567. /**
  52568. * Adds all the elements from the container to the scene
  52569. * @param container the container holding the elements
  52570. */
  52571. addFromContainer(container: AbstractScene): void;
  52572. /**
  52573. * Removes all the elements in the container from the scene
  52574. * @param container contains the elements to remove
  52575. * @param dispose if the removed element should be disposed (default: false)
  52576. */
  52577. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52578. }
  52579. }
  52580. declare module "babylonjs/Shaders/layer.fragment" {
  52581. /** @hidden */
  52582. export var layerPixelShader: {
  52583. name: string;
  52584. shader: string;
  52585. };
  52586. }
  52587. declare module "babylonjs/Shaders/layer.vertex" {
  52588. /** @hidden */
  52589. export var layerVertexShader: {
  52590. name: string;
  52591. shader: string;
  52592. };
  52593. }
  52594. declare module "babylonjs/Layers/layer" {
  52595. import { Observable } from "babylonjs/Misc/observable";
  52596. import { Nullable } from "babylonjs/types";
  52597. import { Scene } from "babylonjs/scene";
  52598. import { Vector2 } from "babylonjs/Maths/math.vector";
  52599. import { Color4 } from "babylonjs/Maths/math.color";
  52600. import { Texture } from "babylonjs/Materials/Textures/texture";
  52601. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52602. import "babylonjs/Shaders/layer.fragment";
  52603. import "babylonjs/Shaders/layer.vertex";
  52604. /**
  52605. * This represents a full screen 2d layer.
  52606. * This can be useful to display a picture in the background of your scene for instance.
  52607. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52608. */
  52609. export class Layer {
  52610. /**
  52611. * Define the name of the layer.
  52612. */
  52613. name: string;
  52614. /**
  52615. * Define the texture the layer should display.
  52616. */
  52617. texture: Nullable<Texture>;
  52618. /**
  52619. * Is the layer in background or foreground.
  52620. */
  52621. isBackground: boolean;
  52622. /**
  52623. * Define the color of the layer (instead of texture).
  52624. */
  52625. color: Color4;
  52626. /**
  52627. * Define the scale of the layer in order to zoom in out of the texture.
  52628. */
  52629. scale: Vector2;
  52630. /**
  52631. * Define an offset for the layer in order to shift the texture.
  52632. */
  52633. offset: Vector2;
  52634. /**
  52635. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52636. */
  52637. alphaBlendingMode: number;
  52638. /**
  52639. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52640. * Alpha test will not mix with the background color in case of transparency.
  52641. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52642. */
  52643. alphaTest: boolean;
  52644. /**
  52645. * Define a mask to restrict the layer to only some of the scene cameras.
  52646. */
  52647. layerMask: number;
  52648. /**
  52649. * Define the list of render target the layer is visible into.
  52650. */
  52651. renderTargetTextures: RenderTargetTexture[];
  52652. /**
  52653. * Define if the layer is only used in renderTarget or if it also
  52654. * renders in the main frame buffer of the canvas.
  52655. */
  52656. renderOnlyInRenderTargetTextures: boolean;
  52657. private _scene;
  52658. private _vertexBuffers;
  52659. private _indexBuffer;
  52660. private _effect;
  52661. private _alphaTestEffect;
  52662. /**
  52663. * An event triggered when the layer is disposed.
  52664. */
  52665. onDisposeObservable: Observable<Layer>;
  52666. private _onDisposeObserver;
  52667. /**
  52668. * Back compatibility with callback before the onDisposeObservable existed.
  52669. * The set callback will be triggered when the layer has been disposed.
  52670. */
  52671. onDispose: () => void;
  52672. /**
  52673. * An event triggered before rendering the scene
  52674. */
  52675. onBeforeRenderObservable: Observable<Layer>;
  52676. private _onBeforeRenderObserver;
  52677. /**
  52678. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52679. * The set callback will be triggered just before rendering the layer.
  52680. */
  52681. onBeforeRender: () => void;
  52682. /**
  52683. * An event triggered after rendering the scene
  52684. */
  52685. onAfterRenderObservable: Observable<Layer>;
  52686. private _onAfterRenderObserver;
  52687. /**
  52688. * Back compatibility with callback before the onAfterRenderObservable existed.
  52689. * The set callback will be triggered just after rendering the layer.
  52690. */
  52691. onAfterRender: () => void;
  52692. /**
  52693. * Instantiates a new layer.
  52694. * This represents a full screen 2d layer.
  52695. * This can be useful to display a picture in the background of your scene for instance.
  52696. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52697. * @param name Define the name of the layer in the scene
  52698. * @param imgUrl Define the url of the texture to display in the layer
  52699. * @param scene Define the scene the layer belongs to
  52700. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52701. * @param color Defines a color for the layer
  52702. */
  52703. constructor(
  52704. /**
  52705. * Define the name of the layer.
  52706. */
  52707. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52708. private _createIndexBuffer;
  52709. /** @hidden */
  52710. _rebuild(): void;
  52711. /**
  52712. * Renders the layer in the scene.
  52713. */
  52714. render(): void;
  52715. /**
  52716. * Disposes and releases the associated ressources.
  52717. */
  52718. dispose(): void;
  52719. }
  52720. }
  52721. declare module "babylonjs/Layers/index" {
  52722. export * from "babylonjs/Layers/effectLayer";
  52723. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52724. export * from "babylonjs/Layers/glowLayer";
  52725. export * from "babylonjs/Layers/highlightLayer";
  52726. export * from "babylonjs/Layers/layer";
  52727. export * from "babylonjs/Layers/layerSceneComponent";
  52728. }
  52729. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52730. /** @hidden */
  52731. export var lensFlarePixelShader: {
  52732. name: string;
  52733. shader: string;
  52734. };
  52735. }
  52736. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52737. /** @hidden */
  52738. export var lensFlareVertexShader: {
  52739. name: string;
  52740. shader: string;
  52741. };
  52742. }
  52743. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52744. import { Scene } from "babylonjs/scene";
  52745. import { Vector3 } from "babylonjs/Maths/math.vector";
  52746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52747. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52748. import "babylonjs/Shaders/lensFlare.fragment";
  52749. import "babylonjs/Shaders/lensFlare.vertex";
  52750. import { Viewport } from "babylonjs/Maths/math.viewport";
  52751. /**
  52752. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52753. * It is usually composed of several `lensFlare`.
  52754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52755. */
  52756. export class LensFlareSystem {
  52757. /**
  52758. * Define the name of the lens flare system
  52759. */
  52760. name: string;
  52761. /**
  52762. * List of lens flares used in this system.
  52763. */
  52764. lensFlares: LensFlare[];
  52765. /**
  52766. * Define a limit from the border the lens flare can be visible.
  52767. */
  52768. borderLimit: number;
  52769. /**
  52770. * Define a viewport border we do not want to see the lens flare in.
  52771. */
  52772. viewportBorder: number;
  52773. /**
  52774. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52775. */
  52776. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52777. /**
  52778. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52779. */
  52780. layerMask: number;
  52781. /**
  52782. * Define the id of the lens flare system in the scene.
  52783. * (equal to name by default)
  52784. */
  52785. id: string;
  52786. private _scene;
  52787. private _emitter;
  52788. private _vertexBuffers;
  52789. private _indexBuffer;
  52790. private _effect;
  52791. private _positionX;
  52792. private _positionY;
  52793. private _isEnabled;
  52794. /** @hidden */
  52795. static _SceneComponentInitialization: (scene: Scene) => void;
  52796. /**
  52797. * Instantiates a lens flare system.
  52798. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52799. * It is usually composed of several `lensFlare`.
  52800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52801. * @param name Define the name of the lens flare system in the scene
  52802. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52803. * @param scene Define the scene the lens flare system belongs to
  52804. */
  52805. constructor(
  52806. /**
  52807. * Define the name of the lens flare system
  52808. */
  52809. name: string, emitter: any, scene: Scene);
  52810. /**
  52811. * Define if the lens flare system is enabled.
  52812. */
  52813. isEnabled: boolean;
  52814. /**
  52815. * Get the scene the effects belongs to.
  52816. * @returns the scene holding the lens flare system
  52817. */
  52818. getScene(): Scene;
  52819. /**
  52820. * Get the emitter of the lens flare system.
  52821. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52822. * @returns the emitter of the lens flare system
  52823. */
  52824. getEmitter(): any;
  52825. /**
  52826. * Set the emitter of the lens flare system.
  52827. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52828. * @param newEmitter Define the new emitter of the system
  52829. */
  52830. setEmitter(newEmitter: any): void;
  52831. /**
  52832. * Get the lens flare system emitter position.
  52833. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52834. * @returns the position
  52835. */
  52836. getEmitterPosition(): Vector3;
  52837. /**
  52838. * @hidden
  52839. */
  52840. computeEffectivePosition(globalViewport: Viewport): boolean;
  52841. /** @hidden */
  52842. _isVisible(): boolean;
  52843. /**
  52844. * @hidden
  52845. */
  52846. render(): boolean;
  52847. /**
  52848. * Dispose and release the lens flare with its associated resources.
  52849. */
  52850. dispose(): void;
  52851. /**
  52852. * Parse a lens flare system from a JSON repressentation
  52853. * @param parsedLensFlareSystem Define the JSON to parse
  52854. * @param scene Define the scene the parsed system should be instantiated in
  52855. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52856. * @returns the parsed system
  52857. */
  52858. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52859. /**
  52860. * Serialize the current Lens Flare System into a JSON representation.
  52861. * @returns the serialized JSON
  52862. */
  52863. serialize(): any;
  52864. }
  52865. }
  52866. declare module "babylonjs/LensFlares/lensFlare" {
  52867. import { Nullable } from "babylonjs/types";
  52868. import { Color3 } from "babylonjs/Maths/math.color";
  52869. import { Texture } from "babylonjs/Materials/Textures/texture";
  52870. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52871. /**
  52872. * This represents one of the lens effect in a `lensFlareSystem`.
  52873. * It controls one of the indiviual texture used in the effect.
  52874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52875. */
  52876. export class LensFlare {
  52877. /**
  52878. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52879. */
  52880. size: number;
  52881. /**
  52882. * 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.
  52883. */
  52884. position: number;
  52885. /**
  52886. * Define the lens color.
  52887. */
  52888. color: Color3;
  52889. /**
  52890. * Define the lens texture.
  52891. */
  52892. texture: Nullable<Texture>;
  52893. /**
  52894. * Define the alpha mode to render this particular lens.
  52895. */
  52896. alphaMode: number;
  52897. private _system;
  52898. /**
  52899. * Creates a new Lens Flare.
  52900. * This represents one of the lens effect in a `lensFlareSystem`.
  52901. * It controls one of the indiviual texture used in the effect.
  52902. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52903. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52904. * @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.
  52905. * @param color Define the lens color
  52906. * @param imgUrl Define the lens texture url
  52907. * @param system Define the `lensFlareSystem` this flare is part of
  52908. * @returns The newly created Lens Flare
  52909. */
  52910. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52911. /**
  52912. * Instantiates a new Lens Flare.
  52913. * This represents one of the lens effect in a `lensFlareSystem`.
  52914. * It controls one of the indiviual texture used in the effect.
  52915. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52916. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52917. * @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.
  52918. * @param color Define the lens color
  52919. * @param imgUrl Define the lens texture url
  52920. * @param system Define the `lensFlareSystem` this flare is part of
  52921. */
  52922. constructor(
  52923. /**
  52924. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52925. */
  52926. size: number,
  52927. /**
  52928. * 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.
  52929. */
  52930. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52931. /**
  52932. * Dispose and release the lens flare with its associated resources.
  52933. */
  52934. dispose(): void;
  52935. }
  52936. }
  52937. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52938. import { Nullable } from "babylonjs/types";
  52939. import { Scene } from "babylonjs/scene";
  52940. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52941. import { AbstractScene } from "babylonjs/abstractScene";
  52942. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52943. module "babylonjs/abstractScene" {
  52944. interface AbstractScene {
  52945. /**
  52946. * The list of lens flare system added to the scene
  52947. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52948. */
  52949. lensFlareSystems: Array<LensFlareSystem>;
  52950. /**
  52951. * Removes the given lens flare system from this scene.
  52952. * @param toRemove The lens flare system to remove
  52953. * @returns The index of the removed lens flare system
  52954. */
  52955. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52956. /**
  52957. * Adds the given lens flare system to this scene
  52958. * @param newLensFlareSystem The lens flare system to add
  52959. */
  52960. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52961. /**
  52962. * Gets a lens flare system using its name
  52963. * @param name defines the name to look for
  52964. * @returns the lens flare system or null if not found
  52965. */
  52966. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52967. /**
  52968. * Gets a lens flare system using its id
  52969. * @param id defines the id to look for
  52970. * @returns the lens flare system or null if not found
  52971. */
  52972. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52973. }
  52974. }
  52975. /**
  52976. * Defines the lens flare scene component responsible to manage any lens flares
  52977. * in a given scene.
  52978. */
  52979. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52980. /**
  52981. * The component name helpfull to identify the component in the list of scene components.
  52982. */
  52983. readonly name: string;
  52984. /**
  52985. * The scene the component belongs to.
  52986. */
  52987. scene: Scene;
  52988. /**
  52989. * Creates a new instance of the component for the given scene
  52990. * @param scene Defines the scene to register the component in
  52991. */
  52992. constructor(scene: Scene);
  52993. /**
  52994. * Registers the component in a given scene
  52995. */
  52996. register(): void;
  52997. /**
  52998. * Rebuilds the elements related to this component in case of
  52999. * context lost for instance.
  53000. */
  53001. rebuild(): void;
  53002. /**
  53003. * Adds all the elements from the container to the scene
  53004. * @param container the container holding the elements
  53005. */
  53006. addFromContainer(container: AbstractScene): void;
  53007. /**
  53008. * Removes all the elements in the container from the scene
  53009. * @param container contains the elements to remove
  53010. * @param dispose if the removed element should be disposed (default: false)
  53011. */
  53012. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53013. /**
  53014. * Serializes the component data to the specified json object
  53015. * @param serializationObject The object to serialize to
  53016. */
  53017. serialize(serializationObject: any): void;
  53018. /**
  53019. * Disposes the component and the associated ressources.
  53020. */
  53021. dispose(): void;
  53022. private _draw;
  53023. }
  53024. }
  53025. declare module "babylonjs/LensFlares/index" {
  53026. export * from "babylonjs/LensFlares/lensFlare";
  53027. export * from "babylonjs/LensFlares/lensFlareSystem";
  53028. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53029. }
  53030. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53031. import { Scene } from "babylonjs/scene";
  53032. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53033. import { AbstractScene } from "babylonjs/abstractScene";
  53034. /**
  53035. * Defines the shadow generator component responsible to manage any shadow generators
  53036. * in a given scene.
  53037. */
  53038. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53039. /**
  53040. * The component name helpfull to identify the component in the list of scene components.
  53041. */
  53042. readonly name: string;
  53043. /**
  53044. * The scene the component belongs to.
  53045. */
  53046. scene: Scene;
  53047. /**
  53048. * Creates a new instance of the component for the given scene
  53049. * @param scene Defines the scene to register the component in
  53050. */
  53051. constructor(scene: Scene);
  53052. /**
  53053. * Registers the component in a given scene
  53054. */
  53055. register(): void;
  53056. /**
  53057. * Rebuilds the elements related to this component in case of
  53058. * context lost for instance.
  53059. */
  53060. rebuild(): void;
  53061. /**
  53062. * Serializes the component data to the specified json object
  53063. * @param serializationObject The object to serialize to
  53064. */
  53065. serialize(serializationObject: any): void;
  53066. /**
  53067. * Adds all the elements from the container to the scene
  53068. * @param container the container holding the elements
  53069. */
  53070. addFromContainer(container: AbstractScene): void;
  53071. /**
  53072. * Removes all the elements in the container from the scene
  53073. * @param container contains the elements to remove
  53074. * @param dispose if the removed element should be disposed (default: false)
  53075. */
  53076. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53077. /**
  53078. * Rebuilds the elements related to this component in case of
  53079. * context lost for instance.
  53080. */
  53081. dispose(): void;
  53082. private _gatherRenderTargets;
  53083. }
  53084. }
  53085. declare module "babylonjs/Lights/Shadows/index" {
  53086. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53087. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53088. }
  53089. declare module "babylonjs/Lights/pointLight" {
  53090. import { Scene } from "babylonjs/scene";
  53091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53093. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53094. import { Effect } from "babylonjs/Materials/effect";
  53095. /**
  53096. * A point light is a light defined by an unique point in world space.
  53097. * The light is emitted in every direction from this point.
  53098. * A good example of a point light is a standard light bulb.
  53099. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53100. */
  53101. export class PointLight extends ShadowLight {
  53102. private _shadowAngle;
  53103. /**
  53104. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53105. * This specifies what angle the shadow will use to be created.
  53106. *
  53107. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53108. */
  53109. /**
  53110. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53111. * This specifies what angle the shadow will use to be created.
  53112. *
  53113. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53114. */
  53115. shadowAngle: number;
  53116. /**
  53117. * Gets the direction if it has been set.
  53118. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53119. */
  53120. /**
  53121. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53122. */
  53123. direction: Vector3;
  53124. /**
  53125. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53126. * A PointLight emits the light in every direction.
  53127. * It can cast shadows.
  53128. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53129. * ```javascript
  53130. * var pointLight = new PointLight("pl", camera.position, scene);
  53131. * ```
  53132. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53133. * @param name The light friendly name
  53134. * @param position The position of the point light in the scene
  53135. * @param scene The scene the lights belongs to
  53136. */
  53137. constructor(name: string, position: Vector3, scene: Scene);
  53138. /**
  53139. * Returns the string "PointLight"
  53140. * @returns the class name
  53141. */
  53142. getClassName(): string;
  53143. /**
  53144. * Returns the integer 0.
  53145. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53146. */
  53147. getTypeID(): number;
  53148. /**
  53149. * Specifies wether or not the shadowmap should be a cube texture.
  53150. * @returns true if the shadowmap needs to be a cube texture.
  53151. */
  53152. needCube(): boolean;
  53153. /**
  53154. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53155. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53156. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53157. */
  53158. getShadowDirection(faceIndex?: number): Vector3;
  53159. /**
  53160. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53161. * - fov = PI / 2
  53162. * - aspect ratio : 1.0
  53163. * - z-near and far equal to the active camera minZ and maxZ.
  53164. * Returns the PointLight.
  53165. */
  53166. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53167. protected _buildUniformLayout(): void;
  53168. /**
  53169. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53170. * @param effect The effect to update
  53171. * @param lightIndex The index of the light in the effect to update
  53172. * @returns The point light
  53173. */
  53174. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53175. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53176. /**
  53177. * Prepares the list of defines specific to the light type.
  53178. * @param defines the list of defines
  53179. * @param lightIndex defines the index of the light for the effect
  53180. */
  53181. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53182. }
  53183. }
  53184. declare module "babylonjs/Lights/index" {
  53185. export * from "babylonjs/Lights/light";
  53186. export * from "babylonjs/Lights/shadowLight";
  53187. export * from "babylonjs/Lights/Shadows/index";
  53188. export * from "babylonjs/Lights/directionalLight";
  53189. export * from "babylonjs/Lights/hemisphericLight";
  53190. export * from "babylonjs/Lights/pointLight";
  53191. export * from "babylonjs/Lights/spotLight";
  53192. }
  53193. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53194. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53195. /**
  53196. * Header information of HDR texture files.
  53197. */
  53198. export interface HDRInfo {
  53199. /**
  53200. * The height of the texture in pixels.
  53201. */
  53202. height: number;
  53203. /**
  53204. * The width of the texture in pixels.
  53205. */
  53206. width: number;
  53207. /**
  53208. * The index of the beginning of the data in the binary file.
  53209. */
  53210. dataPosition: number;
  53211. }
  53212. /**
  53213. * This groups tools to convert HDR texture to native colors array.
  53214. */
  53215. export class HDRTools {
  53216. private static Ldexp;
  53217. private static Rgbe2float;
  53218. private static readStringLine;
  53219. /**
  53220. * Reads header information from an RGBE texture stored in a native array.
  53221. * More information on this format are available here:
  53222. * https://en.wikipedia.org/wiki/RGBE_image_format
  53223. *
  53224. * @param uint8array The binary file stored in native array.
  53225. * @return The header information.
  53226. */
  53227. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53228. /**
  53229. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53230. * This RGBE texture needs to store the information as a panorama.
  53231. *
  53232. * More information on this format are available here:
  53233. * https://en.wikipedia.org/wiki/RGBE_image_format
  53234. *
  53235. * @param buffer The binary file stored in an array buffer.
  53236. * @param size The expected size of the extracted cubemap.
  53237. * @return The Cube Map information.
  53238. */
  53239. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53240. /**
  53241. * Returns the pixels data extracted from an RGBE texture.
  53242. * This pixels will be stored left to right up to down in the R G B order in one array.
  53243. *
  53244. * More information on this format are available here:
  53245. * https://en.wikipedia.org/wiki/RGBE_image_format
  53246. *
  53247. * @param uint8array The binary file stored in an array buffer.
  53248. * @param hdrInfo The header information of the file.
  53249. * @return The pixels data in RGB right to left up to down order.
  53250. */
  53251. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53252. private static RGBE_ReadPixels_RLE;
  53253. }
  53254. }
  53255. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53256. import { Nullable } from "babylonjs/types";
  53257. import { Scene } from "babylonjs/scene";
  53258. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53260. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53261. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53262. /**
  53263. * This represents a texture coming from an HDR input.
  53264. *
  53265. * The only supported format is currently panorama picture stored in RGBE format.
  53266. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53267. */
  53268. export class HDRCubeTexture extends BaseTexture {
  53269. private static _facesMapping;
  53270. private _generateHarmonics;
  53271. private _noMipmap;
  53272. private _textureMatrix;
  53273. private _size;
  53274. private _onLoad;
  53275. private _onError;
  53276. /**
  53277. * The texture URL.
  53278. */
  53279. url: string;
  53280. /**
  53281. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53282. */
  53283. coordinatesMode: number;
  53284. protected _isBlocking: boolean;
  53285. /**
  53286. * Sets wether or not the texture is blocking during loading.
  53287. */
  53288. /**
  53289. * Gets wether or not the texture is blocking during loading.
  53290. */
  53291. isBlocking: boolean;
  53292. protected _rotationY: number;
  53293. /**
  53294. * Sets texture matrix rotation angle around Y axis in radians.
  53295. */
  53296. /**
  53297. * Gets texture matrix rotation angle around Y axis radians.
  53298. */
  53299. rotationY: number;
  53300. /**
  53301. * Gets or sets the center of the bounding box associated with the cube texture
  53302. * It must define where the camera used to render the texture was set
  53303. */
  53304. boundingBoxPosition: Vector3;
  53305. private _boundingBoxSize;
  53306. /**
  53307. * Gets or sets the size of the bounding box associated with the cube texture
  53308. * When defined, the cubemap will switch to local mode
  53309. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53310. * @example https://www.babylonjs-playground.com/#RNASML
  53311. */
  53312. boundingBoxSize: Vector3;
  53313. /**
  53314. * Instantiates an HDRTexture from the following parameters.
  53315. *
  53316. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53317. * @param scene The scene the texture will be used in
  53318. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53319. * @param noMipmap Forces to not generate the mipmap if true
  53320. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53321. * @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)
  53322. * @param reserved Reserved flag for internal use.
  53323. */
  53324. 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>);
  53325. /**
  53326. * Get the current class name of the texture useful for serialization or dynamic coding.
  53327. * @returns "HDRCubeTexture"
  53328. */
  53329. getClassName(): string;
  53330. /**
  53331. * Occurs when the file is raw .hdr file.
  53332. */
  53333. private loadTexture;
  53334. clone(): HDRCubeTexture;
  53335. delayLoad(): void;
  53336. /**
  53337. * Get the texture reflection matrix used to rotate/transform the reflection.
  53338. * @returns the reflection matrix
  53339. */
  53340. getReflectionTextureMatrix(): Matrix;
  53341. /**
  53342. * Set the texture reflection matrix used to rotate/transform the reflection.
  53343. * @param value Define the reflection matrix to set
  53344. */
  53345. setReflectionTextureMatrix(value: Matrix): void;
  53346. /**
  53347. * Parses a JSON representation of an HDR Texture in order to create the texture
  53348. * @param parsedTexture Define the JSON representation
  53349. * @param scene Define the scene the texture should be created in
  53350. * @param rootUrl Define the root url in case we need to load relative dependencies
  53351. * @returns the newly created texture after parsing
  53352. */
  53353. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53354. serialize(): any;
  53355. }
  53356. }
  53357. declare module "babylonjs/Physics/physicsEngine" {
  53358. import { Nullable } from "babylonjs/types";
  53359. import { Vector3 } from "babylonjs/Maths/math.vector";
  53360. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53361. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53362. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53363. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53364. /**
  53365. * Class used to control physics engine
  53366. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53367. */
  53368. export class PhysicsEngine implements IPhysicsEngine {
  53369. private _physicsPlugin;
  53370. /**
  53371. * Global value used to control the smallest number supported by the simulation
  53372. */
  53373. static Epsilon: number;
  53374. private _impostors;
  53375. private _joints;
  53376. /**
  53377. * Gets the gravity vector used by the simulation
  53378. */
  53379. gravity: Vector3;
  53380. /**
  53381. * Factory used to create the default physics plugin.
  53382. * @returns The default physics plugin
  53383. */
  53384. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53385. /**
  53386. * Creates a new Physics Engine
  53387. * @param gravity defines the gravity vector used by the simulation
  53388. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53389. */
  53390. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53391. /**
  53392. * Sets the gravity vector used by the simulation
  53393. * @param gravity defines the gravity vector to use
  53394. */
  53395. setGravity(gravity: Vector3): void;
  53396. /**
  53397. * Set the time step of the physics engine.
  53398. * Default is 1/60.
  53399. * To slow it down, enter 1/600 for example.
  53400. * To speed it up, 1/30
  53401. * @param newTimeStep defines the new timestep to apply to this world.
  53402. */
  53403. setTimeStep(newTimeStep?: number): void;
  53404. /**
  53405. * Get the time step of the physics engine.
  53406. * @returns the current time step
  53407. */
  53408. getTimeStep(): number;
  53409. /**
  53410. * Release all resources
  53411. */
  53412. dispose(): void;
  53413. /**
  53414. * Gets the name of the current physics plugin
  53415. * @returns the name of the plugin
  53416. */
  53417. getPhysicsPluginName(): string;
  53418. /**
  53419. * Adding a new impostor for the impostor tracking.
  53420. * This will be done by the impostor itself.
  53421. * @param impostor the impostor to add
  53422. */
  53423. addImpostor(impostor: PhysicsImpostor): void;
  53424. /**
  53425. * Remove an impostor from the engine.
  53426. * This impostor and its mesh will not longer be updated by the physics engine.
  53427. * @param impostor the impostor to remove
  53428. */
  53429. removeImpostor(impostor: PhysicsImpostor): void;
  53430. /**
  53431. * Add a joint to the physics engine
  53432. * @param mainImpostor defines the main impostor to which the joint is added.
  53433. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53434. * @param joint defines the joint that will connect both impostors.
  53435. */
  53436. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53437. /**
  53438. * Removes a joint from the simulation
  53439. * @param mainImpostor defines the impostor used with the joint
  53440. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53441. * @param joint defines the joint to remove
  53442. */
  53443. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53444. /**
  53445. * Called by the scene. No need to call it.
  53446. * @param delta defines the timespam between frames
  53447. */
  53448. _step(delta: number): void;
  53449. /**
  53450. * Gets the current plugin used to run the simulation
  53451. * @returns current plugin
  53452. */
  53453. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53454. /**
  53455. * Gets the list of physic impostors
  53456. * @returns an array of PhysicsImpostor
  53457. */
  53458. getImpostors(): Array<PhysicsImpostor>;
  53459. /**
  53460. * Gets the impostor for a physics enabled object
  53461. * @param object defines the object impersonated by the impostor
  53462. * @returns the PhysicsImpostor or null if not found
  53463. */
  53464. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53465. /**
  53466. * Gets the impostor for a physics body object
  53467. * @param body defines physics body used by the impostor
  53468. * @returns the PhysicsImpostor or null if not found
  53469. */
  53470. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53471. /**
  53472. * Does a raycast in the physics world
  53473. * @param from when should the ray start?
  53474. * @param to when should the ray end?
  53475. * @returns PhysicsRaycastResult
  53476. */
  53477. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53478. }
  53479. }
  53480. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53481. import { Nullable } from "babylonjs/types";
  53482. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53484. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53485. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53486. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53487. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53488. /** @hidden */
  53489. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53490. private _useDeltaForWorldStep;
  53491. world: any;
  53492. name: string;
  53493. private _physicsMaterials;
  53494. private _fixedTimeStep;
  53495. private _cannonRaycastResult;
  53496. private _raycastResult;
  53497. private _physicsBodysToRemoveAfterStep;
  53498. BJSCANNON: any;
  53499. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53500. setGravity(gravity: Vector3): void;
  53501. setTimeStep(timeStep: number): void;
  53502. getTimeStep(): number;
  53503. executeStep(delta: number): void;
  53504. private _removeMarkedPhysicsBodiesFromWorld;
  53505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53507. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53508. private _processChildMeshes;
  53509. removePhysicsBody(impostor: PhysicsImpostor): void;
  53510. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53511. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53512. private _addMaterial;
  53513. private _checkWithEpsilon;
  53514. private _createShape;
  53515. private _createHeightmap;
  53516. private _minus90X;
  53517. private _plus90X;
  53518. private _tmpPosition;
  53519. private _tmpDeltaPosition;
  53520. private _tmpUnityRotation;
  53521. private _updatePhysicsBodyTransformation;
  53522. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53523. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53524. isSupported(): boolean;
  53525. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53526. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53527. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53528. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53529. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53530. getBodyMass(impostor: PhysicsImpostor): number;
  53531. getBodyFriction(impostor: PhysicsImpostor): number;
  53532. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53533. getBodyRestitution(impostor: PhysicsImpostor): number;
  53534. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53535. sleepBody(impostor: PhysicsImpostor): void;
  53536. wakeUpBody(impostor: PhysicsImpostor): void;
  53537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53538. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53540. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53541. getRadius(impostor: PhysicsImpostor): number;
  53542. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53543. dispose(): void;
  53544. private _extendNamespace;
  53545. /**
  53546. * Does a raycast in the physics world
  53547. * @param from when should the ray start?
  53548. * @param to when should the ray end?
  53549. * @returns PhysicsRaycastResult
  53550. */
  53551. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53552. }
  53553. }
  53554. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53555. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53556. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53557. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53559. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53560. import { Nullable } from "babylonjs/types";
  53561. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53562. /** @hidden */
  53563. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53564. world: any;
  53565. name: string;
  53566. BJSOIMO: any;
  53567. private _raycastResult;
  53568. constructor(iterations?: number, oimoInjection?: any);
  53569. setGravity(gravity: Vector3): void;
  53570. setTimeStep(timeStep: number): void;
  53571. getTimeStep(): number;
  53572. private _tmpImpostorsArray;
  53573. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53574. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53575. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53576. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53577. private _tmpPositionVector;
  53578. removePhysicsBody(impostor: PhysicsImpostor): void;
  53579. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53581. isSupported(): boolean;
  53582. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53583. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53584. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53586. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53588. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53589. getBodyMass(impostor: PhysicsImpostor): number;
  53590. getBodyFriction(impostor: PhysicsImpostor): number;
  53591. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53592. getBodyRestitution(impostor: PhysicsImpostor): number;
  53593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53594. sleepBody(impostor: PhysicsImpostor): void;
  53595. wakeUpBody(impostor: PhysicsImpostor): void;
  53596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53597. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53600. getRadius(impostor: PhysicsImpostor): number;
  53601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53602. dispose(): void;
  53603. /**
  53604. * Does a raycast in the physics world
  53605. * @param from when should the ray start?
  53606. * @param to when should the ray end?
  53607. * @returns PhysicsRaycastResult
  53608. */
  53609. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53610. }
  53611. }
  53612. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53613. import { Nullable } from "babylonjs/types";
  53614. import { Scene } from "babylonjs/scene";
  53615. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53616. import { Color4 } from "babylonjs/Maths/math.color";
  53617. import { Mesh } from "babylonjs/Meshes/mesh";
  53618. /**
  53619. * Class containing static functions to help procedurally build meshes
  53620. */
  53621. export class RibbonBuilder {
  53622. /**
  53623. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53624. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53625. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53626. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53627. * * 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
  53628. * * 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
  53629. * * 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
  53630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53633. * * 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
  53634. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53635. * * 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
  53636. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53638. * @param name defines the name of the mesh
  53639. * @param options defines the options used to create the mesh
  53640. * @param scene defines the hosting scene
  53641. * @returns the ribbon mesh
  53642. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53644. */
  53645. static CreateRibbon(name: string, options: {
  53646. pathArray: Vector3[][];
  53647. closeArray?: boolean;
  53648. closePath?: boolean;
  53649. offset?: number;
  53650. updatable?: boolean;
  53651. sideOrientation?: number;
  53652. frontUVs?: Vector4;
  53653. backUVs?: Vector4;
  53654. instance?: Mesh;
  53655. invertUV?: boolean;
  53656. uvs?: Vector2[];
  53657. colors?: Color4[];
  53658. }, scene?: Nullable<Scene>): Mesh;
  53659. }
  53660. }
  53661. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53662. import { Nullable } from "babylonjs/types";
  53663. import { Scene } from "babylonjs/scene";
  53664. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53665. import { Mesh } from "babylonjs/Meshes/mesh";
  53666. /**
  53667. * Class containing static functions to help procedurally build meshes
  53668. */
  53669. export class ShapeBuilder {
  53670. /**
  53671. * 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.
  53672. * * 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.
  53673. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53674. * * 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.
  53675. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53676. * * 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
  53677. * * 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
  53678. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53683. * @param name defines the name of the mesh
  53684. * @param options defines the options used to create the mesh
  53685. * @param scene defines the hosting scene
  53686. * @returns the extruded shape mesh
  53687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53689. */
  53690. static ExtrudeShape(name: string, options: {
  53691. shape: Vector3[];
  53692. path: Vector3[];
  53693. scale?: number;
  53694. rotation?: number;
  53695. cap?: number;
  53696. updatable?: boolean;
  53697. sideOrientation?: number;
  53698. frontUVs?: Vector4;
  53699. backUVs?: Vector4;
  53700. instance?: Mesh;
  53701. invertUV?: boolean;
  53702. }, scene?: Nullable<Scene>): Mesh;
  53703. /**
  53704. * Creates an custom extruded shape mesh.
  53705. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53706. * * 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.
  53707. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53708. * * 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
  53709. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53710. * * 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
  53711. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53712. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53713. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53714. * * 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
  53715. * * 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
  53716. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53721. * @param name defines the name of the mesh
  53722. * @param options defines the options used to create the mesh
  53723. * @param scene defines the hosting scene
  53724. * @returns the custom extruded shape mesh
  53725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53726. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53728. */
  53729. static ExtrudeShapeCustom(name: string, options: {
  53730. shape: Vector3[];
  53731. path: Vector3[];
  53732. scaleFunction?: any;
  53733. rotationFunction?: any;
  53734. ribbonCloseArray?: boolean;
  53735. ribbonClosePath?: boolean;
  53736. cap?: number;
  53737. updatable?: boolean;
  53738. sideOrientation?: number;
  53739. frontUVs?: Vector4;
  53740. backUVs?: Vector4;
  53741. instance?: Mesh;
  53742. invertUV?: boolean;
  53743. }, scene?: Nullable<Scene>): Mesh;
  53744. private static _ExtrudeShapeGeneric;
  53745. }
  53746. }
  53747. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53748. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53749. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53750. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53751. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53752. import { Nullable } from "babylonjs/types";
  53753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53754. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53755. /**
  53756. * AmmoJS Physics plugin
  53757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53758. * @see https://github.com/kripken/ammo.js/
  53759. */
  53760. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53761. private _useDeltaForWorldStep;
  53762. /**
  53763. * Reference to the Ammo library
  53764. */
  53765. bjsAMMO: any;
  53766. /**
  53767. * Created ammoJS world which physics bodies are added to
  53768. */
  53769. world: any;
  53770. /**
  53771. * Name of the plugin
  53772. */
  53773. name: string;
  53774. private _timeStep;
  53775. private _fixedTimeStep;
  53776. private _maxSteps;
  53777. private _tmpQuaternion;
  53778. private _tmpAmmoTransform;
  53779. private _tmpAmmoQuaternion;
  53780. private _tmpAmmoConcreteContactResultCallback;
  53781. private _collisionConfiguration;
  53782. private _dispatcher;
  53783. private _overlappingPairCache;
  53784. private _solver;
  53785. private _softBodySolver;
  53786. private _tmpAmmoVectorA;
  53787. private _tmpAmmoVectorB;
  53788. private _tmpAmmoVectorC;
  53789. private _tmpAmmoVectorD;
  53790. private _tmpContactCallbackResult;
  53791. private _tmpAmmoVectorRCA;
  53792. private _tmpAmmoVectorRCB;
  53793. private _raycastResult;
  53794. private static readonly DISABLE_COLLISION_FLAG;
  53795. private static readonly KINEMATIC_FLAG;
  53796. private static readonly DISABLE_DEACTIVATION_FLAG;
  53797. /**
  53798. * Initializes the ammoJS plugin
  53799. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53800. * @param ammoInjection can be used to inject your own ammo reference
  53801. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53802. */
  53803. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53804. /**
  53805. * Sets the gravity of the physics world (m/(s^2))
  53806. * @param gravity Gravity to set
  53807. */
  53808. setGravity(gravity: Vector3): void;
  53809. /**
  53810. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53811. * @param timeStep timestep to use in seconds
  53812. */
  53813. setTimeStep(timeStep: number): void;
  53814. /**
  53815. * 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)
  53816. * @param fixedTimeStep fixedTimeStep to use in seconds
  53817. */
  53818. setFixedTimeStep(fixedTimeStep: number): void;
  53819. /**
  53820. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53821. * @param maxSteps the maximum number of steps by the physics engine per frame
  53822. */
  53823. setMaxSteps(maxSteps: number): void;
  53824. /**
  53825. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53826. * @returns the current timestep in seconds
  53827. */
  53828. getTimeStep(): number;
  53829. private _isImpostorInContact;
  53830. private _isImpostorPairInContact;
  53831. private _stepSimulation;
  53832. /**
  53833. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53834. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53835. * After the step the babylon meshes are set to the position of the physics imposters
  53836. * @param delta amount of time to step forward
  53837. * @param impostors array of imposters to update before/after the step
  53838. */
  53839. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53840. /**
  53841. * Update babylon mesh to match physics world object
  53842. * @param impostor imposter to match
  53843. */
  53844. private _afterSoftStep;
  53845. /**
  53846. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53847. * @param impostor imposter to match
  53848. */
  53849. private _ropeStep;
  53850. /**
  53851. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53852. * @param impostor imposter to match
  53853. */
  53854. private _softbodyOrClothStep;
  53855. private _tmpVector;
  53856. private _tmpMatrix;
  53857. /**
  53858. * Applies an impulse on the imposter
  53859. * @param impostor imposter to apply impulse to
  53860. * @param force amount of force to be applied to the imposter
  53861. * @param contactPoint the location to apply the impulse on the imposter
  53862. */
  53863. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53864. /**
  53865. * Applies a force on the imposter
  53866. * @param impostor imposter to apply force
  53867. * @param force amount of force to be applied to the imposter
  53868. * @param contactPoint the location to apply the force on the imposter
  53869. */
  53870. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53871. /**
  53872. * Creates a physics body using the plugin
  53873. * @param impostor the imposter to create the physics body on
  53874. */
  53875. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53876. /**
  53877. * Removes the physics body from the imposter and disposes of the body's memory
  53878. * @param impostor imposter to remove the physics body from
  53879. */
  53880. removePhysicsBody(impostor: PhysicsImpostor): void;
  53881. /**
  53882. * Generates a joint
  53883. * @param impostorJoint the imposter joint to create the joint with
  53884. */
  53885. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53886. /**
  53887. * Removes a joint
  53888. * @param impostorJoint the imposter joint to remove the joint from
  53889. */
  53890. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53891. private _addMeshVerts;
  53892. /**
  53893. * Initialise the soft body vertices to match its object's (mesh) vertices
  53894. * Softbody vertices (nodes) are in world space and to match this
  53895. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53896. * @param impostor to create the softbody for
  53897. */
  53898. private _softVertexData;
  53899. /**
  53900. * Create an impostor's soft body
  53901. * @param impostor to create the softbody for
  53902. */
  53903. private _createSoftbody;
  53904. /**
  53905. * Create cloth for an impostor
  53906. * @param impostor to create the softbody for
  53907. */
  53908. private _createCloth;
  53909. /**
  53910. * Create rope for an impostor
  53911. * @param impostor to create the softbody for
  53912. */
  53913. private _createRope;
  53914. private _addHullVerts;
  53915. private _createShape;
  53916. /**
  53917. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53918. * @param impostor imposter containing the physics body and babylon object
  53919. */
  53920. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53921. /**
  53922. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53923. * @param impostor imposter containing the physics body and babylon object
  53924. * @param newPosition new position
  53925. * @param newRotation new rotation
  53926. */
  53927. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53928. /**
  53929. * If this plugin is supported
  53930. * @returns true if its supported
  53931. */
  53932. isSupported(): boolean;
  53933. /**
  53934. * Sets the linear velocity of the physics body
  53935. * @param impostor imposter to set the velocity on
  53936. * @param velocity velocity to set
  53937. */
  53938. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53939. /**
  53940. * Sets the angular velocity of the physics body
  53941. * @param impostor imposter to set the velocity on
  53942. * @param velocity velocity to set
  53943. */
  53944. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53945. /**
  53946. * gets the linear velocity
  53947. * @param impostor imposter to get linear velocity from
  53948. * @returns linear velocity
  53949. */
  53950. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53951. /**
  53952. * gets the angular velocity
  53953. * @param impostor imposter to get angular velocity from
  53954. * @returns angular velocity
  53955. */
  53956. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53957. /**
  53958. * Sets the mass of physics body
  53959. * @param impostor imposter to set the mass on
  53960. * @param mass mass to set
  53961. */
  53962. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53963. /**
  53964. * Gets the mass of the physics body
  53965. * @param impostor imposter to get the mass from
  53966. * @returns mass
  53967. */
  53968. getBodyMass(impostor: PhysicsImpostor): number;
  53969. /**
  53970. * Gets friction of the impostor
  53971. * @param impostor impostor to get friction from
  53972. * @returns friction value
  53973. */
  53974. getBodyFriction(impostor: PhysicsImpostor): number;
  53975. /**
  53976. * Sets friction of the impostor
  53977. * @param impostor impostor to set friction on
  53978. * @param friction friction value
  53979. */
  53980. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53981. /**
  53982. * Gets restitution of the impostor
  53983. * @param impostor impostor to get restitution from
  53984. * @returns restitution value
  53985. */
  53986. getBodyRestitution(impostor: PhysicsImpostor): number;
  53987. /**
  53988. * Sets resitution of the impostor
  53989. * @param impostor impostor to set resitution on
  53990. * @param restitution resitution value
  53991. */
  53992. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53993. /**
  53994. * Gets pressure inside the impostor
  53995. * @param impostor impostor to get pressure from
  53996. * @returns pressure value
  53997. */
  53998. getBodyPressure(impostor: PhysicsImpostor): number;
  53999. /**
  54000. * Sets pressure inside a soft body impostor
  54001. * Cloth and rope must remain 0 pressure
  54002. * @param impostor impostor to set pressure on
  54003. * @param pressure pressure value
  54004. */
  54005. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54006. /**
  54007. * Gets stiffness of the impostor
  54008. * @param impostor impostor to get stiffness from
  54009. * @returns pressure value
  54010. */
  54011. getBodyStiffness(impostor: PhysicsImpostor): number;
  54012. /**
  54013. * Sets stiffness of the impostor
  54014. * @param impostor impostor to set stiffness on
  54015. * @param stiffness stiffness value from 0 to 1
  54016. */
  54017. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54018. /**
  54019. * Gets velocityIterations of the impostor
  54020. * @param impostor impostor to get velocity iterations from
  54021. * @returns velocityIterations value
  54022. */
  54023. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54024. /**
  54025. * Sets velocityIterations of the impostor
  54026. * @param impostor impostor to set velocity iterations on
  54027. * @param velocityIterations velocityIterations value
  54028. */
  54029. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54030. /**
  54031. * Gets positionIterations of the impostor
  54032. * @param impostor impostor to get position iterations from
  54033. * @returns positionIterations value
  54034. */
  54035. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54036. /**
  54037. * Sets positionIterations of the impostor
  54038. * @param impostor impostor to set position on
  54039. * @param positionIterations positionIterations value
  54040. */
  54041. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54042. /**
  54043. * Append an anchor to a cloth object
  54044. * @param impostor is the cloth impostor to add anchor to
  54045. * @param otherImpostor is the rigid impostor to anchor to
  54046. * @param width ratio across width from 0 to 1
  54047. * @param height ratio up height from 0 to 1
  54048. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54049. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54050. */
  54051. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54052. /**
  54053. * Append an hook to a rope object
  54054. * @param impostor is the rope impostor to add hook to
  54055. * @param otherImpostor is the rigid impostor to hook to
  54056. * @param length ratio along the rope from 0 to 1
  54057. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54058. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54059. */
  54060. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54061. /**
  54062. * Sleeps the physics body and stops it from being active
  54063. * @param impostor impostor to sleep
  54064. */
  54065. sleepBody(impostor: PhysicsImpostor): void;
  54066. /**
  54067. * Activates the physics body
  54068. * @param impostor impostor to activate
  54069. */
  54070. wakeUpBody(impostor: PhysicsImpostor): void;
  54071. /**
  54072. * Updates the distance parameters of the joint
  54073. * @param joint joint to update
  54074. * @param maxDistance maximum distance of the joint
  54075. * @param minDistance minimum distance of the joint
  54076. */
  54077. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54078. /**
  54079. * Sets a motor on the joint
  54080. * @param joint joint to set motor on
  54081. * @param speed speed of the motor
  54082. * @param maxForce maximum force of the motor
  54083. * @param motorIndex index of the motor
  54084. */
  54085. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54086. /**
  54087. * Sets the motors limit
  54088. * @param joint joint to set limit on
  54089. * @param upperLimit upper limit
  54090. * @param lowerLimit lower limit
  54091. */
  54092. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54093. /**
  54094. * Syncs the position and rotation of a mesh with the impostor
  54095. * @param mesh mesh to sync
  54096. * @param impostor impostor to update the mesh with
  54097. */
  54098. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54099. /**
  54100. * Gets the radius of the impostor
  54101. * @param impostor impostor to get radius from
  54102. * @returns the radius
  54103. */
  54104. getRadius(impostor: PhysicsImpostor): number;
  54105. /**
  54106. * Gets the box size of the impostor
  54107. * @param impostor impostor to get box size from
  54108. * @param result the resulting box size
  54109. */
  54110. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54111. /**
  54112. * Disposes of the impostor
  54113. */
  54114. dispose(): void;
  54115. /**
  54116. * Does a raycast in the physics world
  54117. * @param from when should the ray start?
  54118. * @param to when should the ray end?
  54119. * @returns PhysicsRaycastResult
  54120. */
  54121. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54122. }
  54123. }
  54124. declare module "babylonjs/Probes/reflectionProbe" {
  54125. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54126. import { Vector3 } from "babylonjs/Maths/math.vector";
  54127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54128. import { Nullable } from "babylonjs/types";
  54129. import { Scene } from "babylonjs/scene";
  54130. module "babylonjs/abstractScene" {
  54131. interface AbstractScene {
  54132. /**
  54133. * The list of reflection probes added to the scene
  54134. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54135. */
  54136. reflectionProbes: Array<ReflectionProbe>;
  54137. /**
  54138. * Removes the given reflection probe from this scene.
  54139. * @param toRemove The reflection probe to remove
  54140. * @returns The index of the removed reflection probe
  54141. */
  54142. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54143. /**
  54144. * Adds the given reflection probe to this scene.
  54145. * @param newReflectionProbe The reflection probe to add
  54146. */
  54147. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54148. }
  54149. }
  54150. /**
  54151. * Class used to generate realtime reflection / refraction cube textures
  54152. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54153. */
  54154. export class ReflectionProbe {
  54155. /** defines the name of the probe */
  54156. name: string;
  54157. private _scene;
  54158. private _renderTargetTexture;
  54159. private _projectionMatrix;
  54160. private _viewMatrix;
  54161. private _target;
  54162. private _add;
  54163. private _attachedMesh;
  54164. private _invertYAxis;
  54165. /** Gets or sets probe position (center of the cube map) */
  54166. position: Vector3;
  54167. /**
  54168. * Creates a new reflection probe
  54169. * @param name defines the name of the probe
  54170. * @param size defines the texture resolution (for each face)
  54171. * @param scene defines the hosting scene
  54172. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54173. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54174. */
  54175. constructor(
  54176. /** defines the name of the probe */
  54177. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54178. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54179. samples: number;
  54180. /** Gets or sets the refresh rate to use (on every frame by default) */
  54181. refreshRate: number;
  54182. /**
  54183. * Gets the hosting scene
  54184. * @returns a Scene
  54185. */
  54186. getScene(): Scene;
  54187. /** Gets the internal CubeTexture used to render to */
  54188. readonly cubeTexture: RenderTargetTexture;
  54189. /** Gets the list of meshes to render */
  54190. readonly renderList: Nullable<AbstractMesh[]>;
  54191. /**
  54192. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54193. * @param mesh defines the mesh to attach to
  54194. */
  54195. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54196. /**
  54197. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54198. * @param renderingGroupId The rendering group id corresponding to its index
  54199. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54200. */
  54201. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54202. /**
  54203. * Clean all associated resources
  54204. */
  54205. dispose(): void;
  54206. /**
  54207. * Converts the reflection probe information to a readable string for debug purpose.
  54208. * @param fullDetails Supports for multiple levels of logging within scene loading
  54209. * @returns the human readable reflection probe info
  54210. */
  54211. toString(fullDetails?: boolean): string;
  54212. /**
  54213. * Get the class name of the relfection probe.
  54214. * @returns "ReflectionProbe"
  54215. */
  54216. getClassName(): string;
  54217. /**
  54218. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54219. * @returns The JSON representation of the texture
  54220. */
  54221. serialize(): any;
  54222. /**
  54223. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54224. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54225. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54226. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54227. * @returns The parsed reflection probe if successful
  54228. */
  54229. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54230. }
  54231. }
  54232. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54233. /** @hidden */
  54234. export var _BabylonLoaderRegistered: boolean;
  54235. }
  54236. declare module "babylonjs/Loading/Plugins/index" {
  54237. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54238. }
  54239. declare module "babylonjs/Loading/index" {
  54240. export * from "babylonjs/Loading/loadingScreen";
  54241. export * from "babylonjs/Loading/Plugins/index";
  54242. export * from "babylonjs/Loading/sceneLoader";
  54243. export * from "babylonjs/Loading/sceneLoaderFlags";
  54244. }
  54245. declare module "babylonjs/Materials/Background/index" {
  54246. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54247. }
  54248. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54249. import { Scene } from "babylonjs/scene";
  54250. import { Color3 } from "babylonjs/Maths/math.color";
  54251. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54253. /**
  54254. * The Physically based simple base material of BJS.
  54255. *
  54256. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54257. * It is used as the base class for both the specGloss and metalRough conventions.
  54258. */
  54259. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54260. /**
  54261. * Number of Simultaneous lights allowed on the material.
  54262. */
  54263. maxSimultaneousLights: number;
  54264. /**
  54265. * If sets to true, disables all the lights affecting the material.
  54266. */
  54267. disableLighting: boolean;
  54268. /**
  54269. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54270. */
  54271. environmentTexture: BaseTexture;
  54272. /**
  54273. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54274. */
  54275. invertNormalMapX: boolean;
  54276. /**
  54277. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54278. */
  54279. invertNormalMapY: boolean;
  54280. /**
  54281. * Normal map used in the model.
  54282. */
  54283. normalTexture: BaseTexture;
  54284. /**
  54285. * Emissivie color used to self-illuminate the model.
  54286. */
  54287. emissiveColor: Color3;
  54288. /**
  54289. * Emissivie texture used to self-illuminate the model.
  54290. */
  54291. emissiveTexture: BaseTexture;
  54292. /**
  54293. * Occlusion Channel Strenght.
  54294. */
  54295. occlusionStrength: number;
  54296. /**
  54297. * Occlusion Texture of the material (adding extra occlusion effects).
  54298. */
  54299. occlusionTexture: BaseTexture;
  54300. /**
  54301. * Defines the alpha limits in alpha test mode.
  54302. */
  54303. alphaCutOff: number;
  54304. /**
  54305. * Gets the current double sided mode.
  54306. */
  54307. /**
  54308. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54309. */
  54310. doubleSided: boolean;
  54311. /**
  54312. * Stores the pre-calculated light information of a mesh in a texture.
  54313. */
  54314. lightmapTexture: BaseTexture;
  54315. /**
  54316. * If true, the light map contains occlusion information instead of lighting info.
  54317. */
  54318. useLightmapAsShadowmap: boolean;
  54319. /**
  54320. * Instantiates a new PBRMaterial instance.
  54321. *
  54322. * @param name The material name
  54323. * @param scene The scene the material will be use in.
  54324. */
  54325. constructor(name: string, scene: Scene);
  54326. getClassName(): string;
  54327. }
  54328. }
  54329. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54330. import { Scene } from "babylonjs/scene";
  54331. import { Color3 } from "babylonjs/Maths/math.color";
  54332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54333. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54334. /**
  54335. * The PBR material of BJS following the metal roughness convention.
  54336. *
  54337. * This fits to the PBR convention in the GLTF definition:
  54338. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54339. */
  54340. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54341. /**
  54342. * The base color has two different interpretations depending on the value of metalness.
  54343. * When the material is a metal, the base color is the specific measured reflectance value
  54344. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54345. * of the material.
  54346. */
  54347. baseColor: Color3;
  54348. /**
  54349. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54350. * well as opacity information in the alpha channel.
  54351. */
  54352. baseTexture: BaseTexture;
  54353. /**
  54354. * Specifies the metallic scalar value of the material.
  54355. * Can also be used to scale the metalness values of the metallic texture.
  54356. */
  54357. metallic: number;
  54358. /**
  54359. * Specifies the roughness scalar value of the material.
  54360. * Can also be used to scale the roughness values of the metallic texture.
  54361. */
  54362. roughness: number;
  54363. /**
  54364. * Texture containing both the metallic value in the B channel and the
  54365. * roughness value in the G channel to keep better precision.
  54366. */
  54367. metallicRoughnessTexture: BaseTexture;
  54368. /**
  54369. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54370. *
  54371. * @param name The material name
  54372. * @param scene The scene the material will be use in.
  54373. */
  54374. constructor(name: string, scene: Scene);
  54375. /**
  54376. * Return the currrent class name of the material.
  54377. */
  54378. getClassName(): string;
  54379. /**
  54380. * Makes a duplicate of the current material.
  54381. * @param name - name to use for the new material.
  54382. */
  54383. clone(name: string): PBRMetallicRoughnessMaterial;
  54384. /**
  54385. * Serialize the material to a parsable JSON object.
  54386. */
  54387. serialize(): any;
  54388. /**
  54389. * Parses a JSON object correponding to the serialize function.
  54390. */
  54391. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54392. }
  54393. }
  54394. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54395. import { Scene } from "babylonjs/scene";
  54396. import { Color3 } from "babylonjs/Maths/math.color";
  54397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54398. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54399. /**
  54400. * The PBR material of BJS following the specular glossiness convention.
  54401. *
  54402. * This fits to the PBR convention in the GLTF definition:
  54403. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54404. */
  54405. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54406. /**
  54407. * Specifies the diffuse color of the material.
  54408. */
  54409. diffuseColor: Color3;
  54410. /**
  54411. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54412. * channel.
  54413. */
  54414. diffuseTexture: BaseTexture;
  54415. /**
  54416. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54417. */
  54418. specularColor: Color3;
  54419. /**
  54420. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54421. */
  54422. glossiness: number;
  54423. /**
  54424. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54425. */
  54426. specularGlossinessTexture: BaseTexture;
  54427. /**
  54428. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54429. *
  54430. * @param name The material name
  54431. * @param scene The scene the material will be use in.
  54432. */
  54433. constructor(name: string, scene: Scene);
  54434. /**
  54435. * Return the currrent class name of the material.
  54436. */
  54437. getClassName(): string;
  54438. /**
  54439. * Makes a duplicate of the current material.
  54440. * @param name - name to use for the new material.
  54441. */
  54442. clone(name: string): PBRSpecularGlossinessMaterial;
  54443. /**
  54444. * Serialize the material to a parsable JSON object.
  54445. */
  54446. serialize(): any;
  54447. /**
  54448. * Parses a JSON object correponding to the serialize function.
  54449. */
  54450. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54451. }
  54452. }
  54453. declare module "babylonjs/Materials/PBR/index" {
  54454. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54455. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54456. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54457. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54458. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54459. }
  54460. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54461. import { Nullable } from "babylonjs/types";
  54462. import { Scene } from "babylonjs/scene";
  54463. import { Matrix } from "babylonjs/Maths/math.vector";
  54464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54465. /**
  54466. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54467. * It can help converting any input color in a desired output one. This can then be used to create effects
  54468. * from sepia, black and white to sixties or futuristic rendering...
  54469. *
  54470. * The only supported format is currently 3dl.
  54471. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54472. */
  54473. export class ColorGradingTexture extends BaseTexture {
  54474. /**
  54475. * The current texture matrix. (will always be identity in color grading texture)
  54476. */
  54477. private _textureMatrix;
  54478. /**
  54479. * The texture URL.
  54480. */
  54481. url: string;
  54482. /**
  54483. * Empty line regex stored for GC.
  54484. */
  54485. private static _noneEmptyLineRegex;
  54486. private _engine;
  54487. /**
  54488. * Instantiates a ColorGradingTexture from the following parameters.
  54489. *
  54490. * @param url The location of the color gradind data (currently only supporting 3dl)
  54491. * @param scene The scene the texture will be used in
  54492. */
  54493. constructor(url: string, scene: Scene);
  54494. /**
  54495. * Returns the texture matrix used in most of the material.
  54496. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54497. */
  54498. getTextureMatrix(): Matrix;
  54499. /**
  54500. * Occurs when the file being loaded is a .3dl LUT file.
  54501. */
  54502. private load3dlTexture;
  54503. /**
  54504. * Starts the loading process of the texture.
  54505. */
  54506. private loadTexture;
  54507. /**
  54508. * Clones the color gradind texture.
  54509. */
  54510. clone(): ColorGradingTexture;
  54511. /**
  54512. * Called during delayed load for textures.
  54513. */
  54514. delayLoad(): void;
  54515. /**
  54516. * Parses a color grading texture serialized by Babylon.
  54517. * @param parsedTexture The texture information being parsedTexture
  54518. * @param scene The scene to load the texture in
  54519. * @param rootUrl The root url of the data assets to load
  54520. * @return A color gradind texture
  54521. */
  54522. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54523. /**
  54524. * Serializes the LUT texture to json format.
  54525. */
  54526. serialize(): any;
  54527. }
  54528. }
  54529. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54531. import { Scene } from "babylonjs/scene";
  54532. import { Nullable } from "babylonjs/types";
  54533. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54534. /**
  54535. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54536. */
  54537. export class EquiRectangularCubeTexture extends BaseTexture {
  54538. /** The six faces of the cube. */
  54539. private static _FacesMapping;
  54540. private _noMipmap;
  54541. private _onLoad;
  54542. private _onError;
  54543. /** The size of the cubemap. */
  54544. private _size;
  54545. /** The buffer of the image. */
  54546. private _buffer;
  54547. /** The width of the input image. */
  54548. private _width;
  54549. /** The height of the input image. */
  54550. private _height;
  54551. /** The URL to the image. */
  54552. url: string;
  54553. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54554. coordinatesMode: number;
  54555. /**
  54556. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54557. * @param url The location of the image
  54558. * @param scene The scene the texture will be used in
  54559. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54560. * @param noMipmap Forces to not generate the mipmap if true
  54561. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54562. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54563. * @param onLoad — defines a callback called when texture is loaded
  54564. * @param onError — defines a callback called if there is an error
  54565. */
  54566. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54567. /**
  54568. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54569. */
  54570. private loadImage;
  54571. /**
  54572. * Convert the image buffer into a cubemap and create a CubeTexture.
  54573. */
  54574. private loadTexture;
  54575. /**
  54576. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54577. * @param buffer The ArrayBuffer that should be converted.
  54578. * @returns The buffer as Float32Array.
  54579. */
  54580. private getFloat32ArrayFromArrayBuffer;
  54581. /**
  54582. * Get the current class name of the texture useful for serialization or dynamic coding.
  54583. * @returns "EquiRectangularCubeTexture"
  54584. */
  54585. getClassName(): string;
  54586. /**
  54587. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54588. * @returns A clone of the current EquiRectangularCubeTexture.
  54589. */
  54590. clone(): EquiRectangularCubeTexture;
  54591. }
  54592. }
  54593. declare module "babylonjs/Misc/tga" {
  54594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54595. /**
  54596. * Based on jsTGALoader - Javascript loader for TGA file
  54597. * By Vincent Thibault
  54598. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54599. */
  54600. export class TGATools {
  54601. private static _TYPE_INDEXED;
  54602. private static _TYPE_RGB;
  54603. private static _TYPE_GREY;
  54604. private static _TYPE_RLE_INDEXED;
  54605. private static _TYPE_RLE_RGB;
  54606. private static _TYPE_RLE_GREY;
  54607. private static _ORIGIN_MASK;
  54608. private static _ORIGIN_SHIFT;
  54609. private static _ORIGIN_BL;
  54610. private static _ORIGIN_BR;
  54611. private static _ORIGIN_UL;
  54612. private static _ORIGIN_UR;
  54613. /**
  54614. * Gets the header of a TGA file
  54615. * @param data defines the TGA data
  54616. * @returns the header
  54617. */
  54618. static GetTGAHeader(data: Uint8Array): any;
  54619. /**
  54620. * Uploads TGA content to a Babylon Texture
  54621. * @hidden
  54622. */
  54623. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54624. /** @hidden */
  54625. 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;
  54626. /** @hidden */
  54627. 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;
  54628. /** @hidden */
  54629. 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;
  54630. /** @hidden */
  54631. 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;
  54632. /** @hidden */
  54633. 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;
  54634. /** @hidden */
  54635. 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;
  54636. }
  54637. }
  54638. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54639. import { Nullable } from "babylonjs/types";
  54640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54641. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54642. /**
  54643. * Implementation of the TGA Texture Loader.
  54644. * @hidden
  54645. */
  54646. export class _TGATextureLoader implements IInternalTextureLoader {
  54647. /**
  54648. * Defines wether the loader supports cascade loading the different faces.
  54649. */
  54650. readonly supportCascades: boolean;
  54651. /**
  54652. * This returns if the loader support the current file information.
  54653. * @param extension defines the file extension of the file being loaded
  54654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54655. * @param fallback defines the fallback internal texture if any
  54656. * @param isBase64 defines whether the texture is encoded as a base64
  54657. * @param isBuffer defines whether the texture data are stored as a buffer
  54658. * @returns true if the loader can load the specified file
  54659. */
  54660. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54661. /**
  54662. * Transform the url before loading if required.
  54663. * @param rootUrl the url of the texture
  54664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54665. * @returns the transformed texture
  54666. */
  54667. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54668. /**
  54669. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54670. * @param rootUrl the url of the texture
  54671. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54672. * @returns the fallback texture
  54673. */
  54674. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54675. /**
  54676. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54677. * @param data contains the texture data
  54678. * @param texture defines the BabylonJS internal texture
  54679. * @param createPolynomials will be true if polynomials have been requested
  54680. * @param onLoad defines the callback to trigger once the texture is ready
  54681. * @param onError defines the callback to trigger in case of error
  54682. */
  54683. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54684. /**
  54685. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54686. * @param data contains the texture data
  54687. * @param texture defines the BabylonJS internal texture
  54688. * @param callback defines the method to call once ready to upload
  54689. */
  54690. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54691. }
  54692. }
  54693. declare module "babylonjs/Misc/basis" {
  54694. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54695. /**
  54696. * Info about the .basis files
  54697. */
  54698. class BasisFileInfo {
  54699. /**
  54700. * If the file has alpha
  54701. */
  54702. hasAlpha: boolean;
  54703. /**
  54704. * Info about each image of the basis file
  54705. */
  54706. images: Array<{
  54707. levels: Array<{
  54708. width: number;
  54709. height: number;
  54710. transcodedPixels: ArrayBufferView;
  54711. }>;
  54712. }>;
  54713. }
  54714. /**
  54715. * Result of transcoding a basis file
  54716. */
  54717. class TranscodeResult {
  54718. /**
  54719. * Info about the .basis file
  54720. */
  54721. fileInfo: BasisFileInfo;
  54722. /**
  54723. * Format to use when loading the file
  54724. */
  54725. format: number;
  54726. }
  54727. /**
  54728. * Configuration options for the Basis transcoder
  54729. */
  54730. export class BasisTranscodeConfiguration {
  54731. /**
  54732. * Supported compression formats used to determine the supported output format of the transcoder
  54733. */
  54734. supportedCompressionFormats?: {
  54735. /**
  54736. * etc1 compression format
  54737. */
  54738. etc1?: boolean;
  54739. /**
  54740. * s3tc compression format
  54741. */
  54742. s3tc?: boolean;
  54743. /**
  54744. * pvrtc compression format
  54745. */
  54746. pvrtc?: boolean;
  54747. /**
  54748. * etc2 compression format
  54749. */
  54750. etc2?: boolean;
  54751. };
  54752. /**
  54753. * If mipmap levels should be loaded for transcoded images (Default: true)
  54754. */
  54755. loadMipmapLevels?: boolean;
  54756. /**
  54757. * Index of a single image to load (Default: all images)
  54758. */
  54759. loadSingleImage?: number;
  54760. }
  54761. /**
  54762. * Used to load .Basis files
  54763. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54764. */
  54765. export class BasisTools {
  54766. private static _IgnoreSupportedFormats;
  54767. /**
  54768. * URL to use when loading the basis transcoder
  54769. */
  54770. static JSModuleURL: string;
  54771. /**
  54772. * URL to use when loading the wasm module for the transcoder
  54773. */
  54774. static WasmModuleURL: string;
  54775. /**
  54776. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54777. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54778. * @returns internal format corresponding to the Basis format
  54779. */
  54780. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54781. private static _WorkerPromise;
  54782. private static _Worker;
  54783. private static _actionId;
  54784. private static _CreateWorkerAsync;
  54785. /**
  54786. * Transcodes a loaded image file to compressed pixel data
  54787. * @param imageData image data to transcode
  54788. * @param config configuration options for the transcoding
  54789. * @returns a promise resulting in the transcoded image
  54790. */
  54791. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54792. /**
  54793. * Loads a texture from the transcode result
  54794. * @param texture texture load to
  54795. * @param transcodeResult the result of transcoding the basis file to load from
  54796. */
  54797. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54798. }
  54799. }
  54800. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54801. import { Nullable } from "babylonjs/types";
  54802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54803. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54804. /**
  54805. * Loader for .basis file format
  54806. */
  54807. export class _BasisTextureLoader implements IInternalTextureLoader {
  54808. /**
  54809. * Defines whether the loader supports cascade loading the different faces.
  54810. */
  54811. readonly supportCascades: boolean;
  54812. /**
  54813. * This returns if the loader support the current file information.
  54814. * @param extension defines the file extension of the file being loaded
  54815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54816. * @param fallback defines the fallback internal texture if any
  54817. * @param isBase64 defines whether the texture is encoded as a base64
  54818. * @param isBuffer defines whether the texture data are stored as a buffer
  54819. * @returns true if the loader can load the specified file
  54820. */
  54821. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54822. /**
  54823. * Transform the url before loading if required.
  54824. * @param rootUrl the url of the texture
  54825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54826. * @returns the transformed texture
  54827. */
  54828. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54829. /**
  54830. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54831. * @param rootUrl the url of the texture
  54832. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54833. * @returns the fallback texture
  54834. */
  54835. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54836. /**
  54837. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54838. * @param data contains the texture data
  54839. * @param texture defines the BabylonJS internal texture
  54840. * @param createPolynomials will be true if polynomials have been requested
  54841. * @param onLoad defines the callback to trigger once the texture is ready
  54842. * @param onError defines the callback to trigger in case of error
  54843. */
  54844. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54845. /**
  54846. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54847. * @param data contains the texture data
  54848. * @param texture defines the BabylonJS internal texture
  54849. * @param callback defines the method to call once ready to upload
  54850. */
  54851. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54852. }
  54853. }
  54854. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54855. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54856. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54857. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54858. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54859. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54860. }
  54861. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54862. import { Scene } from "babylonjs/scene";
  54863. import { Texture } from "babylonjs/Materials/Textures/texture";
  54864. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54865. /**
  54866. * 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.
  54867. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54868. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54869. */
  54870. export class CustomProceduralTexture extends ProceduralTexture {
  54871. private _animate;
  54872. private _time;
  54873. private _config;
  54874. private _texturePath;
  54875. /**
  54876. * Instantiates a new Custom Procedural Texture.
  54877. * 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.
  54878. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54879. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54880. * @param name Define the name of the texture
  54881. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54882. * @param size Define the size of the texture to create
  54883. * @param scene Define the scene the texture belongs to
  54884. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54885. * @param generateMipMaps Define if the texture should creates mip maps or not
  54886. */
  54887. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54888. private _loadJson;
  54889. /**
  54890. * Is the texture ready to be used ? (rendered at least once)
  54891. * @returns true if ready, otherwise, false.
  54892. */
  54893. isReady(): boolean;
  54894. /**
  54895. * Render the texture to its associated render target.
  54896. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54897. */
  54898. render(useCameraPostProcess?: boolean): void;
  54899. /**
  54900. * Update the list of dependant textures samplers in the shader.
  54901. */
  54902. updateTextures(): void;
  54903. /**
  54904. * Update the uniform values of the procedural texture in the shader.
  54905. */
  54906. updateShaderUniforms(): void;
  54907. /**
  54908. * Define if the texture animates or not.
  54909. */
  54910. animate: boolean;
  54911. }
  54912. }
  54913. declare module "babylonjs/Shaders/noise.fragment" {
  54914. /** @hidden */
  54915. export var noisePixelShader: {
  54916. name: string;
  54917. shader: string;
  54918. };
  54919. }
  54920. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54921. import { Nullable } from "babylonjs/types";
  54922. import { Scene } from "babylonjs/scene";
  54923. import { Texture } from "babylonjs/Materials/Textures/texture";
  54924. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54925. import "babylonjs/Shaders/noise.fragment";
  54926. /**
  54927. * Class used to generate noise procedural textures
  54928. */
  54929. export class NoiseProceduralTexture extends ProceduralTexture {
  54930. private _time;
  54931. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54932. brightness: number;
  54933. /** Defines the number of octaves to process */
  54934. octaves: number;
  54935. /** Defines the level of persistence (0.8 by default) */
  54936. persistence: number;
  54937. /** Gets or sets animation speed factor (default is 1) */
  54938. animationSpeedFactor: number;
  54939. /**
  54940. * Creates a new NoiseProceduralTexture
  54941. * @param name defines the name fo the texture
  54942. * @param size defines the size of the texture (default is 256)
  54943. * @param scene defines the hosting scene
  54944. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54945. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54946. */
  54947. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54948. private _updateShaderUniforms;
  54949. protected _getDefines(): string;
  54950. /** Generate the current state of the procedural texture */
  54951. render(useCameraPostProcess?: boolean): void;
  54952. /**
  54953. * Serializes this noise procedural texture
  54954. * @returns a serialized noise procedural texture object
  54955. */
  54956. serialize(): any;
  54957. /**
  54958. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54959. * @param parsedTexture defines parsed texture data
  54960. * @param scene defines the current scene
  54961. * @param rootUrl defines the root URL containing noise procedural texture information
  54962. * @returns a parsed NoiseProceduralTexture
  54963. */
  54964. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54965. }
  54966. }
  54967. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54968. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54969. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54970. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54971. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54972. }
  54973. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54974. import { Nullable } from "babylonjs/types";
  54975. import { Scene } from "babylonjs/scene";
  54976. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54978. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54979. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54980. /**
  54981. * Raw cube texture where the raw buffers are passed in
  54982. */
  54983. export class RawCubeTexture extends CubeTexture {
  54984. /**
  54985. * Creates a cube texture where the raw buffers are passed in.
  54986. * @param scene defines the scene the texture is attached to
  54987. * @param data defines the array of data to use to create each face
  54988. * @param size defines the size of the textures
  54989. * @param format defines the format of the data
  54990. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54991. * @param generateMipMaps defines if the engine should generate the mip levels
  54992. * @param invertY defines if data must be stored with Y axis inverted
  54993. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54994. * @param compression defines the compression used (null by default)
  54995. */
  54996. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54997. /**
  54998. * Updates the raw cube texture.
  54999. * @param data defines the data to store
  55000. * @param format defines the data format
  55001. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55002. * @param invertY defines if data must be stored with Y axis inverted
  55003. * @param compression defines the compression used (null by default)
  55004. * @param level defines which level of the texture to update
  55005. */
  55006. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55007. /**
  55008. * Updates a raw cube texture with RGBD encoded data.
  55009. * @param data defines the array of data [mipmap][face] to use to create each face
  55010. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55011. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55012. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55013. * @returns a promsie that resolves when the operation is complete
  55014. */
  55015. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55016. /**
  55017. * Clones the raw cube texture.
  55018. * @return a new cube texture
  55019. */
  55020. clone(): CubeTexture;
  55021. /** @hidden */
  55022. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55023. }
  55024. }
  55025. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55026. import { Scene } from "babylonjs/scene";
  55027. import { Texture } from "babylonjs/Materials/Textures/texture";
  55028. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55029. /**
  55030. * Class used to store 3D textures containing user data
  55031. */
  55032. export class RawTexture3D extends Texture {
  55033. /** Gets or sets the texture format to use */
  55034. format: number;
  55035. private _engine;
  55036. /**
  55037. * Create a new RawTexture3D
  55038. * @param data defines the data of the texture
  55039. * @param width defines the width of the texture
  55040. * @param height defines the height of the texture
  55041. * @param depth defines the depth of the texture
  55042. * @param format defines the texture format to use
  55043. * @param scene defines the hosting scene
  55044. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55045. * @param invertY defines if texture must be stored with Y axis inverted
  55046. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55047. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55048. */
  55049. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55050. /** Gets or sets the texture format to use */
  55051. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55052. /**
  55053. * Update the texture with new data
  55054. * @param data defines the data to store in the texture
  55055. */
  55056. update(data: ArrayBufferView): void;
  55057. }
  55058. }
  55059. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55060. import { Scene } from "babylonjs/scene";
  55061. import { Plane } from "babylonjs/Maths/math.plane";
  55062. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55063. /**
  55064. * Creates a refraction texture used by refraction channel of the standard material.
  55065. * It is like a mirror but to see through a material.
  55066. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55067. */
  55068. export class RefractionTexture extends RenderTargetTexture {
  55069. /**
  55070. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55071. * 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.
  55072. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55073. */
  55074. refractionPlane: Plane;
  55075. /**
  55076. * Define how deep under the surface we should see.
  55077. */
  55078. depth: number;
  55079. /**
  55080. * Creates a refraction texture used by refraction channel of the standard material.
  55081. * It is like a mirror but to see through a material.
  55082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55083. * @param name Define the texture name
  55084. * @param size Define the size of the underlying texture
  55085. * @param scene Define the scene the refraction belongs to
  55086. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55087. */
  55088. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55089. /**
  55090. * Clone the refraction texture.
  55091. * @returns the cloned texture
  55092. */
  55093. clone(): RefractionTexture;
  55094. /**
  55095. * Serialize the texture to a JSON representation you could use in Parse later on
  55096. * @returns the serialized JSON representation
  55097. */
  55098. serialize(): any;
  55099. }
  55100. }
  55101. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55102. import { Nullable } from "babylonjs/types";
  55103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55104. import { Matrix } from "babylonjs/Maths/math.vector";
  55105. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55106. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55107. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55108. import { Scene } from "babylonjs/scene";
  55109. /**
  55110. * Defines the options related to the creation of an HtmlElementTexture
  55111. */
  55112. export interface IHtmlElementTextureOptions {
  55113. /**
  55114. * Defines wether mip maps should be created or not.
  55115. */
  55116. generateMipMaps?: boolean;
  55117. /**
  55118. * Defines the sampling mode of the texture.
  55119. */
  55120. samplingMode?: number;
  55121. /**
  55122. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55123. */
  55124. engine: Nullable<ThinEngine>;
  55125. /**
  55126. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55127. */
  55128. scene: Nullable<Scene>;
  55129. }
  55130. /**
  55131. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55132. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55133. * is automatically managed.
  55134. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55135. * in your application.
  55136. *
  55137. * As the update is not automatic, you need to call them manually.
  55138. */
  55139. export class HtmlElementTexture extends BaseTexture {
  55140. /**
  55141. * The texture URL.
  55142. */
  55143. element: HTMLVideoElement | HTMLCanvasElement;
  55144. private static readonly DefaultOptions;
  55145. private _textureMatrix;
  55146. private _engine;
  55147. private _isVideo;
  55148. private _generateMipMaps;
  55149. private _samplingMode;
  55150. /**
  55151. * Instantiates a HtmlElementTexture from the following parameters.
  55152. *
  55153. * @param name Defines the name of the texture
  55154. * @param element Defines the video or canvas the texture is filled with
  55155. * @param options Defines the other none mandatory texture creation options
  55156. */
  55157. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55158. private _createInternalTexture;
  55159. /**
  55160. * Returns the texture matrix used in most of the material.
  55161. */
  55162. getTextureMatrix(): Matrix;
  55163. /**
  55164. * Updates the content of the texture.
  55165. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55166. */
  55167. update(invertY?: Nullable<boolean>): void;
  55168. }
  55169. }
  55170. declare module "babylonjs/Materials/Textures/index" {
  55171. export * from "babylonjs/Materials/Textures/baseTexture";
  55172. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55173. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55174. export * from "babylonjs/Materials/Textures/cubeTexture";
  55175. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55176. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55177. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55178. export * from "babylonjs/Materials/Textures/internalTexture";
  55179. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55180. export * from "babylonjs/Materials/Textures/Loaders/index";
  55181. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55182. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55183. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55184. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55185. export * from "babylonjs/Materials/Textures/rawTexture";
  55186. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55187. export * from "babylonjs/Materials/Textures/refractionTexture";
  55188. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55189. export * from "babylonjs/Materials/Textures/texture";
  55190. export * from "babylonjs/Materials/Textures/videoTexture";
  55191. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55192. }
  55193. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55194. /**
  55195. * Enum used to define the target of a block
  55196. */
  55197. export enum NodeMaterialBlockTargets {
  55198. /** Vertex shader */
  55199. Vertex = 1,
  55200. /** Fragment shader */
  55201. Fragment = 2,
  55202. /** Neutral */
  55203. Neutral = 4,
  55204. /** Vertex and Fragment */
  55205. VertexAndFragment = 3
  55206. }
  55207. }
  55208. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55209. /**
  55210. * Defines the kind of connection point for node based material
  55211. */
  55212. export enum NodeMaterialBlockConnectionPointTypes {
  55213. /** Float */
  55214. Float = 1,
  55215. /** Int */
  55216. Int = 2,
  55217. /** Vector2 */
  55218. Vector2 = 4,
  55219. /** Vector3 */
  55220. Vector3 = 8,
  55221. /** Vector4 */
  55222. Vector4 = 16,
  55223. /** Color3 */
  55224. Color3 = 32,
  55225. /** Color4 */
  55226. Color4 = 64,
  55227. /** Matrix */
  55228. Matrix = 128,
  55229. /** Detect type based on connection */
  55230. AutoDetect = 1024,
  55231. /** Output type that will be defined by input type */
  55232. BasedOnInput = 2048
  55233. }
  55234. }
  55235. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55236. /**
  55237. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55238. */
  55239. export enum NodeMaterialBlockConnectionPointMode {
  55240. /** Value is an uniform */
  55241. Uniform = 0,
  55242. /** Value is a mesh attribute */
  55243. Attribute = 1,
  55244. /** Value is a varying between vertex and fragment shaders */
  55245. Varying = 2,
  55246. /** Mode is undefined */
  55247. Undefined = 3
  55248. }
  55249. }
  55250. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55251. /**
  55252. * Enum used to define system values e.g. values automatically provided by the system
  55253. */
  55254. export enum NodeMaterialSystemValues {
  55255. /** World */
  55256. World = 1,
  55257. /** View */
  55258. View = 2,
  55259. /** Projection */
  55260. Projection = 3,
  55261. /** ViewProjection */
  55262. ViewProjection = 4,
  55263. /** WorldView */
  55264. WorldView = 5,
  55265. /** WorldViewProjection */
  55266. WorldViewProjection = 6,
  55267. /** CameraPosition */
  55268. CameraPosition = 7,
  55269. /** Fog Color */
  55270. FogColor = 8,
  55271. /** Delta time */
  55272. DeltaTime = 9
  55273. }
  55274. }
  55275. declare module "babylonjs/Materials/Node/Enums/index" {
  55276. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55277. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55278. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55279. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55280. }
  55281. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55283. /**
  55284. * Root class for all node material optimizers
  55285. */
  55286. export class NodeMaterialOptimizer {
  55287. /**
  55288. * Function used to optimize a NodeMaterial graph
  55289. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55290. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55291. */
  55292. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55293. }
  55294. }
  55295. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55298. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55299. import { Scene } from "babylonjs/scene";
  55300. /**
  55301. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55302. */
  55303. export class TransformBlock extends NodeMaterialBlock {
  55304. /**
  55305. * Defines the value to use to complement W value to transform it to a Vector4
  55306. */
  55307. complementW: number;
  55308. /**
  55309. * Defines the value to use to complement z value to transform it to a Vector4
  55310. */
  55311. complementZ: number;
  55312. /**
  55313. * Creates a new TransformBlock
  55314. * @param name defines the block name
  55315. */
  55316. constructor(name: string);
  55317. /**
  55318. * Gets the current class name
  55319. * @returns the class name
  55320. */
  55321. getClassName(): string;
  55322. /**
  55323. * Gets the vector input
  55324. */
  55325. readonly vector: NodeMaterialConnectionPoint;
  55326. /**
  55327. * Gets the output component
  55328. */
  55329. readonly output: NodeMaterialConnectionPoint;
  55330. /**
  55331. * Gets the matrix transform input
  55332. */
  55333. readonly transform: NodeMaterialConnectionPoint;
  55334. protected _buildBlock(state: NodeMaterialBuildState): this;
  55335. serialize(): any;
  55336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55337. protected _dumpPropertiesCode(): string;
  55338. }
  55339. }
  55340. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55344. /**
  55345. * Block used to output the vertex position
  55346. */
  55347. export class VertexOutputBlock extends NodeMaterialBlock {
  55348. /**
  55349. * Creates a new VertexOutputBlock
  55350. * @param name defines the block name
  55351. */
  55352. constructor(name: string);
  55353. /**
  55354. * Gets the current class name
  55355. * @returns the class name
  55356. */
  55357. getClassName(): string;
  55358. /**
  55359. * Gets the vector input component
  55360. */
  55361. readonly vector: NodeMaterialConnectionPoint;
  55362. protected _buildBlock(state: NodeMaterialBuildState): this;
  55363. }
  55364. }
  55365. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55369. /**
  55370. * Block used to output the final color
  55371. */
  55372. export class FragmentOutputBlock extends NodeMaterialBlock {
  55373. /**
  55374. * Create a new FragmentOutputBlock
  55375. * @param name defines the block name
  55376. */
  55377. constructor(name: string);
  55378. /**
  55379. * Gets the current class name
  55380. * @returns the class name
  55381. */
  55382. getClassName(): string;
  55383. /**
  55384. * Gets the rgba input component
  55385. */
  55386. readonly rgba: NodeMaterialConnectionPoint;
  55387. /**
  55388. * Gets the rgb input component
  55389. */
  55390. readonly rgb: NodeMaterialConnectionPoint;
  55391. /**
  55392. * Gets the a input component
  55393. */
  55394. readonly a: NodeMaterialConnectionPoint;
  55395. protected _buildBlock(state: NodeMaterialBuildState): this;
  55396. }
  55397. }
  55398. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55404. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55405. import { Effect } from "babylonjs/Materials/effect";
  55406. import { Mesh } from "babylonjs/Meshes/mesh";
  55407. import { Nullable } from "babylonjs/types";
  55408. import { Scene } from "babylonjs/scene";
  55409. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55410. /**
  55411. * Block used to read a reflection texture from a sampler
  55412. */
  55413. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55414. private _define3DName;
  55415. private _defineCubicName;
  55416. private _defineExplicitName;
  55417. private _defineProjectionName;
  55418. private _defineLocalCubicName;
  55419. private _defineSphericalName;
  55420. private _definePlanarName;
  55421. private _defineEquirectangularName;
  55422. private _defineMirroredEquirectangularFixedName;
  55423. private _defineEquirectangularFixedName;
  55424. private _defineSkyboxName;
  55425. private _cubeSamplerName;
  55426. private _2DSamplerName;
  55427. private _positionUVWName;
  55428. private _directionWName;
  55429. private _reflectionCoordsName;
  55430. private _reflection2DCoordsName;
  55431. private _reflectionColorName;
  55432. private _reflectionMatrixName;
  55433. /**
  55434. * Gets or sets the texture associated with the node
  55435. */
  55436. texture: Nullable<BaseTexture>;
  55437. /**
  55438. * Create a new TextureBlock
  55439. * @param name defines the block name
  55440. */
  55441. constructor(name: string);
  55442. /**
  55443. * Gets the current class name
  55444. * @returns the class name
  55445. */
  55446. getClassName(): string;
  55447. /**
  55448. * Gets the world position input component
  55449. */
  55450. readonly position: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Gets the world position input component
  55453. */
  55454. readonly worldPosition: NodeMaterialConnectionPoint;
  55455. /**
  55456. * Gets the world normal input component
  55457. */
  55458. readonly worldNormal: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Gets the world input component
  55461. */
  55462. readonly world: NodeMaterialConnectionPoint;
  55463. /**
  55464. * Gets the camera (or eye) position component
  55465. */
  55466. readonly cameraPosition: NodeMaterialConnectionPoint;
  55467. /**
  55468. * Gets the view input component
  55469. */
  55470. readonly view: NodeMaterialConnectionPoint;
  55471. /**
  55472. * Gets the rgb output component
  55473. */
  55474. readonly rgb: NodeMaterialConnectionPoint;
  55475. /**
  55476. * Gets the r output component
  55477. */
  55478. readonly r: NodeMaterialConnectionPoint;
  55479. /**
  55480. * Gets the g output component
  55481. */
  55482. readonly g: NodeMaterialConnectionPoint;
  55483. /**
  55484. * Gets the b output component
  55485. */
  55486. readonly b: NodeMaterialConnectionPoint;
  55487. autoConfigure(material: NodeMaterial): void;
  55488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55489. isReady(): boolean;
  55490. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55491. private _injectVertexCode;
  55492. private _writeOutput;
  55493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55494. serialize(): any;
  55495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55496. }
  55497. }
  55498. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55500. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55501. import { Scene } from "babylonjs/scene";
  55502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55503. import { Matrix } from "babylonjs/Maths/math.vector";
  55504. import { Mesh } from "babylonjs/Meshes/mesh";
  55505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55506. import { Observable } from "babylonjs/Misc/observable";
  55507. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55508. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55509. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55510. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55511. import { Nullable } from "babylonjs/types";
  55512. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55513. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55514. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55515. /**
  55516. * Interface used to configure the node material editor
  55517. */
  55518. export interface INodeMaterialEditorOptions {
  55519. /** Define the URl to load node editor script */
  55520. editorURL?: string;
  55521. }
  55522. /** @hidden */
  55523. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55524. /** BONES */
  55525. NUM_BONE_INFLUENCERS: number;
  55526. BonesPerMesh: number;
  55527. BONETEXTURE: boolean;
  55528. /** MORPH TARGETS */
  55529. MORPHTARGETS: boolean;
  55530. MORPHTARGETS_NORMAL: boolean;
  55531. MORPHTARGETS_TANGENT: boolean;
  55532. MORPHTARGETS_UV: boolean;
  55533. NUM_MORPH_INFLUENCERS: number;
  55534. /** IMAGE PROCESSING */
  55535. IMAGEPROCESSING: boolean;
  55536. VIGNETTE: boolean;
  55537. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55538. VIGNETTEBLENDMODEOPAQUE: boolean;
  55539. TONEMAPPING: boolean;
  55540. TONEMAPPING_ACES: boolean;
  55541. CONTRAST: boolean;
  55542. EXPOSURE: boolean;
  55543. COLORCURVES: boolean;
  55544. COLORGRADING: boolean;
  55545. COLORGRADING3D: boolean;
  55546. SAMPLER3DGREENDEPTH: boolean;
  55547. SAMPLER3DBGRMAP: boolean;
  55548. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55549. /** MISC. */
  55550. BUMPDIRECTUV: number;
  55551. constructor();
  55552. setValue(name: string, value: boolean): void;
  55553. }
  55554. /**
  55555. * Class used to configure NodeMaterial
  55556. */
  55557. export interface INodeMaterialOptions {
  55558. /**
  55559. * Defines if blocks should emit comments
  55560. */
  55561. emitComments: boolean;
  55562. }
  55563. /**
  55564. * Class used to create a node based material built by assembling shader blocks
  55565. */
  55566. export class NodeMaterial extends PushMaterial {
  55567. private static _BuildIdGenerator;
  55568. private _options;
  55569. private _vertexCompilationState;
  55570. private _fragmentCompilationState;
  55571. private _sharedData;
  55572. private _buildId;
  55573. private _buildWasSuccessful;
  55574. private _cachedWorldViewMatrix;
  55575. private _cachedWorldViewProjectionMatrix;
  55576. private _optimizers;
  55577. private _animationFrame;
  55578. /** Define the URl to load node editor script */
  55579. static EditorURL: string;
  55580. private BJSNODEMATERIALEDITOR;
  55581. /** Get the inspector from bundle or global */
  55582. private _getGlobalNodeMaterialEditor;
  55583. /**
  55584. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  55585. */
  55586. ignoreAlpha: boolean;
  55587. /**
  55588. * Defines the maximum number of lights that can be used in the material
  55589. */
  55590. maxSimultaneousLights: number;
  55591. /**
  55592. * Observable raised when the material is built
  55593. */
  55594. onBuildObservable: Observable<NodeMaterial>;
  55595. /**
  55596. * Gets or sets the root nodes of the material vertex shader
  55597. */
  55598. _vertexOutputNodes: NodeMaterialBlock[];
  55599. /**
  55600. * Gets or sets the root nodes of the material fragment (pixel) shader
  55601. */
  55602. _fragmentOutputNodes: NodeMaterialBlock[];
  55603. /** Gets or sets options to control the node material overall behavior */
  55604. options: INodeMaterialOptions;
  55605. /**
  55606. * Default configuration related to image processing available in the standard Material.
  55607. */
  55608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55609. /**
  55610. * Gets the image processing configuration used either in this material.
  55611. */
  55612. /**
  55613. * Sets the Default image processing configuration used either in the this material.
  55614. *
  55615. * If sets to null, the scene one is in use.
  55616. */
  55617. imageProcessingConfiguration: ImageProcessingConfiguration;
  55618. /**
  55619. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55620. */
  55621. attachedBlocks: NodeMaterialBlock[];
  55622. /**
  55623. * Create a new node based material
  55624. * @param name defines the material name
  55625. * @param scene defines the hosting scene
  55626. * @param options defines creation option
  55627. */
  55628. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55629. /**
  55630. * Gets the current class name of the material e.g. "NodeMaterial"
  55631. * @returns the class name
  55632. */
  55633. getClassName(): string;
  55634. /**
  55635. * Keep track of the image processing observer to allow dispose and replace.
  55636. */
  55637. private _imageProcessingObserver;
  55638. /**
  55639. * Attaches a new image processing configuration to the Standard Material.
  55640. * @param configuration
  55641. */
  55642. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55643. /**
  55644. * Get a block by its name
  55645. * @param name defines the name of the block to retrieve
  55646. * @returns the required block or null if not found
  55647. */
  55648. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55649. /**
  55650. * Get a block by its name
  55651. * @param predicate defines the predicate used to find the good candidate
  55652. * @returns the required block or null if not found
  55653. */
  55654. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55655. /**
  55656. * Get an input block by its name
  55657. * @param predicate defines the predicate used to find the good candidate
  55658. * @returns the required input block or null if not found
  55659. */
  55660. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55661. /**
  55662. * Gets the list of input blocks attached to this material
  55663. * @returns an array of InputBlocks
  55664. */
  55665. getInputBlocks(): InputBlock[];
  55666. /**
  55667. * Adds a new optimizer to the list of optimizers
  55668. * @param optimizer defines the optimizers to add
  55669. * @returns the current material
  55670. */
  55671. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55672. /**
  55673. * Remove an optimizer from the list of optimizers
  55674. * @param optimizer defines the optimizers to remove
  55675. * @returns the current material
  55676. */
  55677. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55678. /**
  55679. * Add a new block to the list of output nodes
  55680. * @param node defines the node to add
  55681. * @returns the current material
  55682. */
  55683. addOutputNode(node: NodeMaterialBlock): this;
  55684. /**
  55685. * Remove a block from the list of root nodes
  55686. * @param node defines the node to remove
  55687. * @returns the current material
  55688. */
  55689. removeOutputNode(node: NodeMaterialBlock): this;
  55690. private _addVertexOutputNode;
  55691. private _removeVertexOutputNode;
  55692. private _addFragmentOutputNode;
  55693. private _removeFragmentOutputNode;
  55694. /**
  55695. * Specifies if the material will require alpha blending
  55696. * @returns a boolean specifying if alpha blending is needed
  55697. */
  55698. needAlphaBlending(): boolean;
  55699. /**
  55700. * Specifies if this material should be rendered in alpha test mode
  55701. * @returns a boolean specifying if an alpha test is needed.
  55702. */
  55703. needAlphaTesting(): boolean;
  55704. private _initializeBlock;
  55705. private _resetDualBlocks;
  55706. /**
  55707. * Build the material and generates the inner effect
  55708. * @param verbose defines if the build should log activity
  55709. */
  55710. build(verbose?: boolean): void;
  55711. /**
  55712. * Runs an otpimization phase to try to improve the shader code
  55713. */
  55714. optimize(): void;
  55715. private _prepareDefinesForAttributes;
  55716. /**
  55717. * Get if the submesh is ready to be used and all its information available.
  55718. * Child classes can use it to update shaders
  55719. * @param mesh defines the mesh to check
  55720. * @param subMesh defines which submesh to check
  55721. * @param useInstances specifies that instances should be used
  55722. * @returns a boolean indicating that the submesh is ready or not
  55723. */
  55724. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55725. /**
  55726. * Get a string representing the shaders built by the current node graph
  55727. */
  55728. readonly compiledShaders: string;
  55729. /**
  55730. * Binds the world matrix to the material
  55731. * @param world defines the world transformation matrix
  55732. */
  55733. bindOnlyWorldMatrix(world: Matrix): void;
  55734. /**
  55735. * Binds the submesh to this material by preparing the effect and shader to draw
  55736. * @param world defines the world transformation matrix
  55737. * @param mesh defines the mesh containing the submesh
  55738. * @param subMesh defines the submesh to bind the material to
  55739. */
  55740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55741. /**
  55742. * Gets the active textures from the material
  55743. * @returns an array of textures
  55744. */
  55745. getActiveTextures(): BaseTexture[];
  55746. /**
  55747. * Gets the list of texture blocks
  55748. * @returns an array of texture blocks
  55749. */
  55750. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55751. /**
  55752. * Specifies if the material uses a texture
  55753. * @param texture defines the texture to check against the material
  55754. * @returns a boolean specifying if the material uses the texture
  55755. */
  55756. hasTexture(texture: BaseTexture): boolean;
  55757. /**
  55758. * Disposes the material
  55759. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55760. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55761. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55762. */
  55763. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55764. /** Creates the node editor window. */
  55765. private _createNodeEditor;
  55766. /**
  55767. * Launch the node material editor
  55768. * @param config Define the configuration of the editor
  55769. * @return a promise fulfilled when the node editor is visible
  55770. */
  55771. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55772. /**
  55773. * Clear the current material
  55774. */
  55775. clear(): void;
  55776. /**
  55777. * Clear the current material and set it to a default state
  55778. */
  55779. setToDefault(): void;
  55780. /**
  55781. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55782. * @param url defines the url to load from
  55783. * @returns a promise that will fullfil when the material is fully loaded
  55784. */
  55785. loadAsync(url: string): Promise<void>;
  55786. private _gatherBlocks;
  55787. /**
  55788. * Generate a string containing the code declaration required to create an equivalent of this material
  55789. * @returns a string
  55790. */
  55791. generateCode(): string;
  55792. /**
  55793. * Serializes this material in a JSON representation
  55794. * @returns the serialized material object
  55795. */
  55796. serialize(): any;
  55797. private _restoreConnections;
  55798. /**
  55799. * Clear the current graph and load a new one from a serialization object
  55800. * @param source defines the JSON representation of the material
  55801. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55802. */
  55803. loadFromSerialization(source: any, rootUrl?: string): void;
  55804. /**
  55805. * Creates a node material from parsed material data
  55806. * @param source defines the JSON representation of the material
  55807. * @param scene defines the hosting scene
  55808. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55809. * @returns a new node material
  55810. */
  55811. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55812. /**
  55813. * Creates a new node material set to default basic configuration
  55814. * @param name defines the name of the material
  55815. * @param scene defines the hosting scene
  55816. * @returns a new NodeMaterial
  55817. */
  55818. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55819. }
  55820. }
  55821. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55824. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55828. import { Effect } from "babylonjs/Materials/effect";
  55829. import { Mesh } from "babylonjs/Meshes/mesh";
  55830. import { Nullable } from "babylonjs/types";
  55831. import { Texture } from "babylonjs/Materials/Textures/texture";
  55832. import { Scene } from "babylonjs/scene";
  55833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55834. /**
  55835. * Block used to read a texture from a sampler
  55836. */
  55837. export class TextureBlock extends NodeMaterialBlock {
  55838. private _defineName;
  55839. private _linearDefineName;
  55840. private _samplerName;
  55841. private _transformedUVName;
  55842. private _textureTransformName;
  55843. private _textureInfoName;
  55844. private _mainUVName;
  55845. private _mainUVDefineName;
  55846. /**
  55847. * Gets or sets the texture associated with the node
  55848. */
  55849. texture: Nullable<Texture>;
  55850. /**
  55851. * Create a new TextureBlock
  55852. * @param name defines the block name
  55853. */
  55854. constructor(name: string);
  55855. /**
  55856. * Gets the current class name
  55857. * @returns the class name
  55858. */
  55859. getClassName(): string;
  55860. /**
  55861. * Gets the uv input component
  55862. */
  55863. readonly uv: NodeMaterialConnectionPoint;
  55864. /**
  55865. * Gets the rgba output component
  55866. */
  55867. readonly rgba: NodeMaterialConnectionPoint;
  55868. /**
  55869. * Gets the rgb output component
  55870. */
  55871. readonly rgb: NodeMaterialConnectionPoint;
  55872. /**
  55873. * Gets the r output component
  55874. */
  55875. readonly r: NodeMaterialConnectionPoint;
  55876. /**
  55877. * Gets the g output component
  55878. */
  55879. readonly g: NodeMaterialConnectionPoint;
  55880. /**
  55881. * Gets the b output component
  55882. */
  55883. readonly b: NodeMaterialConnectionPoint;
  55884. /**
  55885. * Gets the a output component
  55886. */
  55887. readonly a: NodeMaterialConnectionPoint;
  55888. readonly target: NodeMaterialBlockTargets;
  55889. autoConfigure(material: NodeMaterial): void;
  55890. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55892. isReady(): boolean;
  55893. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55894. private readonly _isMixed;
  55895. private _injectVertexCode;
  55896. private _writeOutput;
  55897. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55898. protected _dumpPropertiesCode(): string;
  55899. serialize(): any;
  55900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55901. }
  55902. }
  55903. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55906. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55907. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55908. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55909. import { Scene } from "babylonjs/scene";
  55910. /**
  55911. * Class used to store shared data between 2 NodeMaterialBuildState
  55912. */
  55913. export class NodeMaterialBuildStateSharedData {
  55914. /**
  55915. * Gets the list of emitted varyings
  55916. */
  55917. temps: string[];
  55918. /**
  55919. * Gets the list of emitted varyings
  55920. */
  55921. varyings: string[];
  55922. /**
  55923. * Gets the varying declaration string
  55924. */
  55925. varyingDeclaration: string;
  55926. /**
  55927. * Input blocks
  55928. */
  55929. inputBlocks: InputBlock[];
  55930. /**
  55931. * Input blocks
  55932. */
  55933. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55934. /**
  55935. * Bindable blocks (Blocks that need to set data to the effect)
  55936. */
  55937. bindableBlocks: NodeMaterialBlock[];
  55938. /**
  55939. * List of blocks that can provide a compilation fallback
  55940. */
  55941. blocksWithFallbacks: NodeMaterialBlock[];
  55942. /**
  55943. * List of blocks that can provide a define update
  55944. */
  55945. blocksWithDefines: NodeMaterialBlock[];
  55946. /**
  55947. * List of blocks that can provide a repeatable content
  55948. */
  55949. repeatableContentBlocks: NodeMaterialBlock[];
  55950. /**
  55951. * List of blocks that can provide a dynamic list of uniforms
  55952. */
  55953. dynamicUniformBlocks: NodeMaterialBlock[];
  55954. /**
  55955. * List of blocks that can block the isReady function for the material
  55956. */
  55957. blockingBlocks: NodeMaterialBlock[];
  55958. /**
  55959. * Gets the list of animated inputs
  55960. */
  55961. animatedInputs: InputBlock[];
  55962. /**
  55963. * Build Id used to avoid multiple recompilations
  55964. */
  55965. buildId: number;
  55966. /** List of emitted variables */
  55967. variableNames: {
  55968. [key: string]: number;
  55969. };
  55970. /** List of emitted defines */
  55971. defineNames: {
  55972. [key: string]: number;
  55973. };
  55974. /** Should emit comments? */
  55975. emitComments: boolean;
  55976. /** Emit build activity */
  55977. verbose: boolean;
  55978. /** Gets or sets the hosting scene */
  55979. scene: Scene;
  55980. /**
  55981. * Gets the compilation hints emitted at compilation time
  55982. */
  55983. hints: {
  55984. needWorldViewMatrix: boolean;
  55985. needWorldViewProjectionMatrix: boolean;
  55986. needAlphaBlending: boolean;
  55987. needAlphaTesting: boolean;
  55988. };
  55989. /**
  55990. * List of compilation checks
  55991. */
  55992. checks: {
  55993. emitVertex: boolean;
  55994. emitFragment: boolean;
  55995. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55996. };
  55997. /** Creates a new shared data */
  55998. constructor();
  55999. /**
  56000. * Emits console errors and exceptions if there is a failing check
  56001. */
  56002. emitErrors(): void;
  56003. }
  56004. }
  56005. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56006. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56007. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56008. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56009. /**
  56010. * Class used to store node based material build state
  56011. */
  56012. export class NodeMaterialBuildState {
  56013. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56014. supportUniformBuffers: boolean;
  56015. /**
  56016. * Gets the list of emitted attributes
  56017. */
  56018. attributes: string[];
  56019. /**
  56020. * Gets the list of emitted uniforms
  56021. */
  56022. uniforms: string[];
  56023. /**
  56024. * Gets the list of emitted constants
  56025. */
  56026. constants: string[];
  56027. /**
  56028. * Gets the list of emitted samplers
  56029. */
  56030. samplers: string[];
  56031. /**
  56032. * Gets the list of emitted functions
  56033. */
  56034. functions: {
  56035. [key: string]: string;
  56036. };
  56037. /**
  56038. * Gets the list of emitted extensions
  56039. */
  56040. extensions: {
  56041. [key: string]: string;
  56042. };
  56043. /**
  56044. * Gets the target of the compilation state
  56045. */
  56046. target: NodeMaterialBlockTargets;
  56047. /**
  56048. * Gets the list of emitted counters
  56049. */
  56050. counters: {
  56051. [key: string]: number;
  56052. };
  56053. /**
  56054. * Shared data between multiple NodeMaterialBuildState instances
  56055. */
  56056. sharedData: NodeMaterialBuildStateSharedData;
  56057. /** @hidden */
  56058. _vertexState: NodeMaterialBuildState;
  56059. /** @hidden */
  56060. _attributeDeclaration: string;
  56061. /** @hidden */
  56062. _uniformDeclaration: string;
  56063. /** @hidden */
  56064. _constantDeclaration: string;
  56065. /** @hidden */
  56066. _samplerDeclaration: string;
  56067. /** @hidden */
  56068. _varyingTransfer: string;
  56069. private _repeatableContentAnchorIndex;
  56070. /** @hidden */
  56071. _builtCompilationString: string;
  56072. /**
  56073. * Gets the emitted compilation strings
  56074. */
  56075. compilationString: string;
  56076. /**
  56077. * Finalize the compilation strings
  56078. * @param state defines the current compilation state
  56079. */
  56080. finalize(state: NodeMaterialBuildState): void;
  56081. /** @hidden */
  56082. readonly _repeatableContentAnchor: string;
  56083. /** @hidden */
  56084. _getFreeVariableName(prefix: string): string;
  56085. /** @hidden */
  56086. _getFreeDefineName(prefix: string): string;
  56087. /** @hidden */
  56088. _excludeVariableName(name: string): void;
  56089. /** @hidden */
  56090. _emit2DSampler(name: string): void;
  56091. /** @hidden */
  56092. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56093. /** @hidden */
  56094. _emitExtension(name: string, extension: string): void;
  56095. /** @hidden */
  56096. _emitFunction(name: string, code: string, comments: string): void;
  56097. /** @hidden */
  56098. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56099. replaceStrings?: {
  56100. search: RegExp;
  56101. replace: string;
  56102. }[];
  56103. repeatKey?: string;
  56104. }): string;
  56105. /** @hidden */
  56106. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56107. repeatKey?: string;
  56108. removeAttributes?: boolean;
  56109. removeUniforms?: boolean;
  56110. removeVaryings?: boolean;
  56111. removeIfDef?: boolean;
  56112. replaceStrings?: {
  56113. search: RegExp;
  56114. replace: string;
  56115. }[];
  56116. }, storeKey?: string): void;
  56117. /** @hidden */
  56118. _registerTempVariable(name: string): boolean;
  56119. /** @hidden */
  56120. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56121. /** @hidden */
  56122. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56123. /** @hidden */
  56124. _emitFloat(value: number): string;
  56125. }
  56126. }
  56127. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56128. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56130. import { Nullable } from "babylonjs/types";
  56131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56132. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56133. import { Effect } from "babylonjs/Materials/effect";
  56134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56135. import { Mesh } from "babylonjs/Meshes/mesh";
  56136. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56137. import { Scene } from "babylonjs/scene";
  56138. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56139. /**
  56140. * Defines a block that can be used inside a node based material
  56141. */
  56142. export class NodeMaterialBlock {
  56143. private _buildId;
  56144. private _buildTarget;
  56145. private _target;
  56146. private _isFinalMerger;
  56147. private _isInput;
  56148. /** @hidden */
  56149. _codeVariableName: string;
  56150. /** @hidden */
  56151. _inputs: NodeMaterialConnectionPoint[];
  56152. /** @hidden */
  56153. _outputs: NodeMaterialConnectionPoint[];
  56154. /** @hidden */
  56155. _preparationId: number;
  56156. /**
  56157. * Gets or sets the name of the block
  56158. */
  56159. name: string;
  56160. /**
  56161. * Gets or sets the unique id of the node
  56162. */
  56163. uniqueId: number;
  56164. /**
  56165. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56166. */
  56167. readonly isFinalMerger: boolean;
  56168. /**
  56169. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56170. */
  56171. readonly isInput: boolean;
  56172. /**
  56173. * Gets or sets the build Id
  56174. */
  56175. buildId: number;
  56176. /**
  56177. * Gets or sets the target of the block
  56178. */
  56179. target: NodeMaterialBlockTargets;
  56180. /**
  56181. * Gets the list of input points
  56182. */
  56183. readonly inputs: NodeMaterialConnectionPoint[];
  56184. /** Gets the list of output points */
  56185. readonly outputs: NodeMaterialConnectionPoint[];
  56186. /**
  56187. * Find an input by its name
  56188. * @param name defines the name of the input to look for
  56189. * @returns the input or null if not found
  56190. */
  56191. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56192. /**
  56193. * Find an output by its name
  56194. * @param name defines the name of the outputto look for
  56195. * @returns the output or null if not found
  56196. */
  56197. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56198. /**
  56199. * Creates a new NodeMaterialBlock
  56200. * @param name defines the block name
  56201. * @param target defines the target of that block (Vertex by default)
  56202. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56203. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56204. */
  56205. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56206. /**
  56207. * Initialize the block and prepare the context for build
  56208. * @param state defines the state that will be used for the build
  56209. */
  56210. initialize(state: NodeMaterialBuildState): void;
  56211. /**
  56212. * Bind data to effect. Will only be called for blocks with isBindable === true
  56213. * @param effect defines the effect to bind data to
  56214. * @param nodeMaterial defines the hosting NodeMaterial
  56215. * @param mesh defines the mesh that will be rendered
  56216. */
  56217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56218. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56219. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56220. protected _writeFloat(value: number): string;
  56221. /**
  56222. * Gets the current class name e.g. "NodeMaterialBlock"
  56223. * @returns the class name
  56224. */
  56225. getClassName(): string;
  56226. /**
  56227. * Register a new input. Must be called inside a block constructor
  56228. * @param name defines the connection point name
  56229. * @param type defines the connection point type
  56230. * @param isOptional defines a boolean indicating that this input can be omitted
  56231. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56232. * @returns the current block
  56233. */
  56234. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56235. /**
  56236. * Register a new output. Must be called inside a block constructor
  56237. * @param name defines the connection point name
  56238. * @param type defines the connection point type
  56239. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56240. * @returns the current block
  56241. */
  56242. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56243. /**
  56244. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56245. * @param forOutput defines an optional connection point to check compatibility with
  56246. * @returns the first available input or null
  56247. */
  56248. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56249. /**
  56250. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56251. * @param forBlock defines an optional block to check compatibility with
  56252. * @returns the first available input or null
  56253. */
  56254. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56255. /**
  56256. * Gets the sibling of the given output
  56257. * @param current defines the current output
  56258. * @returns the next output in the list or null
  56259. */
  56260. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56261. /**
  56262. * Connect current block with another block
  56263. * @param other defines the block to connect with
  56264. * @param options define the various options to help pick the right connections
  56265. * @returns the current block
  56266. */
  56267. connectTo(other: NodeMaterialBlock, options?: {
  56268. input?: string;
  56269. output?: string;
  56270. outputSwizzle?: string;
  56271. }): this | undefined;
  56272. protected _buildBlock(state: NodeMaterialBuildState): void;
  56273. /**
  56274. * Add uniforms, samplers and uniform buffers at compilation time
  56275. * @param state defines the state to update
  56276. * @param nodeMaterial defines the node material requesting the update
  56277. * @param defines defines the material defines to update
  56278. * @param uniformBuffers defines the list of uniform buffer names
  56279. */
  56280. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56281. /**
  56282. * Add potential fallbacks if shader compilation fails
  56283. * @param mesh defines the mesh to be rendered
  56284. * @param fallbacks defines the current prioritized list of fallbacks
  56285. */
  56286. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56287. /**
  56288. * Initialize defines for shader compilation
  56289. * @param mesh defines the mesh to be rendered
  56290. * @param nodeMaterial defines the node material requesting the update
  56291. * @param defines defines the material defines to update
  56292. * @param useInstances specifies that instances should be used
  56293. */
  56294. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56295. /**
  56296. * Update defines for shader compilation
  56297. * @param mesh defines the mesh to be rendered
  56298. * @param nodeMaterial defines the node material requesting the update
  56299. * @param defines defines the material defines to update
  56300. * @param useInstances specifies that instances should be used
  56301. */
  56302. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56303. /**
  56304. * Lets the block try to connect some inputs automatically
  56305. * @param material defines the hosting NodeMaterial
  56306. */
  56307. autoConfigure(material: NodeMaterial): void;
  56308. /**
  56309. * Function called when a block is declared as repeatable content generator
  56310. * @param vertexShaderState defines the current compilation state for the vertex shader
  56311. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56312. * @param mesh defines the mesh to be rendered
  56313. * @param defines defines the material defines to update
  56314. */
  56315. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56316. /**
  56317. * Checks if the block is ready
  56318. * @param mesh defines the mesh to be rendered
  56319. * @param nodeMaterial defines the node material requesting the update
  56320. * @param defines defines the material defines to update
  56321. * @param useInstances specifies that instances should be used
  56322. * @returns true if the block is ready
  56323. */
  56324. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56325. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56326. private _processBuild;
  56327. /**
  56328. * Compile the current node and generate the shader code
  56329. * @param state defines the current compilation state (uniforms, samplers, current string)
  56330. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56331. * @returns true if already built
  56332. */
  56333. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56334. protected _inputRename(name: string): string;
  56335. protected _outputRename(name: string): string;
  56336. protected _dumpPropertiesCode(): string;
  56337. /** @hidden */
  56338. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56339. /**
  56340. * Clone the current block to a new identical block
  56341. * @param scene defines the hosting scene
  56342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56343. * @returns a copy of the current block
  56344. */
  56345. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56346. /**
  56347. * Serializes this block in a JSON representation
  56348. * @returns the serialized block object
  56349. */
  56350. serialize(): any;
  56351. /** @hidden */
  56352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56353. }
  56354. }
  56355. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56356. /**
  56357. * Enum defining the type of animations supported by InputBlock
  56358. */
  56359. export enum AnimatedInputBlockTypes {
  56360. /** No animation */
  56361. None = 0,
  56362. /** Time based animation. Will only work for floats */
  56363. Time = 1
  56364. }
  56365. }
  56366. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56368. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56369. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56370. import { Nullable } from "babylonjs/types";
  56371. import { Effect } from "babylonjs/Materials/effect";
  56372. import { Matrix } from "babylonjs/Maths/math.vector";
  56373. import { Scene } from "babylonjs/scene";
  56374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56376. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56377. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56378. /**
  56379. * Block used to expose an input value
  56380. */
  56381. export class InputBlock extends NodeMaterialBlock {
  56382. private _mode;
  56383. private _associatedVariableName;
  56384. private _storedValue;
  56385. private _valueCallback;
  56386. private _type;
  56387. private _animationType;
  56388. /** Gets or set a value used to limit the range of float values */
  56389. min: number;
  56390. /** Gets or set a value used to limit the range of float values */
  56391. max: number;
  56392. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56393. matrixMode: number;
  56394. /** @hidden */
  56395. _systemValue: Nullable<NodeMaterialSystemValues>;
  56396. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56397. visibleInInspector: boolean;
  56398. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56399. isConstant: boolean;
  56400. /**
  56401. * Gets or sets the connection point type (default is float)
  56402. */
  56403. readonly type: NodeMaterialBlockConnectionPointTypes;
  56404. /**
  56405. * Creates a new InputBlock
  56406. * @param name defines the block name
  56407. * @param target defines the target of that block (Vertex by default)
  56408. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56409. */
  56410. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56411. /**
  56412. * Gets the output component
  56413. */
  56414. readonly output: NodeMaterialConnectionPoint;
  56415. /**
  56416. * Set the source of this connection point to a vertex attribute
  56417. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56418. * @returns the current connection point
  56419. */
  56420. setAsAttribute(attributeName?: string): InputBlock;
  56421. /**
  56422. * Set the source of this connection point to a system value
  56423. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56424. * @returns the current connection point
  56425. */
  56426. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56427. /**
  56428. * Gets or sets the value of that point.
  56429. * Please note that this value will be ignored if valueCallback is defined
  56430. */
  56431. value: any;
  56432. /**
  56433. * Gets or sets a callback used to get the value of that point.
  56434. * Please note that setting this value will force the connection point to ignore the value property
  56435. */
  56436. valueCallback: () => any;
  56437. /**
  56438. * Gets or sets the associated variable name in the shader
  56439. */
  56440. associatedVariableName: string;
  56441. /** Gets or sets the type of animation applied to the input */
  56442. animationType: AnimatedInputBlockTypes;
  56443. /**
  56444. * Gets a boolean indicating that this connection point not defined yet
  56445. */
  56446. readonly isUndefined: boolean;
  56447. /**
  56448. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56449. * In this case the connection point name must be the name of the uniform to use.
  56450. * Can only be set on inputs
  56451. */
  56452. isUniform: boolean;
  56453. /**
  56454. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56455. * In this case the connection point name must be the name of the attribute to use
  56456. * Can only be set on inputs
  56457. */
  56458. isAttribute: boolean;
  56459. /**
  56460. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56461. * Can only be set on exit points
  56462. */
  56463. isVarying: boolean;
  56464. /**
  56465. * Gets a boolean indicating that the current connection point is a system value
  56466. */
  56467. readonly isSystemValue: boolean;
  56468. /**
  56469. * Gets or sets the current well known value or null if not defined as a system value
  56470. */
  56471. systemValue: Nullable<NodeMaterialSystemValues>;
  56472. /**
  56473. * Gets the current class name
  56474. * @returns the class name
  56475. */
  56476. getClassName(): string;
  56477. /**
  56478. * Animate the input if animationType !== None
  56479. * @param scene defines the rendering scene
  56480. */
  56481. animate(scene: Scene): void;
  56482. private _emitDefine;
  56483. initialize(state: NodeMaterialBuildState): void;
  56484. /**
  56485. * Set the input block to its default value (based on its type)
  56486. */
  56487. setDefaultValue(): void;
  56488. private _emitConstant;
  56489. private _emit;
  56490. /** @hidden */
  56491. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56492. /** @hidden */
  56493. _transmit(effect: Effect, scene: Scene): void;
  56494. protected _buildBlock(state: NodeMaterialBuildState): void;
  56495. protected _dumpPropertiesCode(): string;
  56496. serialize(): any;
  56497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56498. }
  56499. }
  56500. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56501. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56502. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56503. import { Nullable } from "babylonjs/types";
  56504. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56506. /**
  56507. * Defines a connection point for a block
  56508. */
  56509. export class NodeMaterialConnectionPoint {
  56510. /** @hidden */
  56511. _ownerBlock: NodeMaterialBlock;
  56512. /** @hidden */
  56513. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56514. private _endpoints;
  56515. private _associatedVariableName;
  56516. /** @hidden */
  56517. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56518. /** @hidden */
  56519. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56520. private _type;
  56521. /** @hidden */
  56522. _enforceAssociatedVariableName: boolean;
  56523. /**
  56524. * Gets or sets the additional types supported by this connection point
  56525. */
  56526. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56527. /**
  56528. * Gets or sets the additional types excluded by this connection point
  56529. */
  56530. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56531. /**
  56532. * Gets or sets the associated variable name in the shader
  56533. */
  56534. associatedVariableName: string;
  56535. /**
  56536. * Gets or sets the connection point type (default is float)
  56537. */
  56538. type: NodeMaterialBlockConnectionPointTypes;
  56539. /**
  56540. * Gets or sets the connection point name
  56541. */
  56542. name: string;
  56543. /**
  56544. * Gets or sets a boolean indicating that this connection point can be omitted
  56545. */
  56546. isOptional: boolean;
  56547. /**
  56548. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56549. */
  56550. define: string;
  56551. /** Gets or sets the target of that connection point */
  56552. target: NodeMaterialBlockTargets;
  56553. /**
  56554. * Gets a boolean indicating that the current point is connected
  56555. */
  56556. readonly isConnected: boolean;
  56557. /**
  56558. * Gets a boolean indicating that the current point is connected to an input block
  56559. */
  56560. readonly isConnectedToInputBlock: boolean;
  56561. /**
  56562. * Gets a the connected input block (if any)
  56563. */
  56564. readonly connectInputBlock: Nullable<InputBlock>;
  56565. /** Get the other side of the connection (if any) */
  56566. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56567. /** Get the block that owns this connection point */
  56568. readonly ownerBlock: NodeMaterialBlock;
  56569. /** Get the block connected on the other side of this connection (if any) */
  56570. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56571. /** Get the block connected on the endpoints of this connection (if any) */
  56572. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56573. /** Gets the list of connected endpoints */
  56574. readonly endpoints: NodeMaterialConnectionPoint[];
  56575. /** Gets a boolean indicating if that output point is connected to at least one input */
  56576. readonly hasEndpoints: boolean;
  56577. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56578. readonly isConnectedInVertexShader: boolean;
  56579. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56580. readonly isConnectedInFragmentShader: boolean;
  56581. /**
  56582. * Creates a new connection point
  56583. * @param name defines the connection point name
  56584. * @param ownerBlock defines the block hosting this connection point
  56585. */
  56586. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56587. /**
  56588. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56589. * @returns the class name
  56590. */
  56591. getClassName(): string;
  56592. /**
  56593. * Gets an boolean indicating if the current point can be connected to another point
  56594. * @param connectionPoint defines the other connection point
  56595. * @returns true if the connection is possible
  56596. */
  56597. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56598. /**
  56599. * Connect this point to another connection point
  56600. * @param connectionPoint defines the other connection point
  56601. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56602. * @returns the current connection point
  56603. */
  56604. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56605. /**
  56606. * Disconnect this point from one of his endpoint
  56607. * @param endpoint defines the other connection point
  56608. * @returns the current connection point
  56609. */
  56610. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56611. /**
  56612. * Serializes this point in a JSON representation
  56613. * @returns the serialized point object
  56614. */
  56615. serialize(): any;
  56616. }
  56617. }
  56618. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56622. import { Mesh } from "babylonjs/Meshes/mesh";
  56623. import { Effect } from "babylonjs/Materials/effect";
  56624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56625. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56626. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56627. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56628. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56629. /**
  56630. * Block used to add support for vertex skinning (bones)
  56631. */
  56632. export class BonesBlock extends NodeMaterialBlock {
  56633. /**
  56634. * Creates a new BonesBlock
  56635. * @param name defines the block name
  56636. */
  56637. constructor(name: string);
  56638. /**
  56639. * Initialize the block and prepare the context for build
  56640. * @param state defines the state that will be used for the build
  56641. */
  56642. initialize(state: NodeMaterialBuildState): void;
  56643. /**
  56644. * Gets the current class name
  56645. * @returns the class name
  56646. */
  56647. getClassName(): string;
  56648. /**
  56649. * Gets the matrix indices input component
  56650. */
  56651. readonly matricesIndices: NodeMaterialConnectionPoint;
  56652. /**
  56653. * Gets the matrix weights input component
  56654. */
  56655. readonly matricesWeights: NodeMaterialConnectionPoint;
  56656. /**
  56657. * Gets the extra matrix indices input component
  56658. */
  56659. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56660. /**
  56661. * Gets the extra matrix weights input component
  56662. */
  56663. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56664. /**
  56665. * Gets the world input component
  56666. */
  56667. readonly world: NodeMaterialConnectionPoint;
  56668. /**
  56669. * Gets the output component
  56670. */
  56671. readonly output: NodeMaterialConnectionPoint;
  56672. autoConfigure(material: NodeMaterial): void;
  56673. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56676. protected _buildBlock(state: NodeMaterialBuildState): this;
  56677. }
  56678. }
  56679. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56684. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56685. /**
  56686. * Block used to add support for instances
  56687. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56688. */
  56689. export class InstancesBlock extends NodeMaterialBlock {
  56690. /**
  56691. * Creates a new InstancesBlock
  56692. * @param name defines the block name
  56693. */
  56694. constructor(name: string);
  56695. /**
  56696. * Gets the current class name
  56697. * @returns the class name
  56698. */
  56699. getClassName(): string;
  56700. /**
  56701. * Gets the first world row input component
  56702. */
  56703. readonly world0: NodeMaterialConnectionPoint;
  56704. /**
  56705. * Gets the second world row input component
  56706. */
  56707. readonly world1: NodeMaterialConnectionPoint;
  56708. /**
  56709. * Gets the third world row input component
  56710. */
  56711. readonly world2: NodeMaterialConnectionPoint;
  56712. /**
  56713. * Gets the forth world row input component
  56714. */
  56715. readonly world3: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the world input component
  56718. */
  56719. readonly world: NodeMaterialConnectionPoint;
  56720. /**
  56721. * Gets the output component
  56722. */
  56723. readonly output: NodeMaterialConnectionPoint;
  56724. autoConfigure(material: NodeMaterial): void;
  56725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56726. protected _buildBlock(state: NodeMaterialBuildState): this;
  56727. }
  56728. }
  56729. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56734. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56735. import { Effect } from "babylonjs/Materials/effect";
  56736. import { Mesh } from "babylonjs/Meshes/mesh";
  56737. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56739. /**
  56740. * Block used to add morph targets support to vertex shader
  56741. */
  56742. export class MorphTargetsBlock extends NodeMaterialBlock {
  56743. private _repeatableContentAnchor;
  56744. private _repeatebleContentGenerated;
  56745. /**
  56746. * Create a new MorphTargetsBlock
  56747. * @param name defines the block name
  56748. */
  56749. constructor(name: string);
  56750. /**
  56751. * Gets the current class name
  56752. * @returns the class name
  56753. */
  56754. getClassName(): string;
  56755. /**
  56756. * Gets the position input component
  56757. */
  56758. readonly position: NodeMaterialConnectionPoint;
  56759. /**
  56760. * Gets the normal input component
  56761. */
  56762. readonly normal: NodeMaterialConnectionPoint;
  56763. /**
  56764. * Gets the tangent input component
  56765. */
  56766. readonly tangent: NodeMaterialConnectionPoint;
  56767. /**
  56768. * Gets the tangent input component
  56769. */
  56770. readonly uv: NodeMaterialConnectionPoint;
  56771. /**
  56772. * Gets the position output component
  56773. */
  56774. readonly positionOutput: NodeMaterialConnectionPoint;
  56775. /**
  56776. * Gets the normal output component
  56777. */
  56778. readonly normalOutput: NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the tangent output component
  56781. */
  56782. readonly tangentOutput: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the tangent output component
  56785. */
  56786. readonly uvOutput: NodeMaterialConnectionPoint;
  56787. initialize(state: NodeMaterialBuildState): void;
  56788. autoConfigure(material: NodeMaterial): void;
  56789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56791. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56792. protected _buildBlock(state: NodeMaterialBuildState): this;
  56793. }
  56794. }
  56795. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56799. import { Nullable } from "babylonjs/types";
  56800. import { Scene } from "babylonjs/scene";
  56801. import { Effect } from "babylonjs/Materials/effect";
  56802. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56803. import { Mesh } from "babylonjs/Meshes/mesh";
  56804. import { Light } from "babylonjs/Lights/light";
  56805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56806. /**
  56807. * Block used to get data information from a light
  56808. */
  56809. export class LightInformationBlock extends NodeMaterialBlock {
  56810. private _lightDataUniformName;
  56811. private _lightColorUniformName;
  56812. private _lightTypeDefineName;
  56813. /**
  56814. * Gets or sets the light associated with this block
  56815. */
  56816. light: Nullable<Light>;
  56817. /**
  56818. * Creates a new LightInformationBlock
  56819. * @param name defines the block name
  56820. */
  56821. constructor(name: string);
  56822. /**
  56823. * Gets the current class name
  56824. * @returns the class name
  56825. */
  56826. getClassName(): string;
  56827. /**
  56828. * Gets the world position input component
  56829. */
  56830. readonly worldPosition: NodeMaterialConnectionPoint;
  56831. /**
  56832. * Gets the direction output component
  56833. */
  56834. readonly direction: NodeMaterialConnectionPoint;
  56835. /**
  56836. * Gets the direction output component
  56837. */
  56838. readonly color: NodeMaterialConnectionPoint;
  56839. /**
  56840. * Gets the direction output component
  56841. */
  56842. readonly intensity: NodeMaterialConnectionPoint;
  56843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56845. protected _buildBlock(state: NodeMaterialBuildState): this;
  56846. serialize(): any;
  56847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56848. }
  56849. }
  56850. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56851. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56852. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56853. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56854. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56855. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56856. }
  56857. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56862. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56863. import { Effect } from "babylonjs/Materials/effect";
  56864. import { Mesh } from "babylonjs/Meshes/mesh";
  56865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56866. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56868. /**
  56869. * Block used to add image processing support to fragment shader
  56870. */
  56871. export class ImageProcessingBlock extends NodeMaterialBlock {
  56872. /**
  56873. * Create a new ImageProcessingBlock
  56874. * @param name defines the block name
  56875. */
  56876. constructor(name: string);
  56877. /**
  56878. * Gets the current class name
  56879. * @returns the class name
  56880. */
  56881. getClassName(): string;
  56882. /**
  56883. * Gets the color input component
  56884. */
  56885. readonly color: NodeMaterialConnectionPoint;
  56886. /**
  56887. * Gets the output component
  56888. */
  56889. readonly output: NodeMaterialConnectionPoint;
  56890. /**
  56891. * Initialize the block and prepare the context for build
  56892. * @param state defines the state that will be used for the build
  56893. */
  56894. initialize(state: NodeMaterialBuildState): void;
  56895. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56897. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56898. protected _buildBlock(state: NodeMaterialBuildState): this;
  56899. }
  56900. }
  56901. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56905. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56907. import { Effect } from "babylonjs/Materials/effect";
  56908. import { Mesh } from "babylonjs/Meshes/mesh";
  56909. import { Scene } from "babylonjs/scene";
  56910. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56911. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56912. /**
  56913. * Block used to pertub normals based on a normal map
  56914. */
  56915. export class PerturbNormalBlock extends NodeMaterialBlock {
  56916. private _tangentSpaceParameterName;
  56917. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56918. invertX: boolean;
  56919. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56920. invertY: boolean;
  56921. /**
  56922. * Create a new PerturbNormalBlock
  56923. * @param name defines the block name
  56924. */
  56925. constructor(name: string);
  56926. /**
  56927. * Gets the current class name
  56928. * @returns the class name
  56929. */
  56930. getClassName(): string;
  56931. /**
  56932. * Gets the world position input component
  56933. */
  56934. readonly worldPosition: NodeMaterialConnectionPoint;
  56935. /**
  56936. * Gets the world normal input component
  56937. */
  56938. readonly worldNormal: NodeMaterialConnectionPoint;
  56939. /**
  56940. * Gets the uv input component
  56941. */
  56942. readonly uv: NodeMaterialConnectionPoint;
  56943. /**
  56944. * Gets the normal map color input component
  56945. */
  56946. readonly normalMapColor: NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the strength input component
  56949. */
  56950. readonly strength: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the output component
  56953. */
  56954. readonly output: NodeMaterialConnectionPoint;
  56955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56956. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56957. autoConfigure(material: NodeMaterial): void;
  56958. protected _buildBlock(state: NodeMaterialBuildState): this;
  56959. protected _dumpPropertiesCode(): string;
  56960. serialize(): any;
  56961. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56962. }
  56963. }
  56964. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56968. /**
  56969. * Block used to discard a pixel if a value is smaller than a cutoff
  56970. */
  56971. export class DiscardBlock extends NodeMaterialBlock {
  56972. /**
  56973. * Create a new DiscardBlock
  56974. * @param name defines the block name
  56975. */
  56976. constructor(name: string);
  56977. /**
  56978. * Gets the current class name
  56979. * @returns the class name
  56980. */
  56981. getClassName(): string;
  56982. /**
  56983. * Gets the color input component
  56984. */
  56985. readonly value: NodeMaterialConnectionPoint;
  56986. /**
  56987. * Gets the cutoff input component
  56988. */
  56989. readonly cutoff: NodeMaterialConnectionPoint;
  56990. protected _buildBlock(state: NodeMaterialBuildState): this;
  56991. }
  56992. }
  56993. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56994. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56995. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56996. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56997. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56998. }
  56999. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57002. import { Mesh } from "babylonjs/Meshes/mesh";
  57003. import { Effect } from "babylonjs/Materials/effect";
  57004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57006. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57007. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57008. /**
  57009. * Block used to add support for scene fog
  57010. */
  57011. export class FogBlock extends NodeMaterialBlock {
  57012. private _fogDistanceName;
  57013. private _fogParameters;
  57014. /**
  57015. * Create a new FogBlock
  57016. * @param name defines the block name
  57017. */
  57018. constructor(name: string);
  57019. /**
  57020. * Gets the current class name
  57021. * @returns the class name
  57022. */
  57023. getClassName(): string;
  57024. /**
  57025. * Gets the world position input component
  57026. */
  57027. readonly worldPosition: NodeMaterialConnectionPoint;
  57028. /**
  57029. * Gets the view input component
  57030. */
  57031. readonly view: NodeMaterialConnectionPoint;
  57032. /**
  57033. * Gets the color input component
  57034. */
  57035. readonly input: NodeMaterialConnectionPoint;
  57036. /**
  57037. * Gets the fog color input component
  57038. */
  57039. readonly fogColor: NodeMaterialConnectionPoint;
  57040. /**
  57041. * Gets the output component
  57042. */
  57043. readonly output: NodeMaterialConnectionPoint;
  57044. autoConfigure(material: NodeMaterial): void;
  57045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57047. protected _buildBlock(state: NodeMaterialBuildState): this;
  57048. }
  57049. }
  57050. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57055. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57056. import { Effect } from "babylonjs/Materials/effect";
  57057. import { Mesh } from "babylonjs/Meshes/mesh";
  57058. import { Light } from "babylonjs/Lights/light";
  57059. import { Nullable } from "babylonjs/types";
  57060. import { Scene } from "babylonjs/scene";
  57061. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57062. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57063. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57064. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57065. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57066. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57067. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57068. /**
  57069. * Block used to add light in the fragment shader
  57070. */
  57071. export class LightBlock extends NodeMaterialBlock {
  57072. private _lightId;
  57073. /**
  57074. * Gets or sets the light associated with this block
  57075. */
  57076. light: Nullable<Light>;
  57077. /**
  57078. * Create a new LightBlock
  57079. * @param name defines the block name
  57080. */
  57081. constructor(name: string);
  57082. /**
  57083. * Gets the current class name
  57084. * @returns the class name
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Gets the world position input component
  57089. */
  57090. readonly worldPosition: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the world normal input component
  57093. */
  57094. readonly worldNormal: NodeMaterialConnectionPoint;
  57095. /**
  57096. * Gets the camera (or eye) position component
  57097. */
  57098. readonly cameraPosition: NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the glossiness component
  57101. */
  57102. readonly glossiness: NodeMaterialConnectionPoint;
  57103. /**
  57104. * Gets the glossinness power component
  57105. */
  57106. readonly glossPower: NodeMaterialConnectionPoint;
  57107. /**
  57108. * Gets the diffuse color component
  57109. */
  57110. readonly diffuseColor: NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the specular color component
  57113. */
  57114. readonly specularColor: NodeMaterialConnectionPoint;
  57115. /**
  57116. * Gets the diffuse output component
  57117. */
  57118. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the specular output component
  57121. */
  57122. readonly specularOutput: NodeMaterialConnectionPoint;
  57123. autoConfigure(material: NodeMaterial): void;
  57124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57125. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57126. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57127. private _injectVertexCode;
  57128. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57129. serialize(): any;
  57130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57131. }
  57132. }
  57133. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57134. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57135. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57136. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57137. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57138. }
  57139. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57140. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57141. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57142. }
  57143. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57147. /**
  57148. * Block used to multiply 2 values
  57149. */
  57150. export class MultiplyBlock extends NodeMaterialBlock {
  57151. /**
  57152. * Creates a new MultiplyBlock
  57153. * @param name defines the block name
  57154. */
  57155. constructor(name: string);
  57156. /**
  57157. * Gets the current class name
  57158. * @returns the class name
  57159. */
  57160. getClassName(): string;
  57161. /**
  57162. * Gets the left operand input component
  57163. */
  57164. readonly left: NodeMaterialConnectionPoint;
  57165. /**
  57166. * Gets the right operand input component
  57167. */
  57168. readonly right: NodeMaterialConnectionPoint;
  57169. /**
  57170. * Gets the output component
  57171. */
  57172. readonly output: NodeMaterialConnectionPoint;
  57173. protected _buildBlock(state: NodeMaterialBuildState): this;
  57174. }
  57175. }
  57176. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57180. /**
  57181. * Block used to add 2 vectors
  57182. */
  57183. export class AddBlock extends NodeMaterialBlock {
  57184. /**
  57185. * Creates a new AddBlock
  57186. * @param name defines the block name
  57187. */
  57188. constructor(name: string);
  57189. /**
  57190. * Gets the current class name
  57191. * @returns the class name
  57192. */
  57193. getClassName(): string;
  57194. /**
  57195. * Gets the left operand input component
  57196. */
  57197. readonly left: NodeMaterialConnectionPoint;
  57198. /**
  57199. * Gets the right operand input component
  57200. */
  57201. readonly right: NodeMaterialConnectionPoint;
  57202. /**
  57203. * Gets the output component
  57204. */
  57205. readonly output: NodeMaterialConnectionPoint;
  57206. protected _buildBlock(state: NodeMaterialBuildState): this;
  57207. }
  57208. }
  57209. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57213. /**
  57214. * Block used to scale a vector by a float
  57215. */
  57216. export class ScaleBlock extends NodeMaterialBlock {
  57217. /**
  57218. * Creates a new ScaleBlock
  57219. * @param name defines the block name
  57220. */
  57221. constructor(name: string);
  57222. /**
  57223. * Gets the current class name
  57224. * @returns the class name
  57225. */
  57226. getClassName(): string;
  57227. /**
  57228. * Gets the input component
  57229. */
  57230. readonly input: NodeMaterialConnectionPoint;
  57231. /**
  57232. * Gets the factor input component
  57233. */
  57234. readonly factor: NodeMaterialConnectionPoint;
  57235. /**
  57236. * Gets the output component
  57237. */
  57238. readonly output: NodeMaterialConnectionPoint;
  57239. protected _buildBlock(state: NodeMaterialBuildState): this;
  57240. }
  57241. }
  57242. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57246. import { Scene } from "babylonjs/scene";
  57247. /**
  57248. * Block used to clamp a float
  57249. */
  57250. export class ClampBlock extends NodeMaterialBlock {
  57251. /** Gets or sets the minimum range */
  57252. minimum: number;
  57253. /** Gets or sets the maximum range */
  57254. maximum: number;
  57255. /**
  57256. * Creates a new ClampBlock
  57257. * @param name defines the block name
  57258. */
  57259. constructor(name: string);
  57260. /**
  57261. * Gets the current class name
  57262. * @returns the class name
  57263. */
  57264. getClassName(): string;
  57265. /**
  57266. * Gets the value input component
  57267. */
  57268. readonly value: NodeMaterialConnectionPoint;
  57269. /**
  57270. * Gets the output component
  57271. */
  57272. readonly output: NodeMaterialConnectionPoint;
  57273. protected _buildBlock(state: NodeMaterialBuildState): this;
  57274. protected _dumpPropertiesCode(): string;
  57275. serialize(): any;
  57276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57277. }
  57278. }
  57279. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57283. /**
  57284. * Block used to apply a cross product between 2 vectors
  57285. */
  57286. export class CrossBlock extends NodeMaterialBlock {
  57287. /**
  57288. * Creates a new CrossBlock
  57289. * @param name defines the block name
  57290. */
  57291. constructor(name: string);
  57292. /**
  57293. * Gets the current class name
  57294. * @returns the class name
  57295. */
  57296. getClassName(): string;
  57297. /**
  57298. * Gets the left operand input component
  57299. */
  57300. readonly left: NodeMaterialConnectionPoint;
  57301. /**
  57302. * Gets the right operand input component
  57303. */
  57304. readonly right: NodeMaterialConnectionPoint;
  57305. /**
  57306. * Gets the output component
  57307. */
  57308. readonly output: NodeMaterialConnectionPoint;
  57309. protected _buildBlock(state: NodeMaterialBuildState): this;
  57310. }
  57311. }
  57312. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57316. /**
  57317. * Block used to apply a dot product between 2 vectors
  57318. */
  57319. export class DotBlock extends NodeMaterialBlock {
  57320. /**
  57321. * Creates a new DotBlock
  57322. * @param name defines the block name
  57323. */
  57324. constructor(name: string);
  57325. /**
  57326. * Gets the current class name
  57327. * @returns the class name
  57328. */
  57329. getClassName(): string;
  57330. /**
  57331. * Gets the left operand input component
  57332. */
  57333. readonly left: NodeMaterialConnectionPoint;
  57334. /**
  57335. * Gets the right operand input component
  57336. */
  57337. readonly right: NodeMaterialConnectionPoint;
  57338. /**
  57339. * Gets the output component
  57340. */
  57341. readonly output: NodeMaterialConnectionPoint;
  57342. protected _buildBlock(state: NodeMaterialBuildState): this;
  57343. }
  57344. }
  57345. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57349. import { Vector2 } from "babylonjs/Maths/math.vector";
  57350. import { Scene } from "babylonjs/scene";
  57351. /**
  57352. * Block used to remap a float from a range to a new one
  57353. */
  57354. export class RemapBlock extends NodeMaterialBlock {
  57355. /**
  57356. * Gets or sets the source range
  57357. */
  57358. sourceRange: Vector2;
  57359. /**
  57360. * Gets or sets the target range
  57361. */
  57362. targetRange: Vector2;
  57363. /**
  57364. * Creates a new RemapBlock
  57365. * @param name defines the block name
  57366. */
  57367. constructor(name: string);
  57368. /**
  57369. * Gets the current class name
  57370. * @returns the class name
  57371. */
  57372. getClassName(): string;
  57373. /**
  57374. * Gets the input component
  57375. */
  57376. readonly input: NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the source min input component
  57379. */
  57380. readonly sourceMin: NodeMaterialConnectionPoint;
  57381. /**
  57382. * Gets the source max input component
  57383. */
  57384. readonly sourceMax: NodeMaterialConnectionPoint;
  57385. /**
  57386. * Gets the target min input component
  57387. */
  57388. readonly targetMin: NodeMaterialConnectionPoint;
  57389. /**
  57390. * Gets the target max input component
  57391. */
  57392. readonly targetMax: NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the output component
  57395. */
  57396. readonly output: NodeMaterialConnectionPoint;
  57397. protected _buildBlock(state: NodeMaterialBuildState): this;
  57398. protected _dumpPropertiesCode(): string;
  57399. serialize(): any;
  57400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57401. }
  57402. }
  57403. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57407. /**
  57408. * Block used to normalize a vector
  57409. */
  57410. export class NormalizeBlock extends NodeMaterialBlock {
  57411. /**
  57412. * Creates a new NormalizeBlock
  57413. * @param name defines the block name
  57414. */
  57415. constructor(name: string);
  57416. /**
  57417. * Gets the current class name
  57418. * @returns the class name
  57419. */
  57420. getClassName(): string;
  57421. /**
  57422. * Gets the input component
  57423. */
  57424. readonly input: NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the output component
  57427. */
  57428. readonly output: NodeMaterialConnectionPoint;
  57429. protected _buildBlock(state: NodeMaterialBuildState): this;
  57430. }
  57431. }
  57432. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57436. import { Scene } from "babylonjs/scene";
  57437. /**
  57438. * Operations supported by the Trigonometry block
  57439. */
  57440. export enum TrigonometryBlockOperations {
  57441. /** Cos */
  57442. Cos = 0,
  57443. /** Sin */
  57444. Sin = 1,
  57445. /** Abs */
  57446. Abs = 2,
  57447. /** Exp */
  57448. Exp = 3,
  57449. /** Exp2 */
  57450. Exp2 = 4,
  57451. /** Round */
  57452. Round = 5,
  57453. /** Floor */
  57454. Floor = 6,
  57455. /** Ceiling */
  57456. Ceiling = 7,
  57457. /** Square root */
  57458. Sqrt = 8,
  57459. /** Log */
  57460. Log = 9,
  57461. /** Tangent */
  57462. Tan = 10,
  57463. /** Arc tangent */
  57464. ArcTan = 11,
  57465. /** Arc cosinus */
  57466. ArcCos = 12,
  57467. /** Arc sinus */
  57468. ArcSin = 13,
  57469. /** Fraction */
  57470. Fract = 14,
  57471. /** Sign */
  57472. Sign = 15,
  57473. /** To radians (from degrees) */
  57474. Radians = 16,
  57475. /** To degrees (from radians) */
  57476. Degrees = 17
  57477. }
  57478. /**
  57479. * Block used to apply trigonometry operation to floats
  57480. */
  57481. export class TrigonometryBlock extends NodeMaterialBlock {
  57482. /**
  57483. * Gets or sets the operation applied by the block
  57484. */
  57485. operation: TrigonometryBlockOperations;
  57486. /**
  57487. * Creates a new TrigonometryBlock
  57488. * @param name defines the block name
  57489. */
  57490. constructor(name: string);
  57491. /**
  57492. * Gets the current class name
  57493. * @returns the class name
  57494. */
  57495. getClassName(): string;
  57496. /**
  57497. * Gets the input component
  57498. */
  57499. readonly input: NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the output component
  57502. */
  57503. readonly output: NodeMaterialConnectionPoint;
  57504. protected _buildBlock(state: NodeMaterialBuildState): this;
  57505. serialize(): any;
  57506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57507. }
  57508. }
  57509. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57513. /**
  57514. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57515. */
  57516. export class ColorMergerBlock extends NodeMaterialBlock {
  57517. /**
  57518. * Create a new ColorMergerBlock
  57519. * @param name defines the block name
  57520. */
  57521. constructor(name: string);
  57522. /**
  57523. * Gets the current class name
  57524. * @returns the class name
  57525. */
  57526. getClassName(): string;
  57527. /**
  57528. * Gets the r component (input)
  57529. */
  57530. readonly r: NodeMaterialConnectionPoint;
  57531. /**
  57532. * Gets the g component (input)
  57533. */
  57534. readonly g: NodeMaterialConnectionPoint;
  57535. /**
  57536. * Gets the b component (input)
  57537. */
  57538. readonly b: NodeMaterialConnectionPoint;
  57539. /**
  57540. * Gets the a component (input)
  57541. */
  57542. readonly a: NodeMaterialConnectionPoint;
  57543. /**
  57544. * Gets the rgba component (output)
  57545. */
  57546. readonly rgba: NodeMaterialConnectionPoint;
  57547. /**
  57548. * Gets the rgb component (output)
  57549. */
  57550. readonly rgb: NodeMaterialConnectionPoint;
  57551. protected _buildBlock(state: NodeMaterialBuildState): this;
  57552. }
  57553. }
  57554. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57558. /**
  57559. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57560. */
  57561. export class VectorMergerBlock extends NodeMaterialBlock {
  57562. /**
  57563. * Create a new VectorMergerBlock
  57564. * @param name defines the block name
  57565. */
  57566. constructor(name: string);
  57567. /**
  57568. * Gets the current class name
  57569. * @returns the class name
  57570. */
  57571. getClassName(): string;
  57572. /**
  57573. * Gets the x component (input)
  57574. */
  57575. readonly x: NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the y component (input)
  57578. */
  57579. readonly y: NodeMaterialConnectionPoint;
  57580. /**
  57581. * Gets the z component (input)
  57582. */
  57583. readonly z: NodeMaterialConnectionPoint;
  57584. /**
  57585. * Gets the w component (input)
  57586. */
  57587. readonly w: NodeMaterialConnectionPoint;
  57588. /**
  57589. * Gets the xyzw component (output)
  57590. */
  57591. readonly xyzw: NodeMaterialConnectionPoint;
  57592. /**
  57593. * Gets the xyz component (output)
  57594. */
  57595. readonly xyz: NodeMaterialConnectionPoint;
  57596. /**
  57597. * Gets the xy component (output)
  57598. */
  57599. readonly xy: NodeMaterialConnectionPoint;
  57600. protected _buildBlock(state: NodeMaterialBuildState): this;
  57601. }
  57602. }
  57603. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57607. /**
  57608. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57609. */
  57610. export class ColorSplitterBlock extends NodeMaterialBlock {
  57611. /**
  57612. * Create a new ColorSplitterBlock
  57613. * @param name defines the block name
  57614. */
  57615. constructor(name: string);
  57616. /**
  57617. * Gets the current class name
  57618. * @returns the class name
  57619. */
  57620. getClassName(): string;
  57621. /**
  57622. * Gets the rgba component (input)
  57623. */
  57624. readonly rgba: NodeMaterialConnectionPoint;
  57625. /**
  57626. * Gets the rgb component (input)
  57627. */
  57628. readonly rgbIn: NodeMaterialConnectionPoint;
  57629. /**
  57630. * Gets the rgb component (output)
  57631. */
  57632. readonly rgbOut: NodeMaterialConnectionPoint;
  57633. /**
  57634. * Gets the r component (output)
  57635. */
  57636. readonly r: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the g component (output)
  57639. */
  57640. readonly g: NodeMaterialConnectionPoint;
  57641. /**
  57642. * Gets the b component (output)
  57643. */
  57644. readonly b: NodeMaterialConnectionPoint;
  57645. /**
  57646. * Gets the a component (output)
  57647. */
  57648. readonly a: NodeMaterialConnectionPoint;
  57649. protected _inputRename(name: string): string;
  57650. protected _outputRename(name: string): string;
  57651. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57652. }
  57653. }
  57654. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57658. /**
  57659. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57660. */
  57661. export class VectorSplitterBlock extends NodeMaterialBlock {
  57662. /**
  57663. * Create a new VectorSplitterBlock
  57664. * @param name defines the block name
  57665. */
  57666. constructor(name: string);
  57667. /**
  57668. * Gets the current class name
  57669. * @returns the class name
  57670. */
  57671. getClassName(): string;
  57672. /**
  57673. * Gets the xyzw component (input)
  57674. */
  57675. readonly xyzw: NodeMaterialConnectionPoint;
  57676. /**
  57677. * Gets the xyz component (input)
  57678. */
  57679. readonly xyzIn: NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the xy component (input)
  57682. */
  57683. readonly xyIn: NodeMaterialConnectionPoint;
  57684. /**
  57685. * Gets the xyz component (output)
  57686. */
  57687. readonly xyzOut: NodeMaterialConnectionPoint;
  57688. /**
  57689. * Gets the xy component (output)
  57690. */
  57691. readonly xyOut: NodeMaterialConnectionPoint;
  57692. /**
  57693. * Gets the x component (output)
  57694. */
  57695. readonly x: NodeMaterialConnectionPoint;
  57696. /**
  57697. * Gets the y component (output)
  57698. */
  57699. readonly y: NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the z component (output)
  57702. */
  57703. readonly z: NodeMaterialConnectionPoint;
  57704. /**
  57705. * Gets the w component (output)
  57706. */
  57707. readonly w: NodeMaterialConnectionPoint;
  57708. protected _inputRename(name: string): string;
  57709. protected _outputRename(name: string): string;
  57710. protected _buildBlock(state: NodeMaterialBuildState): this;
  57711. }
  57712. }
  57713. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57717. /**
  57718. * Block used to lerp between 2 values
  57719. */
  57720. export class LerpBlock extends NodeMaterialBlock {
  57721. /**
  57722. * Creates a new LerpBlock
  57723. * @param name defines the block name
  57724. */
  57725. constructor(name: string);
  57726. /**
  57727. * Gets the current class name
  57728. * @returns the class name
  57729. */
  57730. getClassName(): string;
  57731. /**
  57732. * Gets the left operand input component
  57733. */
  57734. readonly left: NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the right operand input component
  57737. */
  57738. readonly right: NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the gradient operand input component
  57741. */
  57742. readonly gradient: NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the output component
  57745. */
  57746. readonly output: NodeMaterialConnectionPoint;
  57747. protected _buildBlock(state: NodeMaterialBuildState): this;
  57748. }
  57749. }
  57750. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57754. /**
  57755. * Block used to divide 2 vectors
  57756. */
  57757. export class DivideBlock extends NodeMaterialBlock {
  57758. /**
  57759. * Creates a new DivideBlock
  57760. * @param name defines the block name
  57761. */
  57762. constructor(name: string);
  57763. /**
  57764. * Gets the current class name
  57765. * @returns the class name
  57766. */
  57767. getClassName(): string;
  57768. /**
  57769. * Gets the left operand input component
  57770. */
  57771. readonly left: NodeMaterialConnectionPoint;
  57772. /**
  57773. * Gets the right operand input component
  57774. */
  57775. readonly right: NodeMaterialConnectionPoint;
  57776. /**
  57777. * Gets the output component
  57778. */
  57779. readonly output: NodeMaterialConnectionPoint;
  57780. protected _buildBlock(state: NodeMaterialBuildState): this;
  57781. }
  57782. }
  57783. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57787. /**
  57788. * Block used to subtract 2 vectors
  57789. */
  57790. export class SubtractBlock extends NodeMaterialBlock {
  57791. /**
  57792. * Creates a new SubtractBlock
  57793. * @param name defines the block name
  57794. */
  57795. constructor(name: string);
  57796. /**
  57797. * Gets the current class name
  57798. * @returns the class name
  57799. */
  57800. getClassName(): string;
  57801. /**
  57802. * Gets the left operand input component
  57803. */
  57804. readonly left: NodeMaterialConnectionPoint;
  57805. /**
  57806. * Gets the right operand input component
  57807. */
  57808. readonly right: NodeMaterialConnectionPoint;
  57809. /**
  57810. * Gets the output component
  57811. */
  57812. readonly output: NodeMaterialConnectionPoint;
  57813. protected _buildBlock(state: NodeMaterialBuildState): this;
  57814. }
  57815. }
  57816. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57817. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57818. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57820. /**
  57821. * Block used to step a value
  57822. */
  57823. export class StepBlock extends NodeMaterialBlock {
  57824. /**
  57825. * Creates a new StepBlock
  57826. * @param name defines the block name
  57827. */
  57828. constructor(name: string);
  57829. /**
  57830. * Gets the current class name
  57831. * @returns the class name
  57832. */
  57833. getClassName(): string;
  57834. /**
  57835. * Gets the value operand input component
  57836. */
  57837. readonly value: NodeMaterialConnectionPoint;
  57838. /**
  57839. * Gets the edge operand input component
  57840. */
  57841. readonly edge: NodeMaterialConnectionPoint;
  57842. /**
  57843. * Gets the output component
  57844. */
  57845. readonly output: NodeMaterialConnectionPoint;
  57846. protected _buildBlock(state: NodeMaterialBuildState): this;
  57847. }
  57848. }
  57849. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57853. /**
  57854. * Block used to get the opposite (1 - x) of a value
  57855. */
  57856. export class OneMinusBlock extends NodeMaterialBlock {
  57857. /**
  57858. * Creates a new OneMinusBlock
  57859. * @param name defines the block name
  57860. */
  57861. constructor(name: string);
  57862. /**
  57863. * Gets the current class name
  57864. * @returns the class name
  57865. */
  57866. getClassName(): string;
  57867. /**
  57868. * Gets the input component
  57869. */
  57870. readonly input: NodeMaterialConnectionPoint;
  57871. /**
  57872. * Gets the output component
  57873. */
  57874. readonly output: NodeMaterialConnectionPoint;
  57875. protected _buildBlock(state: NodeMaterialBuildState): this;
  57876. }
  57877. }
  57878. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57882. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57883. /**
  57884. * Block used to get the view direction
  57885. */
  57886. export class ViewDirectionBlock extends NodeMaterialBlock {
  57887. /**
  57888. * Creates a new ViewDirectionBlock
  57889. * @param name defines the block name
  57890. */
  57891. constructor(name: string);
  57892. /**
  57893. * Gets the current class name
  57894. * @returns the class name
  57895. */
  57896. getClassName(): string;
  57897. /**
  57898. * Gets the world position component
  57899. */
  57900. readonly worldPosition: NodeMaterialConnectionPoint;
  57901. /**
  57902. * Gets the camera position component
  57903. */
  57904. readonly cameraPosition: NodeMaterialConnectionPoint;
  57905. /**
  57906. * Gets the output component
  57907. */
  57908. readonly output: NodeMaterialConnectionPoint;
  57909. autoConfigure(material: NodeMaterial): void;
  57910. protected _buildBlock(state: NodeMaterialBuildState): this;
  57911. }
  57912. }
  57913. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57917. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57918. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57919. /**
  57920. * Block used to compute fresnel value
  57921. */
  57922. export class FresnelBlock extends NodeMaterialBlock {
  57923. /**
  57924. * Create a new FresnelBlock
  57925. * @param name defines the block name
  57926. */
  57927. constructor(name: string);
  57928. /**
  57929. * Gets the current class name
  57930. * @returns the class name
  57931. */
  57932. getClassName(): string;
  57933. /**
  57934. * Gets the world normal input component
  57935. */
  57936. readonly worldNormal: NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the view direction input component
  57939. */
  57940. readonly viewDirection: NodeMaterialConnectionPoint;
  57941. /**
  57942. * Gets the bias input component
  57943. */
  57944. readonly bias: NodeMaterialConnectionPoint;
  57945. /**
  57946. * Gets the camera (or eye) position component
  57947. */
  57948. readonly power: NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the fresnel output component
  57951. */
  57952. readonly fresnel: NodeMaterialConnectionPoint;
  57953. autoConfigure(material: NodeMaterial): void;
  57954. protected _buildBlock(state: NodeMaterialBuildState): this;
  57955. }
  57956. }
  57957. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57961. /**
  57962. * Block used to get the max of 2 values
  57963. */
  57964. export class MaxBlock extends NodeMaterialBlock {
  57965. /**
  57966. * Creates a new MaxBlock
  57967. * @param name defines the block name
  57968. */
  57969. constructor(name: string);
  57970. /**
  57971. * Gets the current class name
  57972. * @returns the class name
  57973. */
  57974. getClassName(): string;
  57975. /**
  57976. * Gets the left operand input component
  57977. */
  57978. readonly left: NodeMaterialConnectionPoint;
  57979. /**
  57980. * Gets the right operand input component
  57981. */
  57982. readonly right: NodeMaterialConnectionPoint;
  57983. /**
  57984. * Gets the output component
  57985. */
  57986. readonly output: NodeMaterialConnectionPoint;
  57987. protected _buildBlock(state: NodeMaterialBuildState): this;
  57988. }
  57989. }
  57990. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57994. /**
  57995. * Block used to get the min of 2 values
  57996. */
  57997. export class MinBlock extends NodeMaterialBlock {
  57998. /**
  57999. * Creates a new MinBlock
  58000. * @param name defines the block name
  58001. */
  58002. constructor(name: string);
  58003. /**
  58004. * Gets the current class name
  58005. * @returns the class name
  58006. */
  58007. getClassName(): string;
  58008. /**
  58009. * Gets the left operand input component
  58010. */
  58011. readonly left: NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the right operand input component
  58014. */
  58015. readonly right: NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the output component
  58018. */
  58019. readonly output: NodeMaterialConnectionPoint;
  58020. protected _buildBlock(state: NodeMaterialBuildState): this;
  58021. }
  58022. }
  58023. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58027. /**
  58028. * Block used to get the distance between 2 values
  58029. */
  58030. export class DistanceBlock extends NodeMaterialBlock {
  58031. /**
  58032. * Creates a new DistanceBlock
  58033. * @param name defines the block name
  58034. */
  58035. constructor(name: string);
  58036. /**
  58037. * Gets the current class name
  58038. * @returns the class name
  58039. */
  58040. getClassName(): string;
  58041. /**
  58042. * Gets the left operand input component
  58043. */
  58044. readonly left: NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the right operand input component
  58047. */
  58048. readonly right: NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the output component
  58051. */
  58052. readonly output: NodeMaterialConnectionPoint;
  58053. protected _buildBlock(state: NodeMaterialBuildState): this;
  58054. }
  58055. }
  58056. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58060. /**
  58061. * Block used to get the length of a vector
  58062. */
  58063. export class LengthBlock extends NodeMaterialBlock {
  58064. /**
  58065. * Creates a new LengthBlock
  58066. * @param name defines the block name
  58067. */
  58068. constructor(name: string);
  58069. /**
  58070. * Gets the current class name
  58071. * @returns the class name
  58072. */
  58073. getClassName(): string;
  58074. /**
  58075. * Gets the value input component
  58076. */
  58077. readonly value: NodeMaterialConnectionPoint;
  58078. /**
  58079. * Gets the output component
  58080. */
  58081. readonly output: NodeMaterialConnectionPoint;
  58082. protected _buildBlock(state: NodeMaterialBuildState): this;
  58083. }
  58084. }
  58085. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58089. /**
  58090. * Block used to get negative version of a value (i.e. x * -1)
  58091. */
  58092. export class NegateBlock extends NodeMaterialBlock {
  58093. /**
  58094. * Creates a new NegateBlock
  58095. * @param name defines the block name
  58096. */
  58097. constructor(name: string);
  58098. /**
  58099. * Gets the current class name
  58100. * @returns the class name
  58101. */
  58102. getClassName(): string;
  58103. /**
  58104. * Gets the value input component
  58105. */
  58106. readonly value: NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the output component
  58109. */
  58110. readonly output: NodeMaterialConnectionPoint;
  58111. protected _buildBlock(state: NodeMaterialBuildState): this;
  58112. }
  58113. }
  58114. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58118. /**
  58119. * Block used to get the value of the first parameter raised to the power of the second
  58120. */
  58121. export class PowBlock extends NodeMaterialBlock {
  58122. /**
  58123. * Creates a new PowBlock
  58124. * @param name defines the block name
  58125. */
  58126. constructor(name: string);
  58127. /**
  58128. * Gets the current class name
  58129. * @returns the class name
  58130. */
  58131. getClassName(): string;
  58132. /**
  58133. * Gets the value operand input component
  58134. */
  58135. readonly value: NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the power operand input component
  58138. */
  58139. readonly power: NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the output component
  58142. */
  58143. readonly output: NodeMaterialConnectionPoint;
  58144. protected _buildBlock(state: NodeMaterialBuildState): this;
  58145. }
  58146. }
  58147. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58151. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58152. /**
  58153. * Block used to get a random number
  58154. */
  58155. export class RandomNumberBlock extends NodeMaterialBlock {
  58156. /**
  58157. * Creates a new RandomNumberBlock
  58158. * @param name defines the block name
  58159. */
  58160. constructor(name: string);
  58161. /**
  58162. * Gets the current class name
  58163. * @returns the class name
  58164. */
  58165. getClassName(): string;
  58166. /**
  58167. * Gets the seed input component
  58168. */
  58169. readonly seed: NodeMaterialConnectionPoint;
  58170. /**
  58171. * Gets the output component
  58172. */
  58173. readonly output: NodeMaterialConnectionPoint;
  58174. protected _buildBlock(state: NodeMaterialBuildState): this;
  58175. }
  58176. }
  58177. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58181. /**
  58182. * Block used to compute arc tangent of 2 values
  58183. */
  58184. export class ArcTan2Block extends NodeMaterialBlock {
  58185. /**
  58186. * Creates a new ArcTan2Block
  58187. * @param name defines the block name
  58188. */
  58189. constructor(name: string);
  58190. /**
  58191. * Gets the current class name
  58192. * @returns the class name
  58193. */
  58194. getClassName(): string;
  58195. /**
  58196. * Gets the x operand input component
  58197. */
  58198. readonly x: NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the y operand input component
  58201. */
  58202. readonly y: NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the output component
  58205. */
  58206. readonly output: NodeMaterialConnectionPoint;
  58207. protected _buildBlock(state: NodeMaterialBuildState): this;
  58208. }
  58209. }
  58210. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58214. /**
  58215. * Block used to smooth step a value
  58216. */
  58217. export class SmoothStepBlock extends NodeMaterialBlock {
  58218. /**
  58219. * Creates a new SmoothStepBlock
  58220. * @param name defines the block name
  58221. */
  58222. constructor(name: string);
  58223. /**
  58224. * Gets the current class name
  58225. * @returns the class name
  58226. */
  58227. getClassName(): string;
  58228. /**
  58229. * Gets the value operand input component
  58230. */
  58231. readonly value: NodeMaterialConnectionPoint;
  58232. /**
  58233. * Gets the first edge operand input component
  58234. */
  58235. readonly edge0: NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the second edge operand input component
  58238. */
  58239. readonly edge1: NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the output component
  58242. */
  58243. readonly output: NodeMaterialConnectionPoint;
  58244. protected _buildBlock(state: NodeMaterialBuildState): this;
  58245. }
  58246. }
  58247. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58251. /**
  58252. * Block used to get the reciprocal (1 / x) of a value
  58253. */
  58254. export class ReciprocalBlock extends NodeMaterialBlock {
  58255. /**
  58256. * Creates a new ReciprocalBlock
  58257. * @param name defines the block name
  58258. */
  58259. constructor(name: string);
  58260. /**
  58261. * Gets the current class name
  58262. * @returns the class name
  58263. */
  58264. getClassName(): string;
  58265. /**
  58266. * Gets the input component
  58267. */
  58268. readonly input: NodeMaterialConnectionPoint;
  58269. /**
  58270. * Gets the output component
  58271. */
  58272. readonly output: NodeMaterialConnectionPoint;
  58273. protected _buildBlock(state: NodeMaterialBuildState): this;
  58274. }
  58275. }
  58276. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58280. /**
  58281. * Block used to replace a color by another one
  58282. */
  58283. export class ReplaceColorBlock extends NodeMaterialBlock {
  58284. /**
  58285. * Creates a new ReplaceColorBlock
  58286. * @param name defines the block name
  58287. */
  58288. constructor(name: string);
  58289. /**
  58290. * Gets the current class name
  58291. * @returns the class name
  58292. */
  58293. getClassName(): string;
  58294. /**
  58295. * Gets the value input component
  58296. */
  58297. readonly value: NodeMaterialConnectionPoint;
  58298. /**
  58299. * Gets the reference input component
  58300. */
  58301. readonly reference: NodeMaterialConnectionPoint;
  58302. /**
  58303. * Gets the distance input component
  58304. */
  58305. readonly distance: NodeMaterialConnectionPoint;
  58306. /**
  58307. * Gets the replacement input component
  58308. */
  58309. readonly replacement: NodeMaterialConnectionPoint;
  58310. /**
  58311. * Gets the output component
  58312. */
  58313. readonly output: NodeMaterialConnectionPoint;
  58314. protected _buildBlock(state: NodeMaterialBuildState): this;
  58315. }
  58316. }
  58317. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58321. /**
  58322. * Block used to posterize a value
  58323. * @see https://en.wikipedia.org/wiki/Posterization
  58324. */
  58325. export class PosterizeBlock extends NodeMaterialBlock {
  58326. /**
  58327. * Creates a new PosterizeBlock
  58328. * @param name defines the block name
  58329. */
  58330. constructor(name: string);
  58331. /**
  58332. * Gets the current class name
  58333. * @returns the class name
  58334. */
  58335. getClassName(): string;
  58336. /**
  58337. * Gets the value input component
  58338. */
  58339. readonly value: NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the steps input component
  58342. */
  58343. readonly steps: NodeMaterialConnectionPoint;
  58344. /**
  58345. * Gets the output component
  58346. */
  58347. readonly output: NodeMaterialConnectionPoint;
  58348. protected _buildBlock(state: NodeMaterialBuildState): this;
  58349. }
  58350. }
  58351. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58355. import { Scene } from "babylonjs/scene";
  58356. /**
  58357. * Operations supported by the Wave block
  58358. */
  58359. export enum WaveBlockKind {
  58360. /** SawTooth */
  58361. SawTooth = 0,
  58362. /** Square */
  58363. Square = 1,
  58364. /** Triangle */
  58365. Triangle = 2
  58366. }
  58367. /**
  58368. * Block used to apply wave operation to floats
  58369. */
  58370. export class WaveBlock extends NodeMaterialBlock {
  58371. /**
  58372. * Gets or sets the kibnd of wave to be applied by the block
  58373. */
  58374. kind: WaveBlockKind;
  58375. /**
  58376. * Creates a new WaveBlock
  58377. * @param name defines the block name
  58378. */
  58379. constructor(name: string);
  58380. /**
  58381. * Gets the current class name
  58382. * @returns the class name
  58383. */
  58384. getClassName(): string;
  58385. /**
  58386. * Gets the input component
  58387. */
  58388. readonly input: NodeMaterialConnectionPoint;
  58389. /**
  58390. * Gets the output component
  58391. */
  58392. readonly output: NodeMaterialConnectionPoint;
  58393. protected _buildBlock(state: NodeMaterialBuildState): this;
  58394. serialize(): any;
  58395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58396. }
  58397. }
  58398. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58402. import { Color3 } from "babylonjs/Maths/math.color";
  58403. import { Scene } from "babylonjs/scene";
  58404. /**
  58405. * Class used to store a color step for the GradientBlock
  58406. */
  58407. export class GradientBlockColorStep {
  58408. /**
  58409. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58410. */
  58411. step: number;
  58412. /**
  58413. * Gets or sets the color associated with this step
  58414. */
  58415. color: Color3;
  58416. /**
  58417. * Creates a new GradientBlockColorStep
  58418. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58419. * @param color defines the color associated with this step
  58420. */
  58421. constructor(
  58422. /**
  58423. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58424. */
  58425. step: number,
  58426. /**
  58427. * Gets or sets the color associated with this step
  58428. */
  58429. color: Color3);
  58430. }
  58431. /**
  58432. * Block used to return a color from a gradient based on an input value between 0 and 1
  58433. */
  58434. export class GradientBlock extends NodeMaterialBlock {
  58435. /**
  58436. * Gets or sets the list of color steps
  58437. */
  58438. colorSteps: GradientBlockColorStep[];
  58439. /**
  58440. * Creates a new GradientBlock
  58441. * @param name defines the block name
  58442. */
  58443. constructor(name: string);
  58444. /**
  58445. * Gets the current class name
  58446. * @returns the class name
  58447. */
  58448. getClassName(): string;
  58449. /**
  58450. * Gets the gradient input component
  58451. */
  58452. readonly gradient: NodeMaterialConnectionPoint;
  58453. /**
  58454. * Gets the output component
  58455. */
  58456. readonly output: NodeMaterialConnectionPoint;
  58457. private _writeColorConstant;
  58458. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58459. serialize(): any;
  58460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58461. protected _dumpPropertiesCode(): string;
  58462. }
  58463. }
  58464. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58468. /**
  58469. * Block used to normalize lerp between 2 values
  58470. */
  58471. export class NLerpBlock extends NodeMaterialBlock {
  58472. /**
  58473. * Creates a new NLerpBlock
  58474. * @param name defines the block name
  58475. */
  58476. constructor(name: string);
  58477. /**
  58478. * Gets the current class name
  58479. * @returns the class name
  58480. */
  58481. getClassName(): string;
  58482. /**
  58483. * Gets the left operand input component
  58484. */
  58485. readonly left: NodeMaterialConnectionPoint;
  58486. /**
  58487. * Gets the right operand input component
  58488. */
  58489. readonly right: NodeMaterialConnectionPoint;
  58490. /**
  58491. * Gets the gradient operand input component
  58492. */
  58493. readonly gradient: NodeMaterialConnectionPoint;
  58494. /**
  58495. * Gets the output component
  58496. */
  58497. readonly output: NodeMaterialConnectionPoint;
  58498. protected _buildBlock(state: NodeMaterialBuildState): this;
  58499. }
  58500. }
  58501. declare module "babylonjs/Materials/Node/Blocks/index" {
  58502. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58503. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58504. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58505. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58506. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58507. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58508. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58509. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58510. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58511. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58512. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58513. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58514. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58515. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58516. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58517. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58518. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58519. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58520. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58521. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58522. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58523. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58524. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58525. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58526. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58527. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58528. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58529. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58530. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58531. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58532. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58533. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58534. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58535. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58536. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58537. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58538. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58539. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58540. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58541. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58542. }
  58543. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58544. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58545. }
  58546. declare module "babylonjs/Materials/Node/index" {
  58547. export * from "babylonjs/Materials/Node/Enums/index";
  58548. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58549. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58550. export * from "babylonjs/Materials/Node/nodeMaterial";
  58551. export * from "babylonjs/Materials/Node/Blocks/index";
  58552. export * from "babylonjs/Materials/Node/Optimizers/index";
  58553. }
  58554. declare module "babylonjs/Materials/effectRenderer" {
  58555. import { Nullable } from "babylonjs/types";
  58556. import { Texture } from "babylonjs/Materials/Textures/texture";
  58557. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58558. import { Viewport } from "babylonjs/Maths/math.viewport";
  58559. import { Observable } from "babylonjs/Misc/observable";
  58560. import { Effect } from "babylonjs/Materials/effect";
  58561. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58562. import "babylonjs/Shaders/postprocess.vertex";
  58563. /**
  58564. * Effect Render Options
  58565. */
  58566. export interface IEffectRendererOptions {
  58567. /**
  58568. * Defines the vertices positions.
  58569. */
  58570. positions?: number[];
  58571. /**
  58572. * Defines the indices.
  58573. */
  58574. indices?: number[];
  58575. }
  58576. /**
  58577. * Helper class to render one or more effects
  58578. */
  58579. export class EffectRenderer {
  58580. private engine;
  58581. private static _DefaultOptions;
  58582. private _vertexBuffers;
  58583. private _indexBuffer;
  58584. private _ringBufferIndex;
  58585. private _ringScreenBuffer;
  58586. private _fullscreenViewport;
  58587. private _getNextFrameBuffer;
  58588. /**
  58589. * Creates an effect renderer
  58590. * @param engine the engine to use for rendering
  58591. * @param options defines the options of the effect renderer
  58592. */
  58593. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58594. /**
  58595. * Sets the current viewport in normalized coordinates 0-1
  58596. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58597. */
  58598. setViewport(viewport?: Viewport): void;
  58599. /**
  58600. * Binds the embedded attributes buffer to the effect.
  58601. * @param effect Defines the effect to bind the attributes for
  58602. */
  58603. bindBuffers(effect: Effect): void;
  58604. /**
  58605. * Sets the current effect wrapper to use during draw.
  58606. * The effect needs to be ready before calling this api.
  58607. * This also sets the default full screen position attribute.
  58608. * @param effectWrapper Defines the effect to draw with
  58609. */
  58610. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58611. /**
  58612. * Draws a full screen quad.
  58613. */
  58614. draw(): void;
  58615. /**
  58616. * renders one or more effects to a specified texture
  58617. * @param effectWrappers list of effects to renderer
  58618. * @param outputTexture texture to draw to, if null it will render to the screen
  58619. */
  58620. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58621. /**
  58622. * Disposes of the effect renderer
  58623. */
  58624. dispose(): void;
  58625. }
  58626. /**
  58627. * Options to create an EffectWrapper
  58628. */
  58629. interface EffectWrapperCreationOptions {
  58630. /**
  58631. * Engine to use to create the effect
  58632. */
  58633. engine: ThinEngine;
  58634. /**
  58635. * Fragment shader for the effect
  58636. */
  58637. fragmentShader: string;
  58638. /**
  58639. * Vertex shader for the effect
  58640. */
  58641. vertexShader?: string;
  58642. /**
  58643. * Attributes to use in the shader
  58644. */
  58645. attributeNames?: Array<string>;
  58646. /**
  58647. * Uniforms to use in the shader
  58648. */
  58649. uniformNames?: Array<string>;
  58650. /**
  58651. * Texture sampler names to use in the shader
  58652. */
  58653. samplerNames?: Array<string>;
  58654. /**
  58655. * The friendly name of the effect displayed in Spector.
  58656. */
  58657. name?: string;
  58658. }
  58659. /**
  58660. * Wraps an effect to be used for rendering
  58661. */
  58662. export class EffectWrapper {
  58663. /**
  58664. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58665. */
  58666. onApplyObservable: Observable<{}>;
  58667. /**
  58668. * The underlying effect
  58669. */
  58670. effect: Effect;
  58671. /**
  58672. * Creates an effect to be renderer
  58673. * @param creationOptions options to create the effect
  58674. */
  58675. constructor(creationOptions: EffectWrapperCreationOptions);
  58676. /**
  58677. * Disposes of the effect wrapper
  58678. */
  58679. dispose(): void;
  58680. }
  58681. }
  58682. declare module "babylonjs/Materials/index" {
  58683. export * from "babylonjs/Materials/Background/index";
  58684. export * from "babylonjs/Materials/colorCurves";
  58685. export * from "babylonjs/Materials/iEffectFallbacks";
  58686. export * from "babylonjs/Materials/effectFallbacks";
  58687. export * from "babylonjs/Materials/effect";
  58688. export * from "babylonjs/Materials/fresnelParameters";
  58689. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58690. export * from "babylonjs/Materials/material";
  58691. export * from "babylonjs/Materials/materialDefines";
  58692. export * from "babylonjs/Materials/materialHelper";
  58693. export * from "babylonjs/Materials/multiMaterial";
  58694. export * from "babylonjs/Materials/PBR/index";
  58695. export * from "babylonjs/Materials/pushMaterial";
  58696. export * from "babylonjs/Materials/shaderMaterial";
  58697. export * from "babylonjs/Materials/standardMaterial";
  58698. export * from "babylonjs/Materials/Textures/index";
  58699. export * from "babylonjs/Materials/uniformBuffer";
  58700. export * from "babylonjs/Materials/materialFlags";
  58701. export * from "babylonjs/Materials/Node/index";
  58702. export * from "babylonjs/Materials/effectRenderer";
  58703. }
  58704. declare module "babylonjs/Maths/index" {
  58705. export * from "babylonjs/Maths/math.scalar";
  58706. export * from "babylonjs/Maths/math";
  58707. export * from "babylonjs/Maths/sphericalPolynomial";
  58708. }
  58709. declare module "babylonjs/Misc/workerPool" {
  58710. import { IDisposable } from "babylonjs/scene";
  58711. /**
  58712. * Helper class to push actions to a pool of workers.
  58713. */
  58714. export class WorkerPool implements IDisposable {
  58715. private _workerInfos;
  58716. private _pendingActions;
  58717. /**
  58718. * Constructor
  58719. * @param workers Array of workers to use for actions
  58720. */
  58721. constructor(workers: Array<Worker>);
  58722. /**
  58723. * Terminates all workers and clears any pending actions.
  58724. */
  58725. dispose(): void;
  58726. /**
  58727. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58728. * pended until a worker has completed its action.
  58729. * @param action The action to perform. Call onComplete when the action is complete.
  58730. */
  58731. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58732. private _execute;
  58733. }
  58734. }
  58735. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58736. import { IDisposable } from "babylonjs/scene";
  58737. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58738. /**
  58739. * Configuration for Draco compression
  58740. */
  58741. export interface IDracoCompressionConfiguration {
  58742. /**
  58743. * Configuration for the decoder.
  58744. */
  58745. decoder: {
  58746. /**
  58747. * The url to the WebAssembly module.
  58748. */
  58749. wasmUrl?: string;
  58750. /**
  58751. * The url to the WebAssembly binary.
  58752. */
  58753. wasmBinaryUrl?: string;
  58754. /**
  58755. * The url to the fallback JavaScript module.
  58756. */
  58757. fallbackUrl?: string;
  58758. };
  58759. }
  58760. /**
  58761. * Draco compression (https://google.github.io/draco/)
  58762. *
  58763. * This class wraps the Draco module.
  58764. *
  58765. * **Encoder**
  58766. *
  58767. * The encoder is not currently implemented.
  58768. *
  58769. * **Decoder**
  58770. *
  58771. * 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.
  58772. *
  58773. * To update the configuration, use the following code:
  58774. * ```javascript
  58775. * DracoCompression.Configuration = {
  58776. * decoder: {
  58777. * wasmUrl: "<url to the WebAssembly library>",
  58778. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58779. * fallbackUrl: "<url to the fallback JavaScript library>",
  58780. * }
  58781. * };
  58782. * ```
  58783. *
  58784. * 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.
  58785. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58786. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58787. *
  58788. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58789. * ```javascript
  58790. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58791. * ```
  58792. *
  58793. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58794. */
  58795. export class DracoCompression implements IDisposable {
  58796. private _workerPoolPromise?;
  58797. private _decoderModulePromise?;
  58798. /**
  58799. * The configuration. Defaults to the following urls:
  58800. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58801. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58802. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58803. */
  58804. static Configuration: IDracoCompressionConfiguration;
  58805. /**
  58806. * Returns true if the decoder configuration is available.
  58807. */
  58808. static readonly DecoderAvailable: boolean;
  58809. /**
  58810. * Default number of workers to create when creating the draco compression object.
  58811. */
  58812. static DefaultNumWorkers: number;
  58813. private static GetDefaultNumWorkers;
  58814. private static _Default;
  58815. /**
  58816. * Default instance for the draco compression object.
  58817. */
  58818. static readonly Default: DracoCompression;
  58819. /**
  58820. * Constructor
  58821. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58822. */
  58823. constructor(numWorkers?: number);
  58824. /**
  58825. * Stop all async operations and release resources.
  58826. */
  58827. dispose(): void;
  58828. /**
  58829. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58830. * @returns a promise that resolves when ready
  58831. */
  58832. whenReadyAsync(): Promise<void>;
  58833. /**
  58834. * Decode Draco compressed mesh data to vertex data.
  58835. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58836. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58837. * @returns A promise that resolves with the decoded vertex data
  58838. */
  58839. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58840. [kind: string]: number;
  58841. }): Promise<VertexData>;
  58842. }
  58843. }
  58844. declare module "babylonjs/Meshes/Compression/index" {
  58845. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58846. }
  58847. declare module "babylonjs/Meshes/csg" {
  58848. import { Nullable } from "babylonjs/types";
  58849. import { Scene } from "babylonjs/scene";
  58850. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58851. import { Mesh } from "babylonjs/Meshes/mesh";
  58852. import { Material } from "babylonjs/Materials/material";
  58853. /**
  58854. * Class for building Constructive Solid Geometry
  58855. */
  58856. export class CSG {
  58857. private polygons;
  58858. /**
  58859. * The world matrix
  58860. */
  58861. matrix: Matrix;
  58862. /**
  58863. * Stores the position
  58864. */
  58865. position: Vector3;
  58866. /**
  58867. * Stores the rotation
  58868. */
  58869. rotation: Vector3;
  58870. /**
  58871. * Stores the rotation quaternion
  58872. */
  58873. rotationQuaternion: Nullable<Quaternion>;
  58874. /**
  58875. * Stores the scaling vector
  58876. */
  58877. scaling: Vector3;
  58878. /**
  58879. * Convert the Mesh to CSG
  58880. * @param mesh The Mesh to convert to CSG
  58881. * @returns A new CSG from the Mesh
  58882. */
  58883. static FromMesh(mesh: Mesh): CSG;
  58884. /**
  58885. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58886. * @param polygons Polygons used to construct a CSG solid
  58887. */
  58888. private static FromPolygons;
  58889. /**
  58890. * Clones, or makes a deep copy, of the CSG
  58891. * @returns A new CSG
  58892. */
  58893. clone(): CSG;
  58894. /**
  58895. * Unions this CSG with another CSG
  58896. * @param csg The CSG to union against this CSG
  58897. * @returns The unioned CSG
  58898. */
  58899. union(csg: CSG): CSG;
  58900. /**
  58901. * Unions this CSG with another CSG in place
  58902. * @param csg The CSG to union against this CSG
  58903. */
  58904. unionInPlace(csg: CSG): void;
  58905. /**
  58906. * Subtracts this CSG with another CSG
  58907. * @param csg The CSG to subtract against this CSG
  58908. * @returns A new CSG
  58909. */
  58910. subtract(csg: CSG): CSG;
  58911. /**
  58912. * Subtracts this CSG with another CSG in place
  58913. * @param csg The CSG to subtact against this CSG
  58914. */
  58915. subtractInPlace(csg: CSG): void;
  58916. /**
  58917. * Intersect this CSG with another CSG
  58918. * @param csg The CSG to intersect against this CSG
  58919. * @returns A new CSG
  58920. */
  58921. intersect(csg: CSG): CSG;
  58922. /**
  58923. * Intersects this CSG with another CSG in place
  58924. * @param csg The CSG to intersect against this CSG
  58925. */
  58926. intersectInPlace(csg: CSG): void;
  58927. /**
  58928. * Return a new CSG solid with solid and empty space switched. This solid is
  58929. * not modified.
  58930. * @returns A new CSG solid with solid and empty space switched
  58931. */
  58932. inverse(): CSG;
  58933. /**
  58934. * Inverses the CSG in place
  58935. */
  58936. inverseInPlace(): void;
  58937. /**
  58938. * This is used to keep meshes transformations so they can be restored
  58939. * when we build back a Babylon Mesh
  58940. * NB : All CSG operations are performed in world coordinates
  58941. * @param csg The CSG to copy the transform attributes from
  58942. * @returns This CSG
  58943. */
  58944. copyTransformAttributes(csg: CSG): CSG;
  58945. /**
  58946. * Build Raw mesh from CSG
  58947. * Coordinates here are in world space
  58948. * @param name The name of the mesh geometry
  58949. * @param scene The Scene
  58950. * @param keepSubMeshes Specifies if the submeshes should be kept
  58951. * @returns A new Mesh
  58952. */
  58953. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58954. /**
  58955. * Build Mesh from CSG taking material and transforms into account
  58956. * @param name The name of the Mesh
  58957. * @param material The material of the Mesh
  58958. * @param scene The Scene
  58959. * @param keepSubMeshes Specifies if submeshes should be kept
  58960. * @returns The new Mesh
  58961. */
  58962. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58963. }
  58964. }
  58965. declare module "babylonjs/Meshes/trailMesh" {
  58966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58967. import { Mesh } from "babylonjs/Meshes/mesh";
  58968. import { Scene } from "babylonjs/scene";
  58969. /**
  58970. * Class used to create a trail following a mesh
  58971. */
  58972. export class TrailMesh extends Mesh {
  58973. private _generator;
  58974. private _autoStart;
  58975. private _running;
  58976. private _diameter;
  58977. private _length;
  58978. private _sectionPolygonPointsCount;
  58979. private _sectionVectors;
  58980. private _sectionNormalVectors;
  58981. private _beforeRenderObserver;
  58982. /**
  58983. * @constructor
  58984. * @param name The value used by scene.getMeshByName() to do a lookup.
  58985. * @param generator The mesh to generate a trail.
  58986. * @param scene The scene to add this mesh to.
  58987. * @param diameter Diameter of trailing mesh. Default is 1.
  58988. * @param length Length of trailing mesh. Default is 60.
  58989. * @param autoStart Automatically start trailing mesh. Default true.
  58990. */
  58991. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58992. /**
  58993. * "TrailMesh"
  58994. * @returns "TrailMesh"
  58995. */
  58996. getClassName(): string;
  58997. private _createMesh;
  58998. /**
  58999. * Start trailing mesh.
  59000. */
  59001. start(): void;
  59002. /**
  59003. * Stop trailing mesh.
  59004. */
  59005. stop(): void;
  59006. /**
  59007. * Update trailing mesh geometry.
  59008. */
  59009. update(): void;
  59010. /**
  59011. * Returns a new TrailMesh object.
  59012. * @param name is a string, the name given to the new mesh
  59013. * @param newGenerator use new generator object for cloned trail mesh
  59014. * @returns a new mesh
  59015. */
  59016. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59017. /**
  59018. * Serializes this trail mesh
  59019. * @param serializationObject object to write serialization to
  59020. */
  59021. serialize(serializationObject: any): void;
  59022. /**
  59023. * Parses a serialized trail mesh
  59024. * @param parsedMesh the serialized mesh
  59025. * @param scene the scene to create the trail mesh in
  59026. * @returns the created trail mesh
  59027. */
  59028. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59029. }
  59030. }
  59031. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59032. import { Nullable } from "babylonjs/types";
  59033. import { Scene } from "babylonjs/scene";
  59034. import { Vector4 } from "babylonjs/Maths/math.vector";
  59035. import { Color4 } from "babylonjs/Maths/math.color";
  59036. import { Mesh } from "babylonjs/Meshes/mesh";
  59037. /**
  59038. * Class containing static functions to help procedurally build meshes
  59039. */
  59040. export class TiledBoxBuilder {
  59041. /**
  59042. * Creates a box mesh
  59043. * 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)
  59044. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59048. * @param name defines the name of the mesh
  59049. * @param options defines the options used to create the mesh
  59050. * @param scene defines the hosting scene
  59051. * @returns the box mesh
  59052. */
  59053. static CreateTiledBox(name: string, options: {
  59054. pattern?: number;
  59055. width?: number;
  59056. height?: number;
  59057. depth?: number;
  59058. tileSize?: number;
  59059. tileWidth?: number;
  59060. tileHeight?: number;
  59061. alignHorizontal?: number;
  59062. alignVertical?: number;
  59063. faceUV?: Vector4[];
  59064. faceColors?: Color4[];
  59065. sideOrientation?: number;
  59066. updatable?: boolean;
  59067. }, scene?: Nullable<Scene>): Mesh;
  59068. }
  59069. }
  59070. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59071. import { Vector4 } from "babylonjs/Maths/math.vector";
  59072. import { Mesh } from "babylonjs/Meshes/mesh";
  59073. /**
  59074. * Class containing static functions to help procedurally build meshes
  59075. */
  59076. export class TorusKnotBuilder {
  59077. /**
  59078. * Creates a torus knot mesh
  59079. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59080. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59081. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59082. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59086. * @param name defines the name of the mesh
  59087. * @param options defines the options used to create the mesh
  59088. * @param scene defines the hosting scene
  59089. * @returns the torus knot mesh
  59090. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59091. */
  59092. static CreateTorusKnot(name: string, options: {
  59093. radius?: number;
  59094. tube?: number;
  59095. radialSegments?: number;
  59096. tubularSegments?: number;
  59097. p?: number;
  59098. q?: number;
  59099. updatable?: boolean;
  59100. sideOrientation?: number;
  59101. frontUVs?: Vector4;
  59102. backUVs?: Vector4;
  59103. }, scene: any): Mesh;
  59104. }
  59105. }
  59106. declare module "babylonjs/Meshes/polygonMesh" {
  59107. import { Scene } from "babylonjs/scene";
  59108. import { Vector2 } from "babylonjs/Maths/math.vector";
  59109. import { Mesh } from "babylonjs/Meshes/mesh";
  59110. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59111. import { Path2 } from "babylonjs/Maths/math.path";
  59112. /**
  59113. * Polygon
  59114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59115. */
  59116. export class Polygon {
  59117. /**
  59118. * Creates a rectangle
  59119. * @param xmin bottom X coord
  59120. * @param ymin bottom Y coord
  59121. * @param xmax top X coord
  59122. * @param ymax top Y coord
  59123. * @returns points that make the resulting rectation
  59124. */
  59125. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59126. /**
  59127. * Creates a circle
  59128. * @param radius radius of circle
  59129. * @param cx scale in x
  59130. * @param cy scale in y
  59131. * @param numberOfSides number of sides that make up the circle
  59132. * @returns points that make the resulting circle
  59133. */
  59134. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59135. /**
  59136. * Creates a polygon from input string
  59137. * @param input Input polygon data
  59138. * @returns the parsed points
  59139. */
  59140. static Parse(input: string): Vector2[];
  59141. /**
  59142. * Starts building a polygon from x and y coordinates
  59143. * @param x x coordinate
  59144. * @param y y coordinate
  59145. * @returns the started path2
  59146. */
  59147. static StartingAt(x: number, y: number): Path2;
  59148. }
  59149. /**
  59150. * Builds a polygon
  59151. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59152. */
  59153. export class PolygonMeshBuilder {
  59154. private _points;
  59155. private _outlinepoints;
  59156. private _holes;
  59157. private _name;
  59158. private _scene;
  59159. private _epoints;
  59160. private _eholes;
  59161. private _addToepoint;
  59162. /**
  59163. * Babylon reference to the earcut plugin.
  59164. */
  59165. bjsEarcut: any;
  59166. /**
  59167. * Creates a PolygonMeshBuilder
  59168. * @param name name of the builder
  59169. * @param contours Path of the polygon
  59170. * @param scene scene to add to when creating the mesh
  59171. * @param earcutInjection can be used to inject your own earcut reference
  59172. */
  59173. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59174. /**
  59175. * Adds a whole within the polygon
  59176. * @param hole Array of points defining the hole
  59177. * @returns this
  59178. */
  59179. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59180. /**
  59181. * Creates the polygon
  59182. * @param updatable If the mesh should be updatable
  59183. * @param depth The depth of the mesh created
  59184. * @returns the created mesh
  59185. */
  59186. build(updatable?: boolean, depth?: number): Mesh;
  59187. /**
  59188. * Creates the polygon
  59189. * @param depth The depth of the mesh created
  59190. * @returns the created VertexData
  59191. */
  59192. buildVertexData(depth?: number): VertexData;
  59193. /**
  59194. * Adds a side to the polygon
  59195. * @param positions points that make the polygon
  59196. * @param normals normals of the polygon
  59197. * @param uvs uvs of the polygon
  59198. * @param indices indices of the polygon
  59199. * @param bounds bounds of the polygon
  59200. * @param points points of the polygon
  59201. * @param depth depth of the polygon
  59202. * @param flip flip of the polygon
  59203. */
  59204. private addSide;
  59205. }
  59206. }
  59207. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59208. import { Scene } from "babylonjs/scene";
  59209. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59210. import { Color4 } from "babylonjs/Maths/math.color";
  59211. import { Mesh } from "babylonjs/Meshes/mesh";
  59212. import { Nullable } from "babylonjs/types";
  59213. /**
  59214. * Class containing static functions to help procedurally build meshes
  59215. */
  59216. export class PolygonBuilder {
  59217. /**
  59218. * Creates a polygon mesh
  59219. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59220. * * 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
  59221. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59224. * * Remember you can only change the shape positions, not their number when updating a polygon
  59225. * @param name defines the name of the mesh
  59226. * @param options defines the options used to create the mesh
  59227. * @param scene defines the hosting scene
  59228. * @param earcutInjection can be used to inject your own earcut reference
  59229. * @returns the polygon mesh
  59230. */
  59231. static CreatePolygon(name: string, options: {
  59232. shape: Vector3[];
  59233. holes?: Vector3[][];
  59234. depth?: number;
  59235. faceUV?: Vector4[];
  59236. faceColors?: Color4[];
  59237. updatable?: boolean;
  59238. sideOrientation?: number;
  59239. frontUVs?: Vector4;
  59240. backUVs?: Vector4;
  59241. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59242. /**
  59243. * Creates an extruded polygon mesh, with depth in the Y direction.
  59244. * * 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)
  59245. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59246. * @param name defines the name of the mesh
  59247. * @param options defines the options used to create the mesh
  59248. * @param scene defines the hosting scene
  59249. * @param earcutInjection can be used to inject your own earcut reference
  59250. * @returns the polygon mesh
  59251. */
  59252. static ExtrudePolygon(name: string, options: {
  59253. shape: Vector3[];
  59254. holes?: Vector3[][];
  59255. depth?: number;
  59256. faceUV?: Vector4[];
  59257. faceColors?: Color4[];
  59258. updatable?: boolean;
  59259. sideOrientation?: number;
  59260. frontUVs?: Vector4;
  59261. backUVs?: Vector4;
  59262. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59263. }
  59264. }
  59265. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59266. import { Scene } from "babylonjs/scene";
  59267. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59268. import { Mesh } from "babylonjs/Meshes/mesh";
  59269. import { Nullable } from "babylonjs/types";
  59270. /**
  59271. * Class containing static functions to help procedurally build meshes
  59272. */
  59273. export class LatheBuilder {
  59274. /**
  59275. * Creates lathe mesh.
  59276. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59277. * * 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
  59278. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59279. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59280. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59281. * * 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
  59282. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59283. * * 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
  59284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59288. * @param name defines the name of the mesh
  59289. * @param options defines the options used to create the mesh
  59290. * @param scene defines the hosting scene
  59291. * @returns the lathe mesh
  59292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59293. */
  59294. static CreateLathe(name: string, options: {
  59295. shape: Vector3[];
  59296. radius?: number;
  59297. tessellation?: number;
  59298. clip?: number;
  59299. arc?: number;
  59300. closed?: boolean;
  59301. updatable?: boolean;
  59302. sideOrientation?: number;
  59303. frontUVs?: Vector4;
  59304. backUVs?: Vector4;
  59305. cap?: number;
  59306. invertUV?: boolean;
  59307. }, scene?: Nullable<Scene>): Mesh;
  59308. }
  59309. }
  59310. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59311. import { Nullable } from "babylonjs/types";
  59312. import { Scene } from "babylonjs/scene";
  59313. import { Vector4 } from "babylonjs/Maths/math.vector";
  59314. import { Mesh } from "babylonjs/Meshes/mesh";
  59315. /**
  59316. * Class containing static functions to help procedurally build meshes
  59317. */
  59318. export class TiledPlaneBuilder {
  59319. /**
  59320. * Creates a tiled plane mesh
  59321. * * The parameter `pattern` will, depending on value, do nothing or
  59322. * * * flip (reflect about central vertical) alternate tiles across and up
  59323. * * * flip every tile on alternate rows
  59324. * * * rotate (180 degs) alternate tiles across and up
  59325. * * * rotate every tile on alternate rows
  59326. * * * flip and rotate alternate tiles across and up
  59327. * * * flip and rotate every tile on alternate rows
  59328. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59329. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59332. * * 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)
  59333. * * 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)
  59334. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59335. * @param name defines the name of the mesh
  59336. * @param options defines the options used to create the mesh
  59337. * @param scene defines the hosting scene
  59338. * @returns the box mesh
  59339. */
  59340. static CreateTiledPlane(name: string, options: {
  59341. pattern?: number;
  59342. tileSize?: number;
  59343. tileWidth?: number;
  59344. tileHeight?: number;
  59345. size?: number;
  59346. width?: number;
  59347. height?: number;
  59348. alignHorizontal?: number;
  59349. alignVertical?: number;
  59350. sideOrientation?: number;
  59351. frontUVs?: Vector4;
  59352. backUVs?: Vector4;
  59353. updatable?: boolean;
  59354. }, scene?: Nullable<Scene>): Mesh;
  59355. }
  59356. }
  59357. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59358. import { Nullable } from "babylonjs/types";
  59359. import { Scene } from "babylonjs/scene";
  59360. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59361. import { Mesh } from "babylonjs/Meshes/mesh";
  59362. /**
  59363. * Class containing static functions to help procedurally build meshes
  59364. */
  59365. export class TubeBuilder {
  59366. /**
  59367. * Creates a tube mesh.
  59368. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59369. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59370. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59371. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59372. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59373. * * 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)
  59374. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59375. * * 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
  59376. * * 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
  59377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59379. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59381. * @param name defines the name of the mesh
  59382. * @param options defines the options used to create the mesh
  59383. * @param scene defines the hosting scene
  59384. * @returns the tube mesh
  59385. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59386. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59387. */
  59388. static CreateTube(name: string, options: {
  59389. path: Vector3[];
  59390. radius?: number;
  59391. tessellation?: number;
  59392. radiusFunction?: {
  59393. (i: number, distance: number): number;
  59394. };
  59395. cap?: number;
  59396. arc?: number;
  59397. updatable?: boolean;
  59398. sideOrientation?: number;
  59399. frontUVs?: Vector4;
  59400. backUVs?: Vector4;
  59401. instance?: Mesh;
  59402. invertUV?: boolean;
  59403. }, scene?: Nullable<Scene>): Mesh;
  59404. }
  59405. }
  59406. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59407. import { Scene } from "babylonjs/scene";
  59408. import { Vector4 } from "babylonjs/Maths/math.vector";
  59409. import { Mesh } from "babylonjs/Meshes/mesh";
  59410. import { Nullable } from "babylonjs/types";
  59411. /**
  59412. * Class containing static functions to help procedurally build meshes
  59413. */
  59414. export class IcoSphereBuilder {
  59415. /**
  59416. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59417. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59418. * * 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`)
  59419. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59420. * * 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
  59421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59424. * @param name defines the name of the mesh
  59425. * @param options defines the options used to create the mesh
  59426. * @param scene defines the hosting scene
  59427. * @returns the icosahedron mesh
  59428. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59429. */
  59430. static CreateIcoSphere(name: string, options: {
  59431. radius?: number;
  59432. radiusX?: number;
  59433. radiusY?: number;
  59434. radiusZ?: number;
  59435. flat?: boolean;
  59436. subdivisions?: number;
  59437. sideOrientation?: number;
  59438. frontUVs?: Vector4;
  59439. backUVs?: Vector4;
  59440. updatable?: boolean;
  59441. }, scene?: Nullable<Scene>): Mesh;
  59442. }
  59443. }
  59444. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59445. import { Vector3 } from "babylonjs/Maths/math.vector";
  59446. import { Mesh } from "babylonjs/Meshes/mesh";
  59447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59448. /**
  59449. * Class containing static functions to help procedurally build meshes
  59450. */
  59451. export class DecalBuilder {
  59452. /**
  59453. * Creates a decal mesh.
  59454. * 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
  59455. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59456. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59457. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59458. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59459. * @param name defines the name of the mesh
  59460. * @param sourceMesh defines the mesh where the decal must be applied
  59461. * @param options defines the options used to create the mesh
  59462. * @param scene defines the hosting scene
  59463. * @returns the decal mesh
  59464. * @see https://doc.babylonjs.com/how_to/decals
  59465. */
  59466. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59467. position?: Vector3;
  59468. normal?: Vector3;
  59469. size?: Vector3;
  59470. angle?: number;
  59471. }): Mesh;
  59472. }
  59473. }
  59474. declare module "babylonjs/Meshes/meshBuilder" {
  59475. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59476. import { Nullable } from "babylonjs/types";
  59477. import { Scene } from "babylonjs/scene";
  59478. import { Mesh } from "babylonjs/Meshes/mesh";
  59479. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59480. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59482. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59483. import { Plane } from "babylonjs/Maths/math.plane";
  59484. /**
  59485. * Class containing static functions to help procedurally build meshes
  59486. */
  59487. export class MeshBuilder {
  59488. /**
  59489. * Creates a box mesh
  59490. * * The parameter `size` sets the size (float) of each box side (default 1)
  59491. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59492. * * 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)
  59493. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59497. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59498. * @param name defines the name of the mesh
  59499. * @param options defines the options used to create the mesh
  59500. * @param scene defines the hosting scene
  59501. * @returns the box mesh
  59502. */
  59503. static CreateBox(name: string, options: {
  59504. size?: number;
  59505. width?: number;
  59506. height?: number;
  59507. depth?: number;
  59508. faceUV?: Vector4[];
  59509. faceColors?: Color4[];
  59510. sideOrientation?: number;
  59511. frontUVs?: Vector4;
  59512. backUVs?: Vector4;
  59513. updatable?: boolean;
  59514. }, scene?: Nullable<Scene>): Mesh;
  59515. /**
  59516. * Creates a tiled box mesh
  59517. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59519. * @param name defines the name of the mesh
  59520. * @param options defines the options used to create the mesh
  59521. * @param scene defines the hosting scene
  59522. * @returns the tiled box mesh
  59523. */
  59524. static CreateTiledBox(name: string, options: {
  59525. pattern?: number;
  59526. size?: number;
  59527. width?: number;
  59528. height?: number;
  59529. depth: number;
  59530. tileSize?: number;
  59531. tileWidth?: number;
  59532. tileHeight?: number;
  59533. faceUV?: Vector4[];
  59534. faceColors?: Color4[];
  59535. alignHorizontal?: number;
  59536. alignVertical?: number;
  59537. sideOrientation?: number;
  59538. updatable?: boolean;
  59539. }, scene?: Nullable<Scene>): Mesh;
  59540. /**
  59541. * Creates a sphere mesh
  59542. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59543. * * 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`)
  59544. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59545. * * 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
  59546. * * 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)
  59547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59550. * @param name defines the name of the mesh
  59551. * @param options defines the options used to create the mesh
  59552. * @param scene defines the hosting scene
  59553. * @returns the sphere mesh
  59554. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59555. */
  59556. static CreateSphere(name: string, options: {
  59557. segments?: number;
  59558. diameter?: number;
  59559. diameterX?: number;
  59560. diameterY?: number;
  59561. diameterZ?: number;
  59562. arc?: number;
  59563. slice?: number;
  59564. sideOrientation?: number;
  59565. frontUVs?: Vector4;
  59566. backUVs?: Vector4;
  59567. updatable?: boolean;
  59568. }, scene?: Nullable<Scene>): Mesh;
  59569. /**
  59570. * Creates a plane polygonal mesh. By default, this is a disc
  59571. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59572. * * 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
  59573. * * 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
  59574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59577. * @param name defines the name of the mesh
  59578. * @param options defines the options used to create the mesh
  59579. * @param scene defines the hosting scene
  59580. * @returns the plane polygonal mesh
  59581. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59582. */
  59583. static CreateDisc(name: string, options: {
  59584. radius?: number;
  59585. tessellation?: number;
  59586. arc?: number;
  59587. updatable?: boolean;
  59588. sideOrientation?: number;
  59589. frontUVs?: Vector4;
  59590. backUVs?: Vector4;
  59591. }, scene?: Nullable<Scene>): Mesh;
  59592. /**
  59593. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59594. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59595. * * 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`)
  59596. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59597. * * 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
  59598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59601. * @param name defines the name of the mesh
  59602. * @param options defines the options used to create the mesh
  59603. * @param scene defines the hosting scene
  59604. * @returns the icosahedron mesh
  59605. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59606. */
  59607. static CreateIcoSphere(name: string, options: {
  59608. radius?: number;
  59609. radiusX?: number;
  59610. radiusY?: number;
  59611. radiusZ?: number;
  59612. flat?: boolean;
  59613. subdivisions?: number;
  59614. sideOrientation?: number;
  59615. frontUVs?: Vector4;
  59616. backUVs?: Vector4;
  59617. updatable?: boolean;
  59618. }, scene?: Nullable<Scene>): Mesh;
  59619. /**
  59620. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59621. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59622. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59623. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59624. * * 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
  59625. * * 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
  59626. * * 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
  59627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59630. * * 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
  59631. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59632. * * 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
  59633. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59635. * @param name defines the name of the mesh
  59636. * @param options defines the options used to create the mesh
  59637. * @param scene defines the hosting scene
  59638. * @returns the ribbon mesh
  59639. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59641. */
  59642. static CreateRibbon(name: string, options: {
  59643. pathArray: Vector3[][];
  59644. closeArray?: boolean;
  59645. closePath?: boolean;
  59646. offset?: number;
  59647. updatable?: boolean;
  59648. sideOrientation?: number;
  59649. frontUVs?: Vector4;
  59650. backUVs?: Vector4;
  59651. instance?: Mesh;
  59652. invertUV?: boolean;
  59653. uvs?: Vector2[];
  59654. colors?: Color4[];
  59655. }, scene?: Nullable<Scene>): Mesh;
  59656. /**
  59657. * Creates a cylinder or a cone mesh
  59658. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59659. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59660. * * 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.
  59661. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59662. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59663. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59664. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59665. * * 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).
  59666. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59667. * * 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).
  59668. * * 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
  59669. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59670. * * 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
  59671. * * 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.
  59672. * * If `enclose` is false, a ring surface is one element.
  59673. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59674. * * 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
  59675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59678. * @param name defines the name of the mesh
  59679. * @param options defines the options used to create the mesh
  59680. * @param scene defines the hosting scene
  59681. * @returns the cylinder mesh
  59682. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59683. */
  59684. static CreateCylinder(name: string, options: {
  59685. height?: number;
  59686. diameterTop?: number;
  59687. diameterBottom?: number;
  59688. diameter?: number;
  59689. tessellation?: number;
  59690. subdivisions?: number;
  59691. arc?: number;
  59692. faceColors?: Color4[];
  59693. faceUV?: Vector4[];
  59694. updatable?: boolean;
  59695. hasRings?: boolean;
  59696. enclose?: boolean;
  59697. cap?: number;
  59698. sideOrientation?: number;
  59699. frontUVs?: Vector4;
  59700. backUVs?: Vector4;
  59701. }, scene?: Nullable<Scene>): Mesh;
  59702. /**
  59703. * Creates a torus mesh
  59704. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59705. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59706. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59710. * @param name defines the name of the mesh
  59711. * @param options defines the options used to create the mesh
  59712. * @param scene defines the hosting scene
  59713. * @returns the torus mesh
  59714. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59715. */
  59716. static CreateTorus(name: string, options: {
  59717. diameter?: number;
  59718. thickness?: number;
  59719. tessellation?: number;
  59720. updatable?: boolean;
  59721. sideOrientation?: number;
  59722. frontUVs?: Vector4;
  59723. backUVs?: Vector4;
  59724. }, scene?: Nullable<Scene>): Mesh;
  59725. /**
  59726. * Creates a torus knot mesh
  59727. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59728. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59729. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59730. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59734. * @param name defines the name of the mesh
  59735. * @param options defines the options used to create the mesh
  59736. * @param scene defines the hosting scene
  59737. * @returns the torus knot mesh
  59738. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59739. */
  59740. static CreateTorusKnot(name: string, options: {
  59741. radius?: number;
  59742. tube?: number;
  59743. radialSegments?: number;
  59744. tubularSegments?: number;
  59745. p?: number;
  59746. q?: number;
  59747. updatable?: boolean;
  59748. sideOrientation?: number;
  59749. frontUVs?: Vector4;
  59750. backUVs?: Vector4;
  59751. }, scene?: Nullable<Scene>): Mesh;
  59752. /**
  59753. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59754. * * 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
  59755. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59756. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59757. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59758. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59759. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59760. * * 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
  59761. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59764. * @param name defines the name of the new line system
  59765. * @param options defines the options used to create the line system
  59766. * @param scene defines the hosting scene
  59767. * @returns a new line system mesh
  59768. */
  59769. static CreateLineSystem(name: string, options: {
  59770. lines: Vector3[][];
  59771. updatable?: boolean;
  59772. instance?: Nullable<LinesMesh>;
  59773. colors?: Nullable<Color4[][]>;
  59774. useVertexAlpha?: boolean;
  59775. }, scene: Nullable<Scene>): LinesMesh;
  59776. /**
  59777. * Creates a line mesh
  59778. * 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
  59779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59780. * * The parameter `points` is an array successive Vector3
  59781. * * 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
  59782. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59784. * * When updating an instance, remember that only point positions can change, not the number of points
  59785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59787. * @param name defines the name of the new line system
  59788. * @param options defines the options used to create the line system
  59789. * @param scene defines the hosting scene
  59790. * @returns a new line mesh
  59791. */
  59792. static CreateLines(name: string, options: {
  59793. points: Vector3[];
  59794. updatable?: boolean;
  59795. instance?: Nullable<LinesMesh>;
  59796. colors?: Color4[];
  59797. useVertexAlpha?: boolean;
  59798. }, scene?: Nullable<Scene>): LinesMesh;
  59799. /**
  59800. * Creates a dashed line mesh
  59801. * * 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
  59802. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59803. * * The parameter `points` is an array successive Vector3
  59804. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59805. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59806. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59807. * * 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
  59808. * * When updating an instance, remember that only point positions can change, not the number of points
  59809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59810. * @param name defines the name of the mesh
  59811. * @param options defines the options used to create the mesh
  59812. * @param scene defines the hosting scene
  59813. * @returns the dashed line mesh
  59814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59815. */
  59816. static CreateDashedLines(name: string, options: {
  59817. points: Vector3[];
  59818. dashSize?: number;
  59819. gapSize?: number;
  59820. dashNb?: number;
  59821. updatable?: boolean;
  59822. instance?: LinesMesh;
  59823. }, scene?: Nullable<Scene>): LinesMesh;
  59824. /**
  59825. * 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.
  59826. * * 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.
  59827. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59828. * * 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.
  59829. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59830. * * 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
  59831. * * 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
  59832. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59835. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59837. * @param name defines the name of the mesh
  59838. * @param options defines the options used to create the mesh
  59839. * @param scene defines the hosting scene
  59840. * @returns the extruded shape mesh
  59841. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59843. */
  59844. static ExtrudeShape(name: string, options: {
  59845. shape: Vector3[];
  59846. path: Vector3[];
  59847. scale?: number;
  59848. rotation?: number;
  59849. cap?: number;
  59850. updatable?: boolean;
  59851. sideOrientation?: number;
  59852. frontUVs?: Vector4;
  59853. backUVs?: Vector4;
  59854. instance?: Mesh;
  59855. invertUV?: boolean;
  59856. }, scene?: Nullable<Scene>): Mesh;
  59857. /**
  59858. * Creates an custom extruded shape mesh.
  59859. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59860. * * 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.
  59861. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59862. * * 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
  59863. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59864. * * 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
  59865. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59866. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59867. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59868. * * 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
  59869. * * 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
  59870. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59873. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59875. * @param name defines the name of the mesh
  59876. * @param options defines the options used to create the mesh
  59877. * @param scene defines the hosting scene
  59878. * @returns the custom extruded shape mesh
  59879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59882. */
  59883. static ExtrudeShapeCustom(name: string, options: {
  59884. shape: Vector3[];
  59885. path: Vector3[];
  59886. scaleFunction?: any;
  59887. rotationFunction?: any;
  59888. ribbonCloseArray?: boolean;
  59889. ribbonClosePath?: boolean;
  59890. cap?: number;
  59891. updatable?: boolean;
  59892. sideOrientation?: number;
  59893. frontUVs?: Vector4;
  59894. backUVs?: Vector4;
  59895. instance?: Mesh;
  59896. invertUV?: boolean;
  59897. }, scene?: Nullable<Scene>): Mesh;
  59898. /**
  59899. * Creates lathe mesh.
  59900. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59901. * * 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
  59902. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59903. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59904. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59905. * * 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
  59906. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59907. * * 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
  59908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59912. * @param name defines the name of the mesh
  59913. * @param options defines the options used to create the mesh
  59914. * @param scene defines the hosting scene
  59915. * @returns the lathe mesh
  59916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59917. */
  59918. static CreateLathe(name: string, options: {
  59919. shape: Vector3[];
  59920. radius?: number;
  59921. tessellation?: number;
  59922. clip?: number;
  59923. arc?: number;
  59924. closed?: boolean;
  59925. updatable?: boolean;
  59926. sideOrientation?: number;
  59927. frontUVs?: Vector4;
  59928. backUVs?: Vector4;
  59929. cap?: number;
  59930. invertUV?: boolean;
  59931. }, scene?: Nullable<Scene>): Mesh;
  59932. /**
  59933. * Creates a tiled plane mesh
  59934. * * You can set a limited pattern arrangement with the tiles
  59935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59938. * @param name defines the name of the mesh
  59939. * @param options defines the options used to create the mesh
  59940. * @param scene defines the hosting scene
  59941. * @returns the plane mesh
  59942. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59943. */
  59944. static CreateTiledPlane(name: string, options: {
  59945. pattern?: number;
  59946. tileSize?: number;
  59947. tileWidth?: number;
  59948. tileHeight?: number;
  59949. size?: number;
  59950. width?: number;
  59951. height?: number;
  59952. alignHorizontal?: number;
  59953. alignVertical?: number;
  59954. sideOrientation?: number;
  59955. frontUVs?: Vector4;
  59956. backUVs?: Vector4;
  59957. updatable?: boolean;
  59958. }, scene?: Nullable<Scene>): Mesh;
  59959. /**
  59960. * Creates a plane mesh
  59961. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59962. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59963. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59967. * @param name defines the name of the mesh
  59968. * @param options defines the options used to create the mesh
  59969. * @param scene defines the hosting scene
  59970. * @returns the plane mesh
  59971. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59972. */
  59973. static CreatePlane(name: string, options: {
  59974. size?: number;
  59975. width?: number;
  59976. height?: number;
  59977. sideOrientation?: number;
  59978. frontUVs?: Vector4;
  59979. backUVs?: Vector4;
  59980. updatable?: boolean;
  59981. sourcePlane?: Plane;
  59982. }, scene?: Nullable<Scene>): Mesh;
  59983. /**
  59984. * Creates a ground mesh
  59985. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59986. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59988. * @param name defines the name of the mesh
  59989. * @param options defines the options used to create the mesh
  59990. * @param scene defines the hosting scene
  59991. * @returns the ground mesh
  59992. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59993. */
  59994. static CreateGround(name: string, options: {
  59995. width?: number;
  59996. height?: number;
  59997. subdivisions?: number;
  59998. subdivisionsX?: number;
  59999. subdivisionsY?: number;
  60000. updatable?: boolean;
  60001. }, scene?: Nullable<Scene>): Mesh;
  60002. /**
  60003. * Creates a tiled ground mesh
  60004. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60005. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60006. * * 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
  60007. * * 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
  60008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60009. * @param name defines the name of the mesh
  60010. * @param options defines the options used to create the mesh
  60011. * @param scene defines the hosting scene
  60012. * @returns the tiled ground mesh
  60013. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60014. */
  60015. static CreateTiledGround(name: string, options: {
  60016. xmin: number;
  60017. zmin: number;
  60018. xmax: number;
  60019. zmax: number;
  60020. subdivisions?: {
  60021. w: number;
  60022. h: number;
  60023. };
  60024. precision?: {
  60025. w: number;
  60026. h: number;
  60027. };
  60028. updatable?: boolean;
  60029. }, scene?: Nullable<Scene>): Mesh;
  60030. /**
  60031. * Creates a ground mesh from a height map
  60032. * * The parameter `url` sets the URL of the height map image resource.
  60033. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60034. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60035. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60036. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60037. * * 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.
  60038. * * 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).
  60039. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60041. * @param name defines the name of the mesh
  60042. * @param url defines the url to the height map
  60043. * @param options defines the options used to create the mesh
  60044. * @param scene defines the hosting scene
  60045. * @returns the ground mesh
  60046. * @see https://doc.babylonjs.com/babylon101/height_map
  60047. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60048. */
  60049. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60050. width?: number;
  60051. height?: number;
  60052. subdivisions?: number;
  60053. minHeight?: number;
  60054. maxHeight?: number;
  60055. colorFilter?: Color3;
  60056. alphaFilter?: number;
  60057. updatable?: boolean;
  60058. onReady?: (mesh: GroundMesh) => void;
  60059. }, scene?: Nullable<Scene>): GroundMesh;
  60060. /**
  60061. * Creates a polygon mesh
  60062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60063. * * 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
  60064. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60067. * * Remember you can only change the shape positions, not their number when updating a polygon
  60068. * @param name defines the name of the mesh
  60069. * @param options defines the options used to create the mesh
  60070. * @param scene defines the hosting scene
  60071. * @param earcutInjection can be used to inject your own earcut reference
  60072. * @returns the polygon mesh
  60073. */
  60074. static CreatePolygon(name: string, options: {
  60075. shape: Vector3[];
  60076. holes?: Vector3[][];
  60077. depth?: number;
  60078. faceUV?: Vector4[];
  60079. faceColors?: Color4[];
  60080. updatable?: boolean;
  60081. sideOrientation?: number;
  60082. frontUVs?: Vector4;
  60083. backUVs?: Vector4;
  60084. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60085. /**
  60086. * Creates an extruded polygon mesh, with depth in the Y direction.
  60087. * * 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)
  60088. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60089. * @param name defines the name of the mesh
  60090. * @param options defines the options used to create the mesh
  60091. * @param scene defines the hosting scene
  60092. * @param earcutInjection can be used to inject your own earcut reference
  60093. * @returns the polygon mesh
  60094. */
  60095. static ExtrudePolygon(name: string, options: {
  60096. shape: Vector3[];
  60097. holes?: Vector3[][];
  60098. depth?: number;
  60099. faceUV?: Vector4[];
  60100. faceColors?: Color4[];
  60101. updatable?: boolean;
  60102. sideOrientation?: number;
  60103. frontUVs?: Vector4;
  60104. backUVs?: Vector4;
  60105. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60106. /**
  60107. * Creates a tube mesh.
  60108. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60109. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60110. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60111. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60112. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60113. * * 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)
  60114. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60115. * * 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
  60116. * * 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
  60117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60119. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60121. * @param name defines the name of the mesh
  60122. * @param options defines the options used to create the mesh
  60123. * @param scene defines the hosting scene
  60124. * @returns the tube mesh
  60125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60126. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60127. */
  60128. static CreateTube(name: string, options: {
  60129. path: Vector3[];
  60130. radius?: number;
  60131. tessellation?: number;
  60132. radiusFunction?: {
  60133. (i: number, distance: number): number;
  60134. };
  60135. cap?: number;
  60136. arc?: number;
  60137. updatable?: boolean;
  60138. sideOrientation?: number;
  60139. frontUVs?: Vector4;
  60140. backUVs?: Vector4;
  60141. instance?: Mesh;
  60142. invertUV?: boolean;
  60143. }, scene?: Nullable<Scene>): Mesh;
  60144. /**
  60145. * Creates a polyhedron mesh
  60146. * * 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
  60147. * * The parameter `size` (positive float, default 1) sets the polygon size
  60148. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60149. * * 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`
  60150. * * 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
  60151. * * 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)`)
  60152. * * 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
  60153. * * 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
  60154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60157. * @param name defines the name of the mesh
  60158. * @param options defines the options used to create the mesh
  60159. * @param scene defines the hosting scene
  60160. * @returns the polyhedron mesh
  60161. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60162. */
  60163. static CreatePolyhedron(name: string, options: {
  60164. type?: number;
  60165. size?: number;
  60166. sizeX?: number;
  60167. sizeY?: number;
  60168. sizeZ?: number;
  60169. custom?: any;
  60170. faceUV?: Vector4[];
  60171. faceColors?: Color4[];
  60172. flat?: boolean;
  60173. updatable?: boolean;
  60174. sideOrientation?: number;
  60175. frontUVs?: Vector4;
  60176. backUVs?: Vector4;
  60177. }, scene?: Nullable<Scene>): Mesh;
  60178. /**
  60179. * Creates a decal mesh.
  60180. * 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
  60181. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60182. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60183. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60184. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60185. * @param name defines the name of the mesh
  60186. * @param sourceMesh defines the mesh where the decal must be applied
  60187. * @param options defines the options used to create the mesh
  60188. * @param scene defines the hosting scene
  60189. * @returns the decal mesh
  60190. * @see https://doc.babylonjs.com/how_to/decals
  60191. */
  60192. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60193. position?: Vector3;
  60194. normal?: Vector3;
  60195. size?: Vector3;
  60196. angle?: number;
  60197. }): Mesh;
  60198. }
  60199. }
  60200. declare module "babylonjs/Meshes/meshSimplification" {
  60201. import { Mesh } from "babylonjs/Meshes/mesh";
  60202. /**
  60203. * A simplifier interface for future simplification implementations
  60204. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60205. */
  60206. export interface ISimplifier {
  60207. /**
  60208. * Simplification of a given mesh according to the given settings.
  60209. * Since this requires computation, it is assumed that the function runs async.
  60210. * @param settings The settings of the simplification, including quality and distance
  60211. * @param successCallback A callback that will be called after the mesh was simplified.
  60212. * @param errorCallback in case of an error, this callback will be called. optional.
  60213. */
  60214. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60215. }
  60216. /**
  60217. * Expected simplification settings.
  60218. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60219. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60220. */
  60221. export interface ISimplificationSettings {
  60222. /**
  60223. * Gets or sets the expected quality
  60224. */
  60225. quality: number;
  60226. /**
  60227. * Gets or sets the distance when this optimized version should be used
  60228. */
  60229. distance: number;
  60230. /**
  60231. * Gets an already optimized mesh
  60232. */
  60233. optimizeMesh?: boolean;
  60234. }
  60235. /**
  60236. * Class used to specify simplification options
  60237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60238. */
  60239. export class SimplificationSettings implements ISimplificationSettings {
  60240. /** expected quality */
  60241. quality: number;
  60242. /** distance when this optimized version should be used */
  60243. distance: number;
  60244. /** already optimized mesh */
  60245. optimizeMesh?: boolean | undefined;
  60246. /**
  60247. * Creates a SimplificationSettings
  60248. * @param quality expected quality
  60249. * @param distance distance when this optimized version should be used
  60250. * @param optimizeMesh already optimized mesh
  60251. */
  60252. constructor(
  60253. /** expected quality */
  60254. quality: number,
  60255. /** distance when this optimized version should be used */
  60256. distance: number,
  60257. /** already optimized mesh */
  60258. optimizeMesh?: boolean | undefined);
  60259. }
  60260. /**
  60261. * Interface used to define a simplification task
  60262. */
  60263. export interface ISimplificationTask {
  60264. /**
  60265. * Array of settings
  60266. */
  60267. settings: Array<ISimplificationSettings>;
  60268. /**
  60269. * Simplification type
  60270. */
  60271. simplificationType: SimplificationType;
  60272. /**
  60273. * Mesh to simplify
  60274. */
  60275. mesh: Mesh;
  60276. /**
  60277. * Callback called on success
  60278. */
  60279. successCallback?: () => void;
  60280. /**
  60281. * Defines if parallel processing can be used
  60282. */
  60283. parallelProcessing: boolean;
  60284. }
  60285. /**
  60286. * Queue used to order the simplification tasks
  60287. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60288. */
  60289. export class SimplificationQueue {
  60290. private _simplificationArray;
  60291. /**
  60292. * Gets a boolean indicating that the process is still running
  60293. */
  60294. running: boolean;
  60295. /**
  60296. * Creates a new queue
  60297. */
  60298. constructor();
  60299. /**
  60300. * Adds a new simplification task
  60301. * @param task defines a task to add
  60302. */
  60303. addTask(task: ISimplificationTask): void;
  60304. /**
  60305. * Execute next task
  60306. */
  60307. executeNext(): void;
  60308. /**
  60309. * Execute a simplification task
  60310. * @param task defines the task to run
  60311. */
  60312. runSimplification(task: ISimplificationTask): void;
  60313. private getSimplifier;
  60314. }
  60315. /**
  60316. * The implemented types of simplification
  60317. * At the moment only Quadratic Error Decimation is implemented
  60318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60319. */
  60320. export enum SimplificationType {
  60321. /** Quadratic error decimation */
  60322. QUADRATIC = 0
  60323. }
  60324. }
  60325. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60326. import { Scene } from "babylonjs/scene";
  60327. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60328. import { ISceneComponent } from "babylonjs/sceneComponent";
  60329. module "babylonjs/scene" {
  60330. interface Scene {
  60331. /** @hidden (Backing field) */
  60332. _simplificationQueue: SimplificationQueue;
  60333. /**
  60334. * Gets or sets the simplification queue attached to the scene
  60335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60336. */
  60337. simplificationQueue: SimplificationQueue;
  60338. }
  60339. }
  60340. module "babylonjs/Meshes/mesh" {
  60341. interface Mesh {
  60342. /**
  60343. * Simplify the mesh according to the given array of settings.
  60344. * Function will return immediately and will simplify async
  60345. * @param settings a collection of simplification settings
  60346. * @param parallelProcessing should all levels calculate parallel or one after the other
  60347. * @param simplificationType the type of simplification to run
  60348. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60349. * @returns the current mesh
  60350. */
  60351. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60352. }
  60353. }
  60354. /**
  60355. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60356. * created in a scene
  60357. */
  60358. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60359. /**
  60360. * The component name helpfull to identify the component in the list of scene components.
  60361. */
  60362. readonly name: string;
  60363. /**
  60364. * The scene the component belongs to.
  60365. */
  60366. scene: Scene;
  60367. /**
  60368. * Creates a new instance of the component for the given scene
  60369. * @param scene Defines the scene to register the component in
  60370. */
  60371. constructor(scene: Scene);
  60372. /**
  60373. * Registers the component in a given scene
  60374. */
  60375. register(): void;
  60376. /**
  60377. * Rebuilds the elements related to this component in case of
  60378. * context lost for instance.
  60379. */
  60380. rebuild(): void;
  60381. /**
  60382. * Disposes the component and the associated ressources
  60383. */
  60384. dispose(): void;
  60385. private _beforeCameraUpdate;
  60386. }
  60387. }
  60388. declare module "babylonjs/Meshes/Builders/index" {
  60389. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60390. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60391. export * from "babylonjs/Meshes/Builders/discBuilder";
  60392. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60393. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60394. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60395. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60396. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60397. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60398. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60399. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60400. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60401. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60402. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60403. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60404. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60405. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60406. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60407. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60408. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60409. }
  60410. declare module "babylonjs/Meshes/index" {
  60411. export * from "babylonjs/Meshes/abstractMesh";
  60412. export * from "babylonjs/Meshes/buffer";
  60413. export * from "babylonjs/Meshes/Compression/index";
  60414. export * from "babylonjs/Meshes/csg";
  60415. export * from "babylonjs/Meshes/geometry";
  60416. export * from "babylonjs/Meshes/groundMesh";
  60417. export * from "babylonjs/Meshes/trailMesh";
  60418. export * from "babylonjs/Meshes/instancedMesh";
  60419. export * from "babylonjs/Meshes/linesMesh";
  60420. export * from "babylonjs/Meshes/mesh";
  60421. export * from "babylonjs/Meshes/mesh.vertexData";
  60422. export * from "babylonjs/Meshes/meshBuilder";
  60423. export * from "babylonjs/Meshes/meshSimplification";
  60424. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60425. export * from "babylonjs/Meshes/polygonMesh";
  60426. export * from "babylonjs/Meshes/subMesh";
  60427. export * from "babylonjs/Meshes/meshLODLevel";
  60428. export * from "babylonjs/Meshes/transformNode";
  60429. export * from "babylonjs/Meshes/Builders/index";
  60430. export * from "babylonjs/Meshes/dataBuffer";
  60431. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60432. }
  60433. declare module "babylonjs/Morph/index" {
  60434. export * from "babylonjs/Morph/morphTarget";
  60435. export * from "babylonjs/Morph/morphTargetManager";
  60436. }
  60437. declare module "babylonjs/Navigation/INavigationEngine" {
  60438. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60439. import { Vector3 } from "babylonjs/Maths/math";
  60440. import { Mesh } from "babylonjs/Meshes/mesh";
  60441. import { Scene } from "babylonjs/scene";
  60442. /**
  60443. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60444. */
  60445. export interface INavigationEnginePlugin {
  60446. /**
  60447. * plugin name
  60448. */
  60449. name: string;
  60450. /**
  60451. * Creates a navigation mesh
  60452. * @param meshes array of all the geometry used to compute the navigatio mesh
  60453. * @param parameters bunch of parameters used to filter geometry
  60454. */
  60455. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60456. /**
  60457. * Create a navigation mesh debug mesh
  60458. * @param scene is where the mesh will be added
  60459. * @returns debug display mesh
  60460. */
  60461. createDebugNavMesh(scene: Scene): Mesh;
  60462. /**
  60463. * Get a navigation mesh constrained position, closest to the parameter position
  60464. * @param position world position
  60465. * @returns the closest point to position constrained by the navigation mesh
  60466. */
  60467. getClosestPoint(position: Vector3): Vector3;
  60468. /**
  60469. * Get a navigation mesh constrained position, within a particular radius
  60470. * @param position world position
  60471. * @param maxRadius the maximum distance to the constrained world position
  60472. * @returns the closest point to position constrained by the navigation mesh
  60473. */
  60474. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60475. /**
  60476. * Compute the final position from a segment made of destination-position
  60477. * @param position world position
  60478. * @param destination world position
  60479. * @returns the resulting point along the navmesh
  60480. */
  60481. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60482. /**
  60483. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60484. * @param start world position
  60485. * @param end world position
  60486. * @returns array containing world position composing the path
  60487. */
  60488. computePath(start: Vector3, end: Vector3): Vector3[];
  60489. /**
  60490. * If this plugin is supported
  60491. * @returns true if plugin is supported
  60492. */
  60493. isSupported(): boolean;
  60494. /**
  60495. * Create a new Crowd so you can add agents
  60496. * @param maxAgents the maximum agent count in the crowd
  60497. * @param maxAgentRadius the maximum radius an agent can have
  60498. * @param scene to attach the crowd to
  60499. * @returns the crowd you can add agents to
  60500. */
  60501. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60502. /**
  60503. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60504. * The queries will try to find a solution within those bounds
  60505. * default is (1,1,1)
  60506. * @param extent x,y,z value that define the extent around the queries point of reference
  60507. */
  60508. setDefaultQueryExtent(extent: Vector3): void;
  60509. /**
  60510. * Get the Bounding box extent specified by setDefaultQueryExtent
  60511. * @returns the box extent values
  60512. */
  60513. getDefaultQueryExtent(): Vector3;
  60514. /**
  60515. * Release all resources
  60516. */
  60517. dispose(): void;
  60518. }
  60519. /**
  60520. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60521. */
  60522. export interface ICrowd {
  60523. /**
  60524. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60525. * You can attach anything to that node. The node position is updated in the scene update tick.
  60526. * @param pos world position that will be constrained by the navigation mesh
  60527. * @param parameters agent parameters
  60528. * @param transform hooked to the agent that will be update by the scene
  60529. * @returns agent index
  60530. */
  60531. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60532. /**
  60533. * Returns the agent position in world space
  60534. * @param index agent index returned by addAgent
  60535. * @returns world space position
  60536. */
  60537. getAgentPosition(index: number): Vector3;
  60538. /**
  60539. * Gets the agent velocity in world space
  60540. * @param index agent index returned by addAgent
  60541. * @returns world space velocity
  60542. */
  60543. getAgentVelocity(index: number): Vector3;
  60544. /**
  60545. * remove a particular agent previously created
  60546. * @param index agent index returned by addAgent
  60547. */
  60548. removeAgent(index: number): void;
  60549. /**
  60550. * get the list of all agents attached to this crowd
  60551. * @returns list of agent indices
  60552. */
  60553. getAgents(): number[];
  60554. /**
  60555. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60556. * @param deltaTime in seconds
  60557. */
  60558. update(deltaTime: number): void;
  60559. /**
  60560. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60561. * @param index agent index returned by addAgent
  60562. * @param destination targeted world position
  60563. */
  60564. agentGoto(index: number, destination: Vector3): void;
  60565. /**
  60566. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60567. * The queries will try to find a solution within those bounds
  60568. * default is (1,1,1)
  60569. * @param extent x,y,z value that define the extent around the queries point of reference
  60570. */
  60571. setDefaultQueryExtent(extent: Vector3): void;
  60572. /**
  60573. * Get the Bounding box extent specified by setDefaultQueryExtent
  60574. * @returns the box extent values
  60575. */
  60576. getDefaultQueryExtent(): Vector3;
  60577. /**
  60578. * Release all resources
  60579. */
  60580. dispose(): void;
  60581. }
  60582. /**
  60583. * Configures an agent
  60584. */
  60585. export interface IAgentParameters {
  60586. /**
  60587. * Agent radius. [Limit: >= 0]
  60588. */
  60589. radius: number;
  60590. /**
  60591. * Agent height. [Limit: > 0]
  60592. */
  60593. height: number;
  60594. /**
  60595. * Maximum allowed acceleration. [Limit: >= 0]
  60596. */
  60597. maxAcceleration: number;
  60598. /**
  60599. * Maximum allowed speed. [Limit: >= 0]
  60600. */
  60601. maxSpeed: number;
  60602. /**
  60603. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60604. */
  60605. collisionQueryRange: number;
  60606. /**
  60607. * The path visibility optimization range. [Limit: > 0]
  60608. */
  60609. pathOptimizationRange: number;
  60610. /**
  60611. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60612. */
  60613. separationWeight: number;
  60614. }
  60615. /**
  60616. * Configures the navigation mesh creation
  60617. */
  60618. export interface INavMeshParameters {
  60619. /**
  60620. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60621. */
  60622. cs: number;
  60623. /**
  60624. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60625. */
  60626. ch: number;
  60627. /**
  60628. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60629. */
  60630. walkableSlopeAngle: number;
  60631. /**
  60632. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60633. * be considered walkable. [Limit: >= 3] [Units: vx]
  60634. */
  60635. walkableHeight: number;
  60636. /**
  60637. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60638. */
  60639. walkableClimb: number;
  60640. /**
  60641. * The distance to erode/shrink the walkable area of the heightfield away from
  60642. * obstructions. [Limit: >=0] [Units: vx]
  60643. */
  60644. walkableRadius: number;
  60645. /**
  60646. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60647. */
  60648. maxEdgeLen: number;
  60649. /**
  60650. * The maximum distance a simplfied contour's border edges should deviate
  60651. * the original raw contour. [Limit: >=0] [Units: vx]
  60652. */
  60653. maxSimplificationError: number;
  60654. /**
  60655. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60656. */
  60657. minRegionArea: number;
  60658. /**
  60659. * Any regions with a span count smaller than this value will, if possible,
  60660. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60661. */
  60662. mergeRegionArea: number;
  60663. /**
  60664. * The maximum number of vertices allowed for polygons generated during the
  60665. * contour to polygon conversion process. [Limit: >= 3]
  60666. */
  60667. maxVertsPerPoly: number;
  60668. /**
  60669. * Sets the sampling distance to use when generating the detail mesh.
  60670. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60671. */
  60672. detailSampleDist: number;
  60673. /**
  60674. * The maximum distance the detail mesh surface should deviate from heightfield
  60675. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60676. */
  60677. detailSampleMaxError: number;
  60678. }
  60679. }
  60680. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60681. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60682. import { Mesh } from "babylonjs/Meshes/mesh";
  60683. import { Scene } from "babylonjs/scene";
  60684. import { Vector3 } from "babylonjs/Maths/math";
  60685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60686. /**
  60687. * RecastJS navigation plugin
  60688. */
  60689. export class RecastJSPlugin implements INavigationEnginePlugin {
  60690. /**
  60691. * Reference to the Recast library
  60692. */
  60693. bjsRECAST: any;
  60694. /**
  60695. * plugin name
  60696. */
  60697. name: string;
  60698. /**
  60699. * the first navmesh created. We might extend this to support multiple navmeshes
  60700. */
  60701. navMesh: any;
  60702. /**
  60703. * Initializes the recastJS plugin
  60704. * @param recastInjection can be used to inject your own recast reference
  60705. */
  60706. constructor(recastInjection?: any);
  60707. /**
  60708. * Creates a navigation mesh
  60709. * @param meshes array of all the geometry used to compute the navigatio mesh
  60710. * @param parameters bunch of parameters used to filter geometry
  60711. */
  60712. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60713. /**
  60714. * Create a navigation mesh debug mesh
  60715. * @param scene is where the mesh will be added
  60716. * @returns debug display mesh
  60717. */
  60718. createDebugNavMesh(scene: Scene): Mesh;
  60719. /**
  60720. * Get a navigation mesh constrained position, closest to the parameter position
  60721. * @param position world position
  60722. * @returns the closest point to position constrained by the navigation mesh
  60723. */
  60724. getClosestPoint(position: Vector3): Vector3;
  60725. /**
  60726. * Get a navigation mesh constrained position, within a particular radius
  60727. * @param position world position
  60728. * @param maxRadius the maximum distance to the constrained world position
  60729. * @returns the closest point to position constrained by the navigation mesh
  60730. */
  60731. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60732. /**
  60733. * Compute the final position from a segment made of destination-position
  60734. * @param position world position
  60735. * @param destination world position
  60736. * @returns the resulting point along the navmesh
  60737. */
  60738. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60739. /**
  60740. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60741. * @param start world position
  60742. * @param end world position
  60743. * @returns array containing world position composing the path
  60744. */
  60745. computePath(start: Vector3, end: Vector3): Vector3[];
  60746. /**
  60747. * Create a new Crowd so you can add agents
  60748. * @param maxAgents the maximum agent count in the crowd
  60749. * @param maxAgentRadius the maximum radius an agent can have
  60750. * @param scene to attach the crowd to
  60751. * @returns the crowd you can add agents to
  60752. */
  60753. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60754. /**
  60755. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60756. * The queries will try to find a solution within those bounds
  60757. * default is (1,1,1)
  60758. * @param extent x,y,z value that define the extent around the queries point of reference
  60759. */
  60760. setDefaultQueryExtent(extent: Vector3): void;
  60761. /**
  60762. * Get the Bounding box extent specified by setDefaultQueryExtent
  60763. * @returns the box extent values
  60764. */
  60765. getDefaultQueryExtent(): Vector3;
  60766. /**
  60767. * Disposes
  60768. */
  60769. dispose(): void;
  60770. /**
  60771. * If this plugin is supported
  60772. * @returns true if plugin is supported
  60773. */
  60774. isSupported(): boolean;
  60775. }
  60776. /**
  60777. * Recast detour crowd implementation
  60778. */
  60779. export class RecastJSCrowd implements ICrowd {
  60780. /**
  60781. * Recast/detour plugin
  60782. */
  60783. bjsRECASTPlugin: RecastJSPlugin;
  60784. /**
  60785. * Link to the detour crowd
  60786. */
  60787. recastCrowd: any;
  60788. /**
  60789. * One transform per agent
  60790. */
  60791. transforms: TransformNode[];
  60792. /**
  60793. * All agents created
  60794. */
  60795. agents: number[];
  60796. /**
  60797. * Link to the scene is kept to unregister the crowd from the scene
  60798. */
  60799. private _scene;
  60800. /**
  60801. * Observer for crowd updates
  60802. */
  60803. private _onBeforeAnimationsObserver;
  60804. /**
  60805. * Constructor
  60806. * @param plugin recastJS plugin
  60807. * @param maxAgents the maximum agent count in the crowd
  60808. * @param maxAgentRadius the maximum radius an agent can have
  60809. * @param scene to attach the crowd to
  60810. * @returns the crowd you can add agents to
  60811. */
  60812. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60813. /**
  60814. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60815. * You can attach anything to that node. The node position is updated in the scene update tick.
  60816. * @param pos world position that will be constrained by the navigation mesh
  60817. * @param parameters agent parameters
  60818. * @param transform hooked to the agent that will be update by the scene
  60819. * @returns agent index
  60820. */
  60821. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60822. /**
  60823. * Returns the agent position in world space
  60824. * @param index agent index returned by addAgent
  60825. * @returns world space position
  60826. */
  60827. getAgentPosition(index: number): Vector3;
  60828. /**
  60829. * Returns the agent velocity in world space
  60830. * @param index agent index returned by addAgent
  60831. * @returns world space velocity
  60832. */
  60833. getAgentVelocity(index: number): Vector3;
  60834. /**
  60835. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60836. * @param index agent index returned by addAgent
  60837. * @param destination targeted world position
  60838. */
  60839. agentGoto(index: number, destination: Vector3): void;
  60840. /**
  60841. * remove a particular agent previously created
  60842. * @param index agent index returned by addAgent
  60843. */
  60844. removeAgent(index: number): void;
  60845. /**
  60846. * get the list of all agents attached to this crowd
  60847. * @returns list of agent indices
  60848. */
  60849. getAgents(): number[];
  60850. /**
  60851. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60852. * @param deltaTime in seconds
  60853. */
  60854. update(deltaTime: number): void;
  60855. /**
  60856. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60857. * The queries will try to find a solution within those bounds
  60858. * default is (1,1,1)
  60859. * @param extent x,y,z value that define the extent around the queries point of reference
  60860. */
  60861. setDefaultQueryExtent(extent: Vector3): void;
  60862. /**
  60863. * Get the Bounding box extent specified by setDefaultQueryExtent
  60864. * @returns the box extent values
  60865. */
  60866. getDefaultQueryExtent(): Vector3;
  60867. /**
  60868. * Release all resources
  60869. */
  60870. dispose(): void;
  60871. }
  60872. }
  60873. declare module "babylonjs/Navigation/Plugins/index" {
  60874. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60875. }
  60876. declare module "babylonjs/Navigation/index" {
  60877. export * from "babylonjs/Navigation/INavigationEngine";
  60878. export * from "babylonjs/Navigation/Plugins/index";
  60879. }
  60880. declare module "babylonjs/Offline/database" {
  60881. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60882. /**
  60883. * Class used to enable access to IndexedDB
  60884. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60885. */
  60886. export class Database implements IOfflineProvider {
  60887. private _callbackManifestChecked;
  60888. private _currentSceneUrl;
  60889. private _db;
  60890. private _enableSceneOffline;
  60891. private _enableTexturesOffline;
  60892. private _manifestVersionFound;
  60893. private _mustUpdateRessources;
  60894. private _hasReachedQuota;
  60895. private _isSupported;
  60896. private _idbFactory;
  60897. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60898. private static IsUASupportingBlobStorage;
  60899. /**
  60900. * Gets a boolean indicating if Database storate is enabled (off by default)
  60901. */
  60902. static IDBStorageEnabled: boolean;
  60903. /**
  60904. * Gets a boolean indicating if scene must be saved in the database
  60905. */
  60906. readonly enableSceneOffline: boolean;
  60907. /**
  60908. * Gets a boolean indicating if textures must be saved in the database
  60909. */
  60910. readonly enableTexturesOffline: boolean;
  60911. /**
  60912. * Creates a new Database
  60913. * @param urlToScene defines the url to load the scene
  60914. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60915. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60916. */
  60917. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60918. private static _ParseURL;
  60919. private static _ReturnFullUrlLocation;
  60920. private _checkManifestFile;
  60921. /**
  60922. * Open the database and make it available
  60923. * @param successCallback defines the callback to call on success
  60924. * @param errorCallback defines the callback to call on error
  60925. */
  60926. open(successCallback: () => void, errorCallback: () => void): void;
  60927. /**
  60928. * Loads an image from the database
  60929. * @param url defines the url to load from
  60930. * @param image defines the target DOM image
  60931. */
  60932. loadImage(url: string, image: HTMLImageElement): void;
  60933. private _loadImageFromDBAsync;
  60934. private _saveImageIntoDBAsync;
  60935. private _checkVersionFromDB;
  60936. private _loadVersionFromDBAsync;
  60937. private _saveVersionIntoDBAsync;
  60938. /**
  60939. * Loads a file from database
  60940. * @param url defines the URL to load from
  60941. * @param sceneLoaded defines a callback to call on success
  60942. * @param progressCallBack defines a callback to call when progress changed
  60943. * @param errorCallback defines a callback to call on error
  60944. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60945. */
  60946. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60947. private _loadFileAsync;
  60948. private _saveFileAsync;
  60949. /**
  60950. * Validates if xhr data is correct
  60951. * @param xhr defines the request to validate
  60952. * @param dataType defines the expected data type
  60953. * @returns true if data is correct
  60954. */
  60955. private static _ValidateXHRData;
  60956. }
  60957. }
  60958. declare module "babylonjs/Offline/index" {
  60959. export * from "babylonjs/Offline/database";
  60960. export * from "babylonjs/Offline/IOfflineProvider";
  60961. }
  60962. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60963. /** @hidden */
  60964. export var gpuUpdateParticlesPixelShader: {
  60965. name: string;
  60966. shader: string;
  60967. };
  60968. }
  60969. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60970. /** @hidden */
  60971. export var gpuUpdateParticlesVertexShader: {
  60972. name: string;
  60973. shader: string;
  60974. };
  60975. }
  60976. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60977. /** @hidden */
  60978. export var clipPlaneFragmentDeclaration2: {
  60979. name: string;
  60980. shader: string;
  60981. };
  60982. }
  60983. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60984. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60985. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60987. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60988. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60989. /** @hidden */
  60990. export var gpuRenderParticlesPixelShader: {
  60991. name: string;
  60992. shader: string;
  60993. };
  60994. }
  60995. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60996. /** @hidden */
  60997. export var clipPlaneVertexDeclaration2: {
  60998. name: string;
  60999. shader: string;
  61000. };
  61001. }
  61002. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61004. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61005. /** @hidden */
  61006. export var gpuRenderParticlesVertexShader: {
  61007. name: string;
  61008. shader: string;
  61009. };
  61010. }
  61011. declare module "babylonjs/Particles/gpuParticleSystem" {
  61012. import { Nullable } from "babylonjs/types";
  61013. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61014. import { Observable } from "babylonjs/Misc/observable";
  61015. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61016. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61017. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61018. import { Scene, IDisposable } from "babylonjs/scene";
  61019. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61020. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61021. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61022. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61023. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61024. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61025. /**
  61026. * This represents a GPU particle system in Babylon
  61027. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61028. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61029. */
  61030. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61031. /**
  61032. * The layer mask we are rendering the particles through.
  61033. */
  61034. layerMask: number;
  61035. private _capacity;
  61036. private _activeCount;
  61037. private _currentActiveCount;
  61038. private _accumulatedCount;
  61039. private _renderEffect;
  61040. private _updateEffect;
  61041. private _buffer0;
  61042. private _buffer1;
  61043. private _spriteBuffer;
  61044. private _updateVAO;
  61045. private _renderVAO;
  61046. private _targetIndex;
  61047. private _sourceBuffer;
  61048. private _targetBuffer;
  61049. private _engine;
  61050. private _currentRenderId;
  61051. private _started;
  61052. private _stopped;
  61053. private _timeDelta;
  61054. private _randomTexture;
  61055. private _randomTexture2;
  61056. private _attributesStrideSize;
  61057. private _updateEffectOptions;
  61058. private _randomTextureSize;
  61059. private _actualFrame;
  61060. private readonly _rawTextureWidth;
  61061. /**
  61062. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61063. */
  61064. static readonly IsSupported: boolean;
  61065. /**
  61066. * An event triggered when the system is disposed.
  61067. */
  61068. onDisposeObservable: Observable<GPUParticleSystem>;
  61069. /**
  61070. * Gets the maximum number of particles active at the same time.
  61071. * @returns The max number of active particles.
  61072. */
  61073. getCapacity(): number;
  61074. /**
  61075. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61076. * to override the particles.
  61077. */
  61078. forceDepthWrite: boolean;
  61079. /**
  61080. * Gets or set the number of active particles
  61081. */
  61082. activeParticleCount: number;
  61083. private _preWarmDone;
  61084. /**
  61085. * Is this system ready to be used/rendered
  61086. * @return true if the system is ready
  61087. */
  61088. isReady(): boolean;
  61089. /**
  61090. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61091. * @returns True if it has been started, otherwise false.
  61092. */
  61093. isStarted(): boolean;
  61094. /**
  61095. * Starts the particle system and begins to emit
  61096. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61097. */
  61098. start(delay?: number): void;
  61099. /**
  61100. * Stops the particle system.
  61101. */
  61102. stop(): void;
  61103. /**
  61104. * Remove all active particles
  61105. */
  61106. reset(): void;
  61107. /**
  61108. * Returns the string "GPUParticleSystem"
  61109. * @returns a string containing the class name
  61110. */
  61111. getClassName(): string;
  61112. private _colorGradientsTexture;
  61113. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61114. /**
  61115. * Adds a new color gradient
  61116. * @param gradient defines the gradient to use (between 0 and 1)
  61117. * @param color1 defines the color to affect to the specified gradient
  61118. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61119. * @returns the current particle system
  61120. */
  61121. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61122. /**
  61123. * Remove a specific color gradient
  61124. * @param gradient defines the gradient to remove
  61125. * @returns the current particle system
  61126. */
  61127. removeColorGradient(gradient: number): GPUParticleSystem;
  61128. private _angularSpeedGradientsTexture;
  61129. private _sizeGradientsTexture;
  61130. private _velocityGradientsTexture;
  61131. private _limitVelocityGradientsTexture;
  61132. private _dragGradientsTexture;
  61133. private _addFactorGradient;
  61134. /**
  61135. * Adds a new size gradient
  61136. * @param gradient defines the gradient to use (between 0 and 1)
  61137. * @param factor defines the size factor to affect to the specified gradient
  61138. * @returns the current particle system
  61139. */
  61140. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61141. /**
  61142. * Remove a specific size gradient
  61143. * @param gradient defines the gradient to remove
  61144. * @returns the current particle system
  61145. */
  61146. removeSizeGradient(gradient: number): GPUParticleSystem;
  61147. /**
  61148. * Adds a new angular speed gradient
  61149. * @param gradient defines the gradient to use (between 0 and 1)
  61150. * @param factor defines the angular speed to affect to the specified gradient
  61151. * @returns the current particle system
  61152. */
  61153. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61154. /**
  61155. * Remove a specific angular speed gradient
  61156. * @param gradient defines the gradient to remove
  61157. * @returns the current particle system
  61158. */
  61159. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61160. /**
  61161. * Adds a new velocity gradient
  61162. * @param gradient defines the gradient to use (between 0 and 1)
  61163. * @param factor defines the velocity to affect to the specified gradient
  61164. * @returns the current particle system
  61165. */
  61166. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61167. /**
  61168. * Remove a specific velocity gradient
  61169. * @param gradient defines the gradient to remove
  61170. * @returns the current particle system
  61171. */
  61172. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61173. /**
  61174. * Adds a new limit velocity gradient
  61175. * @param gradient defines the gradient to use (between 0 and 1)
  61176. * @param factor defines the limit velocity value to affect to the specified gradient
  61177. * @returns the current particle system
  61178. */
  61179. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61180. /**
  61181. * Remove a specific limit velocity gradient
  61182. * @param gradient defines the gradient to remove
  61183. * @returns the current particle system
  61184. */
  61185. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61186. /**
  61187. * Adds a new drag gradient
  61188. * @param gradient defines the gradient to use (between 0 and 1)
  61189. * @param factor defines the drag value to affect to the specified gradient
  61190. * @returns the current particle system
  61191. */
  61192. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61193. /**
  61194. * Remove a specific drag gradient
  61195. * @param gradient defines the gradient to remove
  61196. * @returns the current particle system
  61197. */
  61198. removeDragGradient(gradient: number): GPUParticleSystem;
  61199. /**
  61200. * Not supported by GPUParticleSystem
  61201. * @param gradient defines the gradient to use (between 0 and 1)
  61202. * @param factor defines the emit rate value to affect to the specified gradient
  61203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61204. * @returns the current particle system
  61205. */
  61206. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61207. /**
  61208. * Not supported by GPUParticleSystem
  61209. * @param gradient defines the gradient to remove
  61210. * @returns the current particle system
  61211. */
  61212. removeEmitRateGradient(gradient: number): IParticleSystem;
  61213. /**
  61214. * Not supported by GPUParticleSystem
  61215. * @param gradient defines the gradient to use (between 0 and 1)
  61216. * @param factor defines the start size value to affect to the specified gradient
  61217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61218. * @returns the current particle system
  61219. */
  61220. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61221. /**
  61222. * Not supported by GPUParticleSystem
  61223. * @param gradient defines the gradient to remove
  61224. * @returns the current particle system
  61225. */
  61226. removeStartSizeGradient(gradient: number): IParticleSystem;
  61227. /**
  61228. * Not supported by GPUParticleSystem
  61229. * @param gradient defines the gradient to use (between 0 and 1)
  61230. * @param min defines the color remap minimal range
  61231. * @param max defines the color remap maximal range
  61232. * @returns the current particle system
  61233. */
  61234. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61235. /**
  61236. * Not supported by GPUParticleSystem
  61237. * @param gradient defines the gradient to remove
  61238. * @returns the current particle system
  61239. */
  61240. removeColorRemapGradient(): IParticleSystem;
  61241. /**
  61242. * Not supported by GPUParticleSystem
  61243. * @param gradient defines the gradient to use (between 0 and 1)
  61244. * @param min defines the alpha remap minimal range
  61245. * @param max defines the alpha remap maximal range
  61246. * @returns the current particle system
  61247. */
  61248. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61249. /**
  61250. * Not supported by GPUParticleSystem
  61251. * @param gradient defines the gradient to remove
  61252. * @returns the current particle system
  61253. */
  61254. removeAlphaRemapGradient(): IParticleSystem;
  61255. /**
  61256. * Not supported by GPUParticleSystem
  61257. * @param gradient defines the gradient to use (between 0 and 1)
  61258. * @param color defines the color to affect to the specified gradient
  61259. * @returns the current particle system
  61260. */
  61261. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61262. /**
  61263. * Not supported by GPUParticleSystem
  61264. * @param gradient defines the gradient to remove
  61265. * @returns the current particle system
  61266. */
  61267. removeRampGradient(): IParticleSystem;
  61268. /**
  61269. * Not supported by GPUParticleSystem
  61270. * @returns the list of ramp gradients
  61271. */
  61272. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61273. /**
  61274. * Not supported by GPUParticleSystem
  61275. * Gets or sets a boolean indicating that ramp gradients must be used
  61276. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61277. */
  61278. useRampGradients: boolean;
  61279. /**
  61280. * Not supported by GPUParticleSystem
  61281. * @param gradient defines the gradient to use (between 0 and 1)
  61282. * @param factor defines the life time factor to affect to the specified gradient
  61283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61284. * @returns the current particle system
  61285. */
  61286. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61287. /**
  61288. * Not supported by GPUParticleSystem
  61289. * @param gradient defines the gradient to remove
  61290. * @returns the current particle system
  61291. */
  61292. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61293. /**
  61294. * Instantiates a GPU particle system.
  61295. * 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.
  61296. * @param name The name of the particle system
  61297. * @param options The options used to create the system
  61298. * @param scene The scene the particle system belongs to
  61299. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61300. */
  61301. constructor(name: string, options: Partial<{
  61302. capacity: number;
  61303. randomTextureSize: number;
  61304. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61305. protected _reset(): void;
  61306. private _createUpdateVAO;
  61307. private _createRenderVAO;
  61308. private _initialize;
  61309. /** @hidden */
  61310. _recreateUpdateEffect(): void;
  61311. /** @hidden */
  61312. _recreateRenderEffect(): void;
  61313. /**
  61314. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61315. * @param preWarm defines if we are in the pre-warmimg phase
  61316. */
  61317. animate(preWarm?: boolean): void;
  61318. private _createFactorGradientTexture;
  61319. private _createSizeGradientTexture;
  61320. private _createAngularSpeedGradientTexture;
  61321. private _createVelocityGradientTexture;
  61322. private _createLimitVelocityGradientTexture;
  61323. private _createDragGradientTexture;
  61324. private _createColorGradientTexture;
  61325. /**
  61326. * Renders the particle system in its current state
  61327. * @param preWarm defines if the system should only update the particles but not render them
  61328. * @returns the current number of particles
  61329. */
  61330. render(preWarm?: boolean): number;
  61331. /**
  61332. * Rebuilds the particle system
  61333. */
  61334. rebuild(): void;
  61335. private _releaseBuffers;
  61336. private _releaseVAOs;
  61337. /**
  61338. * Disposes the particle system and free the associated resources
  61339. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61340. */
  61341. dispose(disposeTexture?: boolean): void;
  61342. /**
  61343. * Clones the particle system.
  61344. * @param name The name of the cloned object
  61345. * @param newEmitter The new emitter to use
  61346. * @returns the cloned particle system
  61347. */
  61348. clone(name: string, newEmitter: any): GPUParticleSystem;
  61349. /**
  61350. * Serializes the particle system to a JSON object.
  61351. * @returns the JSON object
  61352. */
  61353. serialize(): any;
  61354. /**
  61355. * Parses a JSON object to create a GPU particle system.
  61356. * @param parsedParticleSystem The JSON object to parse
  61357. * @param scene The scene to create the particle system in
  61358. * @param rootUrl The root url to use to load external dependencies like texture
  61359. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61360. * @returns the parsed GPU particle system
  61361. */
  61362. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61363. }
  61364. }
  61365. declare module "babylonjs/Particles/particleSystemSet" {
  61366. import { Nullable } from "babylonjs/types";
  61367. import { Color3 } from "babylonjs/Maths/math.color";
  61368. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61370. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61371. import { Scene, IDisposable } from "babylonjs/scene";
  61372. /**
  61373. * Represents a set of particle systems working together to create a specific effect
  61374. */
  61375. export class ParticleSystemSet implements IDisposable {
  61376. /**
  61377. * Gets or sets base Assets URL
  61378. */
  61379. static BaseAssetsUrl: string;
  61380. private _emitterCreationOptions;
  61381. private _emitterNode;
  61382. /**
  61383. * Gets the particle system list
  61384. */
  61385. systems: IParticleSystem[];
  61386. /**
  61387. * Gets the emitter node used with this set
  61388. */
  61389. readonly emitterNode: Nullable<TransformNode>;
  61390. /**
  61391. * Creates a new emitter mesh as a sphere
  61392. * @param options defines the options used to create the sphere
  61393. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61394. * @param scene defines the hosting scene
  61395. */
  61396. setEmitterAsSphere(options: {
  61397. diameter: number;
  61398. segments: number;
  61399. color: Color3;
  61400. }, renderingGroupId: number, scene: Scene): void;
  61401. /**
  61402. * Starts all particle systems of the set
  61403. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61404. */
  61405. start(emitter?: AbstractMesh): void;
  61406. /**
  61407. * Release all associated resources
  61408. */
  61409. dispose(): void;
  61410. /**
  61411. * Serialize the set into a JSON compatible object
  61412. * @returns a JSON compatible representation of the set
  61413. */
  61414. serialize(): any;
  61415. /**
  61416. * Parse a new ParticleSystemSet from a serialized source
  61417. * @param data defines a JSON compatible representation of the set
  61418. * @param scene defines the hosting scene
  61419. * @param gpu defines if we want GPU particles or CPU particles
  61420. * @returns a new ParticleSystemSet
  61421. */
  61422. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61423. }
  61424. }
  61425. declare module "babylonjs/Particles/particleHelper" {
  61426. import { Nullable } from "babylonjs/types";
  61427. import { Scene } from "babylonjs/scene";
  61428. import { Vector3 } from "babylonjs/Maths/math.vector";
  61429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61430. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61431. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61432. /**
  61433. * This class is made for on one-liner static method to help creating particle system set.
  61434. */
  61435. export class ParticleHelper {
  61436. /**
  61437. * Gets or sets base Assets URL
  61438. */
  61439. static BaseAssetsUrl: string;
  61440. /**
  61441. * Create a default particle system that you can tweak
  61442. * @param emitter defines the emitter to use
  61443. * @param capacity defines the system capacity (default is 500 particles)
  61444. * @param scene defines the hosting scene
  61445. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61446. * @returns the new Particle system
  61447. */
  61448. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61449. /**
  61450. * This is the main static method (one-liner) of this helper to create different particle systems
  61451. * @param type This string represents the type to the particle system to create
  61452. * @param scene The scene where the particle system should live
  61453. * @param gpu If the system will use gpu
  61454. * @returns the ParticleSystemSet created
  61455. */
  61456. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61457. /**
  61458. * Static function used to export a particle system to a ParticleSystemSet variable.
  61459. * Please note that the emitter shape is not exported
  61460. * @param systems defines the particle systems to export
  61461. * @returns the created particle system set
  61462. */
  61463. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61464. }
  61465. }
  61466. declare module "babylonjs/Particles/particleSystemComponent" {
  61467. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61468. import { Effect } from "babylonjs/Materials/effect";
  61469. import "babylonjs/Shaders/particles.vertex";
  61470. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61471. module "babylonjs/Engines/engine" {
  61472. interface Engine {
  61473. /**
  61474. * Create an effect to use with particle systems.
  61475. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61476. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61477. * @param uniformsNames defines a list of attribute names
  61478. * @param samplers defines an array of string used to represent textures
  61479. * @param defines defines the string containing the defines to use to compile the shaders
  61480. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61481. * @param onCompiled defines a function to call when the effect creation is successful
  61482. * @param onError defines a function to call when the effect creation has failed
  61483. * @returns the new Effect
  61484. */
  61485. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61486. }
  61487. }
  61488. module "babylonjs/Meshes/mesh" {
  61489. interface Mesh {
  61490. /**
  61491. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61492. * @returns an array of IParticleSystem
  61493. */
  61494. getEmittedParticleSystems(): IParticleSystem[];
  61495. /**
  61496. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61497. * @returns an array of IParticleSystem
  61498. */
  61499. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61500. }
  61501. }
  61502. /**
  61503. * @hidden
  61504. */
  61505. export var _IDoNeedToBeInTheBuild: number;
  61506. }
  61507. declare module "babylonjs/Particles/pointsCloudSystem" {
  61508. import { Color4 } from "babylonjs/Maths/math";
  61509. import { Mesh } from "babylonjs/Meshes/mesh";
  61510. import { Scene, IDisposable } from "babylonjs/scene";
  61511. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61512. /** Defines the 4 color options */
  61513. export enum PointColor {
  61514. /** color value */
  61515. Color = 2,
  61516. /** uv value */
  61517. UV = 1,
  61518. /** random value */
  61519. Random = 0,
  61520. /** stated value */
  61521. Stated = 3
  61522. }
  61523. /**
  61524. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61525. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61526. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61527. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61528. *
  61529. * Full documentation here : TO BE ENTERED
  61530. */
  61531. export class PointsCloudSystem implements IDisposable {
  61532. /**
  61533. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61534. * Example : var p = SPS.particles[i];
  61535. */
  61536. particles: CloudPoint[];
  61537. /**
  61538. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61539. */
  61540. nbParticles: number;
  61541. /**
  61542. * This a counter for your own usage. It's not set by any SPS functions.
  61543. */
  61544. counter: number;
  61545. /**
  61546. * The PCS name. This name is also given to the underlying mesh.
  61547. */
  61548. name: string;
  61549. /**
  61550. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61551. */
  61552. mesh: Mesh;
  61553. /**
  61554. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61555. * Please read :
  61556. */
  61557. vars: any;
  61558. /**
  61559. * @hidden
  61560. */
  61561. _size: number;
  61562. private _scene;
  61563. private _promises;
  61564. private _positions;
  61565. private _indices;
  61566. private _normals;
  61567. private _colors;
  61568. private _uvs;
  61569. private _indices32;
  61570. private _positions32;
  61571. private _colors32;
  61572. private _uvs32;
  61573. private _updatable;
  61574. private _isVisibilityBoxLocked;
  61575. private _alwaysVisible;
  61576. private _groups;
  61577. private _groupCounter;
  61578. private _computeParticleColor;
  61579. private _computeParticleTexture;
  61580. private _computeParticleRotation;
  61581. private _computeBoundingBox;
  61582. private _isReady;
  61583. /**
  61584. * Creates a PCS (Points Cloud System) object
  61585. * @param name (String) is the PCS name, this will be the underlying mesh name
  61586. * @param pointSize (number) is the size for each point
  61587. * @param scene (Scene) is the scene in which the PCS is added
  61588. * @param options defines the options of the PCS e.g.
  61589. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61590. */
  61591. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61592. updatable?: boolean;
  61593. });
  61594. /**
  61595. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61596. * If no points were added to the PCS, the returned mesh is just a single point.
  61597. * @returns a promise for the created mesh
  61598. */
  61599. buildMeshAsync(): Promise<Mesh>;
  61600. /**
  61601. * @hidden
  61602. */
  61603. private _buildMesh;
  61604. private _addParticle;
  61605. private _randomUnitVector;
  61606. private _getColorIndicesForCoord;
  61607. private _setPointsColorOrUV;
  61608. private _colorFromTexture;
  61609. private _calculateDensity;
  61610. /**
  61611. * Adds points to the PCS in random positions within a unit sphere
  61612. * @param nb (positive integer) the number of particles to be created from this model
  61613. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61614. * @returns the number of groups in the system
  61615. */
  61616. addPoints(nb: number, pointFunction?: any): number;
  61617. /**
  61618. * Adds points to the PCS from the surface of the model shape
  61619. * @param mesh is any Mesh object that will be used as a surface model for the points
  61620. * @param nb (positive integer) the number of particles to be created from this model
  61621. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61622. * @param color (color3) to be used when colorWith is stated
  61623. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61624. * @returns the number of groups in the system
  61625. */
  61626. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61627. /**
  61628. * Adds points to the PCS inside the model shape
  61629. * @param mesh is any Mesh object that will be used as a surface model for the points
  61630. * @param nb (positive integer) the number of particles to be created from this model
  61631. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61632. * @param color (color4) to be used when colorWith is stated
  61633. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61634. * @returns the number of groups in the system
  61635. */
  61636. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61637. /**
  61638. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61639. * This method calls `updateParticle()` for each particle of the SPS.
  61640. * For an animated SPS, it is usually called within the render loop.
  61641. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61642. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61643. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61644. * @returns the PCS.
  61645. */
  61646. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61647. /**
  61648. * Disposes the PCS.
  61649. */
  61650. dispose(): void;
  61651. /**
  61652. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61653. * doc :
  61654. * @returns the PCS.
  61655. */
  61656. refreshVisibleSize(): PointsCloudSystem;
  61657. /**
  61658. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61659. * @param size the size (float) of the visibility box
  61660. * note : this doesn't lock the PCS mesh bounding box.
  61661. * doc :
  61662. */
  61663. setVisibilityBox(size: number): void;
  61664. /**
  61665. * Gets whether the PCS is always visible or not
  61666. * doc :
  61667. */
  61668. /**
  61669. * Sets the PCS as always visible or not
  61670. * doc :
  61671. */
  61672. isAlwaysVisible: boolean;
  61673. /**
  61674. * Tells to `setParticles()` to compute the particle rotations or not
  61675. * Default value : false. The PCS is faster when it's set to false
  61676. * Note : particle rotations are only applied to parent particles
  61677. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61678. */
  61679. computeParticleRotation: boolean;
  61680. /**
  61681. * Tells to `setParticles()` to compute the particle colors or not.
  61682. * Default value : true. The PCS is faster when it's set to false.
  61683. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61684. */
  61685. /**
  61686. * Gets if `setParticles()` computes the particle colors or not.
  61687. * Default value : false. The PCS is faster when it's set to false.
  61688. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61689. */
  61690. computeParticleColor: boolean;
  61691. /**
  61692. * Gets if `setParticles()` computes the particle textures or not.
  61693. * Default value : false. The PCS is faster when it's set to false.
  61694. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61695. */
  61696. computeParticleTexture: boolean;
  61697. /**
  61698. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61699. */
  61700. /**
  61701. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61702. */
  61703. computeBoundingBox: boolean;
  61704. /**
  61705. * This function does nothing. It may be overwritten to set all the particle first values.
  61706. * The PCS doesn't call this function, you may have to call it by your own.
  61707. * doc :
  61708. */
  61709. initParticles(): void;
  61710. /**
  61711. * This function does nothing. It may be overwritten to recycle a particle
  61712. * The PCS doesn't call this function, you can to call it
  61713. * doc :
  61714. * @param particle The particle to recycle
  61715. * @returns the recycled particle
  61716. */
  61717. recycleParticle(particle: CloudPoint): CloudPoint;
  61718. /**
  61719. * Updates a particle : this function should be overwritten by the user.
  61720. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61721. * doc :
  61722. * @example : just set a particle position or velocity and recycle conditions
  61723. * @param particle The particle to update
  61724. * @returns the updated particle
  61725. */
  61726. updateParticle(particle: CloudPoint): CloudPoint;
  61727. /**
  61728. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61729. * This does nothing and may be overwritten by the user.
  61730. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61731. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61732. * @param update the boolean update value actually passed to setParticles()
  61733. */
  61734. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61735. /**
  61736. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61737. * This will be passed three parameters.
  61738. * This does nothing and may be overwritten by the user.
  61739. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61740. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61741. * @param update the boolean update value actually passed to setParticles()
  61742. */
  61743. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61744. }
  61745. }
  61746. declare module "babylonjs/Particles/cloudPoint" {
  61747. import { Nullable } from "babylonjs/types";
  61748. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61749. import { Mesh } from "babylonjs/Meshes/mesh";
  61750. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61751. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61752. /**
  61753. * Represents one particle of a points cloud system.
  61754. */
  61755. export class CloudPoint {
  61756. /**
  61757. * particle global index
  61758. */
  61759. idx: number;
  61760. /**
  61761. * The color of the particle
  61762. */
  61763. color: Nullable<Color4>;
  61764. /**
  61765. * The world space position of the particle.
  61766. */
  61767. position: Vector3;
  61768. /**
  61769. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61770. */
  61771. rotation: Vector3;
  61772. /**
  61773. * The world space rotation quaternion of the particle.
  61774. */
  61775. rotationQuaternion: Nullable<Quaternion>;
  61776. /**
  61777. * The uv of the particle.
  61778. */
  61779. uv: Nullable<Vector2>;
  61780. /**
  61781. * The current speed of the particle.
  61782. */
  61783. velocity: Vector3;
  61784. /**
  61785. * The pivot point in the particle local space.
  61786. */
  61787. pivot: Vector3;
  61788. /**
  61789. * Must the particle be translated from its pivot point in its local space ?
  61790. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61791. * Default : false
  61792. */
  61793. translateFromPivot: boolean;
  61794. /**
  61795. * Index of this particle in the global "positions" array (Internal use)
  61796. * @hidden
  61797. */
  61798. _pos: number;
  61799. /**
  61800. * @hidden Index of this particle in the global "indices" array (Internal use)
  61801. */
  61802. _ind: number;
  61803. /**
  61804. * Group this particle belongs to
  61805. */
  61806. _group: PointsGroup;
  61807. /**
  61808. * Group id of this particle
  61809. */
  61810. groupId: number;
  61811. /**
  61812. * Index of the particle in its group id (Internal use)
  61813. */
  61814. idxInGroup: number;
  61815. /**
  61816. * @hidden Particle BoundingInfo object (Internal use)
  61817. */
  61818. _boundingInfo: BoundingInfo;
  61819. /**
  61820. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61821. */
  61822. _pcs: PointsCloudSystem;
  61823. /**
  61824. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61825. */
  61826. _stillInvisible: boolean;
  61827. /**
  61828. * @hidden Last computed particle rotation matrix
  61829. */
  61830. _rotationMatrix: number[];
  61831. /**
  61832. * Parent particle Id, if any.
  61833. * Default null.
  61834. */
  61835. parentId: Nullable<number>;
  61836. /**
  61837. * @hidden Internal global position in the PCS.
  61838. */
  61839. _globalPosition: Vector3;
  61840. /**
  61841. * Creates a Point Cloud object.
  61842. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61843. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61844. * @param group (PointsGroup) is the group the particle belongs to
  61845. * @param groupId (integer) is the group identifier in the PCS.
  61846. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61847. * @param pcs defines the PCS it is associated to
  61848. */
  61849. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61850. /**
  61851. * get point size
  61852. */
  61853. /**
  61854. * Set point size
  61855. */
  61856. size: Vector3;
  61857. /**
  61858. * Legacy support, changed quaternion to rotationQuaternion
  61859. */
  61860. /**
  61861. * Legacy support, changed quaternion to rotationQuaternion
  61862. */
  61863. quaternion: Nullable<Quaternion>;
  61864. /**
  61865. * Returns a boolean. True if the particle intersects a mesh, else false
  61866. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61867. * @param target is the object (point or mesh) what the intersection is computed against
  61868. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61869. * @returns true if it intersects
  61870. */
  61871. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61872. /**
  61873. * get the rotation matrix of the particle
  61874. * @hidden
  61875. */
  61876. getRotationMatrix(m: Matrix): void;
  61877. }
  61878. /**
  61879. * Represents a group of points in a points cloud system
  61880. * * PCS internal tool, don't use it manually.
  61881. */
  61882. export class PointsGroup {
  61883. /**
  61884. * The group id
  61885. * @hidden
  61886. */
  61887. groupID: number;
  61888. /**
  61889. * image data for group (internal use)
  61890. * @hidden
  61891. */
  61892. _groupImageData: Nullable<ArrayBufferView>;
  61893. /**
  61894. * Image Width (internal use)
  61895. * @hidden
  61896. */
  61897. _groupImgWidth: number;
  61898. /**
  61899. * Image Height (internal use)
  61900. * @hidden
  61901. */
  61902. _groupImgHeight: number;
  61903. /**
  61904. * Custom position function (internal use)
  61905. * @hidden
  61906. */
  61907. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61908. /**
  61909. * density per facet for surface points
  61910. * @hidden
  61911. */
  61912. _groupDensity: number[];
  61913. /**
  61914. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61915. * PCS internal tool, don't use it manually.
  61916. * @hidden
  61917. */
  61918. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61919. }
  61920. }
  61921. declare module "babylonjs/Particles/index" {
  61922. export * from "babylonjs/Particles/baseParticleSystem";
  61923. export * from "babylonjs/Particles/EmitterTypes/index";
  61924. export * from "babylonjs/Particles/gpuParticleSystem";
  61925. export * from "babylonjs/Particles/IParticleSystem";
  61926. export * from "babylonjs/Particles/particle";
  61927. export * from "babylonjs/Particles/particleHelper";
  61928. export * from "babylonjs/Particles/particleSystem";
  61929. export * from "babylonjs/Particles/particleSystemComponent";
  61930. export * from "babylonjs/Particles/particleSystemSet";
  61931. export * from "babylonjs/Particles/solidParticle";
  61932. export * from "babylonjs/Particles/solidParticleSystem";
  61933. export * from "babylonjs/Particles/cloudPoint";
  61934. export * from "babylonjs/Particles/pointsCloudSystem";
  61935. export * from "babylonjs/Particles/subEmitter";
  61936. }
  61937. declare module "babylonjs/Physics/physicsEngineComponent" {
  61938. import { Nullable } from "babylonjs/types";
  61939. import { Observable, Observer } from "babylonjs/Misc/observable";
  61940. import { Vector3 } from "babylonjs/Maths/math.vector";
  61941. import { Mesh } from "babylonjs/Meshes/mesh";
  61942. import { ISceneComponent } from "babylonjs/sceneComponent";
  61943. import { Scene } from "babylonjs/scene";
  61944. import { Node } from "babylonjs/node";
  61945. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61946. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61947. module "babylonjs/scene" {
  61948. interface Scene {
  61949. /** @hidden (Backing field) */
  61950. _physicsEngine: Nullable<IPhysicsEngine>;
  61951. /**
  61952. * Gets the current physics engine
  61953. * @returns a IPhysicsEngine or null if none attached
  61954. */
  61955. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61956. /**
  61957. * Enables physics to the current scene
  61958. * @param gravity defines the scene's gravity for the physics engine
  61959. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61960. * @return a boolean indicating if the physics engine was initialized
  61961. */
  61962. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61963. /**
  61964. * Disables and disposes the physics engine associated with the scene
  61965. */
  61966. disablePhysicsEngine(): void;
  61967. /**
  61968. * Gets a boolean indicating if there is an active physics engine
  61969. * @returns a boolean indicating if there is an active physics engine
  61970. */
  61971. isPhysicsEnabled(): boolean;
  61972. /**
  61973. * Deletes a physics compound impostor
  61974. * @param compound defines the compound to delete
  61975. */
  61976. deleteCompoundImpostor(compound: any): void;
  61977. /**
  61978. * An event triggered when physic simulation is about to be run
  61979. */
  61980. onBeforePhysicsObservable: Observable<Scene>;
  61981. /**
  61982. * An event triggered when physic simulation has been done
  61983. */
  61984. onAfterPhysicsObservable: Observable<Scene>;
  61985. }
  61986. }
  61987. module "babylonjs/Meshes/abstractMesh" {
  61988. interface AbstractMesh {
  61989. /** @hidden */
  61990. _physicsImpostor: Nullable<PhysicsImpostor>;
  61991. /**
  61992. * Gets or sets impostor used for physic simulation
  61993. * @see http://doc.babylonjs.com/features/physics_engine
  61994. */
  61995. physicsImpostor: Nullable<PhysicsImpostor>;
  61996. /**
  61997. * Gets the current physics impostor
  61998. * @see http://doc.babylonjs.com/features/physics_engine
  61999. * @returns a physics impostor or null
  62000. */
  62001. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62002. /** Apply a physic impulse to the mesh
  62003. * @param force defines the force to apply
  62004. * @param contactPoint defines where to apply the force
  62005. * @returns the current mesh
  62006. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62007. */
  62008. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62009. /**
  62010. * Creates a physic joint between two meshes
  62011. * @param otherMesh defines the other mesh to use
  62012. * @param pivot1 defines the pivot to use on this mesh
  62013. * @param pivot2 defines the pivot to use on the other mesh
  62014. * @param options defines additional options (can be plugin dependent)
  62015. * @returns the current mesh
  62016. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62017. */
  62018. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62019. /** @hidden */
  62020. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62021. }
  62022. }
  62023. /**
  62024. * Defines the physics engine scene component responsible to manage a physics engine
  62025. */
  62026. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62027. /**
  62028. * The component name helpful to identify the component in the list of scene components.
  62029. */
  62030. readonly name: string;
  62031. /**
  62032. * The scene the component belongs to.
  62033. */
  62034. scene: Scene;
  62035. /**
  62036. * Creates a new instance of the component for the given scene
  62037. * @param scene Defines the scene to register the component in
  62038. */
  62039. constructor(scene: Scene);
  62040. /**
  62041. * Registers the component in a given scene
  62042. */
  62043. register(): void;
  62044. /**
  62045. * Rebuilds the elements related to this component in case of
  62046. * context lost for instance.
  62047. */
  62048. rebuild(): void;
  62049. /**
  62050. * Disposes the component and the associated ressources
  62051. */
  62052. dispose(): void;
  62053. }
  62054. }
  62055. declare module "babylonjs/Physics/physicsHelper" {
  62056. import { Nullable } from "babylonjs/types";
  62057. import { Vector3 } from "babylonjs/Maths/math.vector";
  62058. import { Mesh } from "babylonjs/Meshes/mesh";
  62059. import { Scene } from "babylonjs/scene";
  62060. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62061. /**
  62062. * A helper for physics simulations
  62063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62064. */
  62065. export class PhysicsHelper {
  62066. private _scene;
  62067. private _physicsEngine;
  62068. /**
  62069. * Initializes the Physics helper
  62070. * @param scene Babylon.js scene
  62071. */
  62072. constructor(scene: Scene);
  62073. /**
  62074. * Applies a radial explosion impulse
  62075. * @param origin the origin of the explosion
  62076. * @param radiusOrEventOptions the radius or the options of radial explosion
  62077. * @param strength the explosion strength
  62078. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62079. * @returns A physics radial explosion event, or null
  62080. */
  62081. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62082. /**
  62083. * Applies a radial explosion force
  62084. * @param origin the origin of the explosion
  62085. * @param radiusOrEventOptions the radius or the options of radial explosion
  62086. * @param strength the explosion strength
  62087. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62088. * @returns A physics radial explosion event, or null
  62089. */
  62090. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62091. /**
  62092. * Creates a gravitational field
  62093. * @param origin the origin of the explosion
  62094. * @param radiusOrEventOptions the radius or the options of radial explosion
  62095. * @param strength the explosion strength
  62096. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62097. * @returns A physics gravitational field event, or null
  62098. */
  62099. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62100. /**
  62101. * Creates a physics updraft event
  62102. * @param origin the origin of the updraft
  62103. * @param radiusOrEventOptions the radius or the options of the updraft
  62104. * @param strength the strength of the updraft
  62105. * @param height the height of the updraft
  62106. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62107. * @returns A physics updraft event, or null
  62108. */
  62109. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62110. /**
  62111. * Creates a physics vortex event
  62112. * @param origin the of the vortex
  62113. * @param radiusOrEventOptions the radius or the options of the vortex
  62114. * @param strength the strength of the vortex
  62115. * @param height the height of the vortex
  62116. * @returns a Physics vortex event, or null
  62117. * A physics vortex event or null
  62118. */
  62119. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62120. }
  62121. /**
  62122. * Represents a physics radial explosion event
  62123. */
  62124. class PhysicsRadialExplosionEvent {
  62125. private _scene;
  62126. private _options;
  62127. private _sphere;
  62128. private _dataFetched;
  62129. /**
  62130. * Initializes a radial explosioin event
  62131. * @param _scene BabylonJS scene
  62132. * @param _options The options for the vortex event
  62133. */
  62134. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62135. /**
  62136. * Returns the data related to the radial explosion event (sphere).
  62137. * @returns The radial explosion event data
  62138. */
  62139. getData(): PhysicsRadialExplosionEventData;
  62140. /**
  62141. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62142. * @param impostor A physics imposter
  62143. * @param origin the origin of the explosion
  62144. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62145. */
  62146. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62147. /**
  62148. * Triggers affecterd impostors callbacks
  62149. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62150. */
  62151. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62152. /**
  62153. * Disposes the sphere.
  62154. * @param force Specifies if the sphere should be disposed by force
  62155. */
  62156. dispose(force?: boolean): void;
  62157. /*** Helpers ***/
  62158. private _prepareSphere;
  62159. private _intersectsWithSphere;
  62160. }
  62161. /**
  62162. * Represents a gravitational field event
  62163. */
  62164. class PhysicsGravitationalFieldEvent {
  62165. private _physicsHelper;
  62166. private _scene;
  62167. private _origin;
  62168. private _options;
  62169. private _tickCallback;
  62170. private _sphere;
  62171. private _dataFetched;
  62172. /**
  62173. * Initializes the physics gravitational field event
  62174. * @param _physicsHelper A physics helper
  62175. * @param _scene BabylonJS scene
  62176. * @param _origin The origin position of the gravitational field event
  62177. * @param _options The options for the vortex event
  62178. */
  62179. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62180. /**
  62181. * Returns the data related to the gravitational field event (sphere).
  62182. * @returns A gravitational field event
  62183. */
  62184. getData(): PhysicsGravitationalFieldEventData;
  62185. /**
  62186. * Enables the gravitational field.
  62187. */
  62188. enable(): void;
  62189. /**
  62190. * Disables the gravitational field.
  62191. */
  62192. disable(): void;
  62193. /**
  62194. * Disposes the sphere.
  62195. * @param force The force to dispose from the gravitational field event
  62196. */
  62197. dispose(force?: boolean): void;
  62198. private _tick;
  62199. }
  62200. /**
  62201. * Represents a physics updraft event
  62202. */
  62203. class PhysicsUpdraftEvent {
  62204. private _scene;
  62205. private _origin;
  62206. private _options;
  62207. private _physicsEngine;
  62208. private _originTop;
  62209. private _originDirection;
  62210. private _tickCallback;
  62211. private _cylinder;
  62212. private _cylinderPosition;
  62213. private _dataFetched;
  62214. /**
  62215. * Initializes the physics updraft event
  62216. * @param _scene BabylonJS scene
  62217. * @param _origin The origin position of the updraft
  62218. * @param _options The options for the updraft event
  62219. */
  62220. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62221. /**
  62222. * Returns the data related to the updraft event (cylinder).
  62223. * @returns A physics updraft event
  62224. */
  62225. getData(): PhysicsUpdraftEventData;
  62226. /**
  62227. * Enables the updraft.
  62228. */
  62229. enable(): void;
  62230. /**
  62231. * Disables the updraft.
  62232. */
  62233. disable(): void;
  62234. /**
  62235. * Disposes the cylinder.
  62236. * @param force Specifies if the updraft should be disposed by force
  62237. */
  62238. dispose(force?: boolean): void;
  62239. private getImpostorHitData;
  62240. private _tick;
  62241. /*** Helpers ***/
  62242. private _prepareCylinder;
  62243. private _intersectsWithCylinder;
  62244. }
  62245. /**
  62246. * Represents a physics vortex event
  62247. */
  62248. class PhysicsVortexEvent {
  62249. private _scene;
  62250. private _origin;
  62251. private _options;
  62252. private _physicsEngine;
  62253. private _originTop;
  62254. private _tickCallback;
  62255. private _cylinder;
  62256. private _cylinderPosition;
  62257. private _dataFetched;
  62258. /**
  62259. * Initializes the physics vortex event
  62260. * @param _scene The BabylonJS scene
  62261. * @param _origin The origin position of the vortex
  62262. * @param _options The options for the vortex event
  62263. */
  62264. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62265. /**
  62266. * Returns the data related to the vortex event (cylinder).
  62267. * @returns The physics vortex event data
  62268. */
  62269. getData(): PhysicsVortexEventData;
  62270. /**
  62271. * Enables the vortex.
  62272. */
  62273. enable(): void;
  62274. /**
  62275. * Disables the cortex.
  62276. */
  62277. disable(): void;
  62278. /**
  62279. * Disposes the sphere.
  62280. * @param force
  62281. */
  62282. dispose(force?: boolean): void;
  62283. private getImpostorHitData;
  62284. private _tick;
  62285. /*** Helpers ***/
  62286. private _prepareCylinder;
  62287. private _intersectsWithCylinder;
  62288. }
  62289. /**
  62290. * Options fot the radial explosion event
  62291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62292. */
  62293. export class PhysicsRadialExplosionEventOptions {
  62294. /**
  62295. * The radius of the sphere for the radial explosion.
  62296. */
  62297. radius: number;
  62298. /**
  62299. * The strenth of the explosion.
  62300. */
  62301. strength: number;
  62302. /**
  62303. * The strenght of the force in correspondence to the distance of the affected object
  62304. */
  62305. falloff: PhysicsRadialImpulseFalloff;
  62306. /**
  62307. * Sphere options for the radial explosion.
  62308. */
  62309. sphere: {
  62310. segments: number;
  62311. diameter: number;
  62312. };
  62313. /**
  62314. * Sphere options for the radial explosion.
  62315. */
  62316. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62317. }
  62318. /**
  62319. * Options fot the updraft event
  62320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62321. */
  62322. export class PhysicsUpdraftEventOptions {
  62323. /**
  62324. * The radius of the cylinder for the vortex
  62325. */
  62326. radius: number;
  62327. /**
  62328. * The strenth of the updraft.
  62329. */
  62330. strength: number;
  62331. /**
  62332. * The height of the cylinder for the updraft.
  62333. */
  62334. height: number;
  62335. /**
  62336. * The mode for the the updraft.
  62337. */
  62338. updraftMode: PhysicsUpdraftMode;
  62339. }
  62340. /**
  62341. * Options fot the vortex event
  62342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62343. */
  62344. export class PhysicsVortexEventOptions {
  62345. /**
  62346. * The radius of the cylinder for the vortex
  62347. */
  62348. radius: number;
  62349. /**
  62350. * The strenth of the vortex.
  62351. */
  62352. strength: number;
  62353. /**
  62354. * The height of the cylinder for the vortex.
  62355. */
  62356. height: number;
  62357. /**
  62358. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62359. */
  62360. centripetalForceThreshold: number;
  62361. /**
  62362. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62363. */
  62364. centripetalForceMultiplier: number;
  62365. /**
  62366. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62367. */
  62368. centrifugalForceMultiplier: number;
  62369. /**
  62370. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62371. */
  62372. updraftForceMultiplier: number;
  62373. }
  62374. /**
  62375. * The strenght of the force in correspondence to the distance of the affected object
  62376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62377. */
  62378. export enum PhysicsRadialImpulseFalloff {
  62379. /** Defines that impulse is constant in strength across it's whole radius */
  62380. Constant = 0,
  62381. /** Defines that impulse gets weaker if it's further from the origin */
  62382. Linear = 1
  62383. }
  62384. /**
  62385. * The strength of the force in correspondence to the distance of the affected object
  62386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62387. */
  62388. export enum PhysicsUpdraftMode {
  62389. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62390. Center = 0,
  62391. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62392. Perpendicular = 1
  62393. }
  62394. /**
  62395. * Interface for a physics hit data
  62396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62397. */
  62398. export interface PhysicsHitData {
  62399. /**
  62400. * The force applied at the contact point
  62401. */
  62402. force: Vector3;
  62403. /**
  62404. * The contact point
  62405. */
  62406. contactPoint: Vector3;
  62407. /**
  62408. * The distance from the origin to the contact point
  62409. */
  62410. distanceFromOrigin: number;
  62411. }
  62412. /**
  62413. * Interface for radial explosion event data
  62414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62415. */
  62416. export interface PhysicsRadialExplosionEventData {
  62417. /**
  62418. * A sphere used for the radial explosion event
  62419. */
  62420. sphere: Mesh;
  62421. }
  62422. /**
  62423. * Interface for gravitational field event data
  62424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62425. */
  62426. export interface PhysicsGravitationalFieldEventData {
  62427. /**
  62428. * A sphere mesh used for the gravitational field event
  62429. */
  62430. sphere: Mesh;
  62431. }
  62432. /**
  62433. * Interface for updraft event data
  62434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62435. */
  62436. export interface PhysicsUpdraftEventData {
  62437. /**
  62438. * A cylinder used for the updraft event
  62439. */
  62440. cylinder: Mesh;
  62441. }
  62442. /**
  62443. * Interface for vortex event data
  62444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62445. */
  62446. export interface PhysicsVortexEventData {
  62447. /**
  62448. * A cylinder used for the vortex event
  62449. */
  62450. cylinder: Mesh;
  62451. }
  62452. /**
  62453. * Interface for an affected physics impostor
  62454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62455. */
  62456. export interface PhysicsAffectedImpostorWithData {
  62457. /**
  62458. * The impostor affected by the effect
  62459. */
  62460. impostor: PhysicsImpostor;
  62461. /**
  62462. * The data about the hit/horce from the explosion
  62463. */
  62464. hitData: PhysicsHitData;
  62465. }
  62466. }
  62467. declare module "babylonjs/Physics/Plugins/index" {
  62468. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62469. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62470. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62471. }
  62472. declare module "babylonjs/Physics/index" {
  62473. export * from "babylonjs/Physics/IPhysicsEngine";
  62474. export * from "babylonjs/Physics/physicsEngine";
  62475. export * from "babylonjs/Physics/physicsEngineComponent";
  62476. export * from "babylonjs/Physics/physicsHelper";
  62477. export * from "babylonjs/Physics/physicsImpostor";
  62478. export * from "babylonjs/Physics/physicsJoint";
  62479. export * from "babylonjs/Physics/Plugins/index";
  62480. }
  62481. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62482. /** @hidden */
  62483. export var blackAndWhitePixelShader: {
  62484. name: string;
  62485. shader: string;
  62486. };
  62487. }
  62488. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62490. import { Camera } from "babylonjs/Cameras/camera";
  62491. import { Engine } from "babylonjs/Engines/engine";
  62492. import "babylonjs/Shaders/blackAndWhite.fragment";
  62493. /**
  62494. * Post process used to render in black and white
  62495. */
  62496. export class BlackAndWhitePostProcess extends PostProcess {
  62497. /**
  62498. * Linear about to convert he result to black and white (default: 1)
  62499. */
  62500. degree: number;
  62501. /**
  62502. * Creates a black and white post process
  62503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62504. * @param name The name of the effect.
  62505. * @param options The required width/height ratio to downsize to before computing the render pass.
  62506. * @param camera The camera to apply the render pass to.
  62507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62508. * @param engine The engine which the post process will be applied. (default: current engine)
  62509. * @param reusable If the post process can be reused on the same frame. (default: false)
  62510. */
  62511. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62512. }
  62513. }
  62514. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62515. import { Nullable } from "babylonjs/types";
  62516. import { Camera } from "babylonjs/Cameras/camera";
  62517. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62518. import { Engine } from "babylonjs/Engines/engine";
  62519. /**
  62520. * This represents a set of one or more post processes in Babylon.
  62521. * A post process can be used to apply a shader to a texture after it is rendered.
  62522. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62523. */
  62524. export class PostProcessRenderEffect {
  62525. private _postProcesses;
  62526. private _getPostProcesses;
  62527. private _singleInstance;
  62528. private _cameras;
  62529. private _indicesForCamera;
  62530. /**
  62531. * Name of the effect
  62532. * @hidden
  62533. */
  62534. _name: string;
  62535. /**
  62536. * Instantiates a post process render effect.
  62537. * A post process can be used to apply a shader to a texture after it is rendered.
  62538. * @param engine The engine the effect is tied to
  62539. * @param name The name of the effect
  62540. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62541. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62542. */
  62543. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62544. /**
  62545. * Checks if all the post processes in the effect are supported.
  62546. */
  62547. readonly isSupported: boolean;
  62548. /**
  62549. * Updates the current state of the effect
  62550. * @hidden
  62551. */
  62552. _update(): void;
  62553. /**
  62554. * Attaches the effect on cameras
  62555. * @param cameras The camera to attach to.
  62556. * @hidden
  62557. */
  62558. _attachCameras(cameras: Camera): void;
  62559. /**
  62560. * Attaches the effect on cameras
  62561. * @param cameras The camera to attach to.
  62562. * @hidden
  62563. */
  62564. _attachCameras(cameras: Camera[]): void;
  62565. /**
  62566. * Detaches the effect on cameras
  62567. * @param cameras The camera to detatch from.
  62568. * @hidden
  62569. */
  62570. _detachCameras(cameras: Camera): void;
  62571. /**
  62572. * Detatches the effect on cameras
  62573. * @param cameras The camera to detatch from.
  62574. * @hidden
  62575. */
  62576. _detachCameras(cameras: Camera[]): void;
  62577. /**
  62578. * Enables the effect on given cameras
  62579. * @param cameras The camera to enable.
  62580. * @hidden
  62581. */
  62582. _enable(cameras: Camera): void;
  62583. /**
  62584. * Enables the effect on given cameras
  62585. * @param cameras The camera to enable.
  62586. * @hidden
  62587. */
  62588. _enable(cameras: Nullable<Camera[]>): void;
  62589. /**
  62590. * Disables the effect on the given cameras
  62591. * @param cameras The camera to disable.
  62592. * @hidden
  62593. */
  62594. _disable(cameras: Camera): void;
  62595. /**
  62596. * Disables the effect on the given cameras
  62597. * @param cameras The camera to disable.
  62598. * @hidden
  62599. */
  62600. _disable(cameras: Nullable<Camera[]>): void;
  62601. /**
  62602. * Gets a list of the post processes contained in the effect.
  62603. * @param camera The camera to get the post processes on.
  62604. * @returns The list of the post processes in the effect.
  62605. */
  62606. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62607. }
  62608. }
  62609. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62611. /** @hidden */
  62612. export var extractHighlightsPixelShader: {
  62613. name: string;
  62614. shader: string;
  62615. };
  62616. }
  62617. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62618. import { Nullable } from "babylonjs/types";
  62619. import { Camera } from "babylonjs/Cameras/camera";
  62620. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62621. import { Engine } from "babylonjs/Engines/engine";
  62622. import "babylonjs/Shaders/extractHighlights.fragment";
  62623. /**
  62624. * 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.
  62625. */
  62626. export class ExtractHighlightsPostProcess extends PostProcess {
  62627. /**
  62628. * The luminance threshold, pixels below this value will be set to black.
  62629. */
  62630. threshold: number;
  62631. /** @hidden */
  62632. _exposure: number;
  62633. /**
  62634. * Post process which has the input texture to be used when performing highlight extraction
  62635. * @hidden
  62636. */
  62637. _inputPostProcess: Nullable<PostProcess>;
  62638. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62639. }
  62640. }
  62641. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62642. /** @hidden */
  62643. export var bloomMergePixelShader: {
  62644. name: string;
  62645. shader: string;
  62646. };
  62647. }
  62648. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62650. import { Nullable } from "babylonjs/types";
  62651. import { Engine } from "babylonjs/Engines/engine";
  62652. import { Camera } from "babylonjs/Cameras/camera";
  62653. import "babylonjs/Shaders/bloomMerge.fragment";
  62654. /**
  62655. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62656. */
  62657. export class BloomMergePostProcess extends PostProcess {
  62658. /** Weight of the bloom to be added to the original input. */
  62659. weight: number;
  62660. /**
  62661. * Creates a new instance of @see BloomMergePostProcess
  62662. * @param name The name of the effect.
  62663. * @param originalFromInput Post process which's input will be used for the merge.
  62664. * @param blurred Blurred highlights post process which's output will be used.
  62665. * @param weight Weight of the bloom to be added to the original input.
  62666. * @param options The required width/height ratio to downsize to before computing the render pass.
  62667. * @param camera The camera to apply the render pass to.
  62668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62669. * @param engine The engine which the post process will be applied. (default: current engine)
  62670. * @param reusable If the post process can be reused on the same frame. (default: false)
  62671. * @param textureType Type of textures used when performing the post process. (default: 0)
  62672. * @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)
  62673. */
  62674. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62675. /** Weight of the bloom to be added to the original input. */
  62676. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62677. }
  62678. }
  62679. declare module "babylonjs/PostProcesses/bloomEffect" {
  62680. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62681. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62682. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62683. import { Camera } from "babylonjs/Cameras/camera";
  62684. import { Scene } from "babylonjs/scene";
  62685. /**
  62686. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62687. */
  62688. export class BloomEffect extends PostProcessRenderEffect {
  62689. private bloomScale;
  62690. /**
  62691. * @hidden Internal
  62692. */
  62693. _effects: Array<PostProcess>;
  62694. /**
  62695. * @hidden Internal
  62696. */
  62697. _downscale: ExtractHighlightsPostProcess;
  62698. private _blurX;
  62699. private _blurY;
  62700. private _merge;
  62701. /**
  62702. * The luminance threshold to find bright areas of the image to bloom.
  62703. */
  62704. threshold: number;
  62705. /**
  62706. * The strength of the bloom.
  62707. */
  62708. weight: number;
  62709. /**
  62710. * Specifies the size of the bloom blur kernel, relative to the final output size
  62711. */
  62712. kernel: number;
  62713. /**
  62714. * Creates a new instance of @see BloomEffect
  62715. * @param scene The scene the effect belongs to.
  62716. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62717. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62718. * @param bloomWeight The the strength of bloom.
  62719. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62720. * @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)
  62721. */
  62722. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62723. /**
  62724. * Disposes each of the internal effects for a given camera.
  62725. * @param camera The camera to dispose the effect on.
  62726. */
  62727. disposeEffects(camera: Camera): void;
  62728. /**
  62729. * @hidden Internal
  62730. */
  62731. _updateEffects(): void;
  62732. /**
  62733. * Internal
  62734. * @returns if all the contained post processes are ready.
  62735. * @hidden
  62736. */
  62737. _isReady(): boolean;
  62738. }
  62739. }
  62740. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62741. /** @hidden */
  62742. export var chromaticAberrationPixelShader: {
  62743. name: string;
  62744. shader: string;
  62745. };
  62746. }
  62747. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62748. import { Vector2 } from "babylonjs/Maths/math.vector";
  62749. import { Nullable } from "babylonjs/types";
  62750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62751. import { Camera } from "babylonjs/Cameras/camera";
  62752. import { Engine } from "babylonjs/Engines/engine";
  62753. import "babylonjs/Shaders/chromaticAberration.fragment";
  62754. /**
  62755. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62756. */
  62757. export class ChromaticAberrationPostProcess extends PostProcess {
  62758. /**
  62759. * The amount of seperation of rgb channels (default: 30)
  62760. */
  62761. aberrationAmount: number;
  62762. /**
  62763. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62764. */
  62765. radialIntensity: number;
  62766. /**
  62767. * 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))
  62768. */
  62769. direction: Vector2;
  62770. /**
  62771. * 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))
  62772. */
  62773. centerPosition: Vector2;
  62774. /**
  62775. * Creates a new instance ChromaticAberrationPostProcess
  62776. * @param name The name of the effect.
  62777. * @param screenWidth The width of the screen to apply the effect on.
  62778. * @param screenHeight The height of the screen to apply the effect on.
  62779. * @param options The required width/height ratio to downsize to before computing the render pass.
  62780. * @param camera The camera to apply the render pass to.
  62781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62782. * @param engine The engine which the post process will be applied. (default: current engine)
  62783. * @param reusable If the post process can be reused on the same frame. (default: false)
  62784. * @param textureType Type of textures used when performing the post process. (default: 0)
  62785. * @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)
  62786. */
  62787. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62788. }
  62789. }
  62790. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62791. /** @hidden */
  62792. export var circleOfConfusionPixelShader: {
  62793. name: string;
  62794. shader: string;
  62795. };
  62796. }
  62797. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62798. import { Nullable } from "babylonjs/types";
  62799. import { Engine } from "babylonjs/Engines/engine";
  62800. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62802. import { Camera } from "babylonjs/Cameras/camera";
  62803. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62804. /**
  62805. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62806. */
  62807. export class CircleOfConfusionPostProcess extends PostProcess {
  62808. /**
  62809. * 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.
  62810. */
  62811. lensSize: number;
  62812. /**
  62813. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62814. */
  62815. fStop: number;
  62816. /**
  62817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62818. */
  62819. focusDistance: number;
  62820. /**
  62821. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62822. */
  62823. focalLength: number;
  62824. private _depthTexture;
  62825. /**
  62826. * Creates a new instance CircleOfConfusionPostProcess
  62827. * @param name The name of the effect.
  62828. * @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.
  62829. * @param options The required width/height ratio to downsize to before computing the render pass.
  62830. * @param camera The camera to apply the render pass to.
  62831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62832. * @param engine The engine which the post process will be applied. (default: current engine)
  62833. * @param reusable If the post process can be reused on the same frame. (default: false)
  62834. * @param textureType Type of textures used when performing the post process. (default: 0)
  62835. * @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)
  62836. */
  62837. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62838. /**
  62839. * 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.
  62840. */
  62841. depthTexture: RenderTargetTexture;
  62842. }
  62843. }
  62844. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62845. /** @hidden */
  62846. export var colorCorrectionPixelShader: {
  62847. name: string;
  62848. shader: string;
  62849. };
  62850. }
  62851. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62852. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62853. import { Engine } from "babylonjs/Engines/engine";
  62854. import { Camera } from "babylonjs/Cameras/camera";
  62855. import "babylonjs/Shaders/colorCorrection.fragment";
  62856. /**
  62857. *
  62858. * This post-process allows the modification of rendered colors by using
  62859. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62860. *
  62861. * The object needs to be provided an url to a texture containing the color
  62862. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62863. * Use an image editing software to tweak the LUT to match your needs.
  62864. *
  62865. * For an example of a color LUT, see here:
  62866. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62867. * For explanations on color grading, see here:
  62868. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62869. *
  62870. */
  62871. export class ColorCorrectionPostProcess extends PostProcess {
  62872. private _colorTableTexture;
  62873. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62874. }
  62875. }
  62876. declare module "babylonjs/Shaders/convolution.fragment" {
  62877. /** @hidden */
  62878. export var convolutionPixelShader: {
  62879. name: string;
  62880. shader: string;
  62881. };
  62882. }
  62883. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62884. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62885. import { Nullable } from "babylonjs/types";
  62886. import { Camera } from "babylonjs/Cameras/camera";
  62887. import { Engine } from "babylonjs/Engines/engine";
  62888. import "babylonjs/Shaders/convolution.fragment";
  62889. /**
  62890. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62891. * input texture to perform effects such as edge detection or sharpening
  62892. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62893. */
  62894. export class ConvolutionPostProcess extends PostProcess {
  62895. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62896. kernel: number[];
  62897. /**
  62898. * Creates a new instance ConvolutionPostProcess
  62899. * @param name The name of the effect.
  62900. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62901. * @param options The required width/height ratio to downsize to before computing the render pass.
  62902. * @param camera The camera to apply the render pass to.
  62903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62904. * @param engine The engine which the post process will be applied. (default: current engine)
  62905. * @param reusable If the post process can be reused on the same frame. (default: false)
  62906. * @param textureType Type of textures used when performing the post process. (default: 0)
  62907. */
  62908. constructor(name: string,
  62909. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62910. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62911. /**
  62912. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62913. */
  62914. static EdgeDetect0Kernel: number[];
  62915. /**
  62916. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62917. */
  62918. static EdgeDetect1Kernel: number[];
  62919. /**
  62920. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62921. */
  62922. static EdgeDetect2Kernel: number[];
  62923. /**
  62924. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62925. */
  62926. static SharpenKernel: number[];
  62927. /**
  62928. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62929. */
  62930. static EmbossKernel: number[];
  62931. /**
  62932. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62933. */
  62934. static GaussianKernel: number[];
  62935. }
  62936. }
  62937. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62938. import { Nullable } from "babylonjs/types";
  62939. import { Vector2 } from "babylonjs/Maths/math.vector";
  62940. import { Camera } from "babylonjs/Cameras/camera";
  62941. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62942. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62943. import { Engine } from "babylonjs/Engines/engine";
  62944. import { Scene } from "babylonjs/scene";
  62945. /**
  62946. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62947. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62948. * based on samples that have a large difference in distance than the center pixel.
  62949. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62950. */
  62951. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62952. direction: Vector2;
  62953. /**
  62954. * Creates a new instance CircleOfConfusionPostProcess
  62955. * @param name The name of the effect.
  62956. * @param scene The scene the effect belongs to.
  62957. * @param direction The direction the blur should be applied.
  62958. * @param kernel The size of the kernel used to blur.
  62959. * @param options The required width/height ratio to downsize to before computing the render pass.
  62960. * @param camera The camera to apply the render pass to.
  62961. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62962. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62964. * @param engine The engine which the post process will be applied. (default: current engine)
  62965. * @param reusable If the post process can be reused on the same frame. (default: false)
  62966. * @param textureType Type of textures used when performing the post process. (default: 0)
  62967. * @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)
  62968. */
  62969. 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);
  62970. }
  62971. }
  62972. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62973. /** @hidden */
  62974. export var depthOfFieldMergePixelShader: {
  62975. name: string;
  62976. shader: string;
  62977. };
  62978. }
  62979. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62980. import { Nullable } from "babylonjs/types";
  62981. import { Camera } from "babylonjs/Cameras/camera";
  62982. import { Effect } from "babylonjs/Materials/effect";
  62983. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62984. import { Engine } from "babylonjs/Engines/engine";
  62985. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62986. /**
  62987. * Options to be set when merging outputs from the default pipeline.
  62988. */
  62989. export class DepthOfFieldMergePostProcessOptions {
  62990. /**
  62991. * The original image to merge on top of
  62992. */
  62993. originalFromInput: PostProcess;
  62994. /**
  62995. * Parameters to perform the merge of the depth of field effect
  62996. */
  62997. depthOfField?: {
  62998. circleOfConfusion: PostProcess;
  62999. blurSteps: Array<PostProcess>;
  63000. };
  63001. /**
  63002. * Parameters to perform the merge of bloom effect
  63003. */
  63004. bloom?: {
  63005. blurred: PostProcess;
  63006. weight: number;
  63007. };
  63008. }
  63009. /**
  63010. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63011. */
  63012. export class DepthOfFieldMergePostProcess extends PostProcess {
  63013. private blurSteps;
  63014. /**
  63015. * Creates a new instance of DepthOfFieldMergePostProcess
  63016. * @param name The name of the effect.
  63017. * @param originalFromInput Post process which's input will be used for the merge.
  63018. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63019. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63020. * @param options The required width/height ratio to downsize to before computing the render pass.
  63021. * @param camera The camera to apply the render pass to.
  63022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63023. * @param engine The engine which the post process will be applied. (default: current engine)
  63024. * @param reusable If the post process can be reused on the same frame. (default: false)
  63025. * @param textureType Type of textures used when performing the post process. (default: 0)
  63026. * @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)
  63027. */
  63028. 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);
  63029. /**
  63030. * Updates the effect with the current post process compile time values and recompiles the shader.
  63031. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63032. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63033. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63034. * @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
  63035. * @param onCompiled Called when the shader has been compiled.
  63036. * @param onError Called if there is an error when compiling a shader.
  63037. */
  63038. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63039. }
  63040. }
  63041. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63042. import { Nullable } from "babylonjs/types";
  63043. import { Camera } from "babylonjs/Cameras/camera";
  63044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63045. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63046. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63047. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63048. import { Scene } from "babylonjs/scene";
  63049. /**
  63050. * Specifies the level of max blur that should be applied when using the depth of field effect
  63051. */
  63052. export enum DepthOfFieldEffectBlurLevel {
  63053. /**
  63054. * Subtle blur
  63055. */
  63056. Low = 0,
  63057. /**
  63058. * Medium blur
  63059. */
  63060. Medium = 1,
  63061. /**
  63062. * Large blur
  63063. */
  63064. High = 2
  63065. }
  63066. /**
  63067. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63068. */
  63069. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63070. private _circleOfConfusion;
  63071. /**
  63072. * @hidden Internal, blurs from high to low
  63073. */
  63074. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63075. private _depthOfFieldBlurY;
  63076. private _dofMerge;
  63077. /**
  63078. * @hidden Internal post processes in depth of field effect
  63079. */
  63080. _effects: Array<PostProcess>;
  63081. /**
  63082. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63083. */
  63084. focalLength: number;
  63085. /**
  63086. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63087. */
  63088. fStop: number;
  63089. /**
  63090. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63091. */
  63092. focusDistance: number;
  63093. /**
  63094. * 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.
  63095. */
  63096. lensSize: number;
  63097. /**
  63098. * Creates a new instance DepthOfFieldEffect
  63099. * @param scene The scene the effect belongs to.
  63100. * @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.
  63101. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63102. * @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)
  63103. */
  63104. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63105. /**
  63106. * Get the current class name of the current effet
  63107. * @returns "DepthOfFieldEffect"
  63108. */
  63109. getClassName(): string;
  63110. /**
  63111. * 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.
  63112. */
  63113. depthTexture: RenderTargetTexture;
  63114. /**
  63115. * Disposes each of the internal effects for a given camera.
  63116. * @param camera The camera to dispose the effect on.
  63117. */
  63118. disposeEffects(camera: Camera): void;
  63119. /**
  63120. * @hidden Internal
  63121. */
  63122. _updateEffects(): void;
  63123. /**
  63124. * Internal
  63125. * @returns if all the contained post processes are ready.
  63126. * @hidden
  63127. */
  63128. _isReady(): boolean;
  63129. }
  63130. }
  63131. declare module "babylonjs/Shaders/displayPass.fragment" {
  63132. /** @hidden */
  63133. export var displayPassPixelShader: {
  63134. name: string;
  63135. shader: string;
  63136. };
  63137. }
  63138. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63139. import { Nullable } from "babylonjs/types";
  63140. import { Camera } from "babylonjs/Cameras/camera";
  63141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63142. import { Engine } from "babylonjs/Engines/engine";
  63143. import "babylonjs/Shaders/displayPass.fragment";
  63144. /**
  63145. * DisplayPassPostProcess which produces an output the same as it's input
  63146. */
  63147. export class DisplayPassPostProcess extends PostProcess {
  63148. /**
  63149. * Creates the DisplayPassPostProcess
  63150. * @param name The name of the effect.
  63151. * @param options The required width/height ratio to downsize to before computing the render pass.
  63152. * @param camera The camera to apply the render pass to.
  63153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63154. * @param engine The engine which the post process will be applied. (default: current engine)
  63155. * @param reusable If the post process can be reused on the same frame. (default: false)
  63156. */
  63157. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63158. }
  63159. }
  63160. declare module "babylonjs/Shaders/filter.fragment" {
  63161. /** @hidden */
  63162. export var filterPixelShader: {
  63163. name: string;
  63164. shader: string;
  63165. };
  63166. }
  63167. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63168. import { Nullable } from "babylonjs/types";
  63169. import { Matrix } from "babylonjs/Maths/math.vector";
  63170. import { Camera } from "babylonjs/Cameras/camera";
  63171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63172. import { Engine } from "babylonjs/Engines/engine";
  63173. import "babylonjs/Shaders/filter.fragment";
  63174. /**
  63175. * Applies a kernel filter to the image
  63176. */
  63177. export class FilterPostProcess extends PostProcess {
  63178. /** The matrix to be applied to the image */
  63179. kernelMatrix: Matrix;
  63180. /**
  63181. *
  63182. * @param name The name of the effect.
  63183. * @param kernelMatrix The matrix to be applied to the image
  63184. * @param options The required width/height ratio to downsize to before computing the render pass.
  63185. * @param camera The camera to apply the render pass to.
  63186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63187. * @param engine The engine which the post process will be applied. (default: current engine)
  63188. * @param reusable If the post process can be reused on the same frame. (default: false)
  63189. */
  63190. constructor(name: string,
  63191. /** The matrix to be applied to the image */
  63192. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63193. }
  63194. }
  63195. declare module "babylonjs/Shaders/fxaa.fragment" {
  63196. /** @hidden */
  63197. export var fxaaPixelShader: {
  63198. name: string;
  63199. shader: string;
  63200. };
  63201. }
  63202. declare module "babylonjs/Shaders/fxaa.vertex" {
  63203. /** @hidden */
  63204. export var fxaaVertexShader: {
  63205. name: string;
  63206. shader: string;
  63207. };
  63208. }
  63209. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63210. import { Nullable } from "babylonjs/types";
  63211. import { Camera } from "babylonjs/Cameras/camera";
  63212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63213. import { Engine } from "babylonjs/Engines/engine";
  63214. import "babylonjs/Shaders/fxaa.fragment";
  63215. import "babylonjs/Shaders/fxaa.vertex";
  63216. /**
  63217. * Fxaa post process
  63218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63219. */
  63220. export class FxaaPostProcess extends PostProcess {
  63221. /** @hidden */
  63222. texelWidth: number;
  63223. /** @hidden */
  63224. texelHeight: number;
  63225. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63226. private _getDefines;
  63227. }
  63228. }
  63229. declare module "babylonjs/Shaders/grain.fragment" {
  63230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63231. /** @hidden */
  63232. export var grainPixelShader: {
  63233. name: string;
  63234. shader: string;
  63235. };
  63236. }
  63237. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63238. import { Nullable } from "babylonjs/types";
  63239. import { Camera } from "babylonjs/Cameras/camera";
  63240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63241. import { Engine } from "babylonjs/Engines/engine";
  63242. import "babylonjs/Shaders/grain.fragment";
  63243. /**
  63244. * The GrainPostProcess adds noise to the image at mid luminance levels
  63245. */
  63246. export class GrainPostProcess extends PostProcess {
  63247. /**
  63248. * The intensity of the grain added (default: 30)
  63249. */
  63250. intensity: number;
  63251. /**
  63252. * If the grain should be randomized on every frame
  63253. */
  63254. animated: boolean;
  63255. /**
  63256. * Creates a new instance of @see GrainPostProcess
  63257. * @param name The name of the effect.
  63258. * @param options The required width/height ratio to downsize to before computing the render pass.
  63259. * @param camera The camera to apply the render pass to.
  63260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63261. * @param engine The engine which the post process will be applied. (default: current engine)
  63262. * @param reusable If the post process can be reused on the same frame. (default: false)
  63263. * @param textureType Type of textures used when performing the post process. (default: 0)
  63264. * @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)
  63265. */
  63266. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63267. }
  63268. }
  63269. declare module "babylonjs/Shaders/highlights.fragment" {
  63270. /** @hidden */
  63271. export var highlightsPixelShader: {
  63272. name: string;
  63273. shader: string;
  63274. };
  63275. }
  63276. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63277. import { Nullable } from "babylonjs/types";
  63278. import { Camera } from "babylonjs/Cameras/camera";
  63279. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63280. import { Engine } from "babylonjs/Engines/engine";
  63281. import "babylonjs/Shaders/highlights.fragment";
  63282. /**
  63283. * Extracts highlights from the image
  63284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63285. */
  63286. export class HighlightsPostProcess extends PostProcess {
  63287. /**
  63288. * Extracts highlights from the image
  63289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63290. * @param name The name of the effect.
  63291. * @param options The required width/height ratio to downsize to before computing the render pass.
  63292. * @param camera The camera to apply the render pass to.
  63293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63294. * @param engine The engine which the post process will be applied. (default: current engine)
  63295. * @param reusable If the post process can be reused on the same frame. (default: false)
  63296. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63297. */
  63298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63299. }
  63300. }
  63301. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63302. /** @hidden */
  63303. export var mrtFragmentDeclaration: {
  63304. name: string;
  63305. shader: string;
  63306. };
  63307. }
  63308. declare module "babylonjs/Shaders/geometry.fragment" {
  63309. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63310. /** @hidden */
  63311. export var geometryPixelShader: {
  63312. name: string;
  63313. shader: string;
  63314. };
  63315. }
  63316. declare module "babylonjs/Shaders/geometry.vertex" {
  63317. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63321. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63322. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63323. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63324. /** @hidden */
  63325. export var geometryVertexShader: {
  63326. name: string;
  63327. shader: string;
  63328. };
  63329. }
  63330. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63331. import { Matrix } from "babylonjs/Maths/math.vector";
  63332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63333. import { Mesh } from "babylonjs/Meshes/mesh";
  63334. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63335. import { Effect } from "babylonjs/Materials/effect";
  63336. import { Scene } from "babylonjs/scene";
  63337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63338. import "babylonjs/Shaders/geometry.fragment";
  63339. import "babylonjs/Shaders/geometry.vertex";
  63340. /** @hidden */
  63341. interface ISavedTransformationMatrix {
  63342. world: Matrix;
  63343. viewProjection: Matrix;
  63344. }
  63345. /**
  63346. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63347. */
  63348. export class GeometryBufferRenderer {
  63349. /**
  63350. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63351. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63352. */
  63353. static readonly POSITION_TEXTURE_TYPE: number;
  63354. /**
  63355. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63356. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63357. */
  63358. static readonly VELOCITY_TEXTURE_TYPE: number;
  63359. /**
  63360. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63361. * in order to compute objects velocities when enableVelocity is set to "true"
  63362. * @hidden
  63363. */
  63364. _previousTransformationMatrices: {
  63365. [index: number]: ISavedTransformationMatrix;
  63366. };
  63367. /**
  63368. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63369. * in order to compute objects velocities when enableVelocity is set to "true"
  63370. * @hidden
  63371. */
  63372. _previousBonesTransformationMatrices: {
  63373. [index: number]: Float32Array;
  63374. };
  63375. /**
  63376. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63377. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63378. */
  63379. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63380. private _scene;
  63381. private _multiRenderTarget;
  63382. private _ratio;
  63383. private _enablePosition;
  63384. private _enableVelocity;
  63385. private _positionIndex;
  63386. private _velocityIndex;
  63387. protected _effect: Effect;
  63388. protected _cachedDefines: string;
  63389. /**
  63390. * Set the render list (meshes to be rendered) used in the G buffer.
  63391. */
  63392. renderList: Mesh[];
  63393. /**
  63394. * Gets wether or not G buffer are supported by the running hardware.
  63395. * This requires draw buffer supports
  63396. */
  63397. readonly isSupported: boolean;
  63398. /**
  63399. * Returns the index of the given texture type in the G-Buffer textures array
  63400. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63401. * @returns the index of the given texture type in the G-Buffer textures array
  63402. */
  63403. getTextureIndex(textureType: number): number;
  63404. /**
  63405. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63406. */
  63407. /**
  63408. * Sets whether or not objects positions are enabled for the G buffer.
  63409. */
  63410. enablePosition: boolean;
  63411. /**
  63412. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63413. */
  63414. /**
  63415. * Sets wether or not objects velocities are enabled for the G buffer.
  63416. */
  63417. enableVelocity: boolean;
  63418. /**
  63419. * Gets the scene associated with the buffer.
  63420. */
  63421. readonly scene: Scene;
  63422. /**
  63423. * Gets the ratio used by the buffer during its creation.
  63424. * How big is the buffer related to the main canvas.
  63425. */
  63426. readonly ratio: number;
  63427. /** @hidden */
  63428. static _SceneComponentInitialization: (scene: Scene) => void;
  63429. /**
  63430. * Creates a new G Buffer for the scene
  63431. * @param scene The scene the buffer belongs to
  63432. * @param ratio How big is the buffer related to the main canvas.
  63433. */
  63434. constructor(scene: Scene, ratio?: number);
  63435. /**
  63436. * Checks wether everything is ready to render a submesh to the G buffer.
  63437. * @param subMesh the submesh to check readiness for
  63438. * @param useInstances is the mesh drawn using instance or not
  63439. * @returns true if ready otherwise false
  63440. */
  63441. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63442. /**
  63443. * Gets the current underlying G Buffer.
  63444. * @returns the buffer
  63445. */
  63446. getGBuffer(): MultiRenderTarget;
  63447. /**
  63448. * Gets the number of samples used to render the buffer (anti aliasing).
  63449. */
  63450. /**
  63451. * Sets the number of samples used to render the buffer (anti aliasing).
  63452. */
  63453. samples: number;
  63454. /**
  63455. * Disposes the renderer and frees up associated resources.
  63456. */
  63457. dispose(): void;
  63458. protected _createRenderTargets(): void;
  63459. private _copyBonesTransformationMatrices;
  63460. }
  63461. }
  63462. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63463. import { Nullable } from "babylonjs/types";
  63464. import { Scene } from "babylonjs/scene";
  63465. import { ISceneComponent } from "babylonjs/sceneComponent";
  63466. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63467. module "babylonjs/scene" {
  63468. interface Scene {
  63469. /** @hidden (Backing field) */
  63470. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63471. /**
  63472. * Gets or Sets the current geometry buffer associated to the scene.
  63473. */
  63474. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63475. /**
  63476. * Enables a GeometryBufferRender and associates it with the scene
  63477. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63478. * @returns the GeometryBufferRenderer
  63479. */
  63480. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63481. /**
  63482. * Disables the GeometryBufferRender associated with the scene
  63483. */
  63484. disableGeometryBufferRenderer(): void;
  63485. }
  63486. }
  63487. /**
  63488. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63489. * in several rendering techniques.
  63490. */
  63491. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63492. /**
  63493. * The component name helpful to identify the component in the list of scene components.
  63494. */
  63495. readonly name: string;
  63496. /**
  63497. * The scene the component belongs to.
  63498. */
  63499. scene: Scene;
  63500. /**
  63501. * Creates a new instance of the component for the given scene
  63502. * @param scene Defines the scene to register the component in
  63503. */
  63504. constructor(scene: Scene);
  63505. /**
  63506. * Registers the component in a given scene
  63507. */
  63508. register(): void;
  63509. /**
  63510. * Rebuilds the elements related to this component in case of
  63511. * context lost for instance.
  63512. */
  63513. rebuild(): void;
  63514. /**
  63515. * Disposes the component and the associated ressources
  63516. */
  63517. dispose(): void;
  63518. private _gatherRenderTargets;
  63519. }
  63520. }
  63521. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63522. /** @hidden */
  63523. export var motionBlurPixelShader: {
  63524. name: string;
  63525. shader: string;
  63526. };
  63527. }
  63528. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63529. import { Nullable } from "babylonjs/types";
  63530. import { Camera } from "babylonjs/Cameras/camera";
  63531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63532. import { Scene } from "babylonjs/scene";
  63533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63534. import "babylonjs/Animations/animatable";
  63535. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63536. import "babylonjs/Shaders/motionBlur.fragment";
  63537. import { Engine } from "babylonjs/Engines/engine";
  63538. /**
  63539. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63540. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63541. * As an example, all you have to do is to create the post-process:
  63542. * var mb = new BABYLON.MotionBlurPostProcess(
  63543. * 'mb', // The name of the effect.
  63544. * scene, // The scene containing the objects to blur according to their velocity.
  63545. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63546. * camera // The camera to apply the render pass to.
  63547. * );
  63548. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63549. */
  63550. export class MotionBlurPostProcess extends PostProcess {
  63551. /**
  63552. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63553. */
  63554. motionStrength: number;
  63555. /**
  63556. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63557. */
  63558. /**
  63559. * Sets the number of iterations to be used for motion blur quality
  63560. */
  63561. motionBlurSamples: number;
  63562. private _motionBlurSamples;
  63563. private _geometryBufferRenderer;
  63564. /**
  63565. * Creates a new instance MotionBlurPostProcess
  63566. * @param name The name of the effect.
  63567. * @param scene The scene containing the objects to blur according to their velocity.
  63568. * @param options The required width/height ratio to downsize to before computing the render pass.
  63569. * @param camera The camera to apply the render pass to.
  63570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63571. * @param engine The engine which the post process will be applied. (default: current engine)
  63572. * @param reusable If the post process can be reused on the same frame. (default: false)
  63573. * @param textureType Type of textures used when performing the post process. (default: 0)
  63574. * @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)
  63575. */
  63576. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63577. /**
  63578. * Excludes the given skinned mesh from computing bones velocities.
  63579. * 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.
  63580. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63581. */
  63582. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63583. /**
  63584. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63585. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63586. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63587. */
  63588. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63589. /**
  63590. * Disposes the post process.
  63591. * @param camera The camera to dispose the post process on.
  63592. */
  63593. dispose(camera?: Camera): void;
  63594. }
  63595. }
  63596. declare module "babylonjs/Shaders/refraction.fragment" {
  63597. /** @hidden */
  63598. export var refractionPixelShader: {
  63599. name: string;
  63600. shader: string;
  63601. };
  63602. }
  63603. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63604. import { Color3 } from "babylonjs/Maths/math.color";
  63605. import { Camera } from "babylonjs/Cameras/camera";
  63606. import { Texture } from "babylonjs/Materials/Textures/texture";
  63607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63608. import { Engine } from "babylonjs/Engines/engine";
  63609. import "babylonjs/Shaders/refraction.fragment";
  63610. /**
  63611. * Post process which applies a refractin texture
  63612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63613. */
  63614. export class RefractionPostProcess extends PostProcess {
  63615. /** the base color of the refraction (used to taint the rendering) */
  63616. color: Color3;
  63617. /** simulated refraction depth */
  63618. depth: number;
  63619. /** the coefficient of the base color (0 to remove base color tainting) */
  63620. colorLevel: number;
  63621. private _refTexture;
  63622. private _ownRefractionTexture;
  63623. /**
  63624. * Gets or sets the refraction texture
  63625. * Please note that you are responsible for disposing the texture if you set it manually
  63626. */
  63627. refractionTexture: Texture;
  63628. /**
  63629. * Initializes the RefractionPostProcess
  63630. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63631. * @param name The name of the effect.
  63632. * @param refractionTextureUrl Url of the refraction texture to use
  63633. * @param color the base color of the refraction (used to taint the rendering)
  63634. * @param depth simulated refraction depth
  63635. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63636. * @param camera The camera to apply the render pass to.
  63637. * @param options The required width/height ratio to downsize to before computing the render pass.
  63638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63639. * @param engine The engine which the post process will be applied. (default: current engine)
  63640. * @param reusable If the post process can be reused on the same frame. (default: false)
  63641. */
  63642. constructor(name: string, refractionTextureUrl: string,
  63643. /** the base color of the refraction (used to taint the rendering) */
  63644. color: Color3,
  63645. /** simulated refraction depth */
  63646. depth: number,
  63647. /** the coefficient of the base color (0 to remove base color tainting) */
  63648. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63649. /**
  63650. * Disposes of the post process
  63651. * @param camera Camera to dispose post process on
  63652. */
  63653. dispose(camera: Camera): void;
  63654. }
  63655. }
  63656. declare module "babylonjs/Shaders/sharpen.fragment" {
  63657. /** @hidden */
  63658. export var sharpenPixelShader: {
  63659. name: string;
  63660. shader: string;
  63661. };
  63662. }
  63663. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63664. import { Nullable } from "babylonjs/types";
  63665. import { Camera } from "babylonjs/Cameras/camera";
  63666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63667. import "babylonjs/Shaders/sharpen.fragment";
  63668. import { Engine } from "babylonjs/Engines/engine";
  63669. /**
  63670. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63671. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63672. */
  63673. export class SharpenPostProcess extends PostProcess {
  63674. /**
  63675. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63676. */
  63677. colorAmount: number;
  63678. /**
  63679. * How much sharpness should be applied (default: 0.3)
  63680. */
  63681. edgeAmount: number;
  63682. /**
  63683. * Creates a new instance ConvolutionPostProcess
  63684. * @param name The name of the effect.
  63685. * @param options The required width/height ratio to downsize to before computing the render pass.
  63686. * @param camera The camera to apply the render pass to.
  63687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63688. * @param engine The engine which the post process will be applied. (default: current engine)
  63689. * @param reusable If the post process can be reused on the same frame. (default: false)
  63690. * @param textureType Type of textures used when performing the post process. (default: 0)
  63691. * @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)
  63692. */
  63693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63694. }
  63695. }
  63696. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63697. import { Nullable } from "babylonjs/types";
  63698. import { Camera } from "babylonjs/Cameras/camera";
  63699. import { Engine } from "babylonjs/Engines/engine";
  63700. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63701. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63702. /**
  63703. * PostProcessRenderPipeline
  63704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63705. */
  63706. export class PostProcessRenderPipeline {
  63707. private engine;
  63708. private _renderEffects;
  63709. private _renderEffectsForIsolatedPass;
  63710. /**
  63711. * List of inspectable custom properties (used by the Inspector)
  63712. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63713. */
  63714. inspectableCustomProperties: IInspectable[];
  63715. /**
  63716. * @hidden
  63717. */
  63718. protected _cameras: Camera[];
  63719. /** @hidden */
  63720. _name: string;
  63721. /**
  63722. * Gets pipeline name
  63723. */
  63724. readonly name: string;
  63725. /**
  63726. * Initializes a PostProcessRenderPipeline
  63727. * @param engine engine to add the pipeline to
  63728. * @param name name of the pipeline
  63729. */
  63730. constructor(engine: Engine, name: string);
  63731. /**
  63732. * Gets the class name
  63733. * @returns "PostProcessRenderPipeline"
  63734. */
  63735. getClassName(): string;
  63736. /**
  63737. * If all the render effects in the pipeline are supported
  63738. */
  63739. readonly isSupported: boolean;
  63740. /**
  63741. * Adds an effect to the pipeline
  63742. * @param renderEffect the effect to add
  63743. */
  63744. addEffect(renderEffect: PostProcessRenderEffect): void;
  63745. /** @hidden */
  63746. _rebuild(): void;
  63747. /** @hidden */
  63748. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63749. /** @hidden */
  63750. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63751. /** @hidden */
  63752. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63753. /** @hidden */
  63754. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63755. /** @hidden */
  63756. _attachCameras(cameras: Camera, unique: boolean): void;
  63757. /** @hidden */
  63758. _attachCameras(cameras: Camera[], unique: boolean): void;
  63759. /** @hidden */
  63760. _detachCameras(cameras: Camera): void;
  63761. /** @hidden */
  63762. _detachCameras(cameras: Nullable<Camera[]>): void;
  63763. /** @hidden */
  63764. _update(): void;
  63765. /** @hidden */
  63766. _reset(): void;
  63767. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63768. /**
  63769. * Disposes of the pipeline
  63770. */
  63771. dispose(): void;
  63772. }
  63773. }
  63774. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63775. import { Camera } from "babylonjs/Cameras/camera";
  63776. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63777. /**
  63778. * PostProcessRenderPipelineManager class
  63779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63780. */
  63781. export class PostProcessRenderPipelineManager {
  63782. private _renderPipelines;
  63783. /**
  63784. * Initializes a PostProcessRenderPipelineManager
  63785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63786. */
  63787. constructor();
  63788. /**
  63789. * Gets the list of supported render pipelines
  63790. */
  63791. readonly supportedPipelines: PostProcessRenderPipeline[];
  63792. /**
  63793. * Adds a pipeline to the manager
  63794. * @param renderPipeline The pipeline to add
  63795. */
  63796. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63797. /**
  63798. * Attaches a camera to the pipeline
  63799. * @param renderPipelineName The name of the pipeline to attach to
  63800. * @param cameras the camera to attach
  63801. * @param unique if the camera can be attached multiple times to the pipeline
  63802. */
  63803. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63804. /**
  63805. * Detaches a camera from the pipeline
  63806. * @param renderPipelineName The name of the pipeline to detach from
  63807. * @param cameras the camera to detach
  63808. */
  63809. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63810. /**
  63811. * Enables an effect by name on a pipeline
  63812. * @param renderPipelineName the name of the pipeline to enable the effect in
  63813. * @param renderEffectName the name of the effect to enable
  63814. * @param cameras the cameras that the effect should be enabled on
  63815. */
  63816. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63817. /**
  63818. * Disables an effect by name on a pipeline
  63819. * @param renderPipelineName the name of the pipeline to disable the effect in
  63820. * @param renderEffectName the name of the effect to disable
  63821. * @param cameras the cameras that the effect should be disabled on
  63822. */
  63823. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63824. /**
  63825. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63826. */
  63827. update(): void;
  63828. /** @hidden */
  63829. _rebuild(): void;
  63830. /**
  63831. * Disposes of the manager and pipelines
  63832. */
  63833. dispose(): void;
  63834. }
  63835. }
  63836. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63837. import { ISceneComponent } from "babylonjs/sceneComponent";
  63838. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63839. import { Scene } from "babylonjs/scene";
  63840. module "babylonjs/scene" {
  63841. interface Scene {
  63842. /** @hidden (Backing field) */
  63843. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63844. /**
  63845. * Gets the postprocess render pipeline manager
  63846. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63847. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63848. */
  63849. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63850. }
  63851. }
  63852. /**
  63853. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63854. */
  63855. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63856. /**
  63857. * The component name helpfull to identify the component in the list of scene components.
  63858. */
  63859. readonly name: string;
  63860. /**
  63861. * The scene the component belongs to.
  63862. */
  63863. scene: Scene;
  63864. /**
  63865. * Creates a new instance of the component for the given scene
  63866. * @param scene Defines the scene to register the component in
  63867. */
  63868. constructor(scene: Scene);
  63869. /**
  63870. * Registers the component in a given scene
  63871. */
  63872. register(): void;
  63873. /**
  63874. * Rebuilds the elements related to this component in case of
  63875. * context lost for instance.
  63876. */
  63877. rebuild(): void;
  63878. /**
  63879. * Disposes the component and the associated ressources
  63880. */
  63881. dispose(): void;
  63882. private _gatherRenderTargets;
  63883. }
  63884. }
  63885. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63886. import { Nullable } from "babylonjs/types";
  63887. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63888. import { Camera } from "babylonjs/Cameras/camera";
  63889. import { IDisposable } from "babylonjs/scene";
  63890. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63891. import { Scene } from "babylonjs/scene";
  63892. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63893. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63894. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63895. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63896. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63898. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63899. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63900. import { Animation } from "babylonjs/Animations/animation";
  63901. /**
  63902. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63903. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63904. */
  63905. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63906. private _scene;
  63907. private _camerasToBeAttached;
  63908. /**
  63909. * ID of the sharpen post process,
  63910. */
  63911. private readonly SharpenPostProcessId;
  63912. /**
  63913. * @ignore
  63914. * ID of the image processing post process;
  63915. */
  63916. readonly ImageProcessingPostProcessId: string;
  63917. /**
  63918. * @ignore
  63919. * ID of the Fast Approximate Anti-Aliasing post process;
  63920. */
  63921. readonly FxaaPostProcessId: string;
  63922. /**
  63923. * ID of the chromatic aberration post process,
  63924. */
  63925. private readonly ChromaticAberrationPostProcessId;
  63926. /**
  63927. * ID of the grain post process
  63928. */
  63929. private readonly GrainPostProcessId;
  63930. /**
  63931. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63932. */
  63933. sharpen: SharpenPostProcess;
  63934. private _sharpenEffect;
  63935. private bloom;
  63936. /**
  63937. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63938. */
  63939. depthOfField: DepthOfFieldEffect;
  63940. /**
  63941. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63942. */
  63943. fxaa: FxaaPostProcess;
  63944. /**
  63945. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63946. */
  63947. imageProcessing: ImageProcessingPostProcess;
  63948. /**
  63949. * Chromatic aberration post process which will shift rgb colors in the image
  63950. */
  63951. chromaticAberration: ChromaticAberrationPostProcess;
  63952. private _chromaticAberrationEffect;
  63953. /**
  63954. * Grain post process which add noise to the image
  63955. */
  63956. grain: GrainPostProcess;
  63957. private _grainEffect;
  63958. /**
  63959. * Glow post process which adds a glow to emissive areas of the image
  63960. */
  63961. private _glowLayer;
  63962. /**
  63963. * Animations which can be used to tweak settings over a period of time
  63964. */
  63965. animations: Animation[];
  63966. private _imageProcessingConfigurationObserver;
  63967. private _sharpenEnabled;
  63968. private _bloomEnabled;
  63969. private _depthOfFieldEnabled;
  63970. private _depthOfFieldBlurLevel;
  63971. private _fxaaEnabled;
  63972. private _imageProcessingEnabled;
  63973. private _defaultPipelineTextureType;
  63974. private _bloomScale;
  63975. private _chromaticAberrationEnabled;
  63976. private _grainEnabled;
  63977. private _buildAllowed;
  63978. /**
  63979. * Gets active scene
  63980. */
  63981. readonly scene: Scene;
  63982. /**
  63983. * Enable or disable the sharpen process from the pipeline
  63984. */
  63985. sharpenEnabled: boolean;
  63986. private _resizeObserver;
  63987. private _hardwareScaleLevel;
  63988. private _bloomKernel;
  63989. /**
  63990. * Specifies the size of the bloom blur kernel, relative to the final output size
  63991. */
  63992. bloomKernel: number;
  63993. /**
  63994. * Specifies the weight of the bloom in the final rendering
  63995. */
  63996. private _bloomWeight;
  63997. /**
  63998. * Specifies the luma threshold for the area that will be blurred by the bloom
  63999. */
  64000. private _bloomThreshold;
  64001. private _hdr;
  64002. /**
  64003. * The strength of the bloom.
  64004. */
  64005. bloomWeight: number;
  64006. /**
  64007. * The strength of the bloom.
  64008. */
  64009. bloomThreshold: number;
  64010. /**
  64011. * The scale of the bloom, lower value will provide better performance.
  64012. */
  64013. bloomScale: number;
  64014. /**
  64015. * Enable or disable the bloom from the pipeline
  64016. */
  64017. bloomEnabled: boolean;
  64018. private _rebuildBloom;
  64019. /**
  64020. * If the depth of field is enabled.
  64021. */
  64022. depthOfFieldEnabled: boolean;
  64023. /**
  64024. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64025. */
  64026. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64027. /**
  64028. * If the anti aliasing is enabled.
  64029. */
  64030. fxaaEnabled: boolean;
  64031. private _samples;
  64032. /**
  64033. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64034. */
  64035. samples: number;
  64036. /**
  64037. * If image processing is enabled.
  64038. */
  64039. imageProcessingEnabled: boolean;
  64040. /**
  64041. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64042. */
  64043. glowLayerEnabled: boolean;
  64044. /**
  64045. * Gets the glow layer (or null if not defined)
  64046. */
  64047. readonly glowLayer: Nullable<GlowLayer>;
  64048. /**
  64049. * Enable or disable the chromaticAberration process from the pipeline
  64050. */
  64051. chromaticAberrationEnabled: boolean;
  64052. /**
  64053. * Enable or disable the grain process from the pipeline
  64054. */
  64055. grainEnabled: boolean;
  64056. /**
  64057. * @constructor
  64058. * @param name - The rendering pipeline name (default: "")
  64059. * @param hdr - If high dynamic range textures should be used (default: true)
  64060. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64061. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64062. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64063. */
  64064. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64065. /**
  64066. * Get the class name
  64067. * @returns "DefaultRenderingPipeline"
  64068. */
  64069. getClassName(): string;
  64070. /**
  64071. * Force the compilation of the entire pipeline.
  64072. */
  64073. prepare(): void;
  64074. private _hasCleared;
  64075. private _prevPostProcess;
  64076. private _prevPrevPostProcess;
  64077. private _setAutoClearAndTextureSharing;
  64078. private _depthOfFieldSceneObserver;
  64079. private _buildPipeline;
  64080. private _disposePostProcesses;
  64081. /**
  64082. * Adds a camera to the pipeline
  64083. * @param camera the camera to be added
  64084. */
  64085. addCamera(camera: Camera): void;
  64086. /**
  64087. * Removes a camera from the pipeline
  64088. * @param camera the camera to remove
  64089. */
  64090. removeCamera(camera: Camera): void;
  64091. /**
  64092. * Dispose of the pipeline and stop all post processes
  64093. */
  64094. dispose(): void;
  64095. /**
  64096. * Serialize the rendering pipeline (Used when exporting)
  64097. * @returns the serialized object
  64098. */
  64099. serialize(): any;
  64100. /**
  64101. * Parse the serialized pipeline
  64102. * @param source Source pipeline.
  64103. * @param scene The scene to load the pipeline to.
  64104. * @param rootUrl The URL of the serialized pipeline.
  64105. * @returns An instantiated pipeline from the serialized object.
  64106. */
  64107. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64108. }
  64109. }
  64110. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64111. /** @hidden */
  64112. export var lensHighlightsPixelShader: {
  64113. name: string;
  64114. shader: string;
  64115. };
  64116. }
  64117. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64118. /** @hidden */
  64119. export var depthOfFieldPixelShader: {
  64120. name: string;
  64121. shader: string;
  64122. };
  64123. }
  64124. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64125. import { Camera } from "babylonjs/Cameras/camera";
  64126. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64127. import { Scene } from "babylonjs/scene";
  64128. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64129. import "babylonjs/Shaders/chromaticAberration.fragment";
  64130. import "babylonjs/Shaders/lensHighlights.fragment";
  64131. import "babylonjs/Shaders/depthOfField.fragment";
  64132. /**
  64133. * BABYLON.JS Chromatic Aberration GLSL Shader
  64134. * Author: Olivier Guyot
  64135. * Separates very slightly R, G and B colors on the edges of the screen
  64136. * Inspired by Francois Tarlier & Martins Upitis
  64137. */
  64138. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64139. /**
  64140. * @ignore
  64141. * The chromatic aberration PostProcess id in the pipeline
  64142. */
  64143. LensChromaticAberrationEffect: string;
  64144. /**
  64145. * @ignore
  64146. * The highlights enhancing PostProcess id in the pipeline
  64147. */
  64148. HighlightsEnhancingEffect: string;
  64149. /**
  64150. * @ignore
  64151. * The depth-of-field PostProcess id in the pipeline
  64152. */
  64153. LensDepthOfFieldEffect: string;
  64154. private _scene;
  64155. private _depthTexture;
  64156. private _grainTexture;
  64157. private _chromaticAberrationPostProcess;
  64158. private _highlightsPostProcess;
  64159. private _depthOfFieldPostProcess;
  64160. private _edgeBlur;
  64161. private _grainAmount;
  64162. private _chromaticAberration;
  64163. private _distortion;
  64164. private _highlightsGain;
  64165. private _highlightsThreshold;
  64166. private _dofDistance;
  64167. private _dofAperture;
  64168. private _dofDarken;
  64169. private _dofPentagon;
  64170. private _blurNoise;
  64171. /**
  64172. * @constructor
  64173. *
  64174. * Effect parameters are as follow:
  64175. * {
  64176. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64177. * edge_blur: number; // from 0 to x (1 for realism)
  64178. * distortion: number; // from 0 to x (1 for realism)
  64179. * grain_amount: number; // from 0 to 1
  64180. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64181. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64182. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64183. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64184. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64185. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64186. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64187. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64188. * }
  64189. * Note: if an effect parameter is unset, effect is disabled
  64190. *
  64191. * @param name The rendering pipeline name
  64192. * @param parameters - An object containing all parameters (see above)
  64193. * @param scene The scene linked to this pipeline
  64194. * @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)
  64195. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64196. */
  64197. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64198. /**
  64199. * Get the class name
  64200. * @returns "LensRenderingPipeline"
  64201. */
  64202. getClassName(): string;
  64203. /**
  64204. * Gets associated scene
  64205. */
  64206. readonly scene: Scene;
  64207. /**
  64208. * Gets or sets the edge blur
  64209. */
  64210. edgeBlur: number;
  64211. /**
  64212. * Gets or sets the grain amount
  64213. */
  64214. grainAmount: number;
  64215. /**
  64216. * Gets or sets the chromatic aberration amount
  64217. */
  64218. chromaticAberration: number;
  64219. /**
  64220. * Gets or sets the depth of field aperture
  64221. */
  64222. dofAperture: number;
  64223. /**
  64224. * Gets or sets the edge distortion
  64225. */
  64226. edgeDistortion: number;
  64227. /**
  64228. * Gets or sets the depth of field distortion
  64229. */
  64230. dofDistortion: number;
  64231. /**
  64232. * Gets or sets the darken out of focus amount
  64233. */
  64234. darkenOutOfFocus: number;
  64235. /**
  64236. * Gets or sets a boolean indicating if blur noise is enabled
  64237. */
  64238. blurNoise: boolean;
  64239. /**
  64240. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64241. */
  64242. pentagonBokeh: boolean;
  64243. /**
  64244. * Gets or sets the highlight grain amount
  64245. */
  64246. highlightsGain: number;
  64247. /**
  64248. * Gets or sets the highlight threshold
  64249. */
  64250. highlightsThreshold: number;
  64251. /**
  64252. * Sets the amount of blur at the edges
  64253. * @param amount blur amount
  64254. */
  64255. setEdgeBlur(amount: number): void;
  64256. /**
  64257. * Sets edge blur to 0
  64258. */
  64259. disableEdgeBlur(): void;
  64260. /**
  64261. * Sets the amout of grain
  64262. * @param amount Amount of grain
  64263. */
  64264. setGrainAmount(amount: number): void;
  64265. /**
  64266. * Set grain amount to 0
  64267. */
  64268. disableGrain(): void;
  64269. /**
  64270. * Sets the chromatic aberration amount
  64271. * @param amount amount of chromatic aberration
  64272. */
  64273. setChromaticAberration(amount: number): void;
  64274. /**
  64275. * Sets chromatic aberration amount to 0
  64276. */
  64277. disableChromaticAberration(): void;
  64278. /**
  64279. * Sets the EdgeDistortion amount
  64280. * @param amount amount of EdgeDistortion
  64281. */
  64282. setEdgeDistortion(amount: number): void;
  64283. /**
  64284. * Sets edge distortion to 0
  64285. */
  64286. disableEdgeDistortion(): void;
  64287. /**
  64288. * Sets the FocusDistance amount
  64289. * @param amount amount of FocusDistance
  64290. */
  64291. setFocusDistance(amount: number): void;
  64292. /**
  64293. * Disables depth of field
  64294. */
  64295. disableDepthOfField(): void;
  64296. /**
  64297. * Sets the Aperture amount
  64298. * @param amount amount of Aperture
  64299. */
  64300. setAperture(amount: number): void;
  64301. /**
  64302. * Sets the DarkenOutOfFocus amount
  64303. * @param amount amount of DarkenOutOfFocus
  64304. */
  64305. setDarkenOutOfFocus(amount: number): void;
  64306. private _pentagonBokehIsEnabled;
  64307. /**
  64308. * Creates a pentagon bokeh effect
  64309. */
  64310. enablePentagonBokeh(): void;
  64311. /**
  64312. * Disables the pentagon bokeh effect
  64313. */
  64314. disablePentagonBokeh(): void;
  64315. /**
  64316. * Enables noise blur
  64317. */
  64318. enableNoiseBlur(): void;
  64319. /**
  64320. * Disables noise blur
  64321. */
  64322. disableNoiseBlur(): void;
  64323. /**
  64324. * Sets the HighlightsGain amount
  64325. * @param amount amount of HighlightsGain
  64326. */
  64327. setHighlightsGain(amount: number): void;
  64328. /**
  64329. * Sets the HighlightsThreshold amount
  64330. * @param amount amount of HighlightsThreshold
  64331. */
  64332. setHighlightsThreshold(amount: number): void;
  64333. /**
  64334. * Disables highlights
  64335. */
  64336. disableHighlights(): void;
  64337. /**
  64338. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64339. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64340. */
  64341. dispose(disableDepthRender?: boolean): void;
  64342. private _createChromaticAberrationPostProcess;
  64343. private _createHighlightsPostProcess;
  64344. private _createDepthOfFieldPostProcess;
  64345. private _createGrainTexture;
  64346. }
  64347. }
  64348. declare module "babylonjs/Shaders/ssao2.fragment" {
  64349. /** @hidden */
  64350. export var ssao2PixelShader: {
  64351. name: string;
  64352. shader: string;
  64353. };
  64354. }
  64355. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64356. /** @hidden */
  64357. export var ssaoCombinePixelShader: {
  64358. name: string;
  64359. shader: string;
  64360. };
  64361. }
  64362. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64363. import { Camera } from "babylonjs/Cameras/camera";
  64364. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64365. import { Scene } from "babylonjs/scene";
  64366. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64367. import "babylonjs/Shaders/ssao2.fragment";
  64368. import "babylonjs/Shaders/ssaoCombine.fragment";
  64369. /**
  64370. * Render pipeline to produce ssao effect
  64371. */
  64372. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64373. /**
  64374. * @ignore
  64375. * The PassPostProcess id in the pipeline that contains the original scene color
  64376. */
  64377. SSAOOriginalSceneColorEffect: string;
  64378. /**
  64379. * @ignore
  64380. * The SSAO PostProcess id in the pipeline
  64381. */
  64382. SSAORenderEffect: string;
  64383. /**
  64384. * @ignore
  64385. * The horizontal blur PostProcess id in the pipeline
  64386. */
  64387. SSAOBlurHRenderEffect: string;
  64388. /**
  64389. * @ignore
  64390. * The vertical blur PostProcess id in the pipeline
  64391. */
  64392. SSAOBlurVRenderEffect: string;
  64393. /**
  64394. * @ignore
  64395. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64396. */
  64397. SSAOCombineRenderEffect: string;
  64398. /**
  64399. * The output strength of the SSAO post-process. Default value is 1.0.
  64400. */
  64401. totalStrength: number;
  64402. /**
  64403. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64404. */
  64405. maxZ: number;
  64406. /**
  64407. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64408. */
  64409. minZAspect: number;
  64410. private _samples;
  64411. /**
  64412. * Number of samples used for the SSAO calculations. Default value is 8
  64413. */
  64414. samples: number;
  64415. private _textureSamples;
  64416. /**
  64417. * Number of samples to use for antialiasing
  64418. */
  64419. textureSamples: number;
  64420. /**
  64421. * Ratio object used for SSAO ratio and blur ratio
  64422. */
  64423. private _ratio;
  64424. /**
  64425. * Dynamically generated sphere sampler.
  64426. */
  64427. private _sampleSphere;
  64428. /**
  64429. * Blur filter offsets
  64430. */
  64431. private _samplerOffsets;
  64432. private _expensiveBlur;
  64433. /**
  64434. * If bilateral blur should be used
  64435. */
  64436. expensiveBlur: boolean;
  64437. /**
  64438. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64439. */
  64440. radius: number;
  64441. /**
  64442. * The base color of the SSAO post-process
  64443. * The final result is "base + ssao" between [0, 1]
  64444. */
  64445. base: number;
  64446. /**
  64447. * Support test.
  64448. */
  64449. static readonly IsSupported: boolean;
  64450. private _scene;
  64451. private _depthTexture;
  64452. private _normalTexture;
  64453. private _randomTexture;
  64454. private _originalColorPostProcess;
  64455. private _ssaoPostProcess;
  64456. private _blurHPostProcess;
  64457. private _blurVPostProcess;
  64458. private _ssaoCombinePostProcess;
  64459. private _firstUpdate;
  64460. /**
  64461. * Gets active scene
  64462. */
  64463. readonly scene: Scene;
  64464. /**
  64465. * @constructor
  64466. * @param name The rendering pipeline name
  64467. * @param scene The scene linked to this pipeline
  64468. * @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 }
  64469. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64470. */
  64471. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64472. /**
  64473. * Get the class name
  64474. * @returns "SSAO2RenderingPipeline"
  64475. */
  64476. getClassName(): string;
  64477. /**
  64478. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64479. */
  64480. dispose(disableGeometryBufferRenderer?: boolean): void;
  64481. private _createBlurPostProcess;
  64482. /** @hidden */
  64483. _rebuild(): void;
  64484. private _bits;
  64485. private _radicalInverse_VdC;
  64486. private _hammersley;
  64487. private _hemisphereSample_uniform;
  64488. private _generateHemisphere;
  64489. private _createSSAOPostProcess;
  64490. private _createSSAOCombinePostProcess;
  64491. private _createRandomTexture;
  64492. /**
  64493. * Serialize the rendering pipeline (Used when exporting)
  64494. * @returns the serialized object
  64495. */
  64496. serialize(): any;
  64497. /**
  64498. * Parse the serialized pipeline
  64499. * @param source Source pipeline.
  64500. * @param scene The scene to load the pipeline to.
  64501. * @param rootUrl The URL of the serialized pipeline.
  64502. * @returns An instantiated pipeline from the serialized object.
  64503. */
  64504. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64505. }
  64506. }
  64507. declare module "babylonjs/Shaders/ssao.fragment" {
  64508. /** @hidden */
  64509. export var ssaoPixelShader: {
  64510. name: string;
  64511. shader: string;
  64512. };
  64513. }
  64514. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64515. import { Camera } from "babylonjs/Cameras/camera";
  64516. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64517. import { Scene } from "babylonjs/scene";
  64518. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64519. import "babylonjs/Shaders/ssao.fragment";
  64520. import "babylonjs/Shaders/ssaoCombine.fragment";
  64521. /**
  64522. * Render pipeline to produce ssao effect
  64523. */
  64524. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64525. /**
  64526. * @ignore
  64527. * The PassPostProcess id in the pipeline that contains the original scene color
  64528. */
  64529. SSAOOriginalSceneColorEffect: string;
  64530. /**
  64531. * @ignore
  64532. * The SSAO PostProcess id in the pipeline
  64533. */
  64534. SSAORenderEffect: string;
  64535. /**
  64536. * @ignore
  64537. * The horizontal blur PostProcess id in the pipeline
  64538. */
  64539. SSAOBlurHRenderEffect: string;
  64540. /**
  64541. * @ignore
  64542. * The vertical blur PostProcess id in the pipeline
  64543. */
  64544. SSAOBlurVRenderEffect: string;
  64545. /**
  64546. * @ignore
  64547. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64548. */
  64549. SSAOCombineRenderEffect: string;
  64550. /**
  64551. * The output strength of the SSAO post-process. Default value is 1.0.
  64552. */
  64553. totalStrength: number;
  64554. /**
  64555. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64556. */
  64557. radius: number;
  64558. /**
  64559. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64560. * Must not be equal to fallOff and superior to fallOff.
  64561. * Default value is 0.0075
  64562. */
  64563. area: number;
  64564. /**
  64565. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64566. * Must not be equal to area and inferior to area.
  64567. * Default value is 0.000001
  64568. */
  64569. fallOff: number;
  64570. /**
  64571. * The base color of the SSAO post-process
  64572. * The final result is "base + ssao" between [0, 1]
  64573. */
  64574. base: number;
  64575. private _scene;
  64576. private _depthTexture;
  64577. private _randomTexture;
  64578. private _originalColorPostProcess;
  64579. private _ssaoPostProcess;
  64580. private _blurHPostProcess;
  64581. private _blurVPostProcess;
  64582. private _ssaoCombinePostProcess;
  64583. private _firstUpdate;
  64584. /**
  64585. * Gets active scene
  64586. */
  64587. readonly scene: Scene;
  64588. /**
  64589. * @constructor
  64590. * @param name - The rendering pipeline name
  64591. * @param scene - The scene linked to this pipeline
  64592. * @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 }
  64593. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64594. */
  64595. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64596. /**
  64597. * Get the class name
  64598. * @returns "SSAORenderingPipeline"
  64599. */
  64600. getClassName(): string;
  64601. /**
  64602. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64603. */
  64604. dispose(disableDepthRender?: boolean): void;
  64605. private _createBlurPostProcess;
  64606. /** @hidden */
  64607. _rebuild(): void;
  64608. private _createSSAOPostProcess;
  64609. private _createSSAOCombinePostProcess;
  64610. private _createRandomTexture;
  64611. }
  64612. }
  64613. declare module "babylonjs/Shaders/standard.fragment" {
  64614. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64615. /** @hidden */
  64616. export var standardPixelShader: {
  64617. name: string;
  64618. shader: string;
  64619. };
  64620. }
  64621. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64622. import { Nullable } from "babylonjs/types";
  64623. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64624. import { Camera } from "babylonjs/Cameras/camera";
  64625. import { Texture } from "babylonjs/Materials/Textures/texture";
  64626. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64627. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64628. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64629. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64630. import { IDisposable } from "babylonjs/scene";
  64631. import { SpotLight } from "babylonjs/Lights/spotLight";
  64632. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64633. import { Scene } from "babylonjs/scene";
  64634. import { Animation } from "babylonjs/Animations/animation";
  64635. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64636. import "babylonjs/Shaders/standard.fragment";
  64637. /**
  64638. * Standard rendering pipeline
  64639. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64640. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64641. */
  64642. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64643. /**
  64644. * Public members
  64645. */
  64646. /**
  64647. * Post-process which contains the original scene color before the pipeline applies all the effects
  64648. */
  64649. originalPostProcess: Nullable<PostProcess>;
  64650. /**
  64651. * Post-process used to down scale an image x4
  64652. */
  64653. downSampleX4PostProcess: Nullable<PostProcess>;
  64654. /**
  64655. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64656. */
  64657. brightPassPostProcess: Nullable<PostProcess>;
  64658. /**
  64659. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64660. */
  64661. blurHPostProcesses: PostProcess[];
  64662. /**
  64663. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64664. */
  64665. blurVPostProcesses: PostProcess[];
  64666. /**
  64667. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64668. */
  64669. textureAdderPostProcess: Nullable<PostProcess>;
  64670. /**
  64671. * Post-process used to create volumetric lighting effect
  64672. */
  64673. volumetricLightPostProcess: Nullable<PostProcess>;
  64674. /**
  64675. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64676. */
  64677. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64678. /**
  64679. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64680. */
  64681. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64682. /**
  64683. * Post-process used to merge the volumetric light effect and the real scene color
  64684. */
  64685. volumetricLightMergePostProces: Nullable<PostProcess>;
  64686. /**
  64687. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64688. */
  64689. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64690. /**
  64691. * Base post-process used to calculate the average luminance of the final image for HDR
  64692. */
  64693. luminancePostProcess: Nullable<PostProcess>;
  64694. /**
  64695. * Post-processes used to create down sample post-processes in order to get
  64696. * the average luminance of the final image for HDR
  64697. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64698. */
  64699. luminanceDownSamplePostProcesses: PostProcess[];
  64700. /**
  64701. * Post-process used to create a HDR effect (light adaptation)
  64702. */
  64703. hdrPostProcess: Nullable<PostProcess>;
  64704. /**
  64705. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64706. */
  64707. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64708. /**
  64709. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64710. */
  64711. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64712. /**
  64713. * Post-process used to merge the final HDR post-process and the real scene color
  64714. */
  64715. hdrFinalPostProcess: Nullable<PostProcess>;
  64716. /**
  64717. * Post-process used to create a lens flare effect
  64718. */
  64719. lensFlarePostProcess: Nullable<PostProcess>;
  64720. /**
  64721. * Post-process that merges the result of the lens flare post-process and the real scene color
  64722. */
  64723. lensFlareComposePostProcess: Nullable<PostProcess>;
  64724. /**
  64725. * Post-process used to create a motion blur effect
  64726. */
  64727. motionBlurPostProcess: Nullable<PostProcess>;
  64728. /**
  64729. * Post-process used to create a depth of field effect
  64730. */
  64731. depthOfFieldPostProcess: Nullable<PostProcess>;
  64732. /**
  64733. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64734. */
  64735. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64736. /**
  64737. * Represents the brightness threshold in order to configure the illuminated surfaces
  64738. */
  64739. brightThreshold: number;
  64740. /**
  64741. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64742. */
  64743. blurWidth: number;
  64744. /**
  64745. * Sets if the blur for highlighted surfaces must be only horizontal
  64746. */
  64747. horizontalBlur: boolean;
  64748. /**
  64749. * Gets the overall exposure used by the pipeline
  64750. */
  64751. /**
  64752. * Sets the overall exposure used by the pipeline
  64753. */
  64754. exposure: number;
  64755. /**
  64756. * Texture used typically to simulate "dirty" on camera lens
  64757. */
  64758. lensTexture: Nullable<Texture>;
  64759. /**
  64760. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64761. */
  64762. volumetricLightCoefficient: number;
  64763. /**
  64764. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64765. */
  64766. volumetricLightPower: number;
  64767. /**
  64768. * Used the set the blur intensity to smooth the volumetric lights
  64769. */
  64770. volumetricLightBlurScale: number;
  64771. /**
  64772. * Light (spot or directional) used to generate the volumetric lights rays
  64773. * The source light must have a shadow generate so the pipeline can get its
  64774. * depth map
  64775. */
  64776. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64777. /**
  64778. * For eye adaptation, represents the minimum luminance the eye can see
  64779. */
  64780. hdrMinimumLuminance: number;
  64781. /**
  64782. * For eye adaptation, represents the decrease luminance speed
  64783. */
  64784. hdrDecreaseRate: number;
  64785. /**
  64786. * For eye adaptation, represents the increase luminance speed
  64787. */
  64788. hdrIncreaseRate: number;
  64789. /**
  64790. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64791. */
  64792. /**
  64793. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64794. */
  64795. hdrAutoExposure: boolean;
  64796. /**
  64797. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64798. */
  64799. lensColorTexture: Nullable<Texture>;
  64800. /**
  64801. * The overall strengh for the lens flare effect
  64802. */
  64803. lensFlareStrength: number;
  64804. /**
  64805. * Dispersion coefficient for lens flare ghosts
  64806. */
  64807. lensFlareGhostDispersal: number;
  64808. /**
  64809. * Main lens flare halo width
  64810. */
  64811. lensFlareHaloWidth: number;
  64812. /**
  64813. * Based on the lens distortion effect, defines how much the lens flare result
  64814. * is distorted
  64815. */
  64816. lensFlareDistortionStrength: number;
  64817. /**
  64818. * Configures the blur intensity used for for lens flare (halo)
  64819. */
  64820. lensFlareBlurWidth: number;
  64821. /**
  64822. * Lens star texture must be used to simulate rays on the flares and is available
  64823. * in the documentation
  64824. */
  64825. lensStarTexture: Nullable<Texture>;
  64826. /**
  64827. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64828. * flare effect by taking account of the dirt texture
  64829. */
  64830. lensFlareDirtTexture: Nullable<Texture>;
  64831. /**
  64832. * Represents the focal length for the depth of field effect
  64833. */
  64834. depthOfFieldDistance: number;
  64835. /**
  64836. * Represents the blur intensity for the blurred part of the depth of field effect
  64837. */
  64838. depthOfFieldBlurWidth: number;
  64839. /**
  64840. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64841. */
  64842. /**
  64843. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64844. */
  64845. motionStrength: number;
  64846. /**
  64847. * Gets wether or not the motion blur post-process is object based or screen based.
  64848. */
  64849. /**
  64850. * Sets wether or not the motion blur post-process should be object based or screen based
  64851. */
  64852. objectBasedMotionBlur: boolean;
  64853. /**
  64854. * List of animations for the pipeline (IAnimatable implementation)
  64855. */
  64856. animations: Animation[];
  64857. /**
  64858. * Private members
  64859. */
  64860. private _scene;
  64861. private _currentDepthOfFieldSource;
  64862. private _basePostProcess;
  64863. private _fixedExposure;
  64864. private _currentExposure;
  64865. private _hdrAutoExposure;
  64866. private _hdrCurrentLuminance;
  64867. private _motionStrength;
  64868. private _isObjectBasedMotionBlur;
  64869. private _floatTextureType;
  64870. private _camerasToBeAttached;
  64871. private _ratio;
  64872. private _bloomEnabled;
  64873. private _depthOfFieldEnabled;
  64874. private _vlsEnabled;
  64875. private _lensFlareEnabled;
  64876. private _hdrEnabled;
  64877. private _motionBlurEnabled;
  64878. private _fxaaEnabled;
  64879. private _motionBlurSamples;
  64880. private _volumetricLightStepsCount;
  64881. private _samples;
  64882. /**
  64883. * @ignore
  64884. * Specifies if the bloom pipeline is enabled
  64885. */
  64886. BloomEnabled: boolean;
  64887. /**
  64888. * @ignore
  64889. * Specifies if the depth of field pipeline is enabed
  64890. */
  64891. DepthOfFieldEnabled: boolean;
  64892. /**
  64893. * @ignore
  64894. * Specifies if the lens flare pipeline is enabed
  64895. */
  64896. LensFlareEnabled: boolean;
  64897. /**
  64898. * @ignore
  64899. * Specifies if the HDR pipeline is enabled
  64900. */
  64901. HDREnabled: boolean;
  64902. /**
  64903. * @ignore
  64904. * Specifies if the volumetric lights scattering effect is enabled
  64905. */
  64906. VLSEnabled: boolean;
  64907. /**
  64908. * @ignore
  64909. * Specifies if the motion blur effect is enabled
  64910. */
  64911. MotionBlurEnabled: boolean;
  64912. /**
  64913. * Specifies if anti-aliasing is enabled
  64914. */
  64915. fxaaEnabled: boolean;
  64916. /**
  64917. * Specifies the number of steps used to calculate the volumetric lights
  64918. * Typically in interval [50, 200]
  64919. */
  64920. volumetricLightStepsCount: number;
  64921. /**
  64922. * Specifies the number of samples used for the motion blur effect
  64923. * Typically in interval [16, 64]
  64924. */
  64925. motionBlurSamples: number;
  64926. /**
  64927. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64928. */
  64929. samples: number;
  64930. /**
  64931. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64932. * @constructor
  64933. * @param name The rendering pipeline name
  64934. * @param scene The scene linked to this pipeline
  64935. * @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)
  64936. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64937. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64938. */
  64939. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64940. private _buildPipeline;
  64941. private _createDownSampleX4PostProcess;
  64942. private _createBrightPassPostProcess;
  64943. private _createBlurPostProcesses;
  64944. private _createTextureAdderPostProcess;
  64945. private _createVolumetricLightPostProcess;
  64946. private _createLuminancePostProcesses;
  64947. private _createHdrPostProcess;
  64948. private _createLensFlarePostProcess;
  64949. private _createDepthOfFieldPostProcess;
  64950. private _createMotionBlurPostProcess;
  64951. private _getDepthTexture;
  64952. private _disposePostProcesses;
  64953. /**
  64954. * Dispose of the pipeline and stop all post processes
  64955. */
  64956. dispose(): void;
  64957. /**
  64958. * Serialize the rendering pipeline (Used when exporting)
  64959. * @returns the serialized object
  64960. */
  64961. serialize(): any;
  64962. /**
  64963. * Parse the serialized pipeline
  64964. * @param source Source pipeline.
  64965. * @param scene The scene to load the pipeline to.
  64966. * @param rootUrl The URL of the serialized pipeline.
  64967. * @returns An instantiated pipeline from the serialized object.
  64968. */
  64969. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64970. /**
  64971. * Luminance steps
  64972. */
  64973. static LuminanceSteps: number;
  64974. }
  64975. }
  64976. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64977. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64978. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64979. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64980. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64981. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64982. }
  64983. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64984. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64985. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64986. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64987. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64988. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64989. }
  64990. declare module "babylonjs/Shaders/tonemap.fragment" {
  64991. /** @hidden */
  64992. export var tonemapPixelShader: {
  64993. name: string;
  64994. shader: string;
  64995. };
  64996. }
  64997. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64998. import { Camera } from "babylonjs/Cameras/camera";
  64999. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65000. import "babylonjs/Shaders/tonemap.fragment";
  65001. import { Engine } from "babylonjs/Engines/engine";
  65002. /** Defines operator used for tonemapping */
  65003. export enum TonemappingOperator {
  65004. /** Hable */
  65005. Hable = 0,
  65006. /** Reinhard */
  65007. Reinhard = 1,
  65008. /** HejiDawson */
  65009. HejiDawson = 2,
  65010. /** Photographic */
  65011. Photographic = 3
  65012. }
  65013. /**
  65014. * Defines a post process to apply tone mapping
  65015. */
  65016. export class TonemapPostProcess extends PostProcess {
  65017. private _operator;
  65018. /** Defines the required exposure adjustement */
  65019. exposureAdjustment: number;
  65020. /**
  65021. * Creates a new TonemapPostProcess
  65022. * @param name defines the name of the postprocess
  65023. * @param _operator defines the operator to use
  65024. * @param exposureAdjustment defines the required exposure adjustement
  65025. * @param camera defines the camera to use (can be null)
  65026. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65027. * @param engine defines the hosting engine (can be ignore if camera is set)
  65028. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65029. */
  65030. constructor(name: string, _operator: TonemappingOperator,
  65031. /** Defines the required exposure adjustement */
  65032. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65033. }
  65034. }
  65035. declare module "babylonjs/Shaders/depth.vertex" {
  65036. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65038. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65039. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65040. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65041. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65042. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65043. /** @hidden */
  65044. export var depthVertexShader: {
  65045. name: string;
  65046. shader: string;
  65047. };
  65048. }
  65049. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65050. /** @hidden */
  65051. export var volumetricLightScatteringPixelShader: {
  65052. name: string;
  65053. shader: string;
  65054. };
  65055. }
  65056. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65057. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65058. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65059. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65060. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65061. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65062. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65063. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65064. /** @hidden */
  65065. export var volumetricLightScatteringPassVertexShader: {
  65066. name: string;
  65067. shader: string;
  65068. };
  65069. }
  65070. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65071. /** @hidden */
  65072. export var volumetricLightScatteringPassPixelShader: {
  65073. name: string;
  65074. shader: string;
  65075. };
  65076. }
  65077. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65078. import { Vector3 } from "babylonjs/Maths/math.vector";
  65079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65080. import { Mesh } from "babylonjs/Meshes/mesh";
  65081. import { Camera } from "babylonjs/Cameras/camera";
  65082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65083. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65084. import { Scene } from "babylonjs/scene";
  65085. import "babylonjs/Meshes/Builders/planeBuilder";
  65086. import "babylonjs/Shaders/depth.vertex";
  65087. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65088. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65089. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65090. import { Engine } from "babylonjs/Engines/engine";
  65091. /**
  65092. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65093. */
  65094. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65095. private _volumetricLightScatteringPass;
  65096. private _volumetricLightScatteringRTT;
  65097. private _viewPort;
  65098. private _screenCoordinates;
  65099. private _cachedDefines;
  65100. /**
  65101. * If not undefined, the mesh position is computed from the attached node position
  65102. */
  65103. attachedNode: {
  65104. position: Vector3;
  65105. };
  65106. /**
  65107. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65108. */
  65109. customMeshPosition: Vector3;
  65110. /**
  65111. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65112. */
  65113. useCustomMeshPosition: boolean;
  65114. /**
  65115. * If the post-process should inverse the light scattering direction
  65116. */
  65117. invert: boolean;
  65118. /**
  65119. * The internal mesh used by the post-process
  65120. */
  65121. mesh: Mesh;
  65122. /**
  65123. * @hidden
  65124. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65125. */
  65126. useDiffuseColor: boolean;
  65127. /**
  65128. * Array containing the excluded meshes not rendered in the internal pass
  65129. */
  65130. excludedMeshes: AbstractMesh[];
  65131. /**
  65132. * Controls the overall intensity of the post-process
  65133. */
  65134. exposure: number;
  65135. /**
  65136. * Dissipates each sample's contribution in range [0, 1]
  65137. */
  65138. decay: number;
  65139. /**
  65140. * Controls the overall intensity of each sample
  65141. */
  65142. weight: number;
  65143. /**
  65144. * Controls the density of each sample
  65145. */
  65146. density: number;
  65147. /**
  65148. * @constructor
  65149. * @param name The post-process name
  65150. * @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)
  65151. * @param camera The camera that the post-process will be attached to
  65152. * @param mesh The mesh used to create the light scattering
  65153. * @param samples The post-process quality, default 100
  65154. * @param samplingModeThe post-process filtering mode
  65155. * @param engine The babylon engine
  65156. * @param reusable If the post-process is reusable
  65157. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65158. */
  65159. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65160. /**
  65161. * Returns the string "VolumetricLightScatteringPostProcess"
  65162. * @returns "VolumetricLightScatteringPostProcess"
  65163. */
  65164. getClassName(): string;
  65165. private _isReady;
  65166. /**
  65167. * Sets the new light position for light scattering effect
  65168. * @param position The new custom light position
  65169. */
  65170. setCustomMeshPosition(position: Vector3): void;
  65171. /**
  65172. * Returns the light position for light scattering effect
  65173. * @return Vector3 The custom light position
  65174. */
  65175. getCustomMeshPosition(): Vector3;
  65176. /**
  65177. * Disposes the internal assets and detaches the post-process from the camera
  65178. */
  65179. dispose(camera: Camera): void;
  65180. /**
  65181. * Returns the render target texture used by the post-process
  65182. * @return the render target texture used by the post-process
  65183. */
  65184. getPass(): RenderTargetTexture;
  65185. private _meshExcluded;
  65186. private _createPass;
  65187. private _updateMeshScreenCoordinates;
  65188. /**
  65189. * Creates a default mesh for the Volumeric Light Scattering post-process
  65190. * @param name The mesh name
  65191. * @param scene The scene where to create the mesh
  65192. * @return the default mesh
  65193. */
  65194. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65195. }
  65196. }
  65197. declare module "babylonjs/PostProcesses/index" {
  65198. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65199. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65200. export * from "babylonjs/PostProcesses/bloomEffect";
  65201. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65202. export * from "babylonjs/PostProcesses/blurPostProcess";
  65203. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65204. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65205. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65206. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65207. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65208. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65209. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65210. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65211. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65212. export * from "babylonjs/PostProcesses/filterPostProcess";
  65213. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65214. export * from "babylonjs/PostProcesses/grainPostProcess";
  65215. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65216. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65217. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65218. export * from "babylonjs/PostProcesses/passPostProcess";
  65219. export * from "babylonjs/PostProcesses/postProcess";
  65220. export * from "babylonjs/PostProcesses/postProcessManager";
  65221. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65222. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65223. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65224. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65225. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65226. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65227. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65228. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65229. }
  65230. declare module "babylonjs/Probes/index" {
  65231. export * from "babylonjs/Probes/reflectionProbe";
  65232. }
  65233. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65234. import { Scene } from "babylonjs/scene";
  65235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65236. import { SmartArray } from "babylonjs/Misc/smartArray";
  65237. import { ISceneComponent } from "babylonjs/sceneComponent";
  65238. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65239. import "babylonjs/Meshes/Builders/boxBuilder";
  65240. import "babylonjs/Shaders/color.fragment";
  65241. import "babylonjs/Shaders/color.vertex";
  65242. import { Color3 } from "babylonjs/Maths/math.color";
  65243. module "babylonjs/scene" {
  65244. interface Scene {
  65245. /** @hidden (Backing field) */
  65246. _boundingBoxRenderer: BoundingBoxRenderer;
  65247. /** @hidden (Backing field) */
  65248. _forceShowBoundingBoxes: boolean;
  65249. /**
  65250. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65251. */
  65252. forceShowBoundingBoxes: boolean;
  65253. /**
  65254. * Gets the bounding box renderer associated with the scene
  65255. * @returns a BoundingBoxRenderer
  65256. */
  65257. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65258. }
  65259. }
  65260. module "babylonjs/Meshes/abstractMesh" {
  65261. interface AbstractMesh {
  65262. /** @hidden (Backing field) */
  65263. _showBoundingBox: boolean;
  65264. /**
  65265. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65266. */
  65267. showBoundingBox: boolean;
  65268. }
  65269. }
  65270. /**
  65271. * Component responsible of rendering the bounding box of the meshes in a scene.
  65272. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65273. */
  65274. export class BoundingBoxRenderer implements ISceneComponent {
  65275. /**
  65276. * The component name helpfull to identify the component in the list of scene components.
  65277. */
  65278. readonly name: string;
  65279. /**
  65280. * The scene the component belongs to.
  65281. */
  65282. scene: Scene;
  65283. /**
  65284. * Color of the bounding box lines placed in front of an object
  65285. */
  65286. frontColor: Color3;
  65287. /**
  65288. * Color of the bounding box lines placed behind an object
  65289. */
  65290. backColor: Color3;
  65291. /**
  65292. * Defines if the renderer should show the back lines or not
  65293. */
  65294. showBackLines: boolean;
  65295. /**
  65296. * @hidden
  65297. */
  65298. renderList: SmartArray<BoundingBox>;
  65299. private _colorShader;
  65300. private _vertexBuffers;
  65301. private _indexBuffer;
  65302. private _fillIndexBuffer;
  65303. private _fillIndexData;
  65304. /**
  65305. * Instantiates a new bounding box renderer in a scene.
  65306. * @param scene the scene the renderer renders in
  65307. */
  65308. constructor(scene: Scene);
  65309. /**
  65310. * Registers the component in a given scene
  65311. */
  65312. register(): void;
  65313. private _evaluateSubMesh;
  65314. private _activeMesh;
  65315. private _prepareRessources;
  65316. private _createIndexBuffer;
  65317. /**
  65318. * Rebuilds the elements related to this component in case of
  65319. * context lost for instance.
  65320. */
  65321. rebuild(): void;
  65322. /**
  65323. * @hidden
  65324. */
  65325. reset(): void;
  65326. /**
  65327. * Render the bounding boxes of a specific rendering group
  65328. * @param renderingGroupId defines the rendering group to render
  65329. */
  65330. render(renderingGroupId: number): void;
  65331. /**
  65332. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65333. * @param mesh Define the mesh to render the occlusion bounding box for
  65334. */
  65335. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65336. /**
  65337. * Dispose and release the resources attached to this renderer.
  65338. */
  65339. dispose(): void;
  65340. }
  65341. }
  65342. declare module "babylonjs/Shaders/depth.fragment" {
  65343. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65344. /** @hidden */
  65345. export var depthPixelShader: {
  65346. name: string;
  65347. shader: string;
  65348. };
  65349. }
  65350. declare module "babylonjs/Rendering/depthRenderer" {
  65351. import { Nullable } from "babylonjs/types";
  65352. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65353. import { Scene } from "babylonjs/scene";
  65354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65355. import { Camera } from "babylonjs/Cameras/camera";
  65356. import "babylonjs/Shaders/depth.fragment";
  65357. import "babylonjs/Shaders/depth.vertex";
  65358. /**
  65359. * This represents a depth renderer in Babylon.
  65360. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65361. */
  65362. export class DepthRenderer {
  65363. private _scene;
  65364. private _depthMap;
  65365. private _effect;
  65366. private readonly _storeNonLinearDepth;
  65367. private readonly _clearColor;
  65368. /** Get if the depth renderer is using packed depth or not */
  65369. readonly isPacked: boolean;
  65370. private _cachedDefines;
  65371. private _camera;
  65372. /**
  65373. * Specifiess that the depth renderer will only be used within
  65374. * the camera it is created for.
  65375. * This can help forcing its rendering during the camera processing.
  65376. */
  65377. useOnlyInActiveCamera: boolean;
  65378. /** @hidden */
  65379. static _SceneComponentInitialization: (scene: Scene) => void;
  65380. /**
  65381. * Instantiates a depth renderer
  65382. * @param scene The scene the renderer belongs to
  65383. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65384. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65385. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65386. */
  65387. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65388. /**
  65389. * Creates the depth rendering effect and checks if the effect is ready.
  65390. * @param subMesh The submesh to be used to render the depth map of
  65391. * @param useInstances If multiple world instances should be used
  65392. * @returns if the depth renderer is ready to render the depth map
  65393. */
  65394. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65395. /**
  65396. * Gets the texture which the depth map will be written to.
  65397. * @returns The depth map texture
  65398. */
  65399. getDepthMap(): RenderTargetTexture;
  65400. /**
  65401. * Disposes of the depth renderer.
  65402. */
  65403. dispose(): void;
  65404. }
  65405. }
  65406. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65407. import { Nullable } from "babylonjs/types";
  65408. import { Scene } from "babylonjs/scene";
  65409. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65410. import { Camera } from "babylonjs/Cameras/camera";
  65411. import { ISceneComponent } from "babylonjs/sceneComponent";
  65412. module "babylonjs/scene" {
  65413. interface Scene {
  65414. /** @hidden (Backing field) */
  65415. _depthRenderer: {
  65416. [id: string]: DepthRenderer;
  65417. };
  65418. /**
  65419. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65420. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65421. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65422. * @returns the created depth renderer
  65423. */
  65424. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65425. /**
  65426. * Disables a depth renderer for a given camera
  65427. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65428. */
  65429. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65430. }
  65431. }
  65432. /**
  65433. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65434. * in several rendering techniques.
  65435. */
  65436. export class DepthRendererSceneComponent implements ISceneComponent {
  65437. /**
  65438. * The component name helpfull to identify the component in the list of scene components.
  65439. */
  65440. readonly name: string;
  65441. /**
  65442. * The scene the component belongs to.
  65443. */
  65444. scene: Scene;
  65445. /**
  65446. * Creates a new instance of the component for the given scene
  65447. * @param scene Defines the scene to register the component in
  65448. */
  65449. constructor(scene: Scene);
  65450. /**
  65451. * Registers the component in a given scene
  65452. */
  65453. register(): void;
  65454. /**
  65455. * Rebuilds the elements related to this component in case of
  65456. * context lost for instance.
  65457. */
  65458. rebuild(): void;
  65459. /**
  65460. * Disposes the component and the associated ressources
  65461. */
  65462. dispose(): void;
  65463. private _gatherRenderTargets;
  65464. private _gatherActiveCameraRenderTargets;
  65465. }
  65466. }
  65467. declare module "babylonjs/Shaders/outline.fragment" {
  65468. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65469. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65470. /** @hidden */
  65471. export var outlinePixelShader: {
  65472. name: string;
  65473. shader: string;
  65474. };
  65475. }
  65476. declare module "babylonjs/Shaders/outline.vertex" {
  65477. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65478. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65479. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65480. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65481. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65483. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65484. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65485. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65486. /** @hidden */
  65487. export var outlineVertexShader: {
  65488. name: string;
  65489. shader: string;
  65490. };
  65491. }
  65492. declare module "babylonjs/Rendering/outlineRenderer" {
  65493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65494. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65495. import { Scene } from "babylonjs/scene";
  65496. import { ISceneComponent } from "babylonjs/sceneComponent";
  65497. import "babylonjs/Shaders/outline.fragment";
  65498. import "babylonjs/Shaders/outline.vertex";
  65499. module "babylonjs/scene" {
  65500. interface Scene {
  65501. /** @hidden */
  65502. _outlineRenderer: OutlineRenderer;
  65503. /**
  65504. * Gets the outline renderer associated with the scene
  65505. * @returns a OutlineRenderer
  65506. */
  65507. getOutlineRenderer(): OutlineRenderer;
  65508. }
  65509. }
  65510. module "babylonjs/Meshes/abstractMesh" {
  65511. interface AbstractMesh {
  65512. /** @hidden (Backing field) */
  65513. _renderOutline: boolean;
  65514. /**
  65515. * Gets or sets a boolean indicating if the outline must be rendered as well
  65516. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65517. */
  65518. renderOutline: boolean;
  65519. /** @hidden (Backing field) */
  65520. _renderOverlay: boolean;
  65521. /**
  65522. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65523. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65524. */
  65525. renderOverlay: boolean;
  65526. }
  65527. }
  65528. /**
  65529. * This class is responsible to draw bothe outline/overlay of meshes.
  65530. * It should not be used directly but through the available method on mesh.
  65531. */
  65532. export class OutlineRenderer implements ISceneComponent {
  65533. /**
  65534. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65535. */
  65536. private static _StencilReference;
  65537. /**
  65538. * The name of the component. Each component must have a unique name.
  65539. */
  65540. name: string;
  65541. /**
  65542. * The scene the component belongs to.
  65543. */
  65544. scene: Scene;
  65545. /**
  65546. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65547. */
  65548. zOffset: number;
  65549. private _engine;
  65550. private _effect;
  65551. private _cachedDefines;
  65552. private _savedDepthWrite;
  65553. /**
  65554. * Instantiates a new outline renderer. (There could be only one per scene).
  65555. * @param scene Defines the scene it belongs to
  65556. */
  65557. constructor(scene: Scene);
  65558. /**
  65559. * Register the component to one instance of a scene.
  65560. */
  65561. register(): void;
  65562. /**
  65563. * Rebuilds the elements related to this component in case of
  65564. * context lost for instance.
  65565. */
  65566. rebuild(): void;
  65567. /**
  65568. * Disposes the component and the associated ressources.
  65569. */
  65570. dispose(): void;
  65571. /**
  65572. * Renders the outline in the canvas.
  65573. * @param subMesh Defines the sumesh to render
  65574. * @param batch Defines the batch of meshes in case of instances
  65575. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65576. */
  65577. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65578. /**
  65579. * Returns whether or not the outline renderer is ready for a given submesh.
  65580. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65581. * @param subMesh Defines the submesh to check readyness for
  65582. * @param useInstances Defines wheter wee are trying to render instances or not
  65583. * @returns true if ready otherwise false
  65584. */
  65585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65586. private _beforeRenderingMesh;
  65587. private _afterRenderingMesh;
  65588. }
  65589. }
  65590. declare module "babylonjs/Rendering/index" {
  65591. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65592. export * from "babylonjs/Rendering/depthRenderer";
  65593. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65594. export * from "babylonjs/Rendering/edgesRenderer";
  65595. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65596. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65597. export * from "babylonjs/Rendering/outlineRenderer";
  65598. export * from "babylonjs/Rendering/renderingGroup";
  65599. export * from "babylonjs/Rendering/renderingManager";
  65600. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65601. }
  65602. declare module "babylonjs/Sprites/spritePackedManager" {
  65603. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65604. import { Scene } from "babylonjs/scene";
  65605. /**
  65606. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65607. * @see http://doc.babylonjs.com/babylon101/sprites
  65608. */
  65609. export class SpritePackedManager extends SpriteManager {
  65610. /** defines the packed manager's name */
  65611. name: string;
  65612. /**
  65613. * Creates a new sprite manager from a packed sprite sheet
  65614. * @param name defines the manager's name
  65615. * @param imgUrl defines the sprite sheet url
  65616. * @param capacity defines the maximum allowed number of sprites
  65617. * @param scene defines the hosting scene
  65618. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65619. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65620. * @param samplingMode defines the smapling mode to use with spritesheet
  65621. * @param fromPacked set to true; do not alter
  65622. */
  65623. constructor(
  65624. /** defines the packed manager's name */
  65625. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65626. }
  65627. }
  65628. declare module "babylonjs/Sprites/index" {
  65629. export * from "babylonjs/Sprites/sprite";
  65630. export * from "babylonjs/Sprites/spriteManager";
  65631. export * from "babylonjs/Sprites/spritePackedManager";
  65632. export * from "babylonjs/Sprites/spriteSceneComponent";
  65633. }
  65634. declare module "babylonjs/States/index" {
  65635. export * from "babylonjs/States/alphaCullingState";
  65636. export * from "babylonjs/States/depthCullingState";
  65637. export * from "babylonjs/States/stencilState";
  65638. }
  65639. declare module "babylonjs/Misc/assetsManager" {
  65640. import { Scene } from "babylonjs/scene";
  65641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65642. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65643. import { Skeleton } from "babylonjs/Bones/skeleton";
  65644. import { Observable } from "babylonjs/Misc/observable";
  65645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65646. import { Texture } from "babylonjs/Materials/Textures/texture";
  65647. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65648. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65649. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65650. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65651. /**
  65652. * Defines the list of states available for a task inside a AssetsManager
  65653. */
  65654. export enum AssetTaskState {
  65655. /**
  65656. * Initialization
  65657. */
  65658. INIT = 0,
  65659. /**
  65660. * Running
  65661. */
  65662. RUNNING = 1,
  65663. /**
  65664. * Done
  65665. */
  65666. DONE = 2,
  65667. /**
  65668. * Error
  65669. */
  65670. ERROR = 3
  65671. }
  65672. /**
  65673. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65674. */
  65675. export abstract class AbstractAssetTask {
  65676. /**
  65677. * Task name
  65678. */ name: string;
  65679. /**
  65680. * Callback called when the task is successful
  65681. */
  65682. onSuccess: (task: any) => void;
  65683. /**
  65684. * Callback called when the task is not successful
  65685. */
  65686. onError: (task: any, message?: string, exception?: any) => void;
  65687. /**
  65688. * Creates a new AssetsManager
  65689. * @param name defines the name of the task
  65690. */
  65691. constructor(
  65692. /**
  65693. * Task name
  65694. */ name: string);
  65695. private _isCompleted;
  65696. private _taskState;
  65697. private _errorObject;
  65698. /**
  65699. * Get if the task is completed
  65700. */
  65701. readonly isCompleted: boolean;
  65702. /**
  65703. * Gets the current state of the task
  65704. */
  65705. readonly taskState: AssetTaskState;
  65706. /**
  65707. * Gets the current error object (if task is in error)
  65708. */
  65709. readonly errorObject: {
  65710. message?: string;
  65711. exception?: any;
  65712. };
  65713. /**
  65714. * Internal only
  65715. * @hidden
  65716. */
  65717. _setErrorObject(message?: string, exception?: any): void;
  65718. /**
  65719. * Execute the current task
  65720. * @param scene defines the scene where you want your assets to be loaded
  65721. * @param onSuccess is a callback called when the task is successfully executed
  65722. * @param onError is a callback called if an error occurs
  65723. */
  65724. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65725. /**
  65726. * Execute the current task
  65727. * @param scene defines the scene where you want your assets to be loaded
  65728. * @param onSuccess is a callback called when the task is successfully executed
  65729. * @param onError is a callback called if an error occurs
  65730. */
  65731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65732. /**
  65733. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65734. * This can be used with failed tasks that have the reason for failure fixed.
  65735. */
  65736. reset(): void;
  65737. private onErrorCallback;
  65738. private onDoneCallback;
  65739. }
  65740. /**
  65741. * Define the interface used by progress events raised during assets loading
  65742. */
  65743. export interface IAssetsProgressEvent {
  65744. /**
  65745. * Defines the number of remaining tasks to process
  65746. */
  65747. remainingCount: number;
  65748. /**
  65749. * Defines the total number of tasks
  65750. */
  65751. totalCount: number;
  65752. /**
  65753. * Defines the task that was just processed
  65754. */
  65755. task: AbstractAssetTask;
  65756. }
  65757. /**
  65758. * Class used to share progress information about assets loading
  65759. */
  65760. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65761. /**
  65762. * Defines the number of remaining tasks to process
  65763. */
  65764. remainingCount: number;
  65765. /**
  65766. * Defines the total number of tasks
  65767. */
  65768. totalCount: number;
  65769. /**
  65770. * Defines the task that was just processed
  65771. */
  65772. task: AbstractAssetTask;
  65773. /**
  65774. * Creates a AssetsProgressEvent
  65775. * @param remainingCount defines the number of remaining tasks to process
  65776. * @param totalCount defines the total number of tasks
  65777. * @param task defines the task that was just processed
  65778. */
  65779. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65780. }
  65781. /**
  65782. * Define a task used by AssetsManager to load meshes
  65783. */
  65784. export class MeshAssetTask extends AbstractAssetTask {
  65785. /**
  65786. * Defines the name of the task
  65787. */
  65788. name: string;
  65789. /**
  65790. * Defines the list of mesh's names you want to load
  65791. */
  65792. meshesNames: any;
  65793. /**
  65794. * Defines the root url to use as a base to load your meshes and associated resources
  65795. */
  65796. rootUrl: string;
  65797. /**
  65798. * Defines the filename of the scene to load from
  65799. */
  65800. sceneFilename: string;
  65801. /**
  65802. * Gets the list of loaded meshes
  65803. */
  65804. loadedMeshes: Array<AbstractMesh>;
  65805. /**
  65806. * Gets the list of loaded particle systems
  65807. */
  65808. loadedParticleSystems: Array<IParticleSystem>;
  65809. /**
  65810. * Gets the list of loaded skeletons
  65811. */
  65812. loadedSkeletons: Array<Skeleton>;
  65813. /**
  65814. * Gets the list of loaded animation groups
  65815. */
  65816. loadedAnimationGroups: Array<AnimationGroup>;
  65817. /**
  65818. * Callback called when the task is successful
  65819. */
  65820. onSuccess: (task: MeshAssetTask) => void;
  65821. /**
  65822. * Callback called when the task is successful
  65823. */
  65824. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65825. /**
  65826. * Creates a new MeshAssetTask
  65827. * @param name defines the name of the task
  65828. * @param meshesNames defines the list of mesh's names you want to load
  65829. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65830. * @param sceneFilename defines the filename of the scene to load from
  65831. */
  65832. constructor(
  65833. /**
  65834. * Defines the name of the task
  65835. */
  65836. name: string,
  65837. /**
  65838. * Defines the list of mesh's names you want to load
  65839. */
  65840. meshesNames: any,
  65841. /**
  65842. * Defines the root url to use as a base to load your meshes and associated resources
  65843. */
  65844. rootUrl: string,
  65845. /**
  65846. * Defines the filename of the scene to load from
  65847. */
  65848. sceneFilename: string);
  65849. /**
  65850. * Execute the current task
  65851. * @param scene defines the scene where you want your assets to be loaded
  65852. * @param onSuccess is a callback called when the task is successfully executed
  65853. * @param onError is a callback called if an error occurs
  65854. */
  65855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65856. }
  65857. /**
  65858. * Define a task used by AssetsManager to load text content
  65859. */
  65860. export class TextFileAssetTask extends AbstractAssetTask {
  65861. /**
  65862. * Defines the name of the task
  65863. */
  65864. name: string;
  65865. /**
  65866. * Defines the location of the file to load
  65867. */
  65868. url: string;
  65869. /**
  65870. * Gets the loaded text string
  65871. */
  65872. text: string;
  65873. /**
  65874. * Callback called when the task is successful
  65875. */
  65876. onSuccess: (task: TextFileAssetTask) => void;
  65877. /**
  65878. * Callback called when the task is successful
  65879. */
  65880. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65881. /**
  65882. * Creates a new TextFileAssetTask object
  65883. * @param name defines the name of the task
  65884. * @param url defines the location of the file to load
  65885. */
  65886. constructor(
  65887. /**
  65888. * Defines the name of the task
  65889. */
  65890. name: string,
  65891. /**
  65892. * Defines the location of the file to load
  65893. */
  65894. url: string);
  65895. /**
  65896. * Execute the current task
  65897. * @param scene defines the scene where you want your assets to be loaded
  65898. * @param onSuccess is a callback called when the task is successfully executed
  65899. * @param onError is a callback called if an error occurs
  65900. */
  65901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65902. }
  65903. /**
  65904. * Define a task used by AssetsManager to load binary data
  65905. */
  65906. export class BinaryFileAssetTask extends AbstractAssetTask {
  65907. /**
  65908. * Defines the name of the task
  65909. */
  65910. name: string;
  65911. /**
  65912. * Defines the location of the file to load
  65913. */
  65914. url: string;
  65915. /**
  65916. * Gets the lodaded data (as an array buffer)
  65917. */
  65918. data: ArrayBuffer;
  65919. /**
  65920. * Callback called when the task is successful
  65921. */
  65922. onSuccess: (task: BinaryFileAssetTask) => void;
  65923. /**
  65924. * Callback called when the task is successful
  65925. */
  65926. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65927. /**
  65928. * Creates a new BinaryFileAssetTask object
  65929. * @param name defines the name of the new task
  65930. * @param url defines the location of the file to load
  65931. */
  65932. constructor(
  65933. /**
  65934. * Defines the name of the task
  65935. */
  65936. name: string,
  65937. /**
  65938. * Defines the location of the file to load
  65939. */
  65940. url: string);
  65941. /**
  65942. * Execute the current task
  65943. * @param scene defines the scene where you want your assets to be loaded
  65944. * @param onSuccess is a callback called when the task is successfully executed
  65945. * @param onError is a callback called if an error occurs
  65946. */
  65947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65948. }
  65949. /**
  65950. * Define a task used by AssetsManager to load images
  65951. */
  65952. export class ImageAssetTask extends AbstractAssetTask {
  65953. /**
  65954. * Defines the name of the task
  65955. */
  65956. name: string;
  65957. /**
  65958. * Defines the location of the image to load
  65959. */
  65960. url: string;
  65961. /**
  65962. * Gets the loaded images
  65963. */
  65964. image: HTMLImageElement;
  65965. /**
  65966. * Callback called when the task is successful
  65967. */
  65968. onSuccess: (task: ImageAssetTask) => void;
  65969. /**
  65970. * Callback called when the task is successful
  65971. */
  65972. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65973. /**
  65974. * Creates a new ImageAssetTask
  65975. * @param name defines the name of the task
  65976. * @param url defines the location of the image to load
  65977. */
  65978. constructor(
  65979. /**
  65980. * Defines the name of the task
  65981. */
  65982. name: string,
  65983. /**
  65984. * Defines the location of the image to load
  65985. */
  65986. url: string);
  65987. /**
  65988. * Execute the current task
  65989. * @param scene defines the scene where you want your assets to be loaded
  65990. * @param onSuccess is a callback called when the task is successfully executed
  65991. * @param onError is a callback called if an error occurs
  65992. */
  65993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65994. }
  65995. /**
  65996. * Defines the interface used by texture loading tasks
  65997. */
  65998. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65999. /**
  66000. * Gets the loaded texture
  66001. */
  66002. texture: TEX;
  66003. }
  66004. /**
  66005. * Define a task used by AssetsManager to load 2D textures
  66006. */
  66007. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66008. /**
  66009. * Defines the name of the task
  66010. */
  66011. name: string;
  66012. /**
  66013. * Defines the location of the file to load
  66014. */
  66015. url: string;
  66016. /**
  66017. * Defines if mipmap should not be generated (default is false)
  66018. */
  66019. noMipmap?: boolean | undefined;
  66020. /**
  66021. * Defines if texture must be inverted on Y axis (default is false)
  66022. */
  66023. invertY?: boolean | undefined;
  66024. /**
  66025. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66026. */
  66027. samplingMode: number;
  66028. /**
  66029. * Gets the loaded texture
  66030. */
  66031. texture: Texture;
  66032. /**
  66033. * Callback called when the task is successful
  66034. */
  66035. onSuccess: (task: TextureAssetTask) => void;
  66036. /**
  66037. * Callback called when the task is successful
  66038. */
  66039. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66040. /**
  66041. * Creates a new TextureAssetTask object
  66042. * @param name defines the name of the task
  66043. * @param url defines the location of the file to load
  66044. * @param noMipmap defines if mipmap should not be generated (default is false)
  66045. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66046. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66047. */
  66048. constructor(
  66049. /**
  66050. * Defines the name of the task
  66051. */
  66052. name: string,
  66053. /**
  66054. * Defines the location of the file to load
  66055. */
  66056. url: string,
  66057. /**
  66058. * Defines if mipmap should not be generated (default is false)
  66059. */
  66060. noMipmap?: boolean | undefined,
  66061. /**
  66062. * Defines if texture must be inverted on Y axis (default is false)
  66063. */
  66064. invertY?: boolean | undefined,
  66065. /**
  66066. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66067. */
  66068. samplingMode?: number);
  66069. /**
  66070. * Execute the current task
  66071. * @param scene defines the scene where you want your assets to be loaded
  66072. * @param onSuccess is a callback called when the task is successfully executed
  66073. * @param onError is a callback called if an error occurs
  66074. */
  66075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66076. }
  66077. /**
  66078. * Define a task used by AssetsManager to load cube textures
  66079. */
  66080. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66081. /**
  66082. * Defines the name of the task
  66083. */
  66084. name: string;
  66085. /**
  66086. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66087. */
  66088. url: string;
  66089. /**
  66090. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66091. */
  66092. extensions?: string[] | undefined;
  66093. /**
  66094. * Defines if mipmaps should not be generated (default is false)
  66095. */
  66096. noMipmap?: boolean | undefined;
  66097. /**
  66098. * Defines the explicit list of files (undefined by default)
  66099. */
  66100. files?: string[] | undefined;
  66101. /**
  66102. * Gets the loaded texture
  66103. */
  66104. texture: CubeTexture;
  66105. /**
  66106. * Callback called when the task is successful
  66107. */
  66108. onSuccess: (task: CubeTextureAssetTask) => void;
  66109. /**
  66110. * Callback called when the task is successful
  66111. */
  66112. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66113. /**
  66114. * Creates a new CubeTextureAssetTask
  66115. * @param name defines the name of the task
  66116. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66117. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66118. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66119. * @param files defines the explicit list of files (undefined by default)
  66120. */
  66121. constructor(
  66122. /**
  66123. * Defines the name of the task
  66124. */
  66125. name: string,
  66126. /**
  66127. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66128. */
  66129. url: string,
  66130. /**
  66131. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66132. */
  66133. extensions?: string[] | undefined,
  66134. /**
  66135. * Defines if mipmaps should not be generated (default is false)
  66136. */
  66137. noMipmap?: boolean | undefined,
  66138. /**
  66139. * Defines the explicit list of files (undefined by default)
  66140. */
  66141. files?: string[] | undefined);
  66142. /**
  66143. * Execute the current task
  66144. * @param scene defines the scene where you want your assets to be loaded
  66145. * @param onSuccess is a callback called when the task is successfully executed
  66146. * @param onError is a callback called if an error occurs
  66147. */
  66148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66149. }
  66150. /**
  66151. * Define a task used by AssetsManager to load HDR cube textures
  66152. */
  66153. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66154. /**
  66155. * Defines the name of the task
  66156. */
  66157. name: string;
  66158. /**
  66159. * Defines the location of the file to load
  66160. */
  66161. url: string;
  66162. /**
  66163. * Defines the desired size (the more it increases the longer the generation will be)
  66164. */
  66165. size: number;
  66166. /**
  66167. * Defines if mipmaps should not be generated (default is false)
  66168. */
  66169. noMipmap: boolean;
  66170. /**
  66171. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66172. */
  66173. generateHarmonics: boolean;
  66174. /**
  66175. * 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)
  66176. */
  66177. gammaSpace: boolean;
  66178. /**
  66179. * Internal Use Only
  66180. */
  66181. reserved: boolean;
  66182. /**
  66183. * Gets the loaded texture
  66184. */
  66185. texture: HDRCubeTexture;
  66186. /**
  66187. * Callback called when the task is successful
  66188. */
  66189. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66190. /**
  66191. * Callback called when the task is successful
  66192. */
  66193. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66194. /**
  66195. * Creates a new HDRCubeTextureAssetTask object
  66196. * @param name defines the name of the task
  66197. * @param url defines the location of the file to load
  66198. * @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.
  66199. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66200. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66201. * @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)
  66202. * @param reserved Internal use only
  66203. */
  66204. constructor(
  66205. /**
  66206. * Defines the name of the task
  66207. */
  66208. name: string,
  66209. /**
  66210. * Defines the location of the file to load
  66211. */
  66212. url: string,
  66213. /**
  66214. * Defines the desired size (the more it increases the longer the generation will be)
  66215. */
  66216. size: number,
  66217. /**
  66218. * Defines if mipmaps should not be generated (default is false)
  66219. */
  66220. noMipmap?: boolean,
  66221. /**
  66222. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66223. */
  66224. generateHarmonics?: boolean,
  66225. /**
  66226. * 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)
  66227. */
  66228. gammaSpace?: boolean,
  66229. /**
  66230. * Internal Use Only
  66231. */
  66232. reserved?: boolean);
  66233. /**
  66234. * Execute the current task
  66235. * @param scene defines the scene where you want your assets to be loaded
  66236. * @param onSuccess is a callback called when the task is successfully executed
  66237. * @param onError is a callback called if an error occurs
  66238. */
  66239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66240. }
  66241. /**
  66242. * Define a task used by AssetsManager to load Equirectangular cube textures
  66243. */
  66244. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66245. /**
  66246. * Defines the name of the task
  66247. */
  66248. name: string;
  66249. /**
  66250. * Defines the location of the file to load
  66251. */
  66252. url: string;
  66253. /**
  66254. * Defines the desired size (the more it increases the longer the generation will be)
  66255. */
  66256. size: number;
  66257. /**
  66258. * Defines if mipmaps should not be generated (default is false)
  66259. */
  66260. noMipmap: boolean;
  66261. /**
  66262. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66263. * but the standard material would require them in Gamma space) (default is true)
  66264. */
  66265. gammaSpace: boolean;
  66266. /**
  66267. * Gets the loaded texture
  66268. */
  66269. texture: EquiRectangularCubeTexture;
  66270. /**
  66271. * Callback called when the task is successful
  66272. */
  66273. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66274. /**
  66275. * Callback called when the task is successful
  66276. */
  66277. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66278. /**
  66279. * Creates a new EquiRectangularCubeTextureAssetTask object
  66280. * @param name defines the name of the task
  66281. * @param url defines the location of the file to load
  66282. * @param size defines the desired size (the more it increases the longer the generation will be)
  66283. * If the size is omitted this implies you are using a preprocessed cubemap.
  66284. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66285. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66286. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66287. * (default is true)
  66288. */
  66289. constructor(
  66290. /**
  66291. * Defines the name of the task
  66292. */
  66293. name: string,
  66294. /**
  66295. * Defines the location of the file to load
  66296. */
  66297. url: string,
  66298. /**
  66299. * Defines the desired size (the more it increases the longer the generation will be)
  66300. */
  66301. size: number,
  66302. /**
  66303. * Defines if mipmaps should not be generated (default is false)
  66304. */
  66305. noMipmap?: boolean,
  66306. /**
  66307. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66308. * but the standard material would require them in Gamma space) (default is true)
  66309. */
  66310. gammaSpace?: boolean);
  66311. /**
  66312. * Execute the current task
  66313. * @param scene defines the scene where you want your assets to be loaded
  66314. * @param onSuccess is a callback called when the task is successfully executed
  66315. * @param onError is a callback called if an error occurs
  66316. */
  66317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66318. }
  66319. /**
  66320. * This class can be used to easily import assets into a scene
  66321. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66322. */
  66323. export class AssetsManager {
  66324. private _scene;
  66325. private _isLoading;
  66326. protected _tasks: AbstractAssetTask[];
  66327. protected _waitingTasksCount: number;
  66328. protected _totalTasksCount: number;
  66329. /**
  66330. * Callback called when all tasks are processed
  66331. */
  66332. onFinish: (tasks: AbstractAssetTask[]) => void;
  66333. /**
  66334. * Callback called when a task is successful
  66335. */
  66336. onTaskSuccess: (task: AbstractAssetTask) => void;
  66337. /**
  66338. * Callback called when a task had an error
  66339. */
  66340. onTaskError: (task: AbstractAssetTask) => void;
  66341. /**
  66342. * Callback called when a task is done (whatever the result is)
  66343. */
  66344. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66345. /**
  66346. * Observable called when all tasks are processed
  66347. */
  66348. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66349. /**
  66350. * Observable called when a task had an error
  66351. */
  66352. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66353. /**
  66354. * Observable called when all tasks were executed
  66355. */
  66356. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66357. /**
  66358. * Observable called when a task is done (whatever the result is)
  66359. */
  66360. onProgressObservable: Observable<IAssetsProgressEvent>;
  66361. /**
  66362. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66364. */
  66365. useDefaultLoadingScreen: boolean;
  66366. /**
  66367. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66368. * when all assets have been downloaded.
  66369. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66370. */
  66371. autoHideLoadingUI: boolean;
  66372. /**
  66373. * Creates a new AssetsManager
  66374. * @param scene defines the scene to work on
  66375. */
  66376. constructor(scene: Scene);
  66377. /**
  66378. * Add a MeshAssetTask to the list of active tasks
  66379. * @param taskName defines the name of the new task
  66380. * @param meshesNames defines the name of meshes to load
  66381. * @param rootUrl defines the root url to use to locate files
  66382. * @param sceneFilename defines the filename of the scene file
  66383. * @returns a new MeshAssetTask object
  66384. */
  66385. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66386. /**
  66387. * Add a TextFileAssetTask to the list of active tasks
  66388. * @param taskName defines the name of the new task
  66389. * @param url defines the url of the file to load
  66390. * @returns a new TextFileAssetTask object
  66391. */
  66392. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66393. /**
  66394. * Add a BinaryFileAssetTask to the list of active tasks
  66395. * @param taskName defines the name of the new task
  66396. * @param url defines the url of the file to load
  66397. * @returns a new BinaryFileAssetTask object
  66398. */
  66399. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66400. /**
  66401. * Add a ImageAssetTask to the list of active tasks
  66402. * @param taskName defines the name of the new task
  66403. * @param url defines the url of the file to load
  66404. * @returns a new ImageAssetTask object
  66405. */
  66406. addImageTask(taskName: string, url: string): ImageAssetTask;
  66407. /**
  66408. * Add a TextureAssetTask to the list of active tasks
  66409. * @param taskName defines the name of the new task
  66410. * @param url defines the url of the file to load
  66411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66412. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66413. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66414. * @returns a new TextureAssetTask object
  66415. */
  66416. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66417. /**
  66418. * Add a CubeTextureAssetTask to the list of active tasks
  66419. * @param taskName defines the name of the new task
  66420. * @param url defines the url of the file to load
  66421. * @param extensions defines the extension to use to load the cube map (can be null)
  66422. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66423. * @param files defines the list of files to load (can be null)
  66424. * @returns a new CubeTextureAssetTask object
  66425. */
  66426. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66427. /**
  66428. *
  66429. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66430. * @param taskName defines the name of the new task
  66431. * @param url defines the url of the file to load
  66432. * @param size defines the size you want for the cubemap (can be null)
  66433. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66434. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66435. * @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)
  66436. * @param reserved Internal use only
  66437. * @returns a new HDRCubeTextureAssetTask object
  66438. */
  66439. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66440. /**
  66441. *
  66442. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66443. * @param taskName defines the name of the new task
  66444. * @param url defines the url of the file to load
  66445. * @param size defines the size you want for the cubemap (can be null)
  66446. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66447. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66448. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66449. * @returns a new EquiRectangularCubeTextureAssetTask object
  66450. */
  66451. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66452. /**
  66453. * Remove a task from the assets manager.
  66454. * @param task the task to remove
  66455. */
  66456. removeTask(task: AbstractAssetTask): void;
  66457. private _decreaseWaitingTasksCount;
  66458. private _runTask;
  66459. /**
  66460. * Reset the AssetsManager and remove all tasks
  66461. * @return the current instance of the AssetsManager
  66462. */
  66463. reset(): AssetsManager;
  66464. /**
  66465. * Start the loading process
  66466. * @return the current instance of the AssetsManager
  66467. */
  66468. load(): AssetsManager;
  66469. /**
  66470. * Start the loading process as an async operation
  66471. * @return a promise returning the list of failed tasks
  66472. */
  66473. loadAsync(): Promise<void>;
  66474. }
  66475. }
  66476. declare module "babylonjs/Misc/deferred" {
  66477. /**
  66478. * Wrapper class for promise with external resolve and reject.
  66479. */
  66480. export class Deferred<T> {
  66481. /**
  66482. * The promise associated with this deferred object.
  66483. */
  66484. readonly promise: Promise<T>;
  66485. private _resolve;
  66486. private _reject;
  66487. /**
  66488. * The resolve method of the promise associated with this deferred object.
  66489. */
  66490. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66491. /**
  66492. * The reject method of the promise associated with this deferred object.
  66493. */
  66494. readonly reject: (reason?: any) => void;
  66495. /**
  66496. * Constructor for this deferred object.
  66497. */
  66498. constructor();
  66499. }
  66500. }
  66501. declare module "babylonjs/Misc/meshExploder" {
  66502. import { Mesh } from "babylonjs/Meshes/mesh";
  66503. /**
  66504. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66505. */
  66506. export class MeshExploder {
  66507. private _centerMesh;
  66508. private _meshes;
  66509. private _meshesOrigins;
  66510. private _toCenterVectors;
  66511. private _scaledDirection;
  66512. private _newPosition;
  66513. private _centerPosition;
  66514. /**
  66515. * Explodes meshes from a center mesh.
  66516. * @param meshes The meshes to explode.
  66517. * @param centerMesh The mesh to be center of explosion.
  66518. */
  66519. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66520. private _setCenterMesh;
  66521. /**
  66522. * Get class name
  66523. * @returns "MeshExploder"
  66524. */
  66525. getClassName(): string;
  66526. /**
  66527. * "Exploded meshes"
  66528. * @returns Array of meshes with the centerMesh at index 0.
  66529. */
  66530. getMeshes(): Array<Mesh>;
  66531. /**
  66532. * Explodes meshes giving a specific direction
  66533. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66534. */
  66535. explode(direction?: number): void;
  66536. }
  66537. }
  66538. declare module "babylonjs/Misc/filesInput" {
  66539. import { Engine } from "babylonjs/Engines/engine";
  66540. import { Scene } from "babylonjs/scene";
  66541. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66542. /**
  66543. * Class used to help managing file picking and drag'n'drop
  66544. */
  66545. export class FilesInput {
  66546. /**
  66547. * List of files ready to be loaded
  66548. */
  66549. static readonly FilesToLoad: {
  66550. [key: string]: File;
  66551. };
  66552. /**
  66553. * Callback called when a file is processed
  66554. */
  66555. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66556. private _engine;
  66557. private _currentScene;
  66558. private _sceneLoadedCallback;
  66559. private _progressCallback;
  66560. private _additionalRenderLoopLogicCallback;
  66561. private _textureLoadingCallback;
  66562. private _startingProcessingFilesCallback;
  66563. private _onReloadCallback;
  66564. private _errorCallback;
  66565. private _elementToMonitor;
  66566. private _sceneFileToLoad;
  66567. private _filesToLoad;
  66568. /**
  66569. * Creates a new FilesInput
  66570. * @param engine defines the rendering engine
  66571. * @param scene defines the hosting scene
  66572. * @param sceneLoadedCallback callback called when scene is loaded
  66573. * @param progressCallback callback called to track progress
  66574. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66575. * @param textureLoadingCallback callback called when a texture is loading
  66576. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66577. * @param onReloadCallback callback called when a reload is requested
  66578. * @param errorCallback callback call if an error occurs
  66579. */
  66580. 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);
  66581. private _dragEnterHandler;
  66582. private _dragOverHandler;
  66583. private _dropHandler;
  66584. /**
  66585. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66586. * @param elementToMonitor defines the DOM element to track
  66587. */
  66588. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66589. /**
  66590. * Release all associated resources
  66591. */
  66592. dispose(): void;
  66593. private renderFunction;
  66594. private drag;
  66595. private drop;
  66596. private _traverseFolder;
  66597. private _processFiles;
  66598. /**
  66599. * Load files from a drop event
  66600. * @param event defines the drop event to use as source
  66601. */
  66602. loadFiles(event: any): void;
  66603. private _processReload;
  66604. /**
  66605. * Reload the current scene from the loaded files
  66606. */
  66607. reload(): void;
  66608. }
  66609. }
  66610. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66611. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66612. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66613. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66614. }
  66615. declare module "babylonjs/Misc/sceneOptimizer" {
  66616. import { Scene, IDisposable } from "babylonjs/scene";
  66617. import { Observable } from "babylonjs/Misc/observable";
  66618. /**
  66619. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66621. */
  66622. export class SceneOptimization {
  66623. /**
  66624. * Defines the priority of this optimization (0 by default which means first in the list)
  66625. */
  66626. priority: number;
  66627. /**
  66628. * Gets a string describing the action executed by the current optimization
  66629. * @returns description string
  66630. */
  66631. getDescription(): string;
  66632. /**
  66633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66634. * @param scene defines the current scene where to apply this optimization
  66635. * @param optimizer defines the current optimizer
  66636. * @returns true if everything that can be done was applied
  66637. */
  66638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66639. /**
  66640. * Creates the SceneOptimization object
  66641. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66642. * @param desc defines the description associated with the optimization
  66643. */
  66644. constructor(
  66645. /**
  66646. * Defines the priority of this optimization (0 by default which means first in the list)
  66647. */
  66648. priority?: number);
  66649. }
  66650. /**
  66651. * Defines an optimization used to reduce the size of render target textures
  66652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66653. */
  66654. export class TextureOptimization extends SceneOptimization {
  66655. /**
  66656. * Defines the priority of this optimization (0 by default which means first in the list)
  66657. */
  66658. priority: number;
  66659. /**
  66660. * 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
  66661. */
  66662. maximumSize: number;
  66663. /**
  66664. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66665. */
  66666. step: number;
  66667. /**
  66668. * Gets a string describing the action executed by the current optimization
  66669. * @returns description string
  66670. */
  66671. getDescription(): string;
  66672. /**
  66673. * Creates the TextureOptimization object
  66674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66675. * @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
  66676. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66677. */
  66678. constructor(
  66679. /**
  66680. * Defines the priority of this optimization (0 by default which means first in the list)
  66681. */
  66682. priority?: number,
  66683. /**
  66684. * 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
  66685. */
  66686. maximumSize?: number,
  66687. /**
  66688. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66689. */
  66690. step?: number);
  66691. /**
  66692. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66693. * @param scene defines the current scene where to apply this optimization
  66694. * @param optimizer defines the current optimizer
  66695. * @returns true if everything that can be done was applied
  66696. */
  66697. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66698. }
  66699. /**
  66700. * Defines an optimization used to increase or decrease the rendering resolution
  66701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66702. */
  66703. export class HardwareScalingOptimization extends SceneOptimization {
  66704. /**
  66705. * Defines the priority of this optimization (0 by default which means first in the list)
  66706. */
  66707. priority: number;
  66708. /**
  66709. * Defines the maximum scale to use (2 by default)
  66710. */
  66711. maximumScale: number;
  66712. /**
  66713. * Defines the step to use between two passes (0.5 by default)
  66714. */
  66715. step: number;
  66716. private _currentScale;
  66717. private _directionOffset;
  66718. /**
  66719. * Gets a string describing the action executed by the current optimization
  66720. * @return description string
  66721. */
  66722. getDescription(): string;
  66723. /**
  66724. * Creates the HardwareScalingOptimization object
  66725. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66726. * @param maximumScale defines the maximum scale to use (2 by default)
  66727. * @param step defines the step to use between two passes (0.5 by default)
  66728. */
  66729. constructor(
  66730. /**
  66731. * Defines the priority of this optimization (0 by default which means first in the list)
  66732. */
  66733. priority?: number,
  66734. /**
  66735. * Defines the maximum scale to use (2 by default)
  66736. */
  66737. maximumScale?: number,
  66738. /**
  66739. * Defines the step to use between two passes (0.5 by default)
  66740. */
  66741. step?: number);
  66742. /**
  66743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66744. * @param scene defines the current scene where to apply this optimization
  66745. * @param optimizer defines the current optimizer
  66746. * @returns true if everything that can be done was applied
  66747. */
  66748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66749. }
  66750. /**
  66751. * Defines an optimization used to remove shadows
  66752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66753. */
  66754. export class ShadowsOptimization extends SceneOptimization {
  66755. /**
  66756. * Gets a string describing the action executed by the current optimization
  66757. * @return description string
  66758. */
  66759. getDescription(): string;
  66760. /**
  66761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66762. * @param scene defines the current scene where to apply this optimization
  66763. * @param optimizer defines the current optimizer
  66764. * @returns true if everything that can be done was applied
  66765. */
  66766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66767. }
  66768. /**
  66769. * Defines an optimization used to turn post-processes off
  66770. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66771. */
  66772. export class PostProcessesOptimization extends SceneOptimization {
  66773. /**
  66774. * Gets a string describing the action executed by the current optimization
  66775. * @return description string
  66776. */
  66777. getDescription(): string;
  66778. /**
  66779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66780. * @param scene defines the current scene where to apply this optimization
  66781. * @param optimizer defines the current optimizer
  66782. * @returns true if everything that can be done was applied
  66783. */
  66784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66785. }
  66786. /**
  66787. * Defines an optimization used to turn lens flares off
  66788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66789. */
  66790. export class LensFlaresOptimization extends SceneOptimization {
  66791. /**
  66792. * Gets a string describing the action executed by the current optimization
  66793. * @return description string
  66794. */
  66795. getDescription(): string;
  66796. /**
  66797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66798. * @param scene defines the current scene where to apply this optimization
  66799. * @param optimizer defines the current optimizer
  66800. * @returns true if everything that can be done was applied
  66801. */
  66802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66803. }
  66804. /**
  66805. * Defines an optimization based on user defined callback.
  66806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66807. */
  66808. export class CustomOptimization extends SceneOptimization {
  66809. /**
  66810. * Callback called to apply the custom optimization.
  66811. */
  66812. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66813. /**
  66814. * Callback called to get custom description
  66815. */
  66816. onGetDescription: () => string;
  66817. /**
  66818. * Gets a string describing the action executed by the current optimization
  66819. * @returns description string
  66820. */
  66821. getDescription(): string;
  66822. /**
  66823. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66824. * @param scene defines the current scene where to apply this optimization
  66825. * @param optimizer defines the current optimizer
  66826. * @returns true if everything that can be done was applied
  66827. */
  66828. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66829. }
  66830. /**
  66831. * Defines an optimization used to turn particles off
  66832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66833. */
  66834. export class ParticlesOptimization extends SceneOptimization {
  66835. /**
  66836. * Gets a string describing the action executed by the current optimization
  66837. * @return description string
  66838. */
  66839. getDescription(): string;
  66840. /**
  66841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66842. * @param scene defines the current scene where to apply this optimization
  66843. * @param optimizer defines the current optimizer
  66844. * @returns true if everything that can be done was applied
  66845. */
  66846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66847. }
  66848. /**
  66849. * Defines an optimization used to turn render targets off
  66850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66851. */
  66852. export class RenderTargetsOptimization extends SceneOptimization {
  66853. /**
  66854. * Gets a string describing the action executed by the current optimization
  66855. * @return description string
  66856. */
  66857. getDescription(): string;
  66858. /**
  66859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66860. * @param scene defines the current scene where to apply this optimization
  66861. * @param optimizer defines the current optimizer
  66862. * @returns true if everything that can be done was applied
  66863. */
  66864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66865. }
  66866. /**
  66867. * Defines an optimization used to merge meshes with compatible materials
  66868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66869. */
  66870. export class MergeMeshesOptimization extends SceneOptimization {
  66871. private static _UpdateSelectionTree;
  66872. /**
  66873. * Gets or sets a boolean which defines if optimization octree has to be updated
  66874. */
  66875. /**
  66876. * Gets or sets a boolean which defines if optimization octree has to be updated
  66877. */
  66878. static UpdateSelectionTree: boolean;
  66879. /**
  66880. * Gets a string describing the action executed by the current optimization
  66881. * @return description string
  66882. */
  66883. getDescription(): string;
  66884. private _canBeMerged;
  66885. /**
  66886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66887. * @param scene defines the current scene where to apply this optimization
  66888. * @param optimizer defines the current optimizer
  66889. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66890. * @returns true if everything that can be done was applied
  66891. */
  66892. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66893. }
  66894. /**
  66895. * Defines a list of options used by SceneOptimizer
  66896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66897. */
  66898. export class SceneOptimizerOptions {
  66899. /**
  66900. * Defines the target frame rate to reach (60 by default)
  66901. */
  66902. targetFrameRate: number;
  66903. /**
  66904. * Defines the interval between two checkes (2000ms by default)
  66905. */
  66906. trackerDuration: number;
  66907. /**
  66908. * Gets the list of optimizations to apply
  66909. */
  66910. optimizations: SceneOptimization[];
  66911. /**
  66912. * Creates a new list of options used by SceneOptimizer
  66913. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66914. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66915. */
  66916. constructor(
  66917. /**
  66918. * Defines the target frame rate to reach (60 by default)
  66919. */
  66920. targetFrameRate?: number,
  66921. /**
  66922. * Defines the interval between two checkes (2000ms by default)
  66923. */
  66924. trackerDuration?: number);
  66925. /**
  66926. * Add a new optimization
  66927. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66928. * @returns the current SceneOptimizerOptions
  66929. */
  66930. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66931. /**
  66932. * Add a new custom optimization
  66933. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66934. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66935. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66936. * @returns the current SceneOptimizerOptions
  66937. */
  66938. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66939. /**
  66940. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66941. * @param targetFrameRate defines the target frame rate (60 by default)
  66942. * @returns a SceneOptimizerOptions object
  66943. */
  66944. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66945. /**
  66946. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66947. * @param targetFrameRate defines the target frame rate (60 by default)
  66948. * @returns a SceneOptimizerOptions object
  66949. */
  66950. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66951. /**
  66952. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66953. * @param targetFrameRate defines the target frame rate (60 by default)
  66954. * @returns a SceneOptimizerOptions object
  66955. */
  66956. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66957. }
  66958. /**
  66959. * Class used to run optimizations in order to reach a target frame rate
  66960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66961. */
  66962. export class SceneOptimizer implements IDisposable {
  66963. private _isRunning;
  66964. private _options;
  66965. private _scene;
  66966. private _currentPriorityLevel;
  66967. private _targetFrameRate;
  66968. private _trackerDuration;
  66969. private _currentFrameRate;
  66970. private _sceneDisposeObserver;
  66971. private _improvementMode;
  66972. /**
  66973. * Defines an observable called when the optimizer reaches the target frame rate
  66974. */
  66975. onSuccessObservable: Observable<SceneOptimizer>;
  66976. /**
  66977. * Defines an observable called when the optimizer enables an optimization
  66978. */
  66979. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66980. /**
  66981. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66982. */
  66983. onFailureObservable: Observable<SceneOptimizer>;
  66984. /**
  66985. * Gets a boolean indicating if the optimizer is in improvement mode
  66986. */
  66987. readonly isInImprovementMode: boolean;
  66988. /**
  66989. * Gets the current priority level (0 at start)
  66990. */
  66991. readonly currentPriorityLevel: number;
  66992. /**
  66993. * Gets the current frame rate checked by the SceneOptimizer
  66994. */
  66995. readonly currentFrameRate: number;
  66996. /**
  66997. * Gets or sets the current target frame rate (60 by default)
  66998. */
  66999. /**
  67000. * Gets or sets the current target frame rate (60 by default)
  67001. */
  67002. targetFrameRate: number;
  67003. /**
  67004. * Gets or sets the current interval between two checks (every 2000ms by default)
  67005. */
  67006. /**
  67007. * Gets or sets the current interval between two checks (every 2000ms by default)
  67008. */
  67009. trackerDuration: number;
  67010. /**
  67011. * Gets the list of active optimizations
  67012. */
  67013. readonly optimizations: SceneOptimization[];
  67014. /**
  67015. * Creates a new SceneOptimizer
  67016. * @param scene defines the scene to work on
  67017. * @param options defines the options to use with the SceneOptimizer
  67018. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67019. * @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)
  67020. */
  67021. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67022. /**
  67023. * Stops the current optimizer
  67024. */
  67025. stop(): void;
  67026. /**
  67027. * Reset the optimizer to initial step (current priority level = 0)
  67028. */
  67029. reset(): void;
  67030. /**
  67031. * Start the optimizer. By default it will try to reach a specific framerate
  67032. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67033. */
  67034. start(): void;
  67035. private _checkCurrentState;
  67036. /**
  67037. * Release all resources
  67038. */
  67039. dispose(): void;
  67040. /**
  67041. * Helper function to create a SceneOptimizer with one single line of code
  67042. * @param scene defines the scene to work on
  67043. * @param options defines the options to use with the SceneOptimizer
  67044. * @param onSuccess defines a callback to call on success
  67045. * @param onFailure defines a callback to call on failure
  67046. * @returns the new SceneOptimizer object
  67047. */
  67048. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67049. }
  67050. }
  67051. declare module "babylonjs/Misc/sceneSerializer" {
  67052. import { Scene } from "babylonjs/scene";
  67053. /**
  67054. * Class used to serialize a scene into a string
  67055. */
  67056. export class SceneSerializer {
  67057. /**
  67058. * Clear cache used by a previous serialization
  67059. */
  67060. static ClearCache(): void;
  67061. /**
  67062. * Serialize a scene into a JSON compatible object
  67063. * @param scene defines the scene to serialize
  67064. * @returns a JSON compatible object
  67065. */
  67066. static Serialize(scene: Scene): any;
  67067. /**
  67068. * Serialize a mesh into a JSON compatible object
  67069. * @param toSerialize defines the mesh to serialize
  67070. * @param withParents defines if parents must be serialized as well
  67071. * @param withChildren defines if children must be serialized as well
  67072. * @returns a JSON compatible object
  67073. */
  67074. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67075. }
  67076. }
  67077. declare module "babylonjs/Misc/textureTools" {
  67078. import { Texture } from "babylonjs/Materials/Textures/texture";
  67079. /**
  67080. * Class used to host texture specific utilities
  67081. */
  67082. export class TextureTools {
  67083. /**
  67084. * Uses the GPU to create a copy texture rescaled at a given size
  67085. * @param texture Texture to copy from
  67086. * @param width defines the desired width
  67087. * @param height defines the desired height
  67088. * @param useBilinearMode defines if bilinear mode has to be used
  67089. * @return the generated texture
  67090. */
  67091. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67092. }
  67093. }
  67094. declare module "babylonjs/Misc/videoRecorder" {
  67095. import { Nullable } from "babylonjs/types";
  67096. import { Engine } from "babylonjs/Engines/engine";
  67097. /**
  67098. * This represents the different options available for the video capture.
  67099. */
  67100. export interface VideoRecorderOptions {
  67101. /** Defines the mime type of the video. */
  67102. mimeType: string;
  67103. /** Defines the FPS the video should be recorded at. */
  67104. fps: number;
  67105. /** Defines the chunk size for the recording data. */
  67106. recordChunckSize: number;
  67107. /** The audio tracks to attach to the recording. */
  67108. audioTracks?: MediaStreamTrack[];
  67109. }
  67110. /**
  67111. * This can help with recording videos from BabylonJS.
  67112. * This is based on the available WebRTC functionalities of the browser.
  67113. *
  67114. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67115. */
  67116. export class VideoRecorder {
  67117. private static readonly _defaultOptions;
  67118. /**
  67119. * Returns whether or not the VideoRecorder is available in your browser.
  67120. * @param engine Defines the Babylon Engine.
  67121. * @returns true if supported otherwise false.
  67122. */
  67123. static IsSupported(engine: Engine): boolean;
  67124. private readonly _options;
  67125. private _canvas;
  67126. private _mediaRecorder;
  67127. private _recordedChunks;
  67128. private _fileName;
  67129. private _resolve;
  67130. private _reject;
  67131. /**
  67132. * True when a recording is already in progress.
  67133. */
  67134. readonly isRecording: boolean;
  67135. /**
  67136. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67137. * @param engine Defines the BabylonJS Engine you wish to record.
  67138. * @param options Defines options that can be used to customize the capture.
  67139. */
  67140. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67141. /**
  67142. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67143. */
  67144. stopRecording(): void;
  67145. /**
  67146. * Starts recording the canvas for a max duration specified in parameters.
  67147. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67148. * If null no automatic download will start and you can rely on the promise to get the data back.
  67149. * @param maxDuration Defines the maximum recording time in seconds.
  67150. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67151. * @return A promise callback at the end of the recording with the video data in Blob.
  67152. */
  67153. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67154. /**
  67155. * Releases internal resources used during the recording.
  67156. */
  67157. dispose(): void;
  67158. private _handleDataAvailable;
  67159. private _handleError;
  67160. private _handleStop;
  67161. }
  67162. }
  67163. declare module "babylonjs/Misc/screenshotTools" {
  67164. import { Camera } from "babylonjs/Cameras/camera";
  67165. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67166. import { Engine } from "babylonjs/Engines/engine";
  67167. /**
  67168. * Class containing a set of static utilities functions for screenshots
  67169. */
  67170. export class ScreenshotTools {
  67171. /**
  67172. * Captures a screenshot of the current rendering
  67173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67174. * @param engine defines the rendering engine
  67175. * @param camera defines the source camera
  67176. * @param size This parameter can be set to a single number or to an object with the
  67177. * following (optional) properties: precision, width, height. If a single number is passed,
  67178. * it will be used for both width and height. If an object is passed, the screenshot size
  67179. * will be derived from the parameters. The precision property is a multiplier allowing
  67180. * rendering at a higher or lower resolution
  67181. * @param successCallback defines the callback receives a single parameter which contains the
  67182. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67183. * src parameter of an <img> to display it
  67184. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67185. * Check your browser for supported MIME types
  67186. */
  67187. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67188. /**
  67189. * Captures a screenshot of the current rendering
  67190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67191. * @param engine defines the rendering engine
  67192. * @param camera defines the source camera
  67193. * @param size This parameter can be set to a single number or to an object with the
  67194. * following (optional) properties: precision, width, height. If a single number is passed,
  67195. * it will be used for both width and height. If an object is passed, the screenshot size
  67196. * will be derived from the parameters. The precision property is a multiplier allowing
  67197. * rendering at a higher or lower resolution
  67198. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67199. * Check your browser for supported MIME types
  67200. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67201. * to the src parameter of an <img> to display it
  67202. */
  67203. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67204. /**
  67205. * Generates an image screenshot from the specified camera.
  67206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67207. * @param engine The engine to use for rendering
  67208. * @param camera The camera to use for rendering
  67209. * @param size This parameter can be set to a single number or to an object with the
  67210. * following (optional) properties: precision, width, height. If a single number is passed,
  67211. * it will be used for both width and height. If an object is passed, the screenshot size
  67212. * will be derived from the parameters. The precision property is a multiplier allowing
  67213. * rendering at a higher or lower resolution
  67214. * @param successCallback The callback receives a single parameter which contains the
  67215. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67216. * src parameter of an <img> to display it
  67217. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67218. * Check your browser for supported MIME types
  67219. * @param samples Texture samples (default: 1)
  67220. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67221. * @param fileName A name for for the downloaded file.
  67222. */
  67223. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67224. /**
  67225. * Generates an image screenshot from the specified camera.
  67226. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67227. * @param engine The engine to use for rendering
  67228. * @param camera The camera to use for rendering
  67229. * @param size This parameter can be set to a single number or to an object with the
  67230. * following (optional) properties: precision, width, height. If a single number is passed,
  67231. * it will be used for both width and height. If an object is passed, the screenshot size
  67232. * will be derived from the parameters. The precision property is a multiplier allowing
  67233. * rendering at a higher or lower resolution
  67234. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67235. * Check your browser for supported MIME types
  67236. * @param samples Texture samples (default: 1)
  67237. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67238. * @param fileName A name for for the downloaded file.
  67239. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67240. * to the src parameter of an <img> to display it
  67241. */
  67242. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67243. /**
  67244. * Gets height and width for screenshot size
  67245. * @private
  67246. */
  67247. private static _getScreenshotSize;
  67248. }
  67249. }
  67250. declare module "babylonjs/Misc/index" {
  67251. export * from "babylonjs/Misc/andOrNotEvaluator";
  67252. export * from "babylonjs/Misc/assetsManager";
  67253. export * from "babylonjs/Misc/dds";
  67254. export * from "babylonjs/Misc/decorators";
  67255. export * from "babylonjs/Misc/deferred";
  67256. export * from "babylonjs/Misc/environmentTextureTools";
  67257. export * from "babylonjs/Misc/meshExploder";
  67258. export * from "babylonjs/Misc/filesInput";
  67259. export * from "babylonjs/Misc/HighDynamicRange/index";
  67260. export * from "babylonjs/Misc/khronosTextureContainer";
  67261. export * from "babylonjs/Misc/observable";
  67262. export * from "babylonjs/Misc/performanceMonitor";
  67263. export * from "babylonjs/Misc/promise";
  67264. export * from "babylonjs/Misc/sceneOptimizer";
  67265. export * from "babylonjs/Misc/sceneSerializer";
  67266. export * from "babylonjs/Misc/smartArray";
  67267. export * from "babylonjs/Misc/stringDictionary";
  67268. export * from "babylonjs/Misc/tags";
  67269. export * from "babylonjs/Misc/textureTools";
  67270. export * from "babylonjs/Misc/tga";
  67271. export * from "babylonjs/Misc/tools";
  67272. export * from "babylonjs/Misc/videoRecorder";
  67273. export * from "babylonjs/Misc/virtualJoystick";
  67274. export * from "babylonjs/Misc/workerPool";
  67275. export * from "babylonjs/Misc/logger";
  67276. export * from "babylonjs/Misc/typeStore";
  67277. export * from "babylonjs/Misc/filesInputStore";
  67278. export * from "babylonjs/Misc/deepCopier";
  67279. export * from "babylonjs/Misc/pivotTools";
  67280. export * from "babylonjs/Misc/precisionDate";
  67281. export * from "babylonjs/Misc/screenshotTools";
  67282. export * from "babylonjs/Misc/typeStore";
  67283. export * from "babylonjs/Misc/webRequest";
  67284. export * from "babylonjs/Misc/iInspectable";
  67285. export * from "babylonjs/Misc/brdfTextureTools";
  67286. export * from "babylonjs/Misc/rgbdTextureTools";
  67287. export * from "babylonjs/Misc/gradients";
  67288. export * from "babylonjs/Misc/perfCounter";
  67289. export * from "babylonjs/Misc/fileRequest";
  67290. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67291. export * from "babylonjs/Misc/retryStrategy";
  67292. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67293. export * from "babylonjs/Misc/canvasGenerator";
  67294. export * from "babylonjs/Misc/fileTools";
  67295. export * from "babylonjs/Misc/stringTools";
  67296. }
  67297. declare module "babylonjs/index" {
  67298. export * from "babylonjs/abstractScene";
  67299. export * from "babylonjs/Actions/index";
  67300. export * from "babylonjs/Animations/index";
  67301. export * from "babylonjs/assetContainer";
  67302. export * from "babylonjs/Audio/index";
  67303. export * from "babylonjs/Behaviors/index";
  67304. export * from "babylonjs/Bones/index";
  67305. export * from "babylonjs/Cameras/index";
  67306. export * from "babylonjs/Collisions/index";
  67307. export * from "babylonjs/Culling/index";
  67308. export * from "babylonjs/Debug/index";
  67309. export * from "babylonjs/Engines/index";
  67310. export * from "babylonjs/Events/index";
  67311. export * from "babylonjs/Gamepads/index";
  67312. export * from "babylonjs/Gizmos/index";
  67313. export * from "babylonjs/Helpers/index";
  67314. export * from "babylonjs/Instrumentation/index";
  67315. export * from "babylonjs/Layers/index";
  67316. export * from "babylonjs/LensFlares/index";
  67317. export * from "babylonjs/Lights/index";
  67318. export * from "babylonjs/Loading/index";
  67319. export * from "babylonjs/Materials/index";
  67320. export * from "babylonjs/Maths/index";
  67321. export * from "babylonjs/Meshes/index";
  67322. export * from "babylonjs/Morph/index";
  67323. export * from "babylonjs/Navigation/index";
  67324. export * from "babylonjs/node";
  67325. export * from "babylonjs/Offline/index";
  67326. export * from "babylonjs/Particles/index";
  67327. export * from "babylonjs/Physics/index";
  67328. export * from "babylonjs/PostProcesses/index";
  67329. export * from "babylonjs/Probes/index";
  67330. export * from "babylonjs/Rendering/index";
  67331. export * from "babylonjs/scene";
  67332. export * from "babylonjs/sceneComponent";
  67333. export * from "babylonjs/Sprites/index";
  67334. export * from "babylonjs/States/index";
  67335. export * from "babylonjs/Misc/index";
  67336. export * from "babylonjs/types";
  67337. }
  67338. declare module "babylonjs/Animations/pathCursor" {
  67339. import { Vector3 } from "babylonjs/Maths/math.vector";
  67340. import { Path2 } from "babylonjs/Maths/math.path";
  67341. /**
  67342. * A cursor which tracks a point on a path
  67343. */
  67344. export class PathCursor {
  67345. private path;
  67346. /**
  67347. * Stores path cursor callbacks for when an onchange event is triggered
  67348. */
  67349. private _onchange;
  67350. /**
  67351. * The value of the path cursor
  67352. */
  67353. value: number;
  67354. /**
  67355. * The animation array of the path cursor
  67356. */
  67357. animations: Animation[];
  67358. /**
  67359. * Initializes the path cursor
  67360. * @param path The path to track
  67361. */
  67362. constructor(path: Path2);
  67363. /**
  67364. * Gets the cursor point on the path
  67365. * @returns A point on the path cursor at the cursor location
  67366. */
  67367. getPoint(): Vector3;
  67368. /**
  67369. * Moves the cursor ahead by the step amount
  67370. * @param step The amount to move the cursor forward
  67371. * @returns This path cursor
  67372. */
  67373. moveAhead(step?: number): PathCursor;
  67374. /**
  67375. * Moves the cursor behind by the step amount
  67376. * @param step The amount to move the cursor back
  67377. * @returns This path cursor
  67378. */
  67379. moveBack(step?: number): PathCursor;
  67380. /**
  67381. * Moves the cursor by the step amount
  67382. * If the step amount is greater than one, an exception is thrown
  67383. * @param step The amount to move the cursor
  67384. * @returns This path cursor
  67385. */
  67386. move(step: number): PathCursor;
  67387. /**
  67388. * Ensures that the value is limited between zero and one
  67389. * @returns This path cursor
  67390. */
  67391. private ensureLimits;
  67392. /**
  67393. * Runs onchange callbacks on change (used by the animation engine)
  67394. * @returns This path cursor
  67395. */
  67396. private raiseOnChange;
  67397. /**
  67398. * Executes a function on change
  67399. * @param f A path cursor onchange callback
  67400. * @returns This path cursor
  67401. */
  67402. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67403. }
  67404. }
  67405. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67406. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67407. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67408. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67409. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67410. }
  67411. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67412. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67413. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67414. }
  67415. declare module "babylonjs/Engines/Processors/index" {
  67416. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67417. export * from "babylonjs/Engines/Processors/Expressions/index";
  67418. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67419. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67420. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67421. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67422. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67423. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67424. }
  67425. declare module "babylonjs/Legacy/legacy" {
  67426. import * as Babylon from "babylonjs/index";
  67427. export * from "babylonjs/index";
  67428. }
  67429. declare module "babylonjs/Shaders/blur.fragment" {
  67430. /** @hidden */
  67431. export var blurPixelShader: {
  67432. name: string;
  67433. shader: string;
  67434. };
  67435. }
  67436. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67437. /** @hidden */
  67438. export var pointCloudVertexDeclaration: {
  67439. name: string;
  67440. shader: string;
  67441. };
  67442. }
  67443. declare module "babylonjs" {
  67444. export * from "babylonjs/Legacy/legacy";
  67445. }
  67446. declare module BABYLON {
  67447. /** Alias type for value that can be null */
  67448. export type Nullable<T> = T | null;
  67449. /**
  67450. * Alias type for number that are floats
  67451. * @ignorenaming
  67452. */
  67453. export type float = number;
  67454. /**
  67455. * Alias type for number that are doubles.
  67456. * @ignorenaming
  67457. */
  67458. export type double = number;
  67459. /**
  67460. * Alias type for number that are integer
  67461. * @ignorenaming
  67462. */
  67463. export type int = number;
  67464. /** Alias type for number array or Float32Array */
  67465. export type FloatArray = number[] | Float32Array;
  67466. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67467. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67468. /**
  67469. * Alias for types that can be used by a Buffer or VertexBuffer.
  67470. */
  67471. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67472. /**
  67473. * Alias type for primitive types
  67474. * @ignorenaming
  67475. */
  67476. type Primitive = undefined | null | boolean | string | number | Function;
  67477. /**
  67478. * Type modifier to make all the properties of an object Readonly
  67479. */
  67480. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67481. /**
  67482. * Type modifier to make all the properties of an object Readonly recursively
  67483. */
  67484. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67485. /**
  67486. * Type modifier to make object properties readonly.
  67487. */
  67488. export type DeepImmutableObject<T> = {
  67489. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67490. };
  67491. /** @hidden */
  67492. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67493. }
  67494. }
  67495. declare module BABYLON {
  67496. /**
  67497. * A class serves as a medium between the observable and its observers
  67498. */
  67499. export class EventState {
  67500. /**
  67501. * Create a new EventState
  67502. * @param mask defines the mask associated with this state
  67503. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67504. * @param target defines the original target of the state
  67505. * @param currentTarget defines the current target of the state
  67506. */
  67507. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67508. /**
  67509. * Initialize the current event state
  67510. * @param mask defines the mask associated with this state
  67511. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67512. * @param target defines the original target of the state
  67513. * @param currentTarget defines the current target of the state
  67514. * @returns the current event state
  67515. */
  67516. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67517. /**
  67518. * An Observer can set this property to true to prevent subsequent observers of being notified
  67519. */
  67520. skipNextObservers: boolean;
  67521. /**
  67522. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67523. */
  67524. mask: number;
  67525. /**
  67526. * The object that originally notified the event
  67527. */
  67528. target?: any;
  67529. /**
  67530. * The current object in the bubbling phase
  67531. */
  67532. currentTarget?: any;
  67533. /**
  67534. * This will be populated with the return value of the last function that was executed.
  67535. * If it is the first function in the callback chain it will be the event data.
  67536. */
  67537. lastReturnValue?: any;
  67538. }
  67539. /**
  67540. * Represent an Observer registered to a given Observable object.
  67541. */
  67542. export class Observer<T> {
  67543. /**
  67544. * Defines the callback to call when the observer is notified
  67545. */
  67546. callback: (eventData: T, eventState: EventState) => void;
  67547. /**
  67548. * Defines the mask of the observer (used to filter notifications)
  67549. */
  67550. mask: number;
  67551. /**
  67552. * Defines the current scope used to restore the JS context
  67553. */
  67554. scope: any;
  67555. /** @hidden */
  67556. _willBeUnregistered: boolean;
  67557. /**
  67558. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67559. */
  67560. unregisterOnNextCall: boolean;
  67561. /**
  67562. * Creates a new observer
  67563. * @param callback defines the callback to call when the observer is notified
  67564. * @param mask defines the mask of the observer (used to filter notifications)
  67565. * @param scope defines the current scope used to restore the JS context
  67566. */
  67567. constructor(
  67568. /**
  67569. * Defines the callback to call when the observer is notified
  67570. */
  67571. callback: (eventData: T, eventState: EventState) => void,
  67572. /**
  67573. * Defines the mask of the observer (used to filter notifications)
  67574. */
  67575. mask: number,
  67576. /**
  67577. * Defines the current scope used to restore the JS context
  67578. */
  67579. scope?: any);
  67580. }
  67581. /**
  67582. * Represent a list of observers registered to multiple Observables object.
  67583. */
  67584. export class MultiObserver<T> {
  67585. private _observers;
  67586. private _observables;
  67587. /**
  67588. * Release associated resources
  67589. */
  67590. dispose(): void;
  67591. /**
  67592. * Raise a callback when one of the observable will notify
  67593. * @param observables defines a list of observables to watch
  67594. * @param callback defines the callback to call on notification
  67595. * @param mask defines the mask used to filter notifications
  67596. * @param scope defines the current scope used to restore the JS context
  67597. * @returns the new MultiObserver
  67598. */
  67599. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67600. }
  67601. /**
  67602. * The Observable class is a simple implementation of the Observable pattern.
  67603. *
  67604. * 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.
  67605. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67606. * 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).
  67607. * 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.
  67608. */
  67609. export class Observable<T> {
  67610. private _observers;
  67611. private _eventState;
  67612. private _onObserverAdded;
  67613. /**
  67614. * Gets the list of observers
  67615. */
  67616. readonly observers: Array<Observer<T>>;
  67617. /**
  67618. * Creates a new observable
  67619. * @param onObserverAdded defines a callback to call when a new observer is added
  67620. */
  67621. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67622. /**
  67623. * Create a new Observer with the specified callback
  67624. * @param callback the callback that will be executed for that Observer
  67625. * @param mask the mask used to filter observers
  67626. * @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.
  67627. * @param scope optional scope for the callback to be called from
  67628. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67629. * @returns the new observer created for the callback
  67630. */
  67631. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67632. /**
  67633. * Create a new Observer with the specified callback and unregisters after the next notification
  67634. * @param callback the callback that will be executed for that Observer
  67635. * @returns the new observer created for the callback
  67636. */
  67637. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67638. /**
  67639. * Remove an Observer from the Observable object
  67640. * @param observer the instance of the Observer to remove
  67641. * @returns false if it doesn't belong to this Observable
  67642. */
  67643. remove(observer: Nullable<Observer<T>>): boolean;
  67644. /**
  67645. * Remove a callback from the Observable object
  67646. * @param callback the callback to remove
  67647. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67648. * @returns false if it doesn't belong to this Observable
  67649. */
  67650. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67651. private _deferUnregister;
  67652. private _remove;
  67653. /**
  67654. * Moves the observable to the top of the observer list making it get called first when notified
  67655. * @param observer the observer to move
  67656. */
  67657. makeObserverTopPriority(observer: Observer<T>): void;
  67658. /**
  67659. * Moves the observable to the bottom of the observer list making it get called last when notified
  67660. * @param observer the observer to move
  67661. */
  67662. makeObserverBottomPriority(observer: Observer<T>): void;
  67663. /**
  67664. * Notify all Observers by calling their respective callback with the given data
  67665. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67666. * @param eventData defines the data to send to all observers
  67667. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67668. * @param target defines the original target of the state
  67669. * @param currentTarget defines the current target of the state
  67670. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67671. */
  67672. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67673. /**
  67674. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67675. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67676. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67677. * and it is crucial that all callbacks will be executed.
  67678. * The order of the callbacks is kept, callbacks are not executed parallel.
  67679. *
  67680. * @param eventData The data to be sent to each callback
  67681. * @param mask is used to filter observers defaults to -1
  67682. * @param target defines the callback target (see EventState)
  67683. * @param currentTarget defines he current object in the bubbling phase
  67684. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67685. */
  67686. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67687. /**
  67688. * Notify a specific observer
  67689. * @param observer defines the observer to notify
  67690. * @param eventData defines the data to be sent to each callback
  67691. * @param mask is used to filter observers defaults to -1
  67692. */
  67693. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67694. /**
  67695. * Gets a boolean indicating if the observable has at least one observer
  67696. * @returns true is the Observable has at least one Observer registered
  67697. */
  67698. hasObservers(): boolean;
  67699. /**
  67700. * Clear the list of observers
  67701. */
  67702. clear(): void;
  67703. /**
  67704. * Clone the current observable
  67705. * @returns a new observable
  67706. */
  67707. clone(): Observable<T>;
  67708. /**
  67709. * Does this observable handles observer registered with a given mask
  67710. * @param mask defines the mask to be tested
  67711. * @return whether or not one observer registered with the given mask is handeled
  67712. **/
  67713. hasSpecificMask(mask?: number): boolean;
  67714. }
  67715. }
  67716. declare module BABYLON {
  67717. /**
  67718. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67719. * Babylon.js
  67720. */
  67721. export class DomManagement {
  67722. /**
  67723. * Checks if the window object exists
  67724. * @returns true if the window object exists
  67725. */
  67726. static IsWindowObjectExist(): boolean;
  67727. /**
  67728. * Checks if the navigator object exists
  67729. * @returns true if the navigator object exists
  67730. */
  67731. static IsNavigatorAvailable(): boolean;
  67732. /**
  67733. * Extracts text content from a DOM element hierarchy
  67734. * @param element defines the root element
  67735. * @returns a string
  67736. */
  67737. static GetDOMTextContent(element: HTMLElement): string;
  67738. }
  67739. }
  67740. declare module BABYLON {
  67741. /**
  67742. * Logger used througouht the application to allow configuration of
  67743. * the log level required for the messages.
  67744. */
  67745. export class Logger {
  67746. /**
  67747. * No log
  67748. */
  67749. static readonly NoneLogLevel: number;
  67750. /**
  67751. * Only message logs
  67752. */
  67753. static readonly MessageLogLevel: number;
  67754. /**
  67755. * Only warning logs
  67756. */
  67757. static readonly WarningLogLevel: number;
  67758. /**
  67759. * Only error logs
  67760. */
  67761. static readonly ErrorLogLevel: number;
  67762. /**
  67763. * All logs
  67764. */
  67765. static readonly AllLogLevel: number;
  67766. private static _LogCache;
  67767. /**
  67768. * Gets a value indicating the number of loading errors
  67769. * @ignorenaming
  67770. */
  67771. static errorsCount: number;
  67772. /**
  67773. * Callback called when a new log is added
  67774. */
  67775. static OnNewCacheEntry: (entry: string) => void;
  67776. private static _AddLogEntry;
  67777. private static _FormatMessage;
  67778. private static _LogDisabled;
  67779. private static _LogEnabled;
  67780. private static _WarnDisabled;
  67781. private static _WarnEnabled;
  67782. private static _ErrorDisabled;
  67783. private static _ErrorEnabled;
  67784. /**
  67785. * Log a message to the console
  67786. */
  67787. static Log: (message: string) => void;
  67788. /**
  67789. * Write a warning message to the console
  67790. */
  67791. static Warn: (message: string) => void;
  67792. /**
  67793. * Write an error message to the console
  67794. */
  67795. static Error: (message: string) => void;
  67796. /**
  67797. * Gets current log cache (list of logs)
  67798. */
  67799. static readonly LogCache: string;
  67800. /**
  67801. * Clears the log cache
  67802. */
  67803. static ClearLogCache(): void;
  67804. /**
  67805. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67806. */
  67807. static LogLevels: number;
  67808. }
  67809. }
  67810. declare module BABYLON {
  67811. /** @hidden */
  67812. export class _TypeStore {
  67813. /** @hidden */
  67814. static RegisteredTypes: {
  67815. [key: string]: Object;
  67816. };
  67817. /** @hidden */
  67818. static GetClass(fqdn: string): any;
  67819. }
  67820. }
  67821. declare module BABYLON {
  67822. /**
  67823. * Class containing a set of static utilities functions for deep copy.
  67824. */
  67825. export class DeepCopier {
  67826. /**
  67827. * Tries to copy an object by duplicating every property
  67828. * @param source defines the source object
  67829. * @param destination defines the target object
  67830. * @param doNotCopyList defines a list of properties to avoid
  67831. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67832. */
  67833. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67834. }
  67835. }
  67836. declare module BABYLON {
  67837. /**
  67838. * Class containing a set of static utilities functions for precision date
  67839. */
  67840. export class PrecisionDate {
  67841. /**
  67842. * Gets either window.performance.now() if supported or Date.now() else
  67843. */
  67844. static readonly Now: number;
  67845. }
  67846. }
  67847. declare module BABYLON {
  67848. /** @hidden */
  67849. export class _DevTools {
  67850. static WarnImport(name: string): string;
  67851. }
  67852. }
  67853. declare module BABYLON {
  67854. /**
  67855. * Interface used to define the mechanism to get data from the network
  67856. */
  67857. export interface IWebRequest {
  67858. /**
  67859. * Returns client's response url
  67860. */
  67861. responseURL: string;
  67862. /**
  67863. * Returns client's status
  67864. */
  67865. status: number;
  67866. /**
  67867. * Returns client's status as a text
  67868. */
  67869. statusText: string;
  67870. }
  67871. }
  67872. declare module BABYLON {
  67873. /**
  67874. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67875. */
  67876. export class WebRequest implements IWebRequest {
  67877. private _xhr;
  67878. /**
  67879. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67880. * i.e. when loading files, where the server/service expects an Authorization header
  67881. */
  67882. static CustomRequestHeaders: {
  67883. [key: string]: string;
  67884. };
  67885. /**
  67886. * Add callback functions in this array to update all the requests before they get sent to the network
  67887. */
  67888. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67889. private _injectCustomRequestHeaders;
  67890. /**
  67891. * Gets or sets a function to be called when loading progress changes
  67892. */
  67893. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67894. /**
  67895. * Returns client's state
  67896. */
  67897. readonly readyState: number;
  67898. /**
  67899. * Returns client's status
  67900. */
  67901. readonly status: number;
  67902. /**
  67903. * Returns client's status as a text
  67904. */
  67905. readonly statusText: string;
  67906. /**
  67907. * Returns client's response
  67908. */
  67909. readonly response: any;
  67910. /**
  67911. * Returns client's response url
  67912. */
  67913. readonly responseURL: string;
  67914. /**
  67915. * Returns client's response as text
  67916. */
  67917. readonly responseText: string;
  67918. /**
  67919. * Gets or sets the expected response type
  67920. */
  67921. responseType: XMLHttpRequestResponseType;
  67922. /** @hidden */
  67923. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67924. /** @hidden */
  67925. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67926. /**
  67927. * Cancels any network activity
  67928. */
  67929. abort(): void;
  67930. /**
  67931. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67932. * @param body defines an optional request body
  67933. */
  67934. send(body?: Document | BodyInit | null): void;
  67935. /**
  67936. * Sets the request method, request URL
  67937. * @param method defines the method to use (GET, POST, etc..)
  67938. * @param url defines the url to connect with
  67939. */
  67940. open(method: string, url: string): void;
  67941. /**
  67942. * Sets the value of a request header.
  67943. * @param name The name of the header whose value is to be set
  67944. * @param value The value to set as the body of the header
  67945. */
  67946. setRequestHeader(name: string, value: string): void;
  67947. /**
  67948. * Get the string containing the text of a particular header's value.
  67949. * @param name The name of the header
  67950. * @returns The string containing the text of the given header name
  67951. */
  67952. getResponseHeader(name: string): Nullable<string>;
  67953. }
  67954. }
  67955. declare module BABYLON {
  67956. /**
  67957. * File request interface
  67958. */
  67959. export interface IFileRequest {
  67960. /**
  67961. * Raised when the request is complete (success or error).
  67962. */
  67963. onCompleteObservable: Observable<IFileRequest>;
  67964. /**
  67965. * Aborts the request for a file.
  67966. */
  67967. abort: () => void;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /**
  67972. * Define options used to create a render target texture
  67973. */
  67974. export class RenderTargetCreationOptions {
  67975. /**
  67976. * Specifies is mipmaps must be generated
  67977. */
  67978. generateMipMaps?: boolean;
  67979. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67980. generateDepthBuffer?: boolean;
  67981. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67982. generateStencilBuffer?: boolean;
  67983. /** Defines texture type (int by default) */
  67984. type?: number;
  67985. /** Defines sampling mode (trilinear by default) */
  67986. samplingMode?: number;
  67987. /** Defines format (RGBA by default) */
  67988. format?: number;
  67989. }
  67990. }
  67991. declare module BABYLON {
  67992. /**
  67993. * @hidden
  67994. **/
  67995. export class _TimeToken {
  67996. _startTimeQuery: Nullable<WebGLQuery>;
  67997. _endTimeQuery: Nullable<WebGLQuery>;
  67998. _timeElapsedQuery: Nullable<WebGLQuery>;
  67999. _timeElapsedQueryEnded: boolean;
  68000. }
  68001. }
  68002. declare module BABYLON {
  68003. /** Defines the cross module used constants to avoid circular dependncies */
  68004. export class Constants {
  68005. /** Defines that alpha blending is disabled */
  68006. static readonly ALPHA_DISABLE: number;
  68007. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68008. static readonly ALPHA_ADD: number;
  68009. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68010. static readonly ALPHA_COMBINE: number;
  68011. /** Defines that alpha blending to DEST - SRC * DEST */
  68012. static readonly ALPHA_SUBTRACT: number;
  68013. /** Defines that alpha blending to SRC * DEST */
  68014. static readonly ALPHA_MULTIPLY: number;
  68015. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68016. static readonly ALPHA_MAXIMIZED: number;
  68017. /** Defines that alpha blending to SRC + DEST */
  68018. static readonly ALPHA_ONEONE: number;
  68019. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68020. static readonly ALPHA_PREMULTIPLIED: number;
  68021. /**
  68022. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68023. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68024. */
  68025. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68026. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68027. static readonly ALPHA_INTERPOLATE: number;
  68028. /**
  68029. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68030. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68031. */
  68032. static readonly ALPHA_SCREENMODE: number;
  68033. /**
  68034. * Defines that alpha blending to SRC + DST
  68035. * Alpha will be set to SRC ALPHA + DST ALPHA
  68036. */
  68037. static readonly ALPHA_ONEONE_ONEONE: number;
  68038. /**
  68039. * Defines that alpha blending to SRC * DST ALPHA + DST
  68040. * Alpha will be set to 0
  68041. */
  68042. static readonly ALPHA_ALPHATOCOLOR: number;
  68043. /**
  68044. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68045. */
  68046. static readonly ALPHA_REVERSEONEMINUS: number;
  68047. /**
  68048. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68049. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68050. */
  68051. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68052. /**
  68053. * Defines that alpha blending to SRC + DST
  68054. * Alpha will be set to SRC ALPHA
  68055. */
  68056. static readonly ALPHA_ONEONE_ONEZERO: number;
  68057. /** Defines that alpha blending equation a SUM */
  68058. static readonly ALPHA_EQUATION_ADD: number;
  68059. /** Defines that alpha blending equation a SUBSTRACTION */
  68060. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68061. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68062. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68063. /** Defines that alpha blending equation a MAX operation */
  68064. static readonly ALPHA_EQUATION_MAX: number;
  68065. /** Defines that alpha blending equation a MIN operation */
  68066. static readonly ALPHA_EQUATION_MIN: number;
  68067. /**
  68068. * Defines that alpha blending equation a DARKEN operation:
  68069. * It takes the min of the src and sums the alpha channels.
  68070. */
  68071. static readonly ALPHA_EQUATION_DARKEN: number;
  68072. /** Defines that the ressource is not delayed*/
  68073. static readonly DELAYLOADSTATE_NONE: number;
  68074. /** Defines that the ressource was successfully delay loaded */
  68075. static readonly DELAYLOADSTATE_LOADED: number;
  68076. /** Defines that the ressource is currently delay loading */
  68077. static readonly DELAYLOADSTATE_LOADING: number;
  68078. /** Defines that the ressource is delayed and has not started loading */
  68079. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68081. static readonly NEVER: number;
  68082. /** 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 */
  68083. static readonly ALWAYS: number;
  68084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68085. static readonly LESS: number;
  68086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68087. static readonly EQUAL: number;
  68088. /** 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 */
  68089. static readonly LEQUAL: number;
  68090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68091. static readonly GREATER: number;
  68092. /** 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 */
  68093. static readonly GEQUAL: number;
  68094. /** 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 */
  68095. static readonly NOTEQUAL: number;
  68096. /** Passed to stencilOperation to specify that stencil value must be kept */
  68097. static readonly KEEP: number;
  68098. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68099. static readonly REPLACE: number;
  68100. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68101. static readonly INCR: number;
  68102. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68103. static readonly DECR: number;
  68104. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68105. static readonly INVERT: number;
  68106. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68107. static readonly INCR_WRAP: number;
  68108. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68109. static readonly DECR_WRAP: number;
  68110. /** Texture is not repeating outside of 0..1 UVs */
  68111. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68112. /** Texture is repeating outside of 0..1 UVs */
  68113. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68114. /** Texture is repeating and mirrored */
  68115. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68116. /** ALPHA */
  68117. static readonly TEXTUREFORMAT_ALPHA: number;
  68118. /** LUMINANCE */
  68119. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68120. /** LUMINANCE_ALPHA */
  68121. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68122. /** RGB */
  68123. static readonly TEXTUREFORMAT_RGB: number;
  68124. /** RGBA */
  68125. static readonly TEXTUREFORMAT_RGBA: number;
  68126. /** RED */
  68127. static readonly TEXTUREFORMAT_RED: number;
  68128. /** RED (2nd reference) */
  68129. static readonly TEXTUREFORMAT_R: number;
  68130. /** RG */
  68131. static readonly TEXTUREFORMAT_RG: number;
  68132. /** RED_INTEGER */
  68133. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68134. /** RED_INTEGER (2nd reference) */
  68135. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68136. /** RG_INTEGER */
  68137. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68138. /** RGB_INTEGER */
  68139. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68140. /** RGBA_INTEGER */
  68141. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68142. /** UNSIGNED_BYTE */
  68143. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68144. /** UNSIGNED_BYTE (2nd reference) */
  68145. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68146. /** FLOAT */
  68147. static readonly TEXTURETYPE_FLOAT: number;
  68148. /** HALF_FLOAT */
  68149. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68150. /** BYTE */
  68151. static readonly TEXTURETYPE_BYTE: number;
  68152. /** SHORT */
  68153. static readonly TEXTURETYPE_SHORT: number;
  68154. /** UNSIGNED_SHORT */
  68155. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68156. /** INT */
  68157. static readonly TEXTURETYPE_INT: number;
  68158. /** UNSIGNED_INT */
  68159. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68160. /** UNSIGNED_SHORT_4_4_4_4 */
  68161. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68162. /** UNSIGNED_SHORT_5_5_5_1 */
  68163. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68164. /** UNSIGNED_SHORT_5_6_5 */
  68165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68166. /** UNSIGNED_INT_2_10_10_10_REV */
  68167. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68168. /** UNSIGNED_INT_24_8 */
  68169. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68170. /** UNSIGNED_INT_10F_11F_11F_REV */
  68171. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68172. /** UNSIGNED_INT_5_9_9_9_REV */
  68173. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68174. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68175. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68176. /** nearest is mag = nearest and min = nearest and mip = linear */
  68177. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68178. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68179. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68180. /** Trilinear is mag = linear and min = linear and mip = linear */
  68181. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68182. /** nearest is mag = nearest and min = nearest and mip = linear */
  68183. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68184. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68185. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68186. /** Trilinear is mag = linear and min = linear and mip = linear */
  68187. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68188. /** mag = nearest and min = nearest and mip = nearest */
  68189. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68190. /** mag = nearest and min = linear and mip = nearest */
  68191. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68192. /** mag = nearest and min = linear and mip = linear */
  68193. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68194. /** mag = nearest and min = linear and mip = none */
  68195. static readonly TEXTURE_NEAREST_LINEAR: number;
  68196. /** mag = nearest and min = nearest and mip = none */
  68197. static readonly TEXTURE_NEAREST_NEAREST: number;
  68198. /** mag = linear and min = nearest and mip = nearest */
  68199. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68200. /** mag = linear and min = nearest and mip = linear */
  68201. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68202. /** mag = linear and min = linear and mip = none */
  68203. static readonly TEXTURE_LINEAR_LINEAR: number;
  68204. /** mag = linear and min = nearest and mip = none */
  68205. static readonly TEXTURE_LINEAR_NEAREST: number;
  68206. /** Explicit coordinates mode */
  68207. static readonly TEXTURE_EXPLICIT_MODE: number;
  68208. /** Spherical coordinates mode */
  68209. static readonly TEXTURE_SPHERICAL_MODE: number;
  68210. /** Planar coordinates mode */
  68211. static readonly TEXTURE_PLANAR_MODE: number;
  68212. /** Cubic coordinates mode */
  68213. static readonly TEXTURE_CUBIC_MODE: number;
  68214. /** Projection coordinates mode */
  68215. static readonly TEXTURE_PROJECTION_MODE: number;
  68216. /** Skybox coordinates mode */
  68217. static readonly TEXTURE_SKYBOX_MODE: number;
  68218. /** Inverse Cubic coordinates mode */
  68219. static readonly TEXTURE_INVCUBIC_MODE: number;
  68220. /** Equirectangular coordinates mode */
  68221. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68222. /** Equirectangular Fixed coordinates mode */
  68223. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68224. /** Equirectangular Fixed Mirrored coordinates mode */
  68225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68226. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68227. static readonly SCALEMODE_FLOOR: number;
  68228. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68229. static readonly SCALEMODE_NEAREST: number;
  68230. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68231. static readonly SCALEMODE_CEILING: number;
  68232. /**
  68233. * The dirty texture flag value
  68234. */
  68235. static readonly MATERIAL_TextureDirtyFlag: number;
  68236. /**
  68237. * The dirty light flag value
  68238. */
  68239. static readonly MATERIAL_LightDirtyFlag: number;
  68240. /**
  68241. * The dirty fresnel flag value
  68242. */
  68243. static readonly MATERIAL_FresnelDirtyFlag: number;
  68244. /**
  68245. * The dirty attribute flag value
  68246. */
  68247. static readonly MATERIAL_AttributesDirtyFlag: number;
  68248. /**
  68249. * The dirty misc flag value
  68250. */
  68251. static readonly MATERIAL_MiscDirtyFlag: number;
  68252. /**
  68253. * The all dirty flag value
  68254. */
  68255. static readonly MATERIAL_AllDirtyFlag: number;
  68256. /**
  68257. * Returns the triangle fill mode
  68258. */
  68259. static readonly MATERIAL_TriangleFillMode: number;
  68260. /**
  68261. * Returns the wireframe mode
  68262. */
  68263. static readonly MATERIAL_WireFrameFillMode: number;
  68264. /**
  68265. * Returns the point fill mode
  68266. */
  68267. static readonly MATERIAL_PointFillMode: number;
  68268. /**
  68269. * Returns the point list draw mode
  68270. */
  68271. static readonly MATERIAL_PointListDrawMode: number;
  68272. /**
  68273. * Returns the line list draw mode
  68274. */
  68275. static readonly MATERIAL_LineListDrawMode: number;
  68276. /**
  68277. * Returns the line loop draw mode
  68278. */
  68279. static readonly MATERIAL_LineLoopDrawMode: number;
  68280. /**
  68281. * Returns the line strip draw mode
  68282. */
  68283. static readonly MATERIAL_LineStripDrawMode: number;
  68284. /**
  68285. * Returns the triangle strip draw mode
  68286. */
  68287. static readonly MATERIAL_TriangleStripDrawMode: number;
  68288. /**
  68289. * Returns the triangle fan draw mode
  68290. */
  68291. static readonly MATERIAL_TriangleFanDrawMode: number;
  68292. /**
  68293. * Stores the clock-wise side orientation
  68294. */
  68295. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68296. /**
  68297. * Stores the counter clock-wise side orientation
  68298. */
  68299. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68300. /**
  68301. * Nothing
  68302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68303. */
  68304. static readonly ACTION_NothingTrigger: number;
  68305. /**
  68306. * On pick
  68307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68308. */
  68309. static readonly ACTION_OnPickTrigger: number;
  68310. /**
  68311. * On left pick
  68312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68313. */
  68314. static readonly ACTION_OnLeftPickTrigger: number;
  68315. /**
  68316. * On right pick
  68317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68318. */
  68319. static readonly ACTION_OnRightPickTrigger: number;
  68320. /**
  68321. * On center pick
  68322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68323. */
  68324. static readonly ACTION_OnCenterPickTrigger: number;
  68325. /**
  68326. * On pick down
  68327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68328. */
  68329. static readonly ACTION_OnPickDownTrigger: number;
  68330. /**
  68331. * On double pick
  68332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68333. */
  68334. static readonly ACTION_OnDoublePickTrigger: number;
  68335. /**
  68336. * On pick up
  68337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68338. */
  68339. static readonly ACTION_OnPickUpTrigger: number;
  68340. /**
  68341. * On pick out.
  68342. * This trigger will only be raised if you also declared a OnPickDown
  68343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68344. */
  68345. static readonly ACTION_OnPickOutTrigger: number;
  68346. /**
  68347. * On long press
  68348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68349. */
  68350. static readonly ACTION_OnLongPressTrigger: number;
  68351. /**
  68352. * On pointer over
  68353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68354. */
  68355. static readonly ACTION_OnPointerOverTrigger: number;
  68356. /**
  68357. * On pointer out
  68358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68359. */
  68360. static readonly ACTION_OnPointerOutTrigger: number;
  68361. /**
  68362. * On every frame
  68363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68364. */
  68365. static readonly ACTION_OnEveryFrameTrigger: number;
  68366. /**
  68367. * On intersection enter
  68368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68369. */
  68370. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68371. /**
  68372. * On intersection exit
  68373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68374. */
  68375. static readonly ACTION_OnIntersectionExitTrigger: number;
  68376. /**
  68377. * On key down
  68378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68379. */
  68380. static readonly ACTION_OnKeyDownTrigger: number;
  68381. /**
  68382. * On key up
  68383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68384. */
  68385. static readonly ACTION_OnKeyUpTrigger: number;
  68386. /**
  68387. * Billboard mode will only apply to Y axis
  68388. */
  68389. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68390. /**
  68391. * Billboard mode will apply to all axes
  68392. */
  68393. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68394. /**
  68395. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68396. */
  68397. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68398. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68399. * Test order :
  68400. * Is the bounding sphere outside the frustum ?
  68401. * If not, are the bounding box vertices outside the frustum ?
  68402. * It not, then the cullable object is in the frustum.
  68403. */
  68404. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68405. /** Culling strategy : Bounding Sphere Only.
  68406. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68407. * It's also less accurate than the standard because some not visible objects can still be selected.
  68408. * Test : is the bounding sphere outside the frustum ?
  68409. * If not, then the cullable object is in the frustum.
  68410. */
  68411. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68412. /** Culling strategy : Optimistic Inclusion.
  68413. * This in an inclusion test first, then the standard exclusion test.
  68414. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68415. * 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.
  68416. * Anyway, it's as accurate as the standard strategy.
  68417. * Test :
  68418. * Is the cullable object bounding sphere center in the frustum ?
  68419. * If not, apply the default culling strategy.
  68420. */
  68421. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68422. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68423. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68424. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68425. * 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.
  68426. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68427. * Test :
  68428. * Is the cullable object bounding sphere center in the frustum ?
  68429. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68430. */
  68431. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68432. /**
  68433. * No logging while loading
  68434. */
  68435. static readonly SCENELOADER_NO_LOGGING: number;
  68436. /**
  68437. * Minimal logging while loading
  68438. */
  68439. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68440. /**
  68441. * Summary logging while loading
  68442. */
  68443. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68444. /**
  68445. * Detailled logging while loading
  68446. */
  68447. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68448. }
  68449. }
  68450. declare module BABYLON {
  68451. /**
  68452. * This represents the required contract to create a new type of texture loader.
  68453. */
  68454. export interface IInternalTextureLoader {
  68455. /**
  68456. * Defines wether the loader supports cascade loading the different faces.
  68457. */
  68458. supportCascades: boolean;
  68459. /**
  68460. * This returns if the loader support the current file information.
  68461. * @param extension defines the file extension of the file being loaded
  68462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68463. * @param fallback defines the fallback internal texture if any
  68464. * @param isBase64 defines whether the texture is encoded as a base64
  68465. * @param isBuffer defines whether the texture data are stored as a buffer
  68466. * @returns true if the loader can load the specified file
  68467. */
  68468. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68469. /**
  68470. * Transform the url before loading if required.
  68471. * @param rootUrl the url of the texture
  68472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68473. * @returns the transformed texture
  68474. */
  68475. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68476. /**
  68477. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68478. * @param rootUrl the url of the texture
  68479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68480. * @returns the fallback texture
  68481. */
  68482. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68483. /**
  68484. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68485. * @param data contains the texture data
  68486. * @param texture defines the BabylonJS internal texture
  68487. * @param createPolynomials will be true if polynomials have been requested
  68488. * @param onLoad defines the callback to trigger once the texture is ready
  68489. * @param onError defines the callback to trigger in case of error
  68490. */
  68491. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68492. /**
  68493. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68494. * @param data contains the texture data
  68495. * @param texture defines the BabylonJS internal texture
  68496. * @param callback defines the method to call once ready to upload
  68497. */
  68498. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68499. }
  68500. }
  68501. declare module BABYLON {
  68502. /**
  68503. * Class used to store and describe the pipeline context associated with an effect
  68504. */
  68505. export interface IPipelineContext {
  68506. /**
  68507. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68508. */
  68509. isAsync: boolean;
  68510. /**
  68511. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68512. */
  68513. isReady: boolean;
  68514. /** @hidden */
  68515. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68516. }
  68517. }
  68518. declare module BABYLON {
  68519. /**
  68520. * Class used to store gfx data (like WebGLBuffer)
  68521. */
  68522. export class DataBuffer {
  68523. /**
  68524. * Gets or sets the number of objects referencing this buffer
  68525. */
  68526. references: number;
  68527. /** Gets or sets the size of the underlying buffer */
  68528. capacity: number;
  68529. /**
  68530. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68531. */
  68532. is32Bits: boolean;
  68533. /**
  68534. * Gets the underlying buffer
  68535. */
  68536. readonly underlyingResource: any;
  68537. }
  68538. }
  68539. declare module BABYLON {
  68540. /** @hidden */
  68541. export interface IShaderProcessor {
  68542. attributeProcessor?: (attribute: string) => string;
  68543. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68544. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68545. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68546. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68547. lineProcessor?: (line: string, isFragment: boolean) => string;
  68548. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68549. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68550. }
  68551. }
  68552. declare module BABYLON {
  68553. /** @hidden */
  68554. export interface ProcessingOptions {
  68555. defines: string[];
  68556. indexParameters: any;
  68557. isFragment: boolean;
  68558. shouldUseHighPrecisionShader: boolean;
  68559. supportsUniformBuffers: boolean;
  68560. shadersRepository: string;
  68561. includesShadersStore: {
  68562. [key: string]: string;
  68563. };
  68564. processor?: IShaderProcessor;
  68565. version: string;
  68566. platformName: string;
  68567. lookForClosingBracketForUniformBuffer?: boolean;
  68568. }
  68569. }
  68570. declare module BABYLON {
  68571. /**
  68572. * Helper to manipulate strings
  68573. */
  68574. export class StringTools {
  68575. /**
  68576. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68577. * @param str Source string
  68578. * @param suffix Suffix to search for in the source string
  68579. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68580. */
  68581. static EndsWith(str: string, suffix: string): boolean;
  68582. /**
  68583. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68584. * @param str Source string
  68585. * @param suffix Suffix to search for in the source string
  68586. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68587. */
  68588. static StartsWith(str: string, suffix: string): boolean;
  68589. /**
  68590. * Decodes a buffer into a string
  68591. * @param buffer The buffer to decode
  68592. * @returns The decoded string
  68593. */
  68594. static Decode(buffer: Uint8Array | Uint16Array): string;
  68595. }
  68596. }
  68597. declare module BABYLON {
  68598. /** @hidden */
  68599. export class ShaderCodeNode {
  68600. line: string;
  68601. children: ShaderCodeNode[];
  68602. additionalDefineKey?: string;
  68603. additionalDefineValue?: string;
  68604. isValid(preprocessors: {
  68605. [key: string]: string;
  68606. }): boolean;
  68607. process(preprocessors: {
  68608. [key: string]: string;
  68609. }, options: ProcessingOptions): string;
  68610. }
  68611. }
  68612. declare module BABYLON {
  68613. /** @hidden */
  68614. export class ShaderCodeCursor {
  68615. private _lines;
  68616. lineIndex: number;
  68617. readonly currentLine: string;
  68618. readonly canRead: boolean;
  68619. lines: string[];
  68620. }
  68621. }
  68622. declare module BABYLON {
  68623. /** @hidden */
  68624. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68625. process(preprocessors: {
  68626. [key: string]: string;
  68627. }, options: ProcessingOptions): string;
  68628. }
  68629. }
  68630. declare module BABYLON {
  68631. /** @hidden */
  68632. export class ShaderDefineExpression {
  68633. isTrue(preprocessors: {
  68634. [key: string]: string;
  68635. }): boolean;
  68636. }
  68637. }
  68638. declare module BABYLON {
  68639. /** @hidden */
  68640. export class ShaderCodeTestNode extends ShaderCodeNode {
  68641. testExpression: ShaderDefineExpression;
  68642. isValid(preprocessors: {
  68643. [key: string]: string;
  68644. }): boolean;
  68645. }
  68646. }
  68647. declare module BABYLON {
  68648. /** @hidden */
  68649. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68650. define: string;
  68651. not: boolean;
  68652. constructor(define: string, not?: boolean);
  68653. isTrue(preprocessors: {
  68654. [key: string]: string;
  68655. }): boolean;
  68656. }
  68657. }
  68658. declare module BABYLON {
  68659. /** @hidden */
  68660. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68661. leftOperand: ShaderDefineExpression;
  68662. rightOperand: ShaderDefineExpression;
  68663. isTrue(preprocessors: {
  68664. [key: string]: string;
  68665. }): boolean;
  68666. }
  68667. }
  68668. declare module BABYLON {
  68669. /** @hidden */
  68670. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68671. leftOperand: ShaderDefineExpression;
  68672. rightOperand: ShaderDefineExpression;
  68673. isTrue(preprocessors: {
  68674. [key: string]: string;
  68675. }): boolean;
  68676. }
  68677. }
  68678. declare module BABYLON {
  68679. /** @hidden */
  68680. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68681. define: string;
  68682. operand: string;
  68683. testValue: string;
  68684. constructor(define: string, operand: string, testValue: string);
  68685. isTrue(preprocessors: {
  68686. [key: string]: string;
  68687. }): boolean;
  68688. }
  68689. }
  68690. declare module BABYLON {
  68691. /**
  68692. * Class used to enable access to offline support
  68693. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68694. */
  68695. export interface IOfflineProvider {
  68696. /**
  68697. * Gets a boolean indicating if scene must be saved in the database
  68698. */
  68699. enableSceneOffline: boolean;
  68700. /**
  68701. * Gets a boolean indicating if textures must be saved in the database
  68702. */
  68703. enableTexturesOffline: boolean;
  68704. /**
  68705. * Open the offline support and make it available
  68706. * @param successCallback defines the callback to call on success
  68707. * @param errorCallback defines the callback to call on error
  68708. */
  68709. open(successCallback: () => void, errorCallback: () => void): void;
  68710. /**
  68711. * Loads an image from the offline support
  68712. * @param url defines the url to load from
  68713. * @param image defines the target DOM image
  68714. */
  68715. loadImage(url: string, image: HTMLImageElement): void;
  68716. /**
  68717. * Loads a file from offline support
  68718. * @param url defines the URL to load from
  68719. * @param sceneLoaded defines a callback to call on success
  68720. * @param progressCallBack defines a callback to call when progress changed
  68721. * @param errorCallback defines a callback to call on error
  68722. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68723. */
  68724. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68725. }
  68726. }
  68727. declare module BABYLON {
  68728. /**
  68729. * Class used to help managing file picking and drag'n'drop
  68730. * File Storage
  68731. */
  68732. export class FilesInputStore {
  68733. /**
  68734. * List of files ready to be loaded
  68735. */
  68736. static FilesToLoad: {
  68737. [key: string]: File;
  68738. };
  68739. }
  68740. }
  68741. declare module BABYLON {
  68742. /**
  68743. * Class used to define a retry strategy when error happens while loading assets
  68744. */
  68745. export class RetryStrategy {
  68746. /**
  68747. * Function used to defines an exponential back off strategy
  68748. * @param maxRetries defines the maximum number of retries (3 by default)
  68749. * @param baseInterval defines the interval between retries
  68750. * @returns the strategy function to use
  68751. */
  68752. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68753. }
  68754. }
  68755. declare module BABYLON {
  68756. /**
  68757. * @ignore
  68758. * Application error to support additional information when loading a file
  68759. */
  68760. export abstract class BaseError extends Error {
  68761. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  68762. }
  68763. }
  68764. declare module BABYLON {
  68765. /** @ignore */
  68766. export class LoadFileError extends BaseError {
  68767. request?: WebRequest;
  68768. file?: File;
  68769. /**
  68770. * Creates a new LoadFileError
  68771. * @param message defines the message of the error
  68772. * @param request defines the optional web request
  68773. * @param file defines the optional file
  68774. */
  68775. constructor(message: string, object?: WebRequest | File);
  68776. }
  68777. /** @ignore */
  68778. export class RequestFileError extends BaseError {
  68779. request: WebRequest;
  68780. /**
  68781. * Creates a new LoadFileError
  68782. * @param message defines the message of the error
  68783. * @param request defines the optional web request
  68784. */
  68785. constructor(message: string, request: WebRequest);
  68786. }
  68787. /** @ignore */
  68788. export class ReadFileError extends BaseError {
  68789. file: File;
  68790. /**
  68791. * Creates a new ReadFileError
  68792. * @param message defines the message of the error
  68793. * @param file defines the optional file
  68794. */
  68795. constructor(message: string, file: File);
  68796. }
  68797. /**
  68798. * @hidden
  68799. */
  68800. export class FileTools {
  68801. /**
  68802. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68803. */
  68804. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68805. /**
  68806. * Gets or sets the base URL to use to load assets
  68807. */
  68808. static BaseUrl: string;
  68809. /**
  68810. * Default behaviour for cors in the application.
  68811. * It can be a string if the expected behavior is identical in the entire app.
  68812. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68813. */
  68814. static CorsBehavior: string | ((url: string | string[]) => string);
  68815. /**
  68816. * Gets or sets a function used to pre-process url before using them to load assets
  68817. */
  68818. static PreprocessUrl: (url: string) => string;
  68819. /**
  68820. * Removes unwanted characters from an url
  68821. * @param url defines the url to clean
  68822. * @returns the cleaned url
  68823. */
  68824. private static _CleanUrl;
  68825. /**
  68826. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68827. * @param url define the url we are trying
  68828. * @param element define the dom element where to configure the cors policy
  68829. */
  68830. static SetCorsBehavior(url: string | string[], element: {
  68831. crossOrigin: string | null;
  68832. }): void;
  68833. private static _ArrayBufferToBase64;
  68834. /**
  68835. * Loads an image as an HTMLImageElement.
  68836. * @param input url string, ArrayBuffer, or Blob to load
  68837. * @param onLoad callback called when the image successfully loads
  68838. * @param onError callback called when the image fails to load
  68839. * @param offlineProvider offline provider for caching
  68840. * @param mimeType optional mime type
  68841. * @returns the HTMLImageElement of the loaded image
  68842. */
  68843. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  68844. /**
  68845. * Reads a file from a File object
  68846. * @param file defines the file to load
  68847. * @param onSuccess defines the callback to call when data is loaded
  68848. * @param onProgress defines the callback to call during loading process
  68849. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68850. * @param onError defines the callback to call when an error occurs
  68851. * @returns a file request object
  68852. */
  68853. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  68854. /**
  68855. * Loads a file from a url
  68856. * @param url url to load
  68857. * @param onSuccess callback called when the file successfully loads
  68858. * @param onProgress callback called while file is loading (if the server supports this mode)
  68859. * @param offlineProvider defines the offline provider for caching
  68860. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68861. * @param onError callback called when the file fails to load
  68862. * @returns a file request object
  68863. */
  68864. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  68865. /**
  68866. * Loads a file
  68867. * @param url url to load
  68868. * @param onSuccess callback called when the file successfully loads
  68869. * @param onProgress callback called while file is loading (if the server supports this mode)
  68870. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68871. * @param onError callback called when the file fails to load
  68872. * @param onOpened callback called when the web request is opened
  68873. * @returns a file request object
  68874. */
  68875. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  68876. /**
  68877. * Checks if the loaded document was accessed via `file:`-Protocol.
  68878. * @returns boolean
  68879. */
  68880. static IsFileURL(): boolean;
  68881. }
  68882. }
  68883. declare module BABYLON {
  68884. /** @hidden */
  68885. export class ShaderProcessor {
  68886. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68887. private static _ProcessPrecision;
  68888. private static _ExtractOperation;
  68889. private static _BuildSubExpression;
  68890. private static _BuildExpression;
  68891. private static _MoveCursorWithinIf;
  68892. private static _MoveCursor;
  68893. private static _EvaluatePreProcessors;
  68894. private static _PreparePreProcessors;
  68895. private static _ProcessShaderConversion;
  68896. private static _ProcessIncludes;
  68897. }
  68898. }
  68899. declare module BABYLON {
  68900. /**
  68901. * @hidden
  68902. */
  68903. export interface IColor4Like {
  68904. r: float;
  68905. g: float;
  68906. b: float;
  68907. a: float;
  68908. }
  68909. /**
  68910. * @hidden
  68911. */
  68912. export interface IColor3Like {
  68913. r: float;
  68914. g: float;
  68915. b: float;
  68916. }
  68917. /**
  68918. * @hidden
  68919. */
  68920. export interface IVector4Like {
  68921. x: float;
  68922. y: float;
  68923. z: float;
  68924. w: float;
  68925. }
  68926. /**
  68927. * @hidden
  68928. */
  68929. export interface IVector3Like {
  68930. x: float;
  68931. y: float;
  68932. z: float;
  68933. }
  68934. /**
  68935. * @hidden
  68936. */
  68937. export interface IVector2Like {
  68938. x: float;
  68939. y: float;
  68940. }
  68941. /**
  68942. * @hidden
  68943. */
  68944. export interface IMatrixLike {
  68945. toArray(): DeepImmutable<Float32Array>;
  68946. updateFlag: int;
  68947. }
  68948. /**
  68949. * @hidden
  68950. */
  68951. export interface IViewportLike {
  68952. x: float;
  68953. y: float;
  68954. width: float;
  68955. height: float;
  68956. }
  68957. /**
  68958. * @hidden
  68959. */
  68960. export interface IPlaneLike {
  68961. normal: IVector3Like;
  68962. d: float;
  68963. normalize(): void;
  68964. }
  68965. }
  68966. declare module BABYLON {
  68967. /**
  68968. * Interface used to define common properties for effect fallbacks
  68969. */
  68970. export interface IEffectFallbacks {
  68971. /**
  68972. * Removes the defines that should be removed when falling back.
  68973. * @param currentDefines defines the current define statements for the shader.
  68974. * @param effect defines the current effect we try to compile
  68975. * @returns The resulting defines with defines of the current rank removed.
  68976. */
  68977. reduce(currentDefines: string, effect: Effect): string;
  68978. /**
  68979. * Removes the fallback from the bound mesh.
  68980. */
  68981. unBindMesh(): void;
  68982. /**
  68983. * Checks to see if more fallbacks are still availible.
  68984. */
  68985. hasMoreFallbacks: boolean;
  68986. }
  68987. }
  68988. declare module BABYLON {
  68989. /**
  68990. * Class used to evalaute queries containing `and` and `or` operators
  68991. */
  68992. export class AndOrNotEvaluator {
  68993. /**
  68994. * Evaluate a query
  68995. * @param query defines the query to evaluate
  68996. * @param evaluateCallback defines the callback used to filter result
  68997. * @returns true if the query matches
  68998. */
  68999. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69000. private static _HandleParenthesisContent;
  69001. private static _SimplifyNegation;
  69002. }
  69003. }
  69004. declare module BABYLON {
  69005. /**
  69006. * Class used to store custom tags
  69007. */
  69008. export class Tags {
  69009. /**
  69010. * Adds support for tags on the given object
  69011. * @param obj defines the object to use
  69012. */
  69013. static EnableFor(obj: any): void;
  69014. /**
  69015. * Removes tags support
  69016. * @param obj defines the object to use
  69017. */
  69018. static DisableFor(obj: any): void;
  69019. /**
  69020. * Gets a boolean indicating if the given object has tags
  69021. * @param obj defines the object to use
  69022. * @returns a boolean
  69023. */
  69024. static HasTags(obj: any): boolean;
  69025. /**
  69026. * Gets the tags available on a given object
  69027. * @param obj defines the object to use
  69028. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69029. * @returns the tags
  69030. */
  69031. static GetTags(obj: any, asString?: boolean): any;
  69032. /**
  69033. * Adds tags to an object
  69034. * @param obj defines the object to use
  69035. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69036. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69037. */
  69038. static AddTagsTo(obj: any, tagsString: string): void;
  69039. /**
  69040. * @hidden
  69041. */
  69042. static _AddTagTo(obj: any, tag: string): void;
  69043. /**
  69044. * Removes specific tags from a specific object
  69045. * @param obj defines the object to use
  69046. * @param tagsString defines the tags to remove
  69047. */
  69048. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69049. /**
  69050. * @hidden
  69051. */
  69052. static _RemoveTagFrom(obj: any, tag: string): void;
  69053. /**
  69054. * Defines if tags hosted on an object match a given query
  69055. * @param obj defines the object to use
  69056. * @param tagsQuery defines the tag query
  69057. * @returns a boolean
  69058. */
  69059. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69060. }
  69061. }
  69062. declare module BABYLON {
  69063. /**
  69064. * Scalar computation library
  69065. */
  69066. export class Scalar {
  69067. /**
  69068. * Two pi constants convenient for computation.
  69069. */
  69070. static TwoPi: number;
  69071. /**
  69072. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69073. * @param a number
  69074. * @param b number
  69075. * @param epsilon (default = 1.401298E-45)
  69076. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69077. */
  69078. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69079. /**
  69080. * Returns a string : the upper case translation of the number i to hexadecimal.
  69081. * @param i number
  69082. * @returns the upper case translation of the number i to hexadecimal.
  69083. */
  69084. static ToHex(i: number): string;
  69085. /**
  69086. * Returns -1 if value is negative and +1 is value is positive.
  69087. * @param value the value
  69088. * @returns the value itself if it's equal to zero.
  69089. */
  69090. static Sign(value: number): number;
  69091. /**
  69092. * Returns the value itself if it's between min and max.
  69093. * Returns min if the value is lower than min.
  69094. * Returns max if the value is greater than max.
  69095. * @param value the value to clmap
  69096. * @param min the min value to clamp to (default: 0)
  69097. * @param max the max value to clamp to (default: 1)
  69098. * @returns the clamped value
  69099. */
  69100. static Clamp(value: number, min?: number, max?: number): number;
  69101. /**
  69102. * the log2 of value.
  69103. * @param value the value to compute log2 of
  69104. * @returns the log2 of value.
  69105. */
  69106. static Log2(value: number): number;
  69107. /**
  69108. * Loops the value, so that it is never larger than length and never smaller than 0.
  69109. *
  69110. * This is similar to the modulo operator but it works with floating point numbers.
  69111. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69112. * With t = 5 and length = 2.5, the result would be 0.0.
  69113. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69114. * @param value the value
  69115. * @param length the length
  69116. * @returns the looped value
  69117. */
  69118. static Repeat(value: number, length: number): number;
  69119. /**
  69120. * Normalize the value between 0.0 and 1.0 using min and max values
  69121. * @param value value to normalize
  69122. * @param min max to normalize between
  69123. * @param max min to normalize between
  69124. * @returns the normalized value
  69125. */
  69126. static Normalize(value: number, min: number, max: number): number;
  69127. /**
  69128. * Denormalize the value from 0.0 and 1.0 using min and max values
  69129. * @param normalized value to denormalize
  69130. * @param min max to denormalize between
  69131. * @param max min to denormalize between
  69132. * @returns the denormalized value
  69133. */
  69134. static Denormalize(normalized: number, min: number, max: number): number;
  69135. /**
  69136. * Calculates the shortest difference between two given angles given in degrees.
  69137. * @param current current angle in degrees
  69138. * @param target target angle in degrees
  69139. * @returns the delta
  69140. */
  69141. static DeltaAngle(current: number, target: number): number;
  69142. /**
  69143. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69144. * @param tx value
  69145. * @param length length
  69146. * @returns The returned value will move back and forth between 0 and length
  69147. */
  69148. static PingPong(tx: number, length: number): number;
  69149. /**
  69150. * Interpolates between min and max with smoothing at the limits.
  69151. *
  69152. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69153. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69154. * @param from from
  69155. * @param to to
  69156. * @param tx value
  69157. * @returns the smooth stepped value
  69158. */
  69159. static SmoothStep(from: number, to: number, tx: number): number;
  69160. /**
  69161. * Moves a value current towards target.
  69162. *
  69163. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69164. * Negative values of maxDelta pushes the value away from target.
  69165. * @param current current value
  69166. * @param target target value
  69167. * @param maxDelta max distance to move
  69168. * @returns resulting value
  69169. */
  69170. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69171. /**
  69172. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69173. *
  69174. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69175. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69176. * @param current current value
  69177. * @param target target value
  69178. * @param maxDelta max distance to move
  69179. * @returns resulting angle
  69180. */
  69181. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69182. /**
  69183. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69184. * @param start start value
  69185. * @param end target value
  69186. * @param amount amount to lerp between
  69187. * @returns the lerped value
  69188. */
  69189. static Lerp(start: number, end: number, amount: number): number;
  69190. /**
  69191. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69192. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69193. * @param start start value
  69194. * @param end target value
  69195. * @param amount amount to lerp between
  69196. * @returns the lerped value
  69197. */
  69198. static LerpAngle(start: number, end: number, amount: number): number;
  69199. /**
  69200. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69201. * @param a start value
  69202. * @param b target value
  69203. * @param value value between a and b
  69204. * @returns the inverseLerp value
  69205. */
  69206. static InverseLerp(a: number, b: number, value: number): number;
  69207. /**
  69208. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69209. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69210. * @param value1 spline value
  69211. * @param tangent1 spline value
  69212. * @param value2 spline value
  69213. * @param tangent2 spline value
  69214. * @param amount input value
  69215. * @returns hermite result
  69216. */
  69217. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69218. /**
  69219. * Returns a random float number between and min and max values
  69220. * @param min min value of random
  69221. * @param max max value of random
  69222. * @returns random value
  69223. */
  69224. static RandomRange(min: number, max: number): number;
  69225. /**
  69226. * This function returns percentage of a number in a given range.
  69227. *
  69228. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69229. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69230. * @param number to convert to percentage
  69231. * @param min min range
  69232. * @param max max range
  69233. * @returns the percentage
  69234. */
  69235. static RangeToPercent(number: number, min: number, max: number): number;
  69236. /**
  69237. * This function returns number that corresponds to the percentage in a given range.
  69238. *
  69239. * PercentToRange(0.34,0,100) will return 34.
  69240. * @param percent to convert to number
  69241. * @param min min range
  69242. * @param max max range
  69243. * @returns the number
  69244. */
  69245. static PercentToRange(percent: number, min: number, max: number): number;
  69246. /**
  69247. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69248. * @param angle The angle to normalize in radian.
  69249. * @return The converted angle.
  69250. */
  69251. static NormalizeRadians(angle: number): number;
  69252. }
  69253. }
  69254. declare module BABYLON {
  69255. /**
  69256. * Constant used to convert a value to gamma space
  69257. * @ignorenaming
  69258. */
  69259. export const ToGammaSpace: number;
  69260. /**
  69261. * Constant used to convert a value to linear space
  69262. * @ignorenaming
  69263. */
  69264. export const ToLinearSpace = 2.2;
  69265. /**
  69266. * Constant used to define the minimal number value in Babylon.js
  69267. * @ignorenaming
  69268. */
  69269. let Epsilon: number;
  69270. }
  69271. declare module BABYLON {
  69272. /**
  69273. * Class used to represent a viewport on screen
  69274. */
  69275. export class Viewport {
  69276. /** viewport left coordinate */
  69277. x: number;
  69278. /** viewport top coordinate */
  69279. y: number;
  69280. /**viewport width */
  69281. width: number;
  69282. /** viewport height */
  69283. height: number;
  69284. /**
  69285. * Creates a Viewport object located at (x, y) and sized (width, height)
  69286. * @param x defines viewport left coordinate
  69287. * @param y defines viewport top coordinate
  69288. * @param width defines the viewport width
  69289. * @param height defines the viewport height
  69290. */
  69291. constructor(
  69292. /** viewport left coordinate */
  69293. x: number,
  69294. /** viewport top coordinate */
  69295. y: number,
  69296. /**viewport width */
  69297. width: number,
  69298. /** viewport height */
  69299. height: number);
  69300. /**
  69301. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69302. * @param renderWidth defines the rendering width
  69303. * @param renderHeight defines the rendering height
  69304. * @returns a new Viewport
  69305. */
  69306. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69307. /**
  69308. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69309. * @param renderWidth defines the rendering width
  69310. * @param renderHeight defines the rendering height
  69311. * @param ref defines the target viewport
  69312. * @returns the current viewport
  69313. */
  69314. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69315. /**
  69316. * Returns a new Viewport copied from the current one
  69317. * @returns a new Viewport
  69318. */
  69319. clone(): Viewport;
  69320. }
  69321. }
  69322. declare module BABYLON {
  69323. /**
  69324. * Class containing a set of static utilities functions for arrays.
  69325. */
  69326. export class ArrayTools {
  69327. /**
  69328. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69329. * @param size the number of element to construct and put in the array
  69330. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69331. * @returns a new array filled with new objects
  69332. */
  69333. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /**
  69338. * Class representing a vector containing 2 coordinates
  69339. */
  69340. export class Vector2 {
  69341. /** defines the first coordinate */
  69342. x: number;
  69343. /** defines the second coordinate */
  69344. y: number;
  69345. /**
  69346. * Creates a new Vector2 from the given x and y coordinates
  69347. * @param x defines the first coordinate
  69348. * @param y defines the second coordinate
  69349. */
  69350. constructor(
  69351. /** defines the first coordinate */
  69352. x?: number,
  69353. /** defines the second coordinate */
  69354. y?: number);
  69355. /**
  69356. * Gets a string with the Vector2 coordinates
  69357. * @returns a string with the Vector2 coordinates
  69358. */
  69359. toString(): string;
  69360. /**
  69361. * Gets class name
  69362. * @returns the string "Vector2"
  69363. */
  69364. getClassName(): string;
  69365. /**
  69366. * Gets current vector hash code
  69367. * @returns the Vector2 hash code as a number
  69368. */
  69369. getHashCode(): number;
  69370. /**
  69371. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69372. * @param array defines the source array
  69373. * @param index defines the offset in source array
  69374. * @returns the current Vector2
  69375. */
  69376. toArray(array: FloatArray, index?: number): Vector2;
  69377. /**
  69378. * Copy the current vector to an array
  69379. * @returns a new array with 2 elements: the Vector2 coordinates.
  69380. */
  69381. asArray(): number[];
  69382. /**
  69383. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69384. * @param source defines the source Vector2
  69385. * @returns the current updated Vector2
  69386. */
  69387. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69388. /**
  69389. * Sets the Vector2 coordinates with the given floats
  69390. * @param x defines the first coordinate
  69391. * @param y defines the second coordinate
  69392. * @returns the current updated Vector2
  69393. */
  69394. copyFromFloats(x: number, y: number): Vector2;
  69395. /**
  69396. * Sets the Vector2 coordinates with the given floats
  69397. * @param x defines the first coordinate
  69398. * @param y defines the second coordinate
  69399. * @returns the current updated Vector2
  69400. */
  69401. set(x: number, y: number): Vector2;
  69402. /**
  69403. * Add another vector with the current one
  69404. * @param otherVector defines the other vector
  69405. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69406. */
  69407. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69408. /**
  69409. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69410. * @param otherVector defines the other vector
  69411. * @param result defines the target vector
  69412. * @returns the unmodified current Vector2
  69413. */
  69414. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69415. /**
  69416. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69417. * @param otherVector defines the other vector
  69418. * @returns the current updated Vector2
  69419. */
  69420. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69421. /**
  69422. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69423. * @param otherVector defines the other vector
  69424. * @returns a new Vector2
  69425. */
  69426. addVector3(otherVector: Vector3): Vector2;
  69427. /**
  69428. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69429. * @param otherVector defines the other vector
  69430. * @returns a new Vector2
  69431. */
  69432. subtract(otherVector: Vector2): Vector2;
  69433. /**
  69434. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69435. * @param otherVector defines the other vector
  69436. * @param result defines the target vector
  69437. * @returns the unmodified current Vector2
  69438. */
  69439. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69440. /**
  69441. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69442. * @param otherVector defines the other vector
  69443. * @returns the current updated Vector2
  69444. */
  69445. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69446. /**
  69447. * Multiplies in place the current Vector2 coordinates by the given ones
  69448. * @param otherVector defines the other vector
  69449. * @returns the current updated Vector2
  69450. */
  69451. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69452. /**
  69453. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69454. * @param otherVector defines the other vector
  69455. * @returns a new Vector2
  69456. */
  69457. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69458. /**
  69459. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69460. * @param otherVector defines the other vector
  69461. * @param result defines the target vector
  69462. * @returns the unmodified current Vector2
  69463. */
  69464. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69465. /**
  69466. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69467. * @param x defines the first coordinate
  69468. * @param y defines the second coordinate
  69469. * @returns a new Vector2
  69470. */
  69471. multiplyByFloats(x: number, y: number): Vector2;
  69472. /**
  69473. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69474. * @param otherVector defines the other vector
  69475. * @returns a new Vector2
  69476. */
  69477. divide(otherVector: Vector2): Vector2;
  69478. /**
  69479. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69480. * @param otherVector defines the other vector
  69481. * @param result defines the target vector
  69482. * @returns the unmodified current Vector2
  69483. */
  69484. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69485. /**
  69486. * Divides the current Vector2 coordinates by the given ones
  69487. * @param otherVector defines the other vector
  69488. * @returns the current updated Vector2
  69489. */
  69490. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69491. /**
  69492. * Gets a new Vector2 with current Vector2 negated coordinates
  69493. * @returns a new Vector2
  69494. */
  69495. negate(): Vector2;
  69496. /**
  69497. * Multiply the Vector2 coordinates by scale
  69498. * @param scale defines the scaling factor
  69499. * @returns the current updated Vector2
  69500. */
  69501. scaleInPlace(scale: number): Vector2;
  69502. /**
  69503. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69504. * @param scale defines the scaling factor
  69505. * @returns a new Vector2
  69506. */
  69507. scale(scale: number): Vector2;
  69508. /**
  69509. * Scale the current Vector2 values by a factor to a given Vector2
  69510. * @param scale defines the scale factor
  69511. * @param result defines the Vector2 object where to store the result
  69512. * @returns the unmodified current Vector2
  69513. */
  69514. scaleToRef(scale: number, result: Vector2): Vector2;
  69515. /**
  69516. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69517. * @param scale defines the scale factor
  69518. * @param result defines the Vector2 object where to store the result
  69519. * @returns the unmodified current Vector2
  69520. */
  69521. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69522. /**
  69523. * Gets a boolean if two vectors are equals
  69524. * @param otherVector defines the other vector
  69525. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69526. */
  69527. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69528. /**
  69529. * Gets a boolean if two vectors are equals (using an epsilon value)
  69530. * @param otherVector defines the other vector
  69531. * @param epsilon defines the minimal distance to consider equality
  69532. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69533. */
  69534. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69535. /**
  69536. * Gets a new Vector2 from current Vector2 floored values
  69537. * @returns a new Vector2
  69538. */
  69539. floor(): Vector2;
  69540. /**
  69541. * Gets a new Vector2 from current Vector2 floored values
  69542. * @returns a new Vector2
  69543. */
  69544. fract(): Vector2;
  69545. /**
  69546. * Gets the length of the vector
  69547. * @returns the vector length (float)
  69548. */
  69549. length(): number;
  69550. /**
  69551. * Gets the vector squared length
  69552. * @returns the vector squared length (float)
  69553. */
  69554. lengthSquared(): number;
  69555. /**
  69556. * Normalize the vector
  69557. * @returns the current updated Vector2
  69558. */
  69559. normalize(): Vector2;
  69560. /**
  69561. * Gets a new Vector2 copied from the Vector2
  69562. * @returns a new Vector2
  69563. */
  69564. clone(): Vector2;
  69565. /**
  69566. * Gets a new Vector2(0, 0)
  69567. * @returns a new Vector2
  69568. */
  69569. static Zero(): Vector2;
  69570. /**
  69571. * Gets a new Vector2(1, 1)
  69572. * @returns a new Vector2
  69573. */
  69574. static One(): Vector2;
  69575. /**
  69576. * Gets a new Vector2 set from the given index element of the given array
  69577. * @param array defines the data source
  69578. * @param offset defines the offset in the data source
  69579. * @returns a new Vector2
  69580. */
  69581. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69582. /**
  69583. * Sets "result" from the given index element of the given array
  69584. * @param array defines the data source
  69585. * @param offset defines the offset in the data source
  69586. * @param result defines the target vector
  69587. */
  69588. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69589. /**
  69590. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69591. * @param value1 defines 1st point of control
  69592. * @param value2 defines 2nd point of control
  69593. * @param value3 defines 3rd point of control
  69594. * @param value4 defines 4th point of control
  69595. * @param amount defines the interpolation factor
  69596. * @returns a new Vector2
  69597. */
  69598. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69599. /**
  69600. * 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".
  69601. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69602. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69603. * @param value defines the value to clamp
  69604. * @param min defines the lower limit
  69605. * @param max defines the upper limit
  69606. * @returns a new Vector2
  69607. */
  69608. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69609. /**
  69610. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69611. * @param value1 defines the 1st control point
  69612. * @param tangent1 defines the outgoing tangent
  69613. * @param value2 defines the 2nd control point
  69614. * @param tangent2 defines the incoming tangent
  69615. * @param amount defines the interpolation factor
  69616. * @returns a new Vector2
  69617. */
  69618. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69619. /**
  69620. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69621. * @param start defines the start vector
  69622. * @param end defines the end vector
  69623. * @param amount defines the interpolation factor
  69624. * @returns a new Vector2
  69625. */
  69626. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69627. /**
  69628. * Gets the dot product of the vector "left" and the vector "right"
  69629. * @param left defines first vector
  69630. * @param right defines second vector
  69631. * @returns the dot product (float)
  69632. */
  69633. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69634. /**
  69635. * Returns a new Vector2 equal to the normalized given vector
  69636. * @param vector defines the vector to normalize
  69637. * @returns a new Vector2
  69638. */
  69639. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69640. /**
  69641. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69642. * @param left defines 1st vector
  69643. * @param right defines 2nd vector
  69644. * @returns a new Vector2
  69645. */
  69646. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69647. /**
  69648. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69649. * @param left defines 1st vector
  69650. * @param right defines 2nd vector
  69651. * @returns a new Vector2
  69652. */
  69653. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69654. /**
  69655. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69656. * @param vector defines the vector to transform
  69657. * @param transformation defines the matrix to apply
  69658. * @returns a new Vector2
  69659. */
  69660. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69661. /**
  69662. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69663. * @param vector defines the vector to transform
  69664. * @param transformation defines the matrix to apply
  69665. * @param result defines the target vector
  69666. */
  69667. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69668. /**
  69669. * Determines if a given vector is included in a triangle
  69670. * @param p defines the vector to test
  69671. * @param p0 defines 1st triangle point
  69672. * @param p1 defines 2nd triangle point
  69673. * @param p2 defines 3rd triangle point
  69674. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69675. */
  69676. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69677. /**
  69678. * Gets the distance between the vectors "value1" and "value2"
  69679. * @param value1 defines first vector
  69680. * @param value2 defines second vector
  69681. * @returns the distance between vectors
  69682. */
  69683. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69684. /**
  69685. * Returns the squared distance between the vectors "value1" and "value2"
  69686. * @param value1 defines first vector
  69687. * @param value2 defines second vector
  69688. * @returns the squared distance between vectors
  69689. */
  69690. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69691. /**
  69692. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69693. * @param value1 defines first vector
  69694. * @param value2 defines second vector
  69695. * @returns a new Vector2
  69696. */
  69697. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69698. /**
  69699. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69700. * @param p defines the middle point
  69701. * @param segA defines one point of the segment
  69702. * @param segB defines the other point of the segment
  69703. * @returns the shortest distance
  69704. */
  69705. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69706. }
  69707. /**
  69708. * Classed used to store (x,y,z) vector representation
  69709. * A Vector3 is the main object used in 3D geometry
  69710. * It can represent etiher the coordinates of a point the space, either a direction
  69711. * Reminder: js uses a left handed forward facing system
  69712. */
  69713. export class Vector3 {
  69714. /**
  69715. * Defines the first coordinates (on X axis)
  69716. */
  69717. x: number;
  69718. /**
  69719. * Defines the second coordinates (on Y axis)
  69720. */
  69721. y: number;
  69722. /**
  69723. * Defines the third coordinates (on Z axis)
  69724. */
  69725. z: number;
  69726. private static _UpReadOnly;
  69727. private static _ZeroReadOnly;
  69728. /**
  69729. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69730. * @param x defines the first coordinates (on X axis)
  69731. * @param y defines the second coordinates (on Y axis)
  69732. * @param z defines the third coordinates (on Z axis)
  69733. */
  69734. constructor(
  69735. /**
  69736. * Defines the first coordinates (on X axis)
  69737. */
  69738. x?: number,
  69739. /**
  69740. * Defines the second coordinates (on Y axis)
  69741. */
  69742. y?: number,
  69743. /**
  69744. * Defines the third coordinates (on Z axis)
  69745. */
  69746. z?: number);
  69747. /**
  69748. * Creates a string representation of the Vector3
  69749. * @returns a string with the Vector3 coordinates.
  69750. */
  69751. toString(): string;
  69752. /**
  69753. * Gets the class name
  69754. * @returns the string "Vector3"
  69755. */
  69756. getClassName(): string;
  69757. /**
  69758. * Creates the Vector3 hash code
  69759. * @returns a number which tends to be unique between Vector3 instances
  69760. */
  69761. getHashCode(): number;
  69762. /**
  69763. * Creates an array containing three elements : the coordinates of the Vector3
  69764. * @returns a new array of numbers
  69765. */
  69766. asArray(): number[];
  69767. /**
  69768. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69769. * @param array defines the destination array
  69770. * @param index defines the offset in the destination array
  69771. * @returns the current Vector3
  69772. */
  69773. toArray(array: FloatArray, index?: number): Vector3;
  69774. /**
  69775. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69776. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69777. */
  69778. toQuaternion(): Quaternion;
  69779. /**
  69780. * Adds the given vector to the current Vector3
  69781. * @param otherVector defines the second operand
  69782. * @returns the current updated Vector3
  69783. */
  69784. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69785. /**
  69786. * Adds the given coordinates to the current Vector3
  69787. * @param x defines the x coordinate of the operand
  69788. * @param y defines the y coordinate of the operand
  69789. * @param z defines the z coordinate of the operand
  69790. * @returns the current updated Vector3
  69791. */
  69792. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69793. /**
  69794. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69795. * @param otherVector defines the second operand
  69796. * @returns the resulting Vector3
  69797. */
  69798. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69799. /**
  69800. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69801. * @param otherVector defines the second operand
  69802. * @param result defines the Vector3 object where to store the result
  69803. * @returns the current Vector3
  69804. */
  69805. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69806. /**
  69807. * Subtract the given vector from the current Vector3
  69808. * @param otherVector defines the second operand
  69809. * @returns the current updated Vector3
  69810. */
  69811. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69812. /**
  69813. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69814. * @param otherVector defines the second operand
  69815. * @returns the resulting Vector3
  69816. */
  69817. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69818. /**
  69819. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69820. * @param otherVector defines the second operand
  69821. * @param result defines the Vector3 object where to store the result
  69822. * @returns the current Vector3
  69823. */
  69824. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69825. /**
  69826. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69827. * @param x defines the x coordinate of the operand
  69828. * @param y defines the y coordinate of the operand
  69829. * @param z defines the z coordinate of the operand
  69830. * @returns the resulting Vector3
  69831. */
  69832. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69833. /**
  69834. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69835. * @param x defines the x coordinate of the operand
  69836. * @param y defines the y coordinate of the operand
  69837. * @param z defines the z coordinate of the operand
  69838. * @param result defines the Vector3 object where to store the result
  69839. * @returns the current Vector3
  69840. */
  69841. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69842. /**
  69843. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69844. * @returns a new Vector3
  69845. */
  69846. negate(): Vector3;
  69847. /**
  69848. * Multiplies the Vector3 coordinates by the float "scale"
  69849. * @param scale defines the multiplier factor
  69850. * @returns the current updated Vector3
  69851. */
  69852. scaleInPlace(scale: number): Vector3;
  69853. /**
  69854. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69855. * @param scale defines the multiplier factor
  69856. * @returns a new Vector3
  69857. */
  69858. scale(scale: number): Vector3;
  69859. /**
  69860. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69861. * @param scale defines the multiplier factor
  69862. * @param result defines the Vector3 object where to store the result
  69863. * @returns the current Vector3
  69864. */
  69865. scaleToRef(scale: number, result: Vector3): Vector3;
  69866. /**
  69867. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69868. * @param scale defines the scale factor
  69869. * @param result defines the Vector3 object where to store the result
  69870. * @returns the unmodified current Vector3
  69871. */
  69872. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69873. /**
  69874. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69875. * @param otherVector defines the second operand
  69876. * @returns true if both vectors are equals
  69877. */
  69878. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69879. /**
  69880. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69881. * @param otherVector defines the second operand
  69882. * @param epsilon defines the minimal distance to define values as equals
  69883. * @returns true if both vectors are distant less than epsilon
  69884. */
  69885. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69886. /**
  69887. * Returns true if the current Vector3 coordinates equals the given floats
  69888. * @param x defines the x coordinate of the operand
  69889. * @param y defines the y coordinate of the operand
  69890. * @param z defines the z coordinate of the operand
  69891. * @returns true if both vectors are equals
  69892. */
  69893. equalsToFloats(x: number, y: number, z: number): boolean;
  69894. /**
  69895. * Multiplies the current Vector3 coordinates by the given ones
  69896. * @param otherVector defines the second operand
  69897. * @returns the current updated Vector3
  69898. */
  69899. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69900. /**
  69901. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69902. * @param otherVector defines the second operand
  69903. * @returns the new Vector3
  69904. */
  69905. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69906. /**
  69907. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69908. * @param otherVector defines the second operand
  69909. * @param result defines the Vector3 object where to store the result
  69910. * @returns the current Vector3
  69911. */
  69912. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69913. /**
  69914. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69915. * @param x defines the x coordinate of the operand
  69916. * @param y defines the y coordinate of the operand
  69917. * @param z defines the z coordinate of the operand
  69918. * @returns the new Vector3
  69919. */
  69920. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69921. /**
  69922. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69923. * @param otherVector defines the second operand
  69924. * @returns the new Vector3
  69925. */
  69926. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69927. /**
  69928. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69929. * @param otherVector defines the second operand
  69930. * @param result defines the Vector3 object where to store the result
  69931. * @returns the current Vector3
  69932. */
  69933. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69934. /**
  69935. * Divides the current Vector3 coordinates by the given ones.
  69936. * @param otherVector defines the second operand
  69937. * @returns the current updated Vector3
  69938. */
  69939. divideInPlace(otherVector: Vector3): Vector3;
  69940. /**
  69941. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69942. * @param other defines the second operand
  69943. * @returns the current updated Vector3
  69944. */
  69945. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69946. /**
  69947. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69948. * @param other defines the second operand
  69949. * @returns the current updated Vector3
  69950. */
  69951. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69952. /**
  69953. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69954. * @param x defines the x coordinate of the operand
  69955. * @param y defines the y coordinate of the operand
  69956. * @param z defines the z coordinate of the operand
  69957. * @returns the current updated Vector3
  69958. */
  69959. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69960. /**
  69961. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69962. * @param x defines the x coordinate of the operand
  69963. * @param y defines the y coordinate of the operand
  69964. * @param z defines the z coordinate of the operand
  69965. * @returns the current updated Vector3
  69966. */
  69967. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69968. /**
  69969. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69970. * Check if is non uniform within a certain amount of decimal places to account for this
  69971. * @param epsilon the amount the values can differ
  69972. * @returns if the the vector is non uniform to a certain number of decimal places
  69973. */
  69974. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69975. /**
  69976. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69977. */
  69978. readonly isNonUniform: boolean;
  69979. /**
  69980. * Gets a new Vector3 from current Vector3 floored values
  69981. * @returns a new Vector3
  69982. */
  69983. floor(): Vector3;
  69984. /**
  69985. * Gets a new Vector3 from current Vector3 floored values
  69986. * @returns a new Vector3
  69987. */
  69988. fract(): Vector3;
  69989. /**
  69990. * Gets the length of the Vector3
  69991. * @returns the length of the Vector3
  69992. */
  69993. length(): number;
  69994. /**
  69995. * Gets the squared length of the Vector3
  69996. * @returns squared length of the Vector3
  69997. */
  69998. lengthSquared(): number;
  69999. /**
  70000. * Normalize the current Vector3.
  70001. * Please note that this is an in place operation.
  70002. * @returns the current updated Vector3
  70003. */
  70004. normalize(): Vector3;
  70005. /**
  70006. * Reorders the x y z properties of the vector in place
  70007. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70008. * @returns the current updated vector
  70009. */
  70010. reorderInPlace(order: string): this;
  70011. /**
  70012. * Rotates the vector around 0,0,0 by a quaternion
  70013. * @param quaternion the rotation quaternion
  70014. * @param result vector to store the result
  70015. * @returns the resulting vector
  70016. */
  70017. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70018. /**
  70019. * Rotates a vector around a given point
  70020. * @param quaternion the rotation quaternion
  70021. * @param point the point to rotate around
  70022. * @param result vector to store the result
  70023. * @returns the resulting vector
  70024. */
  70025. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70026. /**
  70027. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70028. * The cross product is then orthogonal to both current and "other"
  70029. * @param other defines the right operand
  70030. * @returns the cross product
  70031. */
  70032. cross(other: Vector3): Vector3;
  70033. /**
  70034. * Normalize the current Vector3 with the given input length.
  70035. * Please note that this is an in place operation.
  70036. * @param len the length of the vector
  70037. * @returns the current updated Vector3
  70038. */
  70039. normalizeFromLength(len: number): Vector3;
  70040. /**
  70041. * Normalize the current Vector3 to a new vector
  70042. * @returns the new Vector3
  70043. */
  70044. normalizeToNew(): Vector3;
  70045. /**
  70046. * Normalize the current Vector3 to the reference
  70047. * @param reference define the Vector3 to update
  70048. * @returns the updated Vector3
  70049. */
  70050. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70051. /**
  70052. * Creates a new Vector3 copied from the current Vector3
  70053. * @returns the new Vector3
  70054. */
  70055. clone(): Vector3;
  70056. /**
  70057. * Copies the given vector coordinates to the current Vector3 ones
  70058. * @param source defines the source Vector3
  70059. * @returns the current updated Vector3
  70060. */
  70061. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70062. /**
  70063. * Copies the given floats to the current Vector3 coordinates
  70064. * @param x defines the x coordinate of the operand
  70065. * @param y defines the y coordinate of the operand
  70066. * @param z defines the z coordinate of the operand
  70067. * @returns the current updated Vector3
  70068. */
  70069. copyFromFloats(x: number, y: number, z: number): Vector3;
  70070. /**
  70071. * Copies the given floats to the current Vector3 coordinates
  70072. * @param x defines the x coordinate of the operand
  70073. * @param y defines the y coordinate of the operand
  70074. * @param z defines the z coordinate of the operand
  70075. * @returns the current updated Vector3
  70076. */
  70077. set(x: number, y: number, z: number): Vector3;
  70078. /**
  70079. * Copies the given float to the current Vector3 coordinates
  70080. * @param v defines the x, y and z coordinates of the operand
  70081. * @returns the current updated Vector3
  70082. */
  70083. setAll(v: number): Vector3;
  70084. /**
  70085. * Get the clip factor between two vectors
  70086. * @param vector0 defines the first operand
  70087. * @param vector1 defines the second operand
  70088. * @param axis defines the axis to use
  70089. * @param size defines the size along the axis
  70090. * @returns the clip factor
  70091. */
  70092. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70093. /**
  70094. * Get angle between two vectors
  70095. * @param vector0 angle between vector0 and vector1
  70096. * @param vector1 angle between vector0 and vector1
  70097. * @param normal direction of the normal
  70098. * @return the angle between vector0 and vector1
  70099. */
  70100. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70101. /**
  70102. * Returns a new Vector3 set from the index "offset" of the given array
  70103. * @param array defines the source array
  70104. * @param offset defines the offset in the source array
  70105. * @returns the new Vector3
  70106. */
  70107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70108. /**
  70109. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70110. * This function is deprecated. Use FromArray instead
  70111. * @param array defines the source array
  70112. * @param offset defines the offset in the source array
  70113. * @returns the new Vector3
  70114. */
  70115. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70116. /**
  70117. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70118. * @param array defines the source array
  70119. * @param offset defines the offset in the source array
  70120. * @param result defines the Vector3 where to store the result
  70121. */
  70122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70123. /**
  70124. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70125. * This function is deprecated. Use FromArrayToRef instead.
  70126. * @param array defines the source array
  70127. * @param offset defines the offset in the source array
  70128. * @param result defines the Vector3 where to store the result
  70129. */
  70130. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70131. /**
  70132. * Sets the given vector "result" with the given floats.
  70133. * @param x defines the x coordinate of the source
  70134. * @param y defines the y coordinate of the source
  70135. * @param z defines the z coordinate of the source
  70136. * @param result defines the Vector3 where to store the result
  70137. */
  70138. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70139. /**
  70140. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70141. * @returns a new empty Vector3
  70142. */
  70143. static Zero(): Vector3;
  70144. /**
  70145. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70146. * @returns a new unit Vector3
  70147. */
  70148. static One(): Vector3;
  70149. /**
  70150. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70151. * @returns a new up Vector3
  70152. */
  70153. static Up(): Vector3;
  70154. /**
  70155. * Gets a up Vector3 that must not be updated
  70156. */
  70157. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70158. /**
  70159. * Gets a zero Vector3 that must not be updated
  70160. */
  70161. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70162. /**
  70163. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70164. * @returns a new down Vector3
  70165. */
  70166. static Down(): Vector3;
  70167. /**
  70168. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70169. * @returns a new forward Vector3
  70170. */
  70171. static Forward(): Vector3;
  70172. /**
  70173. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70174. * @returns a new forward Vector3
  70175. */
  70176. static Backward(): Vector3;
  70177. /**
  70178. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70179. * @returns a new right Vector3
  70180. */
  70181. static Right(): Vector3;
  70182. /**
  70183. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70184. * @returns a new left Vector3
  70185. */
  70186. static Left(): Vector3;
  70187. /**
  70188. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70189. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70190. * @param vector defines the Vector3 to transform
  70191. * @param transformation defines the transformation matrix
  70192. * @returns the transformed Vector3
  70193. */
  70194. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70195. /**
  70196. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70197. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70198. * @param vector defines the Vector3 to transform
  70199. * @param transformation defines the transformation matrix
  70200. * @param result defines the Vector3 where to store the result
  70201. */
  70202. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70203. /**
  70204. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70205. * This method computes tranformed coordinates only, not transformed direction vectors
  70206. * @param x define the x coordinate of the source vector
  70207. * @param y define the y coordinate of the source vector
  70208. * @param z define the z coordinate of the source vector
  70209. * @param transformation defines the transformation matrix
  70210. * @param result defines the Vector3 where to store the result
  70211. */
  70212. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70213. /**
  70214. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70215. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70216. * @param vector defines the Vector3 to transform
  70217. * @param transformation defines the transformation matrix
  70218. * @returns the new Vector3
  70219. */
  70220. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70221. /**
  70222. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70223. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70224. * @param vector defines the Vector3 to transform
  70225. * @param transformation defines the transformation matrix
  70226. * @param result defines the Vector3 where to store the result
  70227. */
  70228. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70229. /**
  70230. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70231. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70232. * @param x define the x coordinate of the source vector
  70233. * @param y define the y coordinate of the source vector
  70234. * @param z define the z coordinate of the source vector
  70235. * @param transformation defines the transformation matrix
  70236. * @param result defines the Vector3 where to store the result
  70237. */
  70238. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70239. /**
  70240. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70241. * @param value1 defines the first control point
  70242. * @param value2 defines the second control point
  70243. * @param value3 defines the third control point
  70244. * @param value4 defines the fourth control point
  70245. * @param amount defines the amount on the spline to use
  70246. * @returns the new Vector3
  70247. */
  70248. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70249. /**
  70250. * 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"
  70251. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70252. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70253. * @param value defines the current value
  70254. * @param min defines the lower range value
  70255. * @param max defines the upper range value
  70256. * @returns the new Vector3
  70257. */
  70258. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70259. /**
  70260. * 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"
  70261. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70262. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70263. * @param value defines the current value
  70264. * @param min defines the lower range value
  70265. * @param max defines the upper range value
  70266. * @param result defines the Vector3 where to store the result
  70267. */
  70268. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70269. /**
  70270. * Checks if a given vector is inside a specific range
  70271. * @param v defines the vector to test
  70272. * @param min defines the minimum range
  70273. * @param max defines the maximum range
  70274. */
  70275. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70276. /**
  70277. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70278. * @param value1 defines the first control point
  70279. * @param tangent1 defines the first tangent vector
  70280. * @param value2 defines the second control point
  70281. * @param tangent2 defines the second tangent vector
  70282. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70283. * @returns the new Vector3
  70284. */
  70285. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70286. /**
  70287. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70288. * @param start defines the start value
  70289. * @param end defines the end value
  70290. * @param amount max defines amount between both (between 0 and 1)
  70291. * @returns the new Vector3
  70292. */
  70293. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70294. /**
  70295. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70296. * @param start defines the start value
  70297. * @param end defines the end value
  70298. * @param amount max defines amount between both (between 0 and 1)
  70299. * @param result defines the Vector3 where to store the result
  70300. */
  70301. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70302. /**
  70303. * Returns the dot product (float) between the vectors "left" and "right"
  70304. * @param left defines the left operand
  70305. * @param right defines the right operand
  70306. * @returns the dot product
  70307. */
  70308. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70309. /**
  70310. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70311. * The cross product is then orthogonal to both "left" and "right"
  70312. * @param left defines the left operand
  70313. * @param right defines the right operand
  70314. * @returns the cross product
  70315. */
  70316. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70317. /**
  70318. * Sets the given vector "result" with the cross product of "left" and "right"
  70319. * The cross product is then orthogonal to both "left" and "right"
  70320. * @param left defines the left operand
  70321. * @param right defines the right operand
  70322. * @param result defines the Vector3 where to store the result
  70323. */
  70324. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70325. /**
  70326. * Returns a new Vector3 as the normalization of the given vector
  70327. * @param vector defines the Vector3 to normalize
  70328. * @returns the new Vector3
  70329. */
  70330. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70331. /**
  70332. * Sets the given vector "result" with the normalization of the given first vector
  70333. * @param vector defines the Vector3 to normalize
  70334. * @param result defines the Vector3 where to store the result
  70335. */
  70336. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70337. /**
  70338. * Project a Vector3 onto screen space
  70339. * @param vector defines the Vector3 to project
  70340. * @param world defines the world matrix to use
  70341. * @param transform defines the transform (view x projection) matrix to use
  70342. * @param viewport defines the screen viewport to use
  70343. * @returns the new Vector3
  70344. */
  70345. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70346. /** @hidden */
  70347. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70348. /**
  70349. * Unproject from screen space to object space
  70350. * @param source defines the screen space Vector3 to use
  70351. * @param viewportWidth defines the current width of the viewport
  70352. * @param viewportHeight defines the current height of the viewport
  70353. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70354. * @param transform defines the transform (view x projection) matrix to use
  70355. * @returns the new Vector3
  70356. */
  70357. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70358. /**
  70359. * Unproject from screen space to object space
  70360. * @param source defines the screen space Vector3 to use
  70361. * @param viewportWidth defines the current width of the viewport
  70362. * @param viewportHeight defines the current height of the viewport
  70363. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70364. * @param view defines the view matrix to use
  70365. * @param projection defines the projection matrix to use
  70366. * @returns the new Vector3
  70367. */
  70368. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70369. /**
  70370. * Unproject from screen space to object space
  70371. * @param source defines the screen space Vector3 to use
  70372. * @param viewportWidth defines the current width of the viewport
  70373. * @param viewportHeight defines the current height of the viewport
  70374. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70375. * @param view defines the view matrix to use
  70376. * @param projection defines the projection matrix to use
  70377. * @param result defines the Vector3 where to store the result
  70378. */
  70379. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70380. /**
  70381. * Unproject from screen space to object space
  70382. * @param sourceX defines the screen space x coordinate to use
  70383. * @param sourceY defines the screen space y coordinate to use
  70384. * @param sourceZ defines the screen space z coordinate to use
  70385. * @param viewportWidth defines the current width of the viewport
  70386. * @param viewportHeight defines the current height of the viewport
  70387. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70388. * @param view defines the view matrix to use
  70389. * @param projection defines the projection matrix to use
  70390. * @param result defines the Vector3 where to store the result
  70391. */
  70392. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70393. /**
  70394. * Gets the minimal coordinate values between two Vector3
  70395. * @param left defines the first operand
  70396. * @param right defines the second operand
  70397. * @returns the new Vector3
  70398. */
  70399. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70400. /**
  70401. * Gets the maximal coordinate values between two Vector3
  70402. * @param left defines the first operand
  70403. * @param right defines the second operand
  70404. * @returns the new Vector3
  70405. */
  70406. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70407. /**
  70408. * Returns the distance between the vectors "value1" and "value2"
  70409. * @param value1 defines the first operand
  70410. * @param value2 defines the second operand
  70411. * @returns the distance
  70412. */
  70413. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70414. /**
  70415. * Returns the squared distance between the vectors "value1" and "value2"
  70416. * @param value1 defines the first operand
  70417. * @param value2 defines the second operand
  70418. * @returns the squared distance
  70419. */
  70420. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70421. /**
  70422. * Returns a new Vector3 located at the center between "value1" and "value2"
  70423. * @param value1 defines the first operand
  70424. * @param value2 defines the second operand
  70425. * @returns the new Vector3
  70426. */
  70427. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70428. /**
  70429. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70430. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70431. * to something in order to rotate it from its local system to the given target system
  70432. * Note: axis1, axis2 and axis3 are normalized during this operation
  70433. * @param axis1 defines the first axis
  70434. * @param axis2 defines the second axis
  70435. * @param axis3 defines the third axis
  70436. * @returns a new Vector3
  70437. */
  70438. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70439. /**
  70440. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70441. * @param axis1 defines the first axis
  70442. * @param axis2 defines the second axis
  70443. * @param axis3 defines the third axis
  70444. * @param ref defines the Vector3 where to store the result
  70445. */
  70446. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70447. }
  70448. /**
  70449. * Vector4 class created for EulerAngle class conversion to Quaternion
  70450. */
  70451. export class Vector4 {
  70452. /** x value of the vector */
  70453. x: number;
  70454. /** y value of the vector */
  70455. y: number;
  70456. /** z value of the vector */
  70457. z: number;
  70458. /** w value of the vector */
  70459. w: number;
  70460. /**
  70461. * Creates a Vector4 object from the given floats.
  70462. * @param x x value of the vector
  70463. * @param y y value of the vector
  70464. * @param z z value of the vector
  70465. * @param w w value of the vector
  70466. */
  70467. constructor(
  70468. /** x value of the vector */
  70469. x: number,
  70470. /** y value of the vector */
  70471. y: number,
  70472. /** z value of the vector */
  70473. z: number,
  70474. /** w value of the vector */
  70475. w: number);
  70476. /**
  70477. * Returns the string with the Vector4 coordinates.
  70478. * @returns a string containing all the vector values
  70479. */
  70480. toString(): string;
  70481. /**
  70482. * Returns the string "Vector4".
  70483. * @returns "Vector4"
  70484. */
  70485. getClassName(): string;
  70486. /**
  70487. * Returns the Vector4 hash code.
  70488. * @returns a unique hash code
  70489. */
  70490. getHashCode(): number;
  70491. /**
  70492. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70493. * @returns the resulting array
  70494. */
  70495. asArray(): number[];
  70496. /**
  70497. * Populates the given array from the given index with the Vector4 coordinates.
  70498. * @param array array to populate
  70499. * @param index index of the array to start at (default: 0)
  70500. * @returns the Vector4.
  70501. */
  70502. toArray(array: FloatArray, index?: number): Vector4;
  70503. /**
  70504. * Adds the given vector to the current Vector4.
  70505. * @param otherVector the vector to add
  70506. * @returns the updated Vector4.
  70507. */
  70508. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70509. /**
  70510. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70511. * @param otherVector the vector to add
  70512. * @returns the resulting vector
  70513. */
  70514. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70515. /**
  70516. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70517. * @param otherVector the vector to add
  70518. * @param result the vector to store the result
  70519. * @returns the current Vector4.
  70520. */
  70521. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70522. /**
  70523. * Subtract in place the given vector from the current Vector4.
  70524. * @param otherVector the vector to subtract
  70525. * @returns the updated Vector4.
  70526. */
  70527. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70528. /**
  70529. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70530. * @param otherVector the vector to add
  70531. * @returns the new vector with the result
  70532. */
  70533. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70534. /**
  70535. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70536. * @param otherVector the vector to subtract
  70537. * @param result the vector to store the result
  70538. * @returns the current Vector4.
  70539. */
  70540. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70541. /**
  70542. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70543. */
  70544. /**
  70545. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70546. * @param x value to subtract
  70547. * @param y value to subtract
  70548. * @param z value to subtract
  70549. * @param w value to subtract
  70550. * @returns new vector containing the result
  70551. */
  70552. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70553. /**
  70554. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70555. * @param x value to subtract
  70556. * @param y value to subtract
  70557. * @param z value to subtract
  70558. * @param w value to subtract
  70559. * @param result the vector to store the result in
  70560. * @returns the current Vector4.
  70561. */
  70562. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70563. /**
  70564. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70565. * @returns a new vector with the negated values
  70566. */
  70567. negate(): Vector4;
  70568. /**
  70569. * Multiplies the current Vector4 coordinates by scale (float).
  70570. * @param scale the number to scale with
  70571. * @returns the updated Vector4.
  70572. */
  70573. scaleInPlace(scale: number): Vector4;
  70574. /**
  70575. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70576. * @param scale the number to scale with
  70577. * @returns a new vector with the result
  70578. */
  70579. scale(scale: number): Vector4;
  70580. /**
  70581. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70582. * @param scale the number to scale with
  70583. * @param result a vector to store the result in
  70584. * @returns the current Vector4.
  70585. */
  70586. scaleToRef(scale: number, result: Vector4): Vector4;
  70587. /**
  70588. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70589. * @param scale defines the scale factor
  70590. * @param result defines the Vector4 object where to store the result
  70591. * @returns the unmodified current Vector4
  70592. */
  70593. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70594. /**
  70595. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70596. * @param otherVector the vector to compare against
  70597. * @returns true if they are equal
  70598. */
  70599. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70600. /**
  70601. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70602. * @param otherVector vector to compare against
  70603. * @param epsilon (Default: very small number)
  70604. * @returns true if they are equal
  70605. */
  70606. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70607. /**
  70608. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70609. * @param x x value to compare against
  70610. * @param y y value to compare against
  70611. * @param z z value to compare against
  70612. * @param w w value to compare against
  70613. * @returns true if equal
  70614. */
  70615. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70616. /**
  70617. * Multiplies in place the current Vector4 by the given one.
  70618. * @param otherVector vector to multiple with
  70619. * @returns the updated Vector4.
  70620. */
  70621. multiplyInPlace(otherVector: Vector4): Vector4;
  70622. /**
  70623. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70624. * @param otherVector vector to multiple with
  70625. * @returns resulting new vector
  70626. */
  70627. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70628. /**
  70629. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70630. * @param otherVector vector to multiple with
  70631. * @param result vector to store the result
  70632. * @returns the current Vector4.
  70633. */
  70634. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70635. /**
  70636. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70637. * @param x x value multiply with
  70638. * @param y y value multiply with
  70639. * @param z z value multiply with
  70640. * @param w w value multiply with
  70641. * @returns resulting new vector
  70642. */
  70643. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70644. /**
  70645. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70646. * @param otherVector vector to devide with
  70647. * @returns resulting new vector
  70648. */
  70649. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70650. /**
  70651. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70652. * @param otherVector vector to devide with
  70653. * @param result vector to store the result
  70654. * @returns the current Vector4.
  70655. */
  70656. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70657. /**
  70658. * Divides the current Vector3 coordinates by the given ones.
  70659. * @param otherVector vector to devide with
  70660. * @returns the updated Vector3.
  70661. */
  70662. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70663. /**
  70664. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70665. * @param other defines the second operand
  70666. * @returns the current updated Vector4
  70667. */
  70668. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70669. /**
  70670. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70671. * @param other defines the second operand
  70672. * @returns the current updated Vector4
  70673. */
  70674. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70675. /**
  70676. * Gets a new Vector4 from current Vector4 floored values
  70677. * @returns a new Vector4
  70678. */
  70679. floor(): Vector4;
  70680. /**
  70681. * Gets a new Vector4 from current Vector3 floored values
  70682. * @returns a new Vector4
  70683. */
  70684. fract(): Vector4;
  70685. /**
  70686. * Returns the Vector4 length (float).
  70687. * @returns the length
  70688. */
  70689. length(): number;
  70690. /**
  70691. * Returns the Vector4 squared length (float).
  70692. * @returns the length squared
  70693. */
  70694. lengthSquared(): number;
  70695. /**
  70696. * Normalizes in place the Vector4.
  70697. * @returns the updated Vector4.
  70698. */
  70699. normalize(): Vector4;
  70700. /**
  70701. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70702. * @returns this converted to a new vector3
  70703. */
  70704. toVector3(): Vector3;
  70705. /**
  70706. * Returns a new Vector4 copied from the current one.
  70707. * @returns the new cloned vector
  70708. */
  70709. clone(): Vector4;
  70710. /**
  70711. * Updates the current Vector4 with the given one coordinates.
  70712. * @param source the source vector to copy from
  70713. * @returns the updated Vector4.
  70714. */
  70715. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70716. /**
  70717. * Updates the current Vector4 coordinates with the given floats.
  70718. * @param x float to copy from
  70719. * @param y float to copy from
  70720. * @param z float to copy from
  70721. * @param w float to copy from
  70722. * @returns the updated Vector4.
  70723. */
  70724. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70725. /**
  70726. * Updates the current Vector4 coordinates with the given floats.
  70727. * @param x float to set from
  70728. * @param y float to set from
  70729. * @param z float to set from
  70730. * @param w float to set from
  70731. * @returns the updated Vector4.
  70732. */
  70733. set(x: number, y: number, z: number, w: number): Vector4;
  70734. /**
  70735. * Copies the given float to the current Vector3 coordinates
  70736. * @param v defines the x, y, z and w coordinates of the operand
  70737. * @returns the current updated Vector3
  70738. */
  70739. setAll(v: number): Vector4;
  70740. /**
  70741. * Returns a new Vector4 set from the starting index of the given array.
  70742. * @param array the array to pull values from
  70743. * @param offset the offset into the array to start at
  70744. * @returns the new vector
  70745. */
  70746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70747. /**
  70748. * Updates the given vector "result" from the starting index of the given array.
  70749. * @param array the array to pull values from
  70750. * @param offset the offset into the array to start at
  70751. * @param result the vector to store the result in
  70752. */
  70753. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70754. /**
  70755. * Updates the given vector "result" from the starting index of the given Float32Array.
  70756. * @param array the array to pull values from
  70757. * @param offset the offset into the array to start at
  70758. * @param result the vector to store the result in
  70759. */
  70760. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70761. /**
  70762. * Updates the given vector "result" coordinates from the given floats.
  70763. * @param x float to set from
  70764. * @param y float to set from
  70765. * @param z float to set from
  70766. * @param w float to set from
  70767. * @param result the vector to the floats in
  70768. */
  70769. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70770. /**
  70771. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70772. * @returns the new vector
  70773. */
  70774. static Zero(): Vector4;
  70775. /**
  70776. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70777. * @returns the new vector
  70778. */
  70779. static One(): Vector4;
  70780. /**
  70781. * Returns a new normalized Vector4 from the given one.
  70782. * @param vector the vector to normalize
  70783. * @returns the vector
  70784. */
  70785. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70786. /**
  70787. * Updates the given vector "result" from the normalization of the given one.
  70788. * @param vector the vector to normalize
  70789. * @param result the vector to store the result in
  70790. */
  70791. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70792. /**
  70793. * Returns a vector with the minimum values from the left and right vectors
  70794. * @param left left vector to minimize
  70795. * @param right right vector to minimize
  70796. * @returns a new vector with the minimum of the left and right vector values
  70797. */
  70798. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70799. /**
  70800. * Returns a vector with the maximum values from the left and right vectors
  70801. * @param left left vector to maximize
  70802. * @param right right vector to maximize
  70803. * @returns a new vector with the maximum of the left and right vector values
  70804. */
  70805. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70806. /**
  70807. * Returns the distance (float) between the vectors "value1" and "value2".
  70808. * @param value1 value to calulate the distance between
  70809. * @param value2 value to calulate the distance between
  70810. * @return the distance between the two vectors
  70811. */
  70812. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70813. /**
  70814. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70815. * @param value1 value to calulate the distance between
  70816. * @param value2 value to calulate the distance between
  70817. * @return the distance between the two vectors squared
  70818. */
  70819. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70820. /**
  70821. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70822. * @param value1 value to calulate the center between
  70823. * @param value2 value to calulate the center between
  70824. * @return the center between the two vectors
  70825. */
  70826. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70827. /**
  70828. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70829. * This methods computes transformed normalized direction vectors only.
  70830. * @param vector the vector to transform
  70831. * @param transformation the transformation matrix to apply
  70832. * @returns the new vector
  70833. */
  70834. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70835. /**
  70836. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70837. * This methods computes transformed normalized direction vectors only.
  70838. * @param vector the vector to transform
  70839. * @param transformation the transformation matrix to apply
  70840. * @param result the vector to store the result in
  70841. */
  70842. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70843. /**
  70844. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70845. * This methods computes transformed normalized direction vectors only.
  70846. * @param x value to transform
  70847. * @param y value to transform
  70848. * @param z value to transform
  70849. * @param w value to transform
  70850. * @param transformation the transformation matrix to apply
  70851. * @param result the vector to store the results in
  70852. */
  70853. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70854. /**
  70855. * Creates a new Vector4 from a Vector3
  70856. * @param source defines the source data
  70857. * @param w defines the 4th component (default is 0)
  70858. * @returns a new Vector4
  70859. */
  70860. static FromVector3(source: Vector3, w?: number): Vector4;
  70861. }
  70862. /**
  70863. * Class used to store quaternion data
  70864. * @see https://en.wikipedia.org/wiki/Quaternion
  70865. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70866. */
  70867. export class Quaternion {
  70868. /** defines the first component (0 by default) */
  70869. x: number;
  70870. /** defines the second component (0 by default) */
  70871. y: number;
  70872. /** defines the third component (0 by default) */
  70873. z: number;
  70874. /** defines the fourth component (1.0 by default) */
  70875. w: number;
  70876. /**
  70877. * Creates a new Quaternion from the given floats
  70878. * @param x defines the first component (0 by default)
  70879. * @param y defines the second component (0 by default)
  70880. * @param z defines the third component (0 by default)
  70881. * @param w defines the fourth component (1.0 by default)
  70882. */
  70883. constructor(
  70884. /** defines the first component (0 by default) */
  70885. x?: number,
  70886. /** defines the second component (0 by default) */
  70887. y?: number,
  70888. /** defines the third component (0 by default) */
  70889. z?: number,
  70890. /** defines the fourth component (1.0 by default) */
  70891. w?: number);
  70892. /**
  70893. * Gets a string representation for the current quaternion
  70894. * @returns a string with the Quaternion coordinates
  70895. */
  70896. toString(): string;
  70897. /**
  70898. * Gets the class name of the quaternion
  70899. * @returns the string "Quaternion"
  70900. */
  70901. getClassName(): string;
  70902. /**
  70903. * Gets a hash code for this quaternion
  70904. * @returns the quaternion hash code
  70905. */
  70906. getHashCode(): number;
  70907. /**
  70908. * Copy the quaternion to an array
  70909. * @returns a new array populated with 4 elements from the quaternion coordinates
  70910. */
  70911. asArray(): number[];
  70912. /**
  70913. * Check if two quaternions are equals
  70914. * @param otherQuaternion defines the second operand
  70915. * @return true if the current quaternion and the given one coordinates are strictly equals
  70916. */
  70917. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70918. /**
  70919. * Clone the current quaternion
  70920. * @returns a new quaternion copied from the current one
  70921. */
  70922. clone(): Quaternion;
  70923. /**
  70924. * Copy a quaternion to the current one
  70925. * @param other defines the other quaternion
  70926. * @returns the updated current quaternion
  70927. */
  70928. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70929. /**
  70930. * Updates the current quaternion with the given float coordinates
  70931. * @param x defines the x coordinate
  70932. * @param y defines the y coordinate
  70933. * @param z defines the z coordinate
  70934. * @param w defines the w coordinate
  70935. * @returns the updated current quaternion
  70936. */
  70937. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70938. /**
  70939. * Updates the current quaternion from the given float coordinates
  70940. * @param x defines the x coordinate
  70941. * @param y defines the y coordinate
  70942. * @param z defines the z coordinate
  70943. * @param w defines the w coordinate
  70944. * @returns the updated current quaternion
  70945. */
  70946. set(x: number, y: number, z: number, w: number): Quaternion;
  70947. /**
  70948. * Adds two quaternions
  70949. * @param other defines the second operand
  70950. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70951. */
  70952. add(other: DeepImmutable<Quaternion>): Quaternion;
  70953. /**
  70954. * Add a quaternion to the current one
  70955. * @param other defines the quaternion to add
  70956. * @returns the current quaternion
  70957. */
  70958. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70959. /**
  70960. * Subtract two quaternions
  70961. * @param other defines the second operand
  70962. * @returns a new quaternion as the subtraction result of the given one from the current one
  70963. */
  70964. subtract(other: Quaternion): Quaternion;
  70965. /**
  70966. * Multiplies the current quaternion by a scale factor
  70967. * @param value defines the scale factor
  70968. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70969. */
  70970. scale(value: number): Quaternion;
  70971. /**
  70972. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70973. * @param scale defines the scale factor
  70974. * @param result defines the Quaternion object where to store the result
  70975. * @returns the unmodified current quaternion
  70976. */
  70977. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70978. /**
  70979. * Multiplies in place the current quaternion by a scale factor
  70980. * @param value defines the scale factor
  70981. * @returns the current modified quaternion
  70982. */
  70983. scaleInPlace(value: number): Quaternion;
  70984. /**
  70985. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70986. * @param scale defines the scale factor
  70987. * @param result defines the Quaternion object where to store the result
  70988. * @returns the unmodified current quaternion
  70989. */
  70990. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70991. /**
  70992. * Multiplies two quaternions
  70993. * @param q1 defines the second operand
  70994. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70995. */
  70996. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70997. /**
  70998. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70999. * @param q1 defines the second operand
  71000. * @param result defines the target quaternion
  71001. * @returns the current quaternion
  71002. */
  71003. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71004. /**
  71005. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71006. * @param q1 defines the second operand
  71007. * @returns the currentupdated quaternion
  71008. */
  71009. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71010. /**
  71011. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71012. * @param ref defines the target quaternion
  71013. * @returns the current quaternion
  71014. */
  71015. conjugateToRef(ref: Quaternion): Quaternion;
  71016. /**
  71017. * Conjugates in place (1-q) the current quaternion
  71018. * @returns the current updated quaternion
  71019. */
  71020. conjugateInPlace(): Quaternion;
  71021. /**
  71022. * Conjugates in place (1-q) the current quaternion
  71023. * @returns a new quaternion
  71024. */
  71025. conjugate(): Quaternion;
  71026. /**
  71027. * Gets length of current quaternion
  71028. * @returns the quaternion length (float)
  71029. */
  71030. length(): number;
  71031. /**
  71032. * Normalize in place the current quaternion
  71033. * @returns the current updated quaternion
  71034. */
  71035. normalize(): Quaternion;
  71036. /**
  71037. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71038. * @param order is a reserved parameter and is ignore for now
  71039. * @returns a new Vector3 containing the Euler angles
  71040. */
  71041. toEulerAngles(order?: string): Vector3;
  71042. /**
  71043. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71044. * @param result defines the vector which will be filled with the Euler angles
  71045. * @param order is a reserved parameter and is ignore for now
  71046. * @returns the current unchanged quaternion
  71047. */
  71048. toEulerAnglesToRef(result: Vector3): Quaternion;
  71049. /**
  71050. * Updates the given rotation matrix with the current quaternion values
  71051. * @param result defines the target matrix
  71052. * @returns the current unchanged quaternion
  71053. */
  71054. toRotationMatrix(result: Matrix): Quaternion;
  71055. /**
  71056. * Updates the current quaternion from the given rotation matrix values
  71057. * @param matrix defines the source matrix
  71058. * @returns the current updated quaternion
  71059. */
  71060. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71061. /**
  71062. * Creates a new quaternion from a rotation matrix
  71063. * @param matrix defines the source matrix
  71064. * @returns a new quaternion created from the given rotation matrix values
  71065. */
  71066. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71067. /**
  71068. * Updates the given quaternion with the given rotation matrix values
  71069. * @param matrix defines the source matrix
  71070. * @param result defines the target quaternion
  71071. */
  71072. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71073. /**
  71074. * Returns the dot product (float) between the quaternions "left" and "right"
  71075. * @param left defines the left operand
  71076. * @param right defines the right operand
  71077. * @returns the dot product
  71078. */
  71079. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71080. /**
  71081. * Checks if the two quaternions are close to each other
  71082. * @param quat0 defines the first quaternion to check
  71083. * @param quat1 defines the second quaternion to check
  71084. * @returns true if the two quaternions are close to each other
  71085. */
  71086. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71087. /**
  71088. * Creates an empty quaternion
  71089. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71090. */
  71091. static Zero(): Quaternion;
  71092. /**
  71093. * Inverse a given quaternion
  71094. * @param q defines the source quaternion
  71095. * @returns a new quaternion as the inverted current quaternion
  71096. */
  71097. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71098. /**
  71099. * Inverse a given quaternion
  71100. * @param q defines the source quaternion
  71101. * @param result the quaternion the result will be stored in
  71102. * @returns the result quaternion
  71103. */
  71104. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71105. /**
  71106. * Creates an identity quaternion
  71107. * @returns the identity quaternion
  71108. */
  71109. static Identity(): Quaternion;
  71110. /**
  71111. * Gets a boolean indicating if the given quaternion is identity
  71112. * @param quaternion defines the quaternion to check
  71113. * @returns true if the quaternion is identity
  71114. */
  71115. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71116. /**
  71117. * Creates a quaternion from a rotation around an axis
  71118. * @param axis defines the axis to use
  71119. * @param angle defines the angle to use
  71120. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71121. */
  71122. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71123. /**
  71124. * Creates a rotation around an axis and stores it into the given quaternion
  71125. * @param axis defines the axis to use
  71126. * @param angle defines the angle to use
  71127. * @param result defines the target quaternion
  71128. * @returns the target quaternion
  71129. */
  71130. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71131. /**
  71132. * Creates a new quaternion from data stored into an array
  71133. * @param array defines the data source
  71134. * @param offset defines the offset in the source array where the data starts
  71135. * @returns a new quaternion
  71136. */
  71137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71138. /**
  71139. * Create a quaternion from Euler rotation angles
  71140. * @param x Pitch
  71141. * @param y Yaw
  71142. * @param z Roll
  71143. * @returns the new Quaternion
  71144. */
  71145. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71146. /**
  71147. * Updates a quaternion from Euler rotation angles
  71148. * @param x Pitch
  71149. * @param y Yaw
  71150. * @param z Roll
  71151. * @param result the quaternion to store the result
  71152. * @returns the updated quaternion
  71153. */
  71154. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71155. /**
  71156. * Create a quaternion from Euler rotation vector
  71157. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71158. * @returns the new Quaternion
  71159. */
  71160. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71161. /**
  71162. * Updates a quaternion from Euler rotation vector
  71163. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71164. * @param result the quaternion to store the result
  71165. * @returns the updated quaternion
  71166. */
  71167. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71168. /**
  71169. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71170. * @param yaw defines the rotation around Y axis
  71171. * @param pitch defines the rotation around X axis
  71172. * @param roll defines the rotation around Z axis
  71173. * @returns the new quaternion
  71174. */
  71175. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71176. /**
  71177. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71178. * @param yaw defines the rotation around Y axis
  71179. * @param pitch defines the rotation around X axis
  71180. * @param roll defines the rotation around Z axis
  71181. * @param result defines the target quaternion
  71182. */
  71183. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71184. /**
  71185. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71186. * @param alpha defines the rotation around first axis
  71187. * @param beta defines the rotation around second axis
  71188. * @param gamma defines the rotation around third axis
  71189. * @returns the new quaternion
  71190. */
  71191. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71192. /**
  71193. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71194. * @param alpha defines the rotation around first axis
  71195. * @param beta defines the rotation around second axis
  71196. * @param gamma defines the rotation around third axis
  71197. * @param result defines the target quaternion
  71198. */
  71199. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71200. /**
  71201. * 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)
  71202. * @param axis1 defines the first axis
  71203. * @param axis2 defines the second axis
  71204. * @param axis3 defines the third axis
  71205. * @returns the new quaternion
  71206. */
  71207. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71208. /**
  71209. * 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
  71210. * @param axis1 defines the first axis
  71211. * @param axis2 defines the second axis
  71212. * @param axis3 defines the third axis
  71213. * @param ref defines the target quaternion
  71214. */
  71215. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71216. /**
  71217. * Interpolates between two quaternions
  71218. * @param left defines first quaternion
  71219. * @param right defines second quaternion
  71220. * @param amount defines the gradient to use
  71221. * @returns the new interpolated quaternion
  71222. */
  71223. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71224. /**
  71225. * Interpolates between two quaternions and stores it into a target quaternion
  71226. * @param left defines first quaternion
  71227. * @param right defines second quaternion
  71228. * @param amount defines the gradient to use
  71229. * @param result defines the target quaternion
  71230. */
  71231. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71232. /**
  71233. * Interpolate between two quaternions using Hermite interpolation
  71234. * @param value1 defines first quaternion
  71235. * @param tangent1 defines the incoming tangent
  71236. * @param value2 defines second quaternion
  71237. * @param tangent2 defines the outgoing tangent
  71238. * @param amount defines the target quaternion
  71239. * @returns the new interpolated quaternion
  71240. */
  71241. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71242. }
  71243. /**
  71244. * Class used to store matrix data (4x4)
  71245. */
  71246. export class Matrix {
  71247. private static _updateFlagSeed;
  71248. private static _identityReadOnly;
  71249. private _isIdentity;
  71250. private _isIdentityDirty;
  71251. private _isIdentity3x2;
  71252. private _isIdentity3x2Dirty;
  71253. /**
  71254. * Gets the update flag of the matrix which is an unique number for the matrix.
  71255. * It will be incremented every time the matrix data change.
  71256. * You can use it to speed the comparison between two versions of the same matrix.
  71257. */
  71258. updateFlag: number;
  71259. private readonly _m;
  71260. /**
  71261. * Gets the internal data of the matrix
  71262. */
  71263. readonly m: DeepImmutable<Float32Array>;
  71264. /** @hidden */
  71265. _markAsUpdated(): void;
  71266. /** @hidden */
  71267. private _updateIdentityStatus;
  71268. /**
  71269. * Creates an empty matrix (filled with zeros)
  71270. */
  71271. constructor();
  71272. /**
  71273. * Check if the current matrix is identity
  71274. * @returns true is the matrix is the identity matrix
  71275. */
  71276. isIdentity(): boolean;
  71277. /**
  71278. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71279. * @returns true is the matrix is the identity matrix
  71280. */
  71281. isIdentityAs3x2(): boolean;
  71282. /**
  71283. * Gets the determinant of the matrix
  71284. * @returns the matrix determinant
  71285. */
  71286. determinant(): number;
  71287. /**
  71288. * Returns the matrix as a Float32Array
  71289. * @returns the matrix underlying array
  71290. */
  71291. toArray(): DeepImmutable<Float32Array>;
  71292. /**
  71293. * Returns the matrix as a Float32Array
  71294. * @returns the matrix underlying array.
  71295. */
  71296. asArray(): DeepImmutable<Float32Array>;
  71297. /**
  71298. * Inverts the current matrix in place
  71299. * @returns the current inverted matrix
  71300. */
  71301. invert(): Matrix;
  71302. /**
  71303. * Sets all the matrix elements to zero
  71304. * @returns the current matrix
  71305. */
  71306. reset(): Matrix;
  71307. /**
  71308. * Adds the current matrix with a second one
  71309. * @param other defines the matrix to add
  71310. * @returns a new matrix as the addition of the current matrix and the given one
  71311. */
  71312. add(other: DeepImmutable<Matrix>): Matrix;
  71313. /**
  71314. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71315. * @param other defines the matrix to add
  71316. * @param result defines the target matrix
  71317. * @returns the current matrix
  71318. */
  71319. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71320. /**
  71321. * Adds in place the given matrix to the current matrix
  71322. * @param other defines the second operand
  71323. * @returns the current updated matrix
  71324. */
  71325. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71326. /**
  71327. * Sets the given matrix to the current inverted Matrix
  71328. * @param other defines the target matrix
  71329. * @returns the unmodified current matrix
  71330. */
  71331. invertToRef(other: Matrix): Matrix;
  71332. /**
  71333. * add a value at the specified position in the current Matrix
  71334. * @param index the index of the value within the matrix. between 0 and 15.
  71335. * @param value the value to be added
  71336. * @returns the current updated matrix
  71337. */
  71338. addAtIndex(index: number, value: number): Matrix;
  71339. /**
  71340. * mutiply the specified position in the current Matrix by a value
  71341. * @param index the index of the value within the matrix. between 0 and 15.
  71342. * @param value the value to be added
  71343. * @returns the current updated matrix
  71344. */
  71345. multiplyAtIndex(index: number, value: number): Matrix;
  71346. /**
  71347. * Inserts the translation vector (using 3 floats) in the current matrix
  71348. * @param x defines the 1st component of the translation
  71349. * @param y defines the 2nd component of the translation
  71350. * @param z defines the 3rd component of the translation
  71351. * @returns the current updated matrix
  71352. */
  71353. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71354. /**
  71355. * Adds the translation vector (using 3 floats) in the current matrix
  71356. * @param x defines the 1st component of the translation
  71357. * @param y defines the 2nd component of the translation
  71358. * @param z defines the 3rd component of the translation
  71359. * @returns the current updated matrix
  71360. */
  71361. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71362. /**
  71363. * Inserts the translation vector in the current matrix
  71364. * @param vector3 defines the translation to insert
  71365. * @returns the current updated matrix
  71366. */
  71367. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71368. /**
  71369. * Gets the translation value of the current matrix
  71370. * @returns a new Vector3 as the extracted translation from the matrix
  71371. */
  71372. getTranslation(): Vector3;
  71373. /**
  71374. * Fill a Vector3 with the extracted translation from the matrix
  71375. * @param result defines the Vector3 where to store the translation
  71376. * @returns the current matrix
  71377. */
  71378. getTranslationToRef(result: Vector3): Matrix;
  71379. /**
  71380. * Remove rotation and scaling part from the matrix
  71381. * @returns the updated matrix
  71382. */
  71383. removeRotationAndScaling(): Matrix;
  71384. /**
  71385. * Multiply two matrices
  71386. * @param other defines the second operand
  71387. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71388. */
  71389. multiply(other: DeepImmutable<Matrix>): Matrix;
  71390. /**
  71391. * Copy the current matrix from the given one
  71392. * @param other defines the source matrix
  71393. * @returns the current updated matrix
  71394. */
  71395. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71396. /**
  71397. * Populates the given array from the starting index with the current matrix values
  71398. * @param array defines the target array
  71399. * @param offset defines the offset in the target array where to start storing values
  71400. * @returns the current matrix
  71401. */
  71402. copyToArray(array: Float32Array, offset?: number): Matrix;
  71403. /**
  71404. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71405. * @param other defines the second operand
  71406. * @param result defines the matrix where to store the multiplication
  71407. * @returns the current matrix
  71408. */
  71409. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71410. /**
  71411. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71412. * @param other defines the second operand
  71413. * @param result defines the array where to store the multiplication
  71414. * @param offset defines the offset in the target array where to start storing values
  71415. * @returns the current matrix
  71416. */
  71417. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71418. /**
  71419. * Check equality between this matrix and a second one
  71420. * @param value defines the second matrix to compare
  71421. * @returns true is the current matrix and the given one values are strictly equal
  71422. */
  71423. equals(value: DeepImmutable<Matrix>): boolean;
  71424. /**
  71425. * Clone the current matrix
  71426. * @returns a new matrix from the current matrix
  71427. */
  71428. clone(): Matrix;
  71429. /**
  71430. * Returns the name of the current matrix class
  71431. * @returns the string "Matrix"
  71432. */
  71433. getClassName(): string;
  71434. /**
  71435. * Gets the hash code of the current matrix
  71436. * @returns the hash code
  71437. */
  71438. getHashCode(): number;
  71439. /**
  71440. * Decomposes the current Matrix into a translation, rotation and scaling components
  71441. * @param scale defines the scale vector3 given as a reference to update
  71442. * @param rotation defines the rotation quaternion given as a reference to update
  71443. * @param translation defines the translation vector3 given as a reference to update
  71444. * @returns true if operation was successful
  71445. */
  71446. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71447. /**
  71448. * Gets specific row of the matrix
  71449. * @param index defines the number of the row to get
  71450. * @returns the index-th row of the current matrix as a new Vector4
  71451. */
  71452. getRow(index: number): Nullable<Vector4>;
  71453. /**
  71454. * Sets the index-th row of the current matrix to the vector4 values
  71455. * @param index defines the number of the row to set
  71456. * @param row defines the target vector4
  71457. * @returns the updated current matrix
  71458. */
  71459. setRow(index: number, row: Vector4): Matrix;
  71460. /**
  71461. * Compute the transpose of the matrix
  71462. * @returns the new transposed matrix
  71463. */
  71464. transpose(): Matrix;
  71465. /**
  71466. * Compute the transpose of the matrix and store it in a given matrix
  71467. * @param result defines the target matrix
  71468. * @returns the current matrix
  71469. */
  71470. transposeToRef(result: Matrix): Matrix;
  71471. /**
  71472. * Sets the index-th row of the current matrix with the given 4 x float values
  71473. * @param index defines the row index
  71474. * @param x defines the x component to set
  71475. * @param y defines the y component to set
  71476. * @param z defines the z component to set
  71477. * @param w defines the w component to set
  71478. * @returns the updated current matrix
  71479. */
  71480. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71481. /**
  71482. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71483. * @param scale defines the scale factor
  71484. * @returns a new matrix
  71485. */
  71486. scale(scale: number): Matrix;
  71487. /**
  71488. * Scale the current matrix values by a factor to a given result matrix
  71489. * @param scale defines the scale factor
  71490. * @param result defines the matrix to store the result
  71491. * @returns the current matrix
  71492. */
  71493. scaleToRef(scale: number, result: Matrix): Matrix;
  71494. /**
  71495. * Scale the current matrix values by a factor and add the result to a given matrix
  71496. * @param scale defines the scale factor
  71497. * @param result defines the Matrix to store the result
  71498. * @returns the current matrix
  71499. */
  71500. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71501. /**
  71502. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71503. * @param ref matrix to store the result
  71504. */
  71505. toNormalMatrix(ref: Matrix): void;
  71506. /**
  71507. * Gets only rotation part of the current matrix
  71508. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71509. */
  71510. getRotationMatrix(): Matrix;
  71511. /**
  71512. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71513. * @param result defines the target matrix to store data to
  71514. * @returns the current matrix
  71515. */
  71516. getRotationMatrixToRef(result: Matrix): Matrix;
  71517. /**
  71518. * Toggles model matrix from being right handed to left handed in place and vice versa
  71519. */
  71520. toggleModelMatrixHandInPlace(): void;
  71521. /**
  71522. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71523. */
  71524. toggleProjectionMatrixHandInPlace(): void;
  71525. /**
  71526. * Creates a matrix from an array
  71527. * @param array defines the source array
  71528. * @param offset defines an offset in the source array
  71529. * @returns a new Matrix set from the starting index of the given array
  71530. */
  71531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71532. /**
  71533. * Copy the content of an array into a given matrix
  71534. * @param array defines the source array
  71535. * @param offset defines an offset in the source array
  71536. * @param result defines the target matrix
  71537. */
  71538. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71539. /**
  71540. * Stores an array into a matrix after having multiplied each component by a given factor
  71541. * @param array defines the source array
  71542. * @param offset defines the offset in the source array
  71543. * @param scale defines the scaling factor
  71544. * @param result defines the target matrix
  71545. */
  71546. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71547. /**
  71548. * Gets an identity matrix that must not be updated
  71549. */
  71550. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71551. /**
  71552. * Stores a list of values (16) inside a given matrix
  71553. * @param initialM11 defines 1st value of 1st row
  71554. * @param initialM12 defines 2nd value of 1st row
  71555. * @param initialM13 defines 3rd value of 1st row
  71556. * @param initialM14 defines 4th value of 1st row
  71557. * @param initialM21 defines 1st value of 2nd row
  71558. * @param initialM22 defines 2nd value of 2nd row
  71559. * @param initialM23 defines 3rd value of 2nd row
  71560. * @param initialM24 defines 4th value of 2nd row
  71561. * @param initialM31 defines 1st value of 3rd row
  71562. * @param initialM32 defines 2nd value of 3rd row
  71563. * @param initialM33 defines 3rd value of 3rd row
  71564. * @param initialM34 defines 4th value of 3rd row
  71565. * @param initialM41 defines 1st value of 4th row
  71566. * @param initialM42 defines 2nd value of 4th row
  71567. * @param initialM43 defines 3rd value of 4th row
  71568. * @param initialM44 defines 4th value of 4th row
  71569. * @param result defines the target matrix
  71570. */
  71571. 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;
  71572. /**
  71573. * Creates new matrix from a list of values (16)
  71574. * @param initialM11 defines 1st value of 1st row
  71575. * @param initialM12 defines 2nd value of 1st row
  71576. * @param initialM13 defines 3rd value of 1st row
  71577. * @param initialM14 defines 4th value of 1st row
  71578. * @param initialM21 defines 1st value of 2nd row
  71579. * @param initialM22 defines 2nd value of 2nd row
  71580. * @param initialM23 defines 3rd value of 2nd row
  71581. * @param initialM24 defines 4th value of 2nd row
  71582. * @param initialM31 defines 1st value of 3rd row
  71583. * @param initialM32 defines 2nd value of 3rd row
  71584. * @param initialM33 defines 3rd value of 3rd row
  71585. * @param initialM34 defines 4th value of 3rd row
  71586. * @param initialM41 defines 1st value of 4th row
  71587. * @param initialM42 defines 2nd value of 4th row
  71588. * @param initialM43 defines 3rd value of 4th row
  71589. * @param initialM44 defines 4th value of 4th row
  71590. * @returns the new matrix
  71591. */
  71592. 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;
  71593. /**
  71594. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71595. * @param scale defines the scale vector3
  71596. * @param rotation defines the rotation quaternion
  71597. * @param translation defines the translation vector3
  71598. * @returns a new matrix
  71599. */
  71600. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71601. /**
  71602. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71603. * @param scale defines the scale vector3
  71604. * @param rotation defines the rotation quaternion
  71605. * @param translation defines the translation vector3
  71606. * @param result defines the target matrix
  71607. */
  71608. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71609. /**
  71610. * Creates a new identity matrix
  71611. * @returns a new identity matrix
  71612. */
  71613. static Identity(): Matrix;
  71614. /**
  71615. * Creates a new identity matrix and stores the result in a given matrix
  71616. * @param result defines the target matrix
  71617. */
  71618. static IdentityToRef(result: Matrix): void;
  71619. /**
  71620. * Creates a new zero matrix
  71621. * @returns a new zero matrix
  71622. */
  71623. static Zero(): Matrix;
  71624. /**
  71625. * Creates a new rotation matrix for "angle" radians around the X axis
  71626. * @param angle defines the angle (in radians) to use
  71627. * @return the new matrix
  71628. */
  71629. static RotationX(angle: number): Matrix;
  71630. /**
  71631. * Creates a new matrix as the invert of a given matrix
  71632. * @param source defines the source matrix
  71633. * @returns the new matrix
  71634. */
  71635. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71636. /**
  71637. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71638. * @param angle defines the angle (in radians) to use
  71639. * @param result defines the target matrix
  71640. */
  71641. static RotationXToRef(angle: number, result: Matrix): void;
  71642. /**
  71643. * Creates a new rotation matrix for "angle" radians around the Y axis
  71644. * @param angle defines the angle (in radians) to use
  71645. * @return the new matrix
  71646. */
  71647. static RotationY(angle: number): Matrix;
  71648. /**
  71649. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71650. * @param angle defines the angle (in radians) to use
  71651. * @param result defines the target matrix
  71652. */
  71653. static RotationYToRef(angle: number, result: Matrix): void;
  71654. /**
  71655. * Creates a new rotation matrix for "angle" radians around the Z axis
  71656. * @param angle defines the angle (in radians) to use
  71657. * @return the new matrix
  71658. */
  71659. static RotationZ(angle: number): Matrix;
  71660. /**
  71661. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71662. * @param angle defines the angle (in radians) to use
  71663. * @param result defines the target matrix
  71664. */
  71665. static RotationZToRef(angle: number, result: Matrix): void;
  71666. /**
  71667. * Creates a new rotation matrix for "angle" radians around the given axis
  71668. * @param axis defines the axis to use
  71669. * @param angle defines the angle (in radians) to use
  71670. * @return the new matrix
  71671. */
  71672. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71673. /**
  71674. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71675. * @param axis defines the axis to use
  71676. * @param angle defines the angle (in radians) to use
  71677. * @param result defines the target matrix
  71678. */
  71679. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71680. /**
  71681. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71682. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71683. * @param from defines the vector to align
  71684. * @param to defines the vector to align to
  71685. * @param result defines the target matrix
  71686. */
  71687. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71688. /**
  71689. * Creates a rotation matrix
  71690. * @param yaw defines the yaw angle in radians (Y axis)
  71691. * @param pitch defines the pitch angle in radians (X axis)
  71692. * @param roll defines the roll angle in radians (X axis)
  71693. * @returns the new rotation matrix
  71694. */
  71695. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71696. /**
  71697. * Creates a rotation matrix and stores it in a given matrix
  71698. * @param yaw defines the yaw angle in radians (Y axis)
  71699. * @param pitch defines the pitch angle in radians (X axis)
  71700. * @param roll defines the roll angle in radians (X axis)
  71701. * @param result defines the target matrix
  71702. */
  71703. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71704. /**
  71705. * Creates a scaling matrix
  71706. * @param x defines the scale factor on X axis
  71707. * @param y defines the scale factor on Y axis
  71708. * @param z defines the scale factor on Z axis
  71709. * @returns the new matrix
  71710. */
  71711. static Scaling(x: number, y: number, z: number): Matrix;
  71712. /**
  71713. * Creates a scaling matrix and stores it in a given matrix
  71714. * @param x defines the scale factor on X axis
  71715. * @param y defines the scale factor on Y axis
  71716. * @param z defines the scale factor on Z axis
  71717. * @param result defines the target matrix
  71718. */
  71719. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71720. /**
  71721. * Creates a translation matrix
  71722. * @param x defines the translation on X axis
  71723. * @param y defines the translation on Y axis
  71724. * @param z defines the translationon Z axis
  71725. * @returns the new matrix
  71726. */
  71727. static Translation(x: number, y: number, z: number): Matrix;
  71728. /**
  71729. * Creates a translation matrix and stores it in a given matrix
  71730. * @param x defines the translation on X axis
  71731. * @param y defines the translation on Y axis
  71732. * @param z defines the translationon Z axis
  71733. * @param result defines the target matrix
  71734. */
  71735. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71736. /**
  71737. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71738. * @param startValue defines the start value
  71739. * @param endValue defines the end value
  71740. * @param gradient defines the gradient factor
  71741. * @returns the new matrix
  71742. */
  71743. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71744. /**
  71745. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71746. * @param startValue defines the start value
  71747. * @param endValue defines the end value
  71748. * @param gradient defines the gradient factor
  71749. * @param result defines the Matrix object where to store data
  71750. */
  71751. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71752. /**
  71753. * Builds a new matrix whose values are computed by:
  71754. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71755. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71756. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71757. * @param startValue defines the first matrix
  71758. * @param endValue defines the second matrix
  71759. * @param gradient defines the gradient between the two matrices
  71760. * @returns the new matrix
  71761. */
  71762. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71763. /**
  71764. * Update a matrix to values which are computed by:
  71765. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71766. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71767. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71768. * @param startValue defines the first matrix
  71769. * @param endValue defines the second matrix
  71770. * @param gradient defines the gradient between the two matrices
  71771. * @param result defines the target matrix
  71772. */
  71773. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71774. /**
  71775. * 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"
  71776. * This function works in left handed mode
  71777. * @param eye defines the final position of the entity
  71778. * @param target defines where the entity should look at
  71779. * @param up defines the up vector for the entity
  71780. * @returns the new matrix
  71781. */
  71782. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71783. /**
  71784. * 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".
  71785. * This function works in left handed mode
  71786. * @param eye defines the final position of the entity
  71787. * @param target defines where the entity should look at
  71788. * @param up defines the up vector for the entity
  71789. * @param result defines the target matrix
  71790. */
  71791. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71792. /**
  71793. * 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"
  71794. * This function works in right handed mode
  71795. * @param eye defines the final position of the entity
  71796. * @param target defines where the entity should look at
  71797. * @param up defines the up vector for the entity
  71798. * @returns the new matrix
  71799. */
  71800. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71801. /**
  71802. * 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".
  71803. * This function works in right handed mode
  71804. * @param eye defines the final position of the entity
  71805. * @param target defines where the entity should look at
  71806. * @param up defines the up vector for the entity
  71807. * @param result defines the target matrix
  71808. */
  71809. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71810. /**
  71811. * Create a left-handed orthographic projection matrix
  71812. * @param width defines the viewport width
  71813. * @param height defines the viewport height
  71814. * @param znear defines the near clip plane
  71815. * @param zfar defines the far clip plane
  71816. * @returns a new matrix as a left-handed orthographic projection matrix
  71817. */
  71818. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71819. /**
  71820. * Store a left-handed orthographic projection to a given matrix
  71821. * @param width defines the viewport width
  71822. * @param height defines the viewport height
  71823. * @param znear defines the near clip plane
  71824. * @param zfar defines the far clip plane
  71825. * @param result defines the target matrix
  71826. */
  71827. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71828. /**
  71829. * Create a left-handed orthographic projection matrix
  71830. * @param left defines the viewport left coordinate
  71831. * @param right defines the viewport right coordinate
  71832. * @param bottom defines the viewport bottom coordinate
  71833. * @param top defines the viewport top coordinate
  71834. * @param znear defines the near clip plane
  71835. * @param zfar defines the far clip plane
  71836. * @returns a new matrix as a left-handed orthographic projection matrix
  71837. */
  71838. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71839. /**
  71840. * Stores a left-handed orthographic projection into a given matrix
  71841. * @param left defines the viewport left coordinate
  71842. * @param right defines the viewport right coordinate
  71843. * @param bottom defines the viewport bottom coordinate
  71844. * @param top defines the viewport top coordinate
  71845. * @param znear defines the near clip plane
  71846. * @param zfar defines the far clip plane
  71847. * @param result defines the target matrix
  71848. */
  71849. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71850. /**
  71851. * Creates a right-handed orthographic projection matrix
  71852. * @param left defines the viewport left coordinate
  71853. * @param right defines the viewport right coordinate
  71854. * @param bottom defines the viewport bottom coordinate
  71855. * @param top defines the viewport top coordinate
  71856. * @param znear defines the near clip plane
  71857. * @param zfar defines the far clip plane
  71858. * @returns a new matrix as a right-handed orthographic projection matrix
  71859. */
  71860. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71861. /**
  71862. * Stores a right-handed orthographic projection into a given matrix
  71863. * @param left defines the viewport left coordinate
  71864. * @param right defines the viewport right coordinate
  71865. * @param bottom defines the viewport bottom coordinate
  71866. * @param top defines the viewport top coordinate
  71867. * @param znear defines the near clip plane
  71868. * @param zfar defines the far clip plane
  71869. * @param result defines the target matrix
  71870. */
  71871. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71872. /**
  71873. * Creates a left-handed perspective projection matrix
  71874. * @param width defines the viewport width
  71875. * @param height defines the viewport height
  71876. * @param znear defines the near clip plane
  71877. * @param zfar defines the far clip plane
  71878. * @returns a new matrix as a left-handed perspective projection matrix
  71879. */
  71880. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71881. /**
  71882. * Creates a left-handed perspective projection matrix
  71883. * @param fov defines the horizontal field of view
  71884. * @param aspect defines the aspect ratio
  71885. * @param znear defines the near clip plane
  71886. * @param zfar defines the far clip plane
  71887. * @returns a new matrix as a left-handed perspective projection matrix
  71888. */
  71889. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71890. /**
  71891. * Stores a left-handed perspective projection into a given matrix
  71892. * @param fov defines the horizontal field of view
  71893. * @param aspect defines the aspect ratio
  71894. * @param znear defines the near clip plane
  71895. * @param zfar defines the far clip plane
  71896. * @param result defines the target matrix
  71897. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71898. */
  71899. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71900. /**
  71901. * Creates a right-handed perspective projection matrix
  71902. * @param fov defines the horizontal field of view
  71903. * @param aspect defines the aspect ratio
  71904. * @param znear defines the near clip plane
  71905. * @param zfar defines the far clip plane
  71906. * @returns a new matrix as a right-handed perspective projection matrix
  71907. */
  71908. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71909. /**
  71910. * Stores a right-handed perspective projection into a given matrix
  71911. * @param fov defines the horizontal field of view
  71912. * @param aspect defines the aspect ratio
  71913. * @param znear defines the near clip plane
  71914. * @param zfar defines the far clip plane
  71915. * @param result defines the target matrix
  71916. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71917. */
  71918. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71919. /**
  71920. * Stores a perspective projection for WebVR info a given matrix
  71921. * @param fov defines the field of view
  71922. * @param znear defines the near clip plane
  71923. * @param zfar defines the far clip plane
  71924. * @param result defines the target matrix
  71925. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71926. */
  71927. static PerspectiveFovWebVRToRef(fov: {
  71928. upDegrees: number;
  71929. downDegrees: number;
  71930. leftDegrees: number;
  71931. rightDegrees: number;
  71932. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71933. /**
  71934. * Computes a complete transformation matrix
  71935. * @param viewport defines the viewport to use
  71936. * @param world defines the world matrix
  71937. * @param view defines the view matrix
  71938. * @param projection defines the projection matrix
  71939. * @param zmin defines the near clip plane
  71940. * @param zmax defines the far clip plane
  71941. * @returns the transformation matrix
  71942. */
  71943. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71944. /**
  71945. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71946. * @param matrix defines the matrix to use
  71947. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71948. */
  71949. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71950. /**
  71951. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71952. * @param matrix defines the matrix to use
  71953. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71954. */
  71955. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71956. /**
  71957. * Compute the transpose of a given matrix
  71958. * @param matrix defines the matrix to transpose
  71959. * @returns the new matrix
  71960. */
  71961. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71962. /**
  71963. * Compute the transpose of a matrix and store it in a target matrix
  71964. * @param matrix defines the matrix to transpose
  71965. * @param result defines the target matrix
  71966. */
  71967. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71968. /**
  71969. * Computes a reflection matrix from a plane
  71970. * @param plane defines the reflection plane
  71971. * @returns a new matrix
  71972. */
  71973. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71974. /**
  71975. * Computes a reflection matrix from a plane
  71976. * @param plane defines the reflection plane
  71977. * @param result defines the target matrix
  71978. */
  71979. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71980. /**
  71981. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71982. * @param xaxis defines the value of the 1st axis
  71983. * @param yaxis defines the value of the 2nd axis
  71984. * @param zaxis defines the value of the 3rd axis
  71985. * @param result defines the target matrix
  71986. */
  71987. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71988. /**
  71989. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71990. * @param quat defines the quaternion to use
  71991. * @param result defines the target matrix
  71992. */
  71993. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71994. }
  71995. /**
  71996. * @hidden
  71997. */
  71998. export class TmpVectors {
  71999. static Vector2: Vector2[];
  72000. static Vector3: Vector3[];
  72001. static Vector4: Vector4[];
  72002. static Quaternion: Quaternion[];
  72003. static Matrix: Matrix[];
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. /**
  72008. * Defines potential orientation for back face culling
  72009. */
  72010. export enum Orientation {
  72011. /**
  72012. * Clockwise
  72013. */
  72014. CW = 0,
  72015. /** Counter clockwise */
  72016. CCW = 1
  72017. }
  72018. /** Class used to represent a Bezier curve */
  72019. export class BezierCurve {
  72020. /**
  72021. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72022. * @param t defines the time
  72023. * @param x1 defines the left coordinate on X axis
  72024. * @param y1 defines the left coordinate on Y axis
  72025. * @param x2 defines the right coordinate on X axis
  72026. * @param y2 defines the right coordinate on Y axis
  72027. * @returns the interpolated value
  72028. */
  72029. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72030. }
  72031. /**
  72032. * Defines angle representation
  72033. */
  72034. export class Angle {
  72035. private _radians;
  72036. /**
  72037. * Creates an Angle object of "radians" radians (float).
  72038. * @param radians the angle in radians
  72039. */
  72040. constructor(radians: number);
  72041. /**
  72042. * Get value in degrees
  72043. * @returns the Angle value in degrees (float)
  72044. */
  72045. degrees(): number;
  72046. /**
  72047. * Get value in radians
  72048. * @returns the Angle value in radians (float)
  72049. */
  72050. radians(): number;
  72051. /**
  72052. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72053. * @param a defines first vector
  72054. * @param b defines second vector
  72055. * @returns a new Angle
  72056. */
  72057. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72058. /**
  72059. * Gets a new Angle object from the given float in radians
  72060. * @param radians defines the angle value in radians
  72061. * @returns a new Angle
  72062. */
  72063. static FromRadians(radians: number): Angle;
  72064. /**
  72065. * Gets a new Angle object from the given float in degrees
  72066. * @param degrees defines the angle value in degrees
  72067. * @returns a new Angle
  72068. */
  72069. static FromDegrees(degrees: number): Angle;
  72070. }
  72071. /**
  72072. * This represents an arc in a 2d space.
  72073. */
  72074. export class Arc2 {
  72075. /** Defines the start point of the arc */
  72076. startPoint: Vector2;
  72077. /** Defines the mid point of the arc */
  72078. midPoint: Vector2;
  72079. /** Defines the end point of the arc */
  72080. endPoint: Vector2;
  72081. /**
  72082. * Defines the center point of the arc.
  72083. */
  72084. centerPoint: Vector2;
  72085. /**
  72086. * Defines the radius of the arc.
  72087. */
  72088. radius: number;
  72089. /**
  72090. * Defines the angle of the arc (from mid point to end point).
  72091. */
  72092. angle: Angle;
  72093. /**
  72094. * Defines the start angle of the arc (from start point to middle point).
  72095. */
  72096. startAngle: Angle;
  72097. /**
  72098. * Defines the orientation of the arc (clock wise/counter clock wise).
  72099. */
  72100. orientation: Orientation;
  72101. /**
  72102. * Creates an Arc object from the three given points : start, middle and end.
  72103. * @param startPoint Defines the start point of the arc
  72104. * @param midPoint Defines the midlle point of the arc
  72105. * @param endPoint Defines the end point of the arc
  72106. */
  72107. constructor(
  72108. /** Defines the start point of the arc */
  72109. startPoint: Vector2,
  72110. /** Defines the mid point of the arc */
  72111. midPoint: Vector2,
  72112. /** Defines the end point of the arc */
  72113. endPoint: Vector2);
  72114. }
  72115. /**
  72116. * Represents a 2D path made up of multiple 2D points
  72117. */
  72118. export class Path2 {
  72119. private _points;
  72120. private _length;
  72121. /**
  72122. * If the path start and end point are the same
  72123. */
  72124. closed: boolean;
  72125. /**
  72126. * Creates a Path2 object from the starting 2D coordinates x and y.
  72127. * @param x the starting points x value
  72128. * @param y the starting points y value
  72129. */
  72130. constructor(x: number, y: number);
  72131. /**
  72132. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72133. * @param x the added points x value
  72134. * @param y the added points y value
  72135. * @returns the updated Path2.
  72136. */
  72137. addLineTo(x: number, y: number): Path2;
  72138. /**
  72139. * 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.
  72140. * @param midX middle point x value
  72141. * @param midY middle point y value
  72142. * @param endX end point x value
  72143. * @param endY end point y value
  72144. * @param numberOfSegments (default: 36)
  72145. * @returns the updated Path2.
  72146. */
  72147. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72148. /**
  72149. * Closes the Path2.
  72150. * @returns the Path2.
  72151. */
  72152. close(): Path2;
  72153. /**
  72154. * Gets the sum of the distance between each sequential point in the path
  72155. * @returns the Path2 total length (float).
  72156. */
  72157. length(): number;
  72158. /**
  72159. * Gets the points which construct the path
  72160. * @returns the Path2 internal array of points.
  72161. */
  72162. getPoints(): Vector2[];
  72163. /**
  72164. * Retreives the point at the distance aways from the starting point
  72165. * @param normalizedLengthPosition the length along the path to retreive the point from
  72166. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72167. */
  72168. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72169. /**
  72170. * Creates a new path starting from an x and y position
  72171. * @param x starting x value
  72172. * @param y starting y value
  72173. * @returns a new Path2 starting at the coordinates (x, y).
  72174. */
  72175. static StartingAt(x: number, y: number): Path2;
  72176. }
  72177. /**
  72178. * Represents a 3D path made up of multiple 3D points
  72179. */
  72180. export class Path3D {
  72181. /**
  72182. * an array of Vector3, the curve axis of the Path3D
  72183. */
  72184. path: Vector3[];
  72185. private _curve;
  72186. private _distances;
  72187. private _tangents;
  72188. private _normals;
  72189. private _binormals;
  72190. private _raw;
  72191. /**
  72192. * new Path3D(path, normal, raw)
  72193. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72194. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72195. * @param path an array of Vector3, the curve axis of the Path3D
  72196. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72197. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72198. */
  72199. constructor(
  72200. /**
  72201. * an array of Vector3, the curve axis of the Path3D
  72202. */
  72203. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72204. /**
  72205. * Returns the Path3D array of successive Vector3 designing its curve.
  72206. * @returns the Path3D array of successive Vector3 designing its curve.
  72207. */
  72208. getCurve(): Vector3[];
  72209. /**
  72210. * Returns an array populated with tangent vectors on each Path3D curve point.
  72211. * @returns an array populated with tangent vectors on each Path3D curve point.
  72212. */
  72213. getTangents(): Vector3[];
  72214. /**
  72215. * Returns an array populated with normal vectors on each Path3D curve point.
  72216. * @returns an array populated with normal vectors on each Path3D curve point.
  72217. */
  72218. getNormals(): Vector3[];
  72219. /**
  72220. * Returns an array populated with binormal vectors on each Path3D curve point.
  72221. * @returns an array populated with binormal vectors on each Path3D curve point.
  72222. */
  72223. getBinormals(): Vector3[];
  72224. /**
  72225. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72226. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72227. */
  72228. getDistances(): number[];
  72229. /**
  72230. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72231. * @param path path which all values are copied into the curves points
  72232. * @param firstNormal which should be projected onto the curve
  72233. * @returns the same object updated.
  72234. */
  72235. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72236. private _compute;
  72237. private _getFirstNonNullVector;
  72238. private _getLastNonNullVector;
  72239. private _normalVector;
  72240. }
  72241. /**
  72242. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72243. * A Curve3 is designed from a series of successive Vector3.
  72244. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72245. */
  72246. export class Curve3 {
  72247. private _points;
  72248. private _length;
  72249. /**
  72250. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72251. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72252. * @param v1 (Vector3) the control point
  72253. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72254. * @param nbPoints (integer) the wanted number of points in the curve
  72255. * @returns the created Curve3
  72256. */
  72257. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72258. /**
  72259. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72260. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72261. * @param v1 (Vector3) the first control point
  72262. * @param v2 (Vector3) the second control point
  72263. * @param v3 (Vector3) the end point of the Cubic Bezier
  72264. * @param nbPoints (integer) the wanted number of points in the curve
  72265. * @returns the created Curve3
  72266. */
  72267. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72268. /**
  72269. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72270. * @param p1 (Vector3) the origin point of the Hermite Spline
  72271. * @param t1 (Vector3) the tangent vector at the origin point
  72272. * @param p2 (Vector3) the end point of the Hermite Spline
  72273. * @param t2 (Vector3) the tangent vector at the end point
  72274. * @param nbPoints (integer) the wanted number of points in the curve
  72275. * @returns the created Curve3
  72276. */
  72277. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72278. /**
  72279. * Returns a Curve3 object along a CatmullRom Spline curve :
  72280. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72281. * @param nbPoints (integer) the wanted number of points between each curve control points
  72282. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72283. * @returns the created Curve3
  72284. */
  72285. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72286. /**
  72287. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72288. * A Curve3 is designed from a series of successive Vector3.
  72289. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72290. * @param points points which make up the curve
  72291. */
  72292. constructor(points: Vector3[]);
  72293. /**
  72294. * @returns the Curve3 stored array of successive Vector3
  72295. */
  72296. getPoints(): Vector3[];
  72297. /**
  72298. * @returns the computed length (float) of the curve.
  72299. */
  72300. length(): number;
  72301. /**
  72302. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72303. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72304. * curveA and curveB keep unchanged.
  72305. * @param curve the curve to continue from this curve
  72306. * @returns the newly constructed curve
  72307. */
  72308. continue(curve: DeepImmutable<Curve3>): Curve3;
  72309. private _computeLength;
  72310. }
  72311. }
  72312. declare module BABYLON {
  72313. /**
  72314. * This represents the main contract an easing function should follow.
  72315. * Easing functions are used throughout the animation system.
  72316. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72317. */
  72318. export interface IEasingFunction {
  72319. /**
  72320. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72321. * of the easing function.
  72322. * The link below provides some of the most common examples of easing functions.
  72323. * @see https://easings.net/
  72324. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72325. * @returns the corresponding value on the curve defined by the easing function
  72326. */
  72327. ease(gradient: number): number;
  72328. }
  72329. /**
  72330. * Base class used for every default easing function.
  72331. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72332. */
  72333. export class EasingFunction implements IEasingFunction {
  72334. /**
  72335. * Interpolation follows the mathematical formula associated with the easing function.
  72336. */
  72337. static readonly EASINGMODE_EASEIN: number;
  72338. /**
  72339. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72340. */
  72341. static readonly EASINGMODE_EASEOUT: number;
  72342. /**
  72343. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72344. */
  72345. static readonly EASINGMODE_EASEINOUT: number;
  72346. private _easingMode;
  72347. /**
  72348. * Sets the easing mode of the current function.
  72349. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72350. */
  72351. setEasingMode(easingMode: number): void;
  72352. /**
  72353. * Gets the current easing mode.
  72354. * @returns the easing mode
  72355. */
  72356. getEasingMode(): number;
  72357. /**
  72358. * @hidden
  72359. */
  72360. easeInCore(gradient: number): number;
  72361. /**
  72362. * Given an input gradient between 0 and 1, this returns the corresponding value
  72363. * of the easing function.
  72364. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72365. * @returns the corresponding value on the curve defined by the easing function
  72366. */
  72367. ease(gradient: number): number;
  72368. }
  72369. /**
  72370. * Easing function with a circle shape (see link below).
  72371. * @see https://easings.net/#easeInCirc
  72372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72373. */
  72374. export class CircleEase extends EasingFunction implements IEasingFunction {
  72375. /** @hidden */
  72376. easeInCore(gradient: number): number;
  72377. }
  72378. /**
  72379. * Easing function with a ease back shape (see link below).
  72380. * @see https://easings.net/#easeInBack
  72381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72382. */
  72383. export class BackEase extends EasingFunction implements IEasingFunction {
  72384. /** Defines the amplitude of the function */
  72385. amplitude: number;
  72386. /**
  72387. * Instantiates a back ease easing
  72388. * @see https://easings.net/#easeInBack
  72389. * @param amplitude Defines the amplitude of the function
  72390. */
  72391. constructor(
  72392. /** Defines the amplitude of the function */
  72393. amplitude?: number);
  72394. /** @hidden */
  72395. easeInCore(gradient: number): number;
  72396. }
  72397. /**
  72398. * Easing function with a bouncing shape (see link below).
  72399. * @see https://easings.net/#easeInBounce
  72400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72401. */
  72402. export class BounceEase extends EasingFunction implements IEasingFunction {
  72403. /** Defines the number of bounces */
  72404. bounces: number;
  72405. /** Defines the amplitude of the bounce */
  72406. bounciness: number;
  72407. /**
  72408. * Instantiates a bounce easing
  72409. * @see https://easings.net/#easeInBounce
  72410. * @param bounces Defines the number of bounces
  72411. * @param bounciness Defines the amplitude of the bounce
  72412. */
  72413. constructor(
  72414. /** Defines the number of bounces */
  72415. bounces?: number,
  72416. /** Defines the amplitude of the bounce */
  72417. bounciness?: number);
  72418. /** @hidden */
  72419. easeInCore(gradient: number): number;
  72420. }
  72421. /**
  72422. * Easing function with a power of 3 shape (see link below).
  72423. * @see https://easings.net/#easeInCubic
  72424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72425. */
  72426. export class CubicEase extends EasingFunction implements IEasingFunction {
  72427. /** @hidden */
  72428. easeInCore(gradient: number): number;
  72429. }
  72430. /**
  72431. * Easing function with an elastic shape (see link below).
  72432. * @see https://easings.net/#easeInElastic
  72433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72434. */
  72435. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72436. /** Defines the number of oscillations*/
  72437. oscillations: number;
  72438. /** Defines the amplitude of the oscillations*/
  72439. springiness: number;
  72440. /**
  72441. * Instantiates an elastic easing function
  72442. * @see https://easings.net/#easeInElastic
  72443. * @param oscillations Defines the number of oscillations
  72444. * @param springiness Defines the amplitude of the oscillations
  72445. */
  72446. constructor(
  72447. /** Defines the number of oscillations*/
  72448. oscillations?: number,
  72449. /** Defines the amplitude of the oscillations*/
  72450. springiness?: number);
  72451. /** @hidden */
  72452. easeInCore(gradient: number): number;
  72453. }
  72454. /**
  72455. * Easing function with an exponential shape (see link below).
  72456. * @see https://easings.net/#easeInExpo
  72457. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72458. */
  72459. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72460. /** Defines the exponent of the function */
  72461. exponent: number;
  72462. /**
  72463. * Instantiates an exponential easing function
  72464. * @see https://easings.net/#easeInExpo
  72465. * @param exponent Defines the exponent of the function
  72466. */
  72467. constructor(
  72468. /** Defines the exponent of the function */
  72469. exponent?: number);
  72470. /** @hidden */
  72471. easeInCore(gradient: number): number;
  72472. }
  72473. /**
  72474. * Easing function with a power shape (see link below).
  72475. * @see https://easings.net/#easeInQuad
  72476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72477. */
  72478. export class PowerEase extends EasingFunction implements IEasingFunction {
  72479. /** Defines the power of the function */
  72480. power: number;
  72481. /**
  72482. * Instantiates an power base easing function
  72483. * @see https://easings.net/#easeInQuad
  72484. * @param power Defines the power of the function
  72485. */
  72486. constructor(
  72487. /** Defines the power of the function */
  72488. power?: number);
  72489. /** @hidden */
  72490. easeInCore(gradient: number): number;
  72491. }
  72492. /**
  72493. * Easing function with a power of 2 shape (see link below).
  72494. * @see https://easings.net/#easeInQuad
  72495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72496. */
  72497. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72498. /** @hidden */
  72499. easeInCore(gradient: number): number;
  72500. }
  72501. /**
  72502. * Easing function with a power of 4 shape (see link below).
  72503. * @see https://easings.net/#easeInQuart
  72504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72505. */
  72506. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72507. /** @hidden */
  72508. easeInCore(gradient: number): number;
  72509. }
  72510. /**
  72511. * Easing function with a power of 5 shape (see link below).
  72512. * @see https://easings.net/#easeInQuint
  72513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72514. */
  72515. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72516. /** @hidden */
  72517. easeInCore(gradient: number): number;
  72518. }
  72519. /**
  72520. * Easing function with a sin shape (see link below).
  72521. * @see https://easings.net/#easeInSine
  72522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72523. */
  72524. export class SineEase extends EasingFunction implements IEasingFunction {
  72525. /** @hidden */
  72526. easeInCore(gradient: number): number;
  72527. }
  72528. /**
  72529. * Easing function with a bezier shape (see link below).
  72530. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72532. */
  72533. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72534. /** Defines the x component of the start tangent in the bezier curve */
  72535. x1: number;
  72536. /** Defines the y component of the start tangent in the bezier curve */
  72537. y1: number;
  72538. /** Defines the x component of the end tangent in the bezier curve */
  72539. x2: number;
  72540. /** Defines the y component of the end tangent in the bezier curve */
  72541. y2: number;
  72542. /**
  72543. * Instantiates a bezier function
  72544. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72545. * @param x1 Defines the x component of the start tangent in the bezier curve
  72546. * @param y1 Defines the y component of the start tangent in the bezier curve
  72547. * @param x2 Defines the x component of the end tangent in the bezier curve
  72548. * @param y2 Defines the y component of the end tangent in the bezier curve
  72549. */
  72550. constructor(
  72551. /** Defines the x component of the start tangent in the bezier curve */
  72552. x1?: number,
  72553. /** Defines the y component of the start tangent in the bezier curve */
  72554. y1?: number,
  72555. /** Defines the x component of the end tangent in the bezier curve */
  72556. x2?: number,
  72557. /** Defines the y component of the end tangent in the bezier curve */
  72558. y2?: number);
  72559. /** @hidden */
  72560. easeInCore(gradient: number): number;
  72561. }
  72562. }
  72563. declare module BABYLON {
  72564. /**
  72565. * Class used to hold a RBG color
  72566. */
  72567. export class Color3 {
  72568. /**
  72569. * Defines the red component (between 0 and 1, default is 0)
  72570. */
  72571. r: number;
  72572. /**
  72573. * Defines the green component (between 0 and 1, default is 0)
  72574. */
  72575. g: number;
  72576. /**
  72577. * Defines the blue component (between 0 and 1, default is 0)
  72578. */
  72579. b: number;
  72580. /**
  72581. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72582. * @param r defines the red component (between 0 and 1, default is 0)
  72583. * @param g defines the green component (between 0 and 1, default is 0)
  72584. * @param b defines the blue component (between 0 and 1, default is 0)
  72585. */
  72586. constructor(
  72587. /**
  72588. * Defines the red component (between 0 and 1, default is 0)
  72589. */
  72590. r?: number,
  72591. /**
  72592. * Defines the green component (between 0 and 1, default is 0)
  72593. */
  72594. g?: number,
  72595. /**
  72596. * Defines the blue component (between 0 and 1, default is 0)
  72597. */
  72598. b?: number);
  72599. /**
  72600. * Creates a string with the Color3 current values
  72601. * @returns the string representation of the Color3 object
  72602. */
  72603. toString(): string;
  72604. /**
  72605. * Returns the string "Color3"
  72606. * @returns "Color3"
  72607. */
  72608. getClassName(): string;
  72609. /**
  72610. * Compute the Color3 hash code
  72611. * @returns an unique number that can be used to hash Color3 objects
  72612. */
  72613. getHashCode(): number;
  72614. /**
  72615. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72616. * @param array defines the array where to store the r,g,b components
  72617. * @param index defines an optional index in the target array to define where to start storing values
  72618. * @returns the current Color3 object
  72619. */
  72620. toArray(array: FloatArray, index?: number): Color3;
  72621. /**
  72622. * Returns a new Color4 object from the current Color3 and the given alpha
  72623. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72624. * @returns a new Color4 object
  72625. */
  72626. toColor4(alpha?: number): Color4;
  72627. /**
  72628. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72629. * @returns the new array
  72630. */
  72631. asArray(): number[];
  72632. /**
  72633. * Returns the luminance value
  72634. * @returns a float value
  72635. */
  72636. toLuminance(): number;
  72637. /**
  72638. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72639. * @param otherColor defines the second operand
  72640. * @returns the new Color3 object
  72641. */
  72642. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72643. /**
  72644. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72645. * @param otherColor defines the second operand
  72646. * @param result defines the Color3 object where to store the result
  72647. * @returns the current Color3
  72648. */
  72649. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72650. /**
  72651. * Determines equality between Color3 objects
  72652. * @param otherColor defines the second operand
  72653. * @returns true if the rgb values are equal to the given ones
  72654. */
  72655. equals(otherColor: DeepImmutable<Color3>): boolean;
  72656. /**
  72657. * Determines equality between the current Color3 object and a set of r,b,g values
  72658. * @param r defines the red component to check
  72659. * @param g defines the green component to check
  72660. * @param b defines the blue component to check
  72661. * @returns true if the rgb values are equal to the given ones
  72662. */
  72663. equalsFloats(r: number, g: number, b: number): boolean;
  72664. /**
  72665. * Multiplies in place each rgb value by scale
  72666. * @param scale defines the scaling factor
  72667. * @returns the updated Color3
  72668. */
  72669. scale(scale: number): Color3;
  72670. /**
  72671. * Multiplies the rgb values by scale and stores the result into "result"
  72672. * @param scale defines the scaling factor
  72673. * @param result defines the Color3 object where to store the result
  72674. * @returns the unmodified current Color3
  72675. */
  72676. scaleToRef(scale: number, result: Color3): Color3;
  72677. /**
  72678. * Scale the current Color3 values by a factor and add the result to a given Color3
  72679. * @param scale defines the scale factor
  72680. * @param result defines color to store the result into
  72681. * @returns the unmodified current Color3
  72682. */
  72683. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72684. /**
  72685. * Clamps the rgb values by the min and max values and stores the result into "result"
  72686. * @param min defines minimum clamping value (default is 0)
  72687. * @param max defines maximum clamping value (default is 1)
  72688. * @param result defines color to store the result into
  72689. * @returns the original Color3
  72690. */
  72691. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72692. /**
  72693. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72694. * @param otherColor defines the second operand
  72695. * @returns the new Color3
  72696. */
  72697. add(otherColor: DeepImmutable<Color3>): Color3;
  72698. /**
  72699. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72700. * @param otherColor defines the second operand
  72701. * @param result defines Color3 object to store the result into
  72702. * @returns the unmodified current Color3
  72703. */
  72704. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72705. /**
  72706. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72707. * @param otherColor defines the second operand
  72708. * @returns the new Color3
  72709. */
  72710. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72711. /**
  72712. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72713. * @param otherColor defines the second operand
  72714. * @param result defines Color3 object to store the result into
  72715. * @returns the unmodified current Color3
  72716. */
  72717. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72718. /**
  72719. * Copy the current object
  72720. * @returns a new Color3 copied the current one
  72721. */
  72722. clone(): Color3;
  72723. /**
  72724. * Copies the rgb values from the source in the current Color3
  72725. * @param source defines the source Color3 object
  72726. * @returns the updated Color3 object
  72727. */
  72728. copyFrom(source: DeepImmutable<Color3>): Color3;
  72729. /**
  72730. * Updates the Color3 rgb values from the given floats
  72731. * @param r defines the red component to read from
  72732. * @param g defines the green component to read from
  72733. * @param b defines the blue component to read from
  72734. * @returns the current Color3 object
  72735. */
  72736. copyFromFloats(r: number, g: number, b: number): Color3;
  72737. /**
  72738. * Updates the Color3 rgb values from the given floats
  72739. * @param r defines the red component to read from
  72740. * @param g defines the green component to read from
  72741. * @param b defines the blue component to read from
  72742. * @returns the current Color3 object
  72743. */
  72744. set(r: number, g: number, b: number): Color3;
  72745. /**
  72746. * Compute the Color3 hexadecimal code as a string
  72747. * @returns a string containing the hexadecimal representation of the Color3 object
  72748. */
  72749. toHexString(): string;
  72750. /**
  72751. * Computes a new Color3 converted from the current one to linear space
  72752. * @returns a new Color3 object
  72753. */
  72754. toLinearSpace(): Color3;
  72755. /**
  72756. * Converts current color in rgb space to HSV values
  72757. * @returns a new color3 representing the HSV values
  72758. */
  72759. toHSV(): Color3;
  72760. /**
  72761. * Converts current color in rgb space to HSV values
  72762. * @param result defines the Color3 where to store the HSV values
  72763. */
  72764. toHSVToRef(result: Color3): void;
  72765. /**
  72766. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72767. * @param convertedColor defines the Color3 object where to store the linear space version
  72768. * @returns the unmodified Color3
  72769. */
  72770. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72771. /**
  72772. * Computes a new Color3 converted from the current one to gamma space
  72773. * @returns a new Color3 object
  72774. */
  72775. toGammaSpace(): Color3;
  72776. /**
  72777. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72778. * @param convertedColor defines the Color3 object where to store the gamma space version
  72779. * @returns the unmodified Color3
  72780. */
  72781. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72782. private static _BlackReadOnly;
  72783. /**
  72784. * Convert Hue, saturation and value to a Color3 (RGB)
  72785. * @param hue defines the hue
  72786. * @param saturation defines the saturation
  72787. * @param value defines the value
  72788. * @param result defines the Color3 where to store the RGB values
  72789. */
  72790. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72791. /**
  72792. * Creates a new Color3 from the string containing valid hexadecimal values
  72793. * @param hex defines a string containing valid hexadecimal values
  72794. * @returns a new Color3 object
  72795. */
  72796. static FromHexString(hex: string): Color3;
  72797. /**
  72798. * Creates a new Color3 from the starting index of the given array
  72799. * @param array defines the source array
  72800. * @param offset defines an offset in the source array
  72801. * @returns a new Color3 object
  72802. */
  72803. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72804. /**
  72805. * Creates a new Color3 from integer values (< 256)
  72806. * @param r defines the red component to read from (value between 0 and 255)
  72807. * @param g defines the green component to read from (value between 0 and 255)
  72808. * @param b defines the blue component to read from (value between 0 and 255)
  72809. * @returns a new Color3 object
  72810. */
  72811. static FromInts(r: number, g: number, b: number): Color3;
  72812. /**
  72813. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72814. * @param start defines the start Color3 value
  72815. * @param end defines the end Color3 value
  72816. * @param amount defines the gradient value between start and end
  72817. * @returns a new Color3 object
  72818. */
  72819. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72820. /**
  72821. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72822. * @param left defines the start value
  72823. * @param right defines the end value
  72824. * @param amount defines the gradient factor
  72825. * @param result defines the Color3 object where to store the result
  72826. */
  72827. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72828. /**
  72829. * Returns a Color3 value containing a red color
  72830. * @returns a new Color3 object
  72831. */
  72832. static Red(): Color3;
  72833. /**
  72834. * Returns a Color3 value containing a green color
  72835. * @returns a new Color3 object
  72836. */
  72837. static Green(): Color3;
  72838. /**
  72839. * Returns a Color3 value containing a blue color
  72840. * @returns a new Color3 object
  72841. */
  72842. static Blue(): Color3;
  72843. /**
  72844. * Returns a Color3 value containing a black color
  72845. * @returns a new Color3 object
  72846. */
  72847. static Black(): Color3;
  72848. /**
  72849. * Gets a Color3 value containing a black color that must not be updated
  72850. */
  72851. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72852. /**
  72853. * Returns a Color3 value containing a white color
  72854. * @returns a new Color3 object
  72855. */
  72856. static White(): Color3;
  72857. /**
  72858. * Returns a Color3 value containing a purple color
  72859. * @returns a new Color3 object
  72860. */
  72861. static Purple(): Color3;
  72862. /**
  72863. * Returns a Color3 value containing a magenta color
  72864. * @returns a new Color3 object
  72865. */
  72866. static Magenta(): Color3;
  72867. /**
  72868. * Returns a Color3 value containing a yellow color
  72869. * @returns a new Color3 object
  72870. */
  72871. static Yellow(): Color3;
  72872. /**
  72873. * Returns a Color3 value containing a gray color
  72874. * @returns a new Color3 object
  72875. */
  72876. static Gray(): Color3;
  72877. /**
  72878. * Returns a Color3 value containing a teal color
  72879. * @returns a new Color3 object
  72880. */
  72881. static Teal(): Color3;
  72882. /**
  72883. * Returns a Color3 value containing a random color
  72884. * @returns a new Color3 object
  72885. */
  72886. static Random(): Color3;
  72887. }
  72888. /**
  72889. * Class used to hold a RBGA color
  72890. */
  72891. export class Color4 {
  72892. /**
  72893. * Defines the red component (between 0 and 1, default is 0)
  72894. */
  72895. r: number;
  72896. /**
  72897. * Defines the green component (between 0 and 1, default is 0)
  72898. */
  72899. g: number;
  72900. /**
  72901. * Defines the blue component (between 0 and 1, default is 0)
  72902. */
  72903. b: number;
  72904. /**
  72905. * Defines the alpha component (between 0 and 1, default is 1)
  72906. */
  72907. a: number;
  72908. /**
  72909. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72910. * @param r defines the red component (between 0 and 1, default is 0)
  72911. * @param g defines the green component (between 0 and 1, default is 0)
  72912. * @param b defines the blue component (between 0 and 1, default is 0)
  72913. * @param a defines the alpha component (between 0 and 1, default is 1)
  72914. */
  72915. constructor(
  72916. /**
  72917. * Defines the red component (between 0 and 1, default is 0)
  72918. */
  72919. r?: number,
  72920. /**
  72921. * Defines the green component (between 0 and 1, default is 0)
  72922. */
  72923. g?: number,
  72924. /**
  72925. * Defines the blue component (between 0 and 1, default is 0)
  72926. */
  72927. b?: number,
  72928. /**
  72929. * Defines the alpha component (between 0 and 1, default is 1)
  72930. */
  72931. a?: number);
  72932. /**
  72933. * Adds in place the given Color4 values to the current Color4 object
  72934. * @param right defines the second operand
  72935. * @returns the current updated Color4 object
  72936. */
  72937. addInPlace(right: DeepImmutable<Color4>): Color4;
  72938. /**
  72939. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72940. * @returns the new array
  72941. */
  72942. asArray(): number[];
  72943. /**
  72944. * Stores from the starting index in the given array the Color4 successive values
  72945. * @param array defines the array where to store the r,g,b components
  72946. * @param index defines an optional index in the target array to define where to start storing values
  72947. * @returns the current Color4 object
  72948. */
  72949. toArray(array: number[], index?: number): Color4;
  72950. /**
  72951. * Determines equality between Color4 objects
  72952. * @param otherColor defines the second operand
  72953. * @returns true if the rgba values are equal to the given ones
  72954. */
  72955. equals(otherColor: DeepImmutable<Color4>): boolean;
  72956. /**
  72957. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72958. * @param right defines the second operand
  72959. * @returns a new Color4 object
  72960. */
  72961. add(right: DeepImmutable<Color4>): Color4;
  72962. /**
  72963. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72964. * @param right defines the second operand
  72965. * @returns a new Color4 object
  72966. */
  72967. subtract(right: DeepImmutable<Color4>): Color4;
  72968. /**
  72969. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72970. * @param right defines the second operand
  72971. * @param result defines the Color4 object where to store the result
  72972. * @returns the current Color4 object
  72973. */
  72974. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72975. /**
  72976. * Creates a new Color4 with the current Color4 values multiplied by scale
  72977. * @param scale defines the scaling factor to apply
  72978. * @returns a new Color4 object
  72979. */
  72980. scale(scale: number): Color4;
  72981. /**
  72982. * Multiplies the current Color4 values by scale and stores the result in "result"
  72983. * @param scale defines the scaling factor to apply
  72984. * @param result defines the Color4 object where to store the result
  72985. * @returns the current unmodified Color4
  72986. */
  72987. scaleToRef(scale: number, result: Color4): Color4;
  72988. /**
  72989. * Scale the current Color4 values by a factor and add the result to a given Color4
  72990. * @param scale defines the scale factor
  72991. * @param result defines the Color4 object where to store the result
  72992. * @returns the unmodified current Color4
  72993. */
  72994. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72995. /**
  72996. * Clamps the rgb values by the min and max values and stores the result into "result"
  72997. * @param min defines minimum clamping value (default is 0)
  72998. * @param max defines maximum clamping value (default is 1)
  72999. * @param result defines color to store the result into.
  73000. * @returns the cuurent Color4
  73001. */
  73002. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73003. /**
  73004. * Multipy an Color4 value by another and return a new Color4 object
  73005. * @param color defines the Color4 value to multiply by
  73006. * @returns a new Color4 object
  73007. */
  73008. multiply(color: Color4): Color4;
  73009. /**
  73010. * Multipy a Color4 value by another and push the result in a reference value
  73011. * @param color defines the Color4 value to multiply by
  73012. * @param result defines the Color4 to fill the result in
  73013. * @returns the result Color4
  73014. */
  73015. multiplyToRef(color: Color4, result: Color4): Color4;
  73016. /**
  73017. * Creates a string with the Color4 current values
  73018. * @returns the string representation of the Color4 object
  73019. */
  73020. toString(): string;
  73021. /**
  73022. * Returns the string "Color4"
  73023. * @returns "Color4"
  73024. */
  73025. getClassName(): string;
  73026. /**
  73027. * Compute the Color4 hash code
  73028. * @returns an unique number that can be used to hash Color4 objects
  73029. */
  73030. getHashCode(): number;
  73031. /**
  73032. * Creates a new Color4 copied from the current one
  73033. * @returns a new Color4 object
  73034. */
  73035. clone(): Color4;
  73036. /**
  73037. * Copies the given Color4 values into the current one
  73038. * @param source defines the source Color4 object
  73039. * @returns the current updated Color4 object
  73040. */
  73041. copyFrom(source: Color4): Color4;
  73042. /**
  73043. * Copies the given float values into the current one
  73044. * @param r defines the red component to read from
  73045. * @param g defines the green component to read from
  73046. * @param b defines the blue component to read from
  73047. * @param a defines the alpha component to read from
  73048. * @returns the current updated Color4 object
  73049. */
  73050. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73051. /**
  73052. * Copies the given float values into the current one
  73053. * @param r defines the red component to read from
  73054. * @param g defines the green component to read from
  73055. * @param b defines the blue component to read from
  73056. * @param a defines the alpha component to read from
  73057. * @returns the current updated Color4 object
  73058. */
  73059. set(r: number, g: number, b: number, a: number): Color4;
  73060. /**
  73061. * Compute the Color4 hexadecimal code as a string
  73062. * @returns a string containing the hexadecimal representation of the Color4 object
  73063. */
  73064. toHexString(): string;
  73065. /**
  73066. * Computes a new Color4 converted from the current one to linear space
  73067. * @returns a new Color4 object
  73068. */
  73069. toLinearSpace(): Color4;
  73070. /**
  73071. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73072. * @param convertedColor defines the Color4 object where to store the linear space version
  73073. * @returns the unmodified Color4
  73074. */
  73075. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73076. /**
  73077. * Computes a new Color4 converted from the current one to gamma space
  73078. * @returns a new Color4 object
  73079. */
  73080. toGammaSpace(): Color4;
  73081. /**
  73082. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73083. * @param convertedColor defines the Color4 object where to store the gamma space version
  73084. * @returns the unmodified Color4
  73085. */
  73086. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73087. /**
  73088. * Creates a new Color4 from the string containing valid hexadecimal values
  73089. * @param hex defines a string containing valid hexadecimal values
  73090. * @returns a new Color4 object
  73091. */
  73092. static FromHexString(hex: string): Color4;
  73093. /**
  73094. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73095. * @param left defines the start value
  73096. * @param right defines the end value
  73097. * @param amount defines the gradient factor
  73098. * @returns a new Color4 object
  73099. */
  73100. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73101. /**
  73102. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73103. * @param left defines the start value
  73104. * @param right defines the end value
  73105. * @param amount defines the gradient factor
  73106. * @param result defines the Color4 object where to store data
  73107. */
  73108. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73109. /**
  73110. * Creates a new Color4 from a Color3 and an alpha value
  73111. * @param color3 defines the source Color3 to read from
  73112. * @param alpha defines the alpha component (1.0 by default)
  73113. * @returns a new Color4 object
  73114. */
  73115. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73116. /**
  73117. * Creates a new Color4 from the starting index element of the given array
  73118. * @param array defines the source array to read from
  73119. * @param offset defines the offset in the source array
  73120. * @returns a new Color4 object
  73121. */
  73122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73123. /**
  73124. * Creates a new Color3 from integer values (< 256)
  73125. * @param r defines the red component to read from (value between 0 and 255)
  73126. * @param g defines the green component to read from (value between 0 and 255)
  73127. * @param b defines the blue component to read from (value between 0 and 255)
  73128. * @param a defines the alpha component to read from (value between 0 and 255)
  73129. * @returns a new Color3 object
  73130. */
  73131. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73132. /**
  73133. * Check the content of a given array and convert it to an array containing RGBA data
  73134. * If the original array was already containing count * 4 values then it is returned directly
  73135. * @param colors defines the array to check
  73136. * @param count defines the number of RGBA data to expect
  73137. * @returns an array containing count * 4 values (RGBA)
  73138. */
  73139. static CheckColors4(colors: number[], count: number): number[];
  73140. }
  73141. /**
  73142. * @hidden
  73143. */
  73144. export class TmpColors {
  73145. static Color3: Color3[];
  73146. static Color4: Color4[];
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. /**
  73151. * Defines an interface which represents an animation key frame
  73152. */
  73153. export interface IAnimationKey {
  73154. /**
  73155. * Frame of the key frame
  73156. */
  73157. frame: number;
  73158. /**
  73159. * Value at the specifies key frame
  73160. */
  73161. value: any;
  73162. /**
  73163. * The input tangent for the cubic hermite spline
  73164. */
  73165. inTangent?: any;
  73166. /**
  73167. * The output tangent for the cubic hermite spline
  73168. */
  73169. outTangent?: any;
  73170. /**
  73171. * The animation interpolation type
  73172. */
  73173. interpolation?: AnimationKeyInterpolation;
  73174. }
  73175. /**
  73176. * Enum for the animation key frame interpolation type
  73177. */
  73178. export enum AnimationKeyInterpolation {
  73179. /**
  73180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73181. */
  73182. STEP = 1
  73183. }
  73184. }
  73185. declare module BABYLON {
  73186. /**
  73187. * Represents the range of an animation
  73188. */
  73189. export class AnimationRange {
  73190. /**The name of the animation range**/
  73191. name: string;
  73192. /**The starting frame of the animation */
  73193. from: number;
  73194. /**The ending frame of the animation*/
  73195. to: number;
  73196. /**
  73197. * Initializes the range of an animation
  73198. * @param name The name of the animation range
  73199. * @param from The starting frame of the animation
  73200. * @param to The ending frame of the animation
  73201. */
  73202. constructor(
  73203. /**The name of the animation range**/
  73204. name: string,
  73205. /**The starting frame of the animation */
  73206. from: number,
  73207. /**The ending frame of the animation*/
  73208. to: number);
  73209. /**
  73210. * Makes a copy of the animation range
  73211. * @returns A copy of the animation range
  73212. */
  73213. clone(): AnimationRange;
  73214. }
  73215. }
  73216. declare module BABYLON {
  73217. /**
  73218. * Composed of a frame, and an action function
  73219. */
  73220. export class AnimationEvent {
  73221. /** The frame for which the event is triggered **/
  73222. frame: number;
  73223. /** The event to perform when triggered **/
  73224. action: (currentFrame: number) => void;
  73225. /** Specifies if the event should be triggered only once**/
  73226. onlyOnce?: boolean | undefined;
  73227. /**
  73228. * Specifies if the animation event is done
  73229. */
  73230. isDone: boolean;
  73231. /**
  73232. * Initializes the animation event
  73233. * @param frame The frame for which the event is triggered
  73234. * @param action The event to perform when triggered
  73235. * @param onlyOnce Specifies if the event should be triggered only once
  73236. */
  73237. constructor(
  73238. /** The frame for which the event is triggered **/
  73239. frame: number,
  73240. /** The event to perform when triggered **/
  73241. action: (currentFrame: number) => void,
  73242. /** Specifies if the event should be triggered only once**/
  73243. onlyOnce?: boolean | undefined);
  73244. /** @hidden */
  73245. _clone(): AnimationEvent;
  73246. }
  73247. }
  73248. declare module BABYLON {
  73249. /**
  73250. * Interface used to define a behavior
  73251. */
  73252. export interface Behavior<T> {
  73253. /** gets or sets behavior's name */
  73254. name: string;
  73255. /**
  73256. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73257. */
  73258. init(): void;
  73259. /**
  73260. * Called when the behavior is attached to a target
  73261. * @param target defines the target where the behavior is attached to
  73262. */
  73263. attach(target: T): void;
  73264. /**
  73265. * Called when the behavior is detached from its target
  73266. */
  73267. detach(): void;
  73268. }
  73269. /**
  73270. * Interface implemented by classes supporting behaviors
  73271. */
  73272. export interface IBehaviorAware<T> {
  73273. /**
  73274. * Attach a behavior
  73275. * @param behavior defines the behavior to attach
  73276. * @returns the current host
  73277. */
  73278. addBehavior(behavior: Behavior<T>): T;
  73279. /**
  73280. * Remove a behavior from the current object
  73281. * @param behavior defines the behavior to detach
  73282. * @returns the current host
  73283. */
  73284. removeBehavior(behavior: Behavior<T>): T;
  73285. /**
  73286. * Gets a behavior using its name to search
  73287. * @param name defines the name to search
  73288. * @returns the behavior or null if not found
  73289. */
  73290. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. /**
  73295. * Defines an array and its length.
  73296. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73297. */
  73298. export interface ISmartArrayLike<T> {
  73299. /**
  73300. * The data of the array.
  73301. */
  73302. data: Array<T>;
  73303. /**
  73304. * The active length of the array.
  73305. */
  73306. length: number;
  73307. }
  73308. /**
  73309. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73310. */
  73311. export class SmartArray<T> implements ISmartArrayLike<T> {
  73312. /**
  73313. * The full set of data from the array.
  73314. */
  73315. data: Array<T>;
  73316. /**
  73317. * The active length of the array.
  73318. */
  73319. length: number;
  73320. protected _id: number;
  73321. /**
  73322. * Instantiates a Smart Array.
  73323. * @param capacity defines the default capacity of the array.
  73324. */
  73325. constructor(capacity: number);
  73326. /**
  73327. * Pushes a value at the end of the active data.
  73328. * @param value defines the object to push in the array.
  73329. */
  73330. push(value: T): void;
  73331. /**
  73332. * Iterates over the active data and apply the lambda to them.
  73333. * @param func defines the action to apply on each value.
  73334. */
  73335. forEach(func: (content: T) => void): void;
  73336. /**
  73337. * Sorts the full sets of data.
  73338. * @param compareFn defines the comparison function to apply.
  73339. */
  73340. sort(compareFn: (a: T, b: T) => number): void;
  73341. /**
  73342. * Resets the active data to an empty array.
  73343. */
  73344. reset(): void;
  73345. /**
  73346. * Releases all the data from the array as well as the array.
  73347. */
  73348. dispose(): void;
  73349. /**
  73350. * Concats the active data with a given array.
  73351. * @param array defines the data to concatenate with.
  73352. */
  73353. concat(array: any): void;
  73354. /**
  73355. * Returns the position of a value in the active data.
  73356. * @param value defines the value to find the index for
  73357. * @returns the index if found in the active data otherwise -1
  73358. */
  73359. indexOf(value: T): number;
  73360. /**
  73361. * Returns whether an element is part of the active data.
  73362. * @param value defines the value to look for
  73363. * @returns true if found in the active data otherwise false
  73364. */
  73365. contains(value: T): boolean;
  73366. private static _GlobalId;
  73367. }
  73368. /**
  73369. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73370. * The data in this array can only be present once
  73371. */
  73372. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73373. private _duplicateId;
  73374. /**
  73375. * Pushes a value at the end of the active data.
  73376. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73377. * @param value defines the object to push in the array.
  73378. */
  73379. push(value: T): void;
  73380. /**
  73381. * Pushes a value at the end of the active data.
  73382. * If the data is already present, it won t be added again
  73383. * @param value defines the object to push in the array.
  73384. * @returns true if added false if it was already present
  73385. */
  73386. pushNoDuplicate(value: T): boolean;
  73387. /**
  73388. * Resets the active data to an empty array.
  73389. */
  73390. reset(): void;
  73391. /**
  73392. * Concats the active data with a given array.
  73393. * This ensures no dupplicate will be present in the result.
  73394. * @param array defines the data to concatenate with.
  73395. */
  73396. concatWithNoDuplicate(array: any): void;
  73397. }
  73398. }
  73399. declare module BABYLON {
  73400. /**
  73401. * @ignore
  73402. * This is a list of all the different input types that are available in the application.
  73403. * Fo instance: ArcRotateCameraGamepadInput...
  73404. */
  73405. export var CameraInputTypes: {};
  73406. /**
  73407. * This is the contract to implement in order to create a new input class.
  73408. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73409. */
  73410. export interface ICameraInput<TCamera extends Camera> {
  73411. /**
  73412. * Defines the camera the input is attached to.
  73413. */
  73414. camera: Nullable<TCamera>;
  73415. /**
  73416. * Gets the class name of the current intput.
  73417. * @returns the class name
  73418. */
  73419. getClassName(): string;
  73420. /**
  73421. * Get the friendly name associated with the input class.
  73422. * @returns the input friendly name
  73423. */
  73424. getSimpleName(): string;
  73425. /**
  73426. * Attach the input controls to a specific dom element to get the input from.
  73427. * @param element Defines the element the controls should be listened from
  73428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73429. */
  73430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73431. /**
  73432. * Detach the current controls from the specified dom element.
  73433. * @param element Defines the element to stop listening the inputs from
  73434. */
  73435. detachControl(element: Nullable<HTMLElement>): void;
  73436. /**
  73437. * Update the current camera state depending on the inputs that have been used this frame.
  73438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73439. */
  73440. checkInputs?: () => void;
  73441. }
  73442. /**
  73443. * Represents a map of input types to input instance or input index to input instance.
  73444. */
  73445. export interface CameraInputsMap<TCamera extends Camera> {
  73446. /**
  73447. * Accessor to the input by input type.
  73448. */
  73449. [name: string]: ICameraInput<TCamera>;
  73450. /**
  73451. * Accessor to the input by input index.
  73452. */
  73453. [idx: number]: ICameraInput<TCamera>;
  73454. }
  73455. /**
  73456. * This represents the input manager used within a camera.
  73457. * It helps dealing with all the different kind of input attached to a camera.
  73458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73459. */
  73460. export class CameraInputsManager<TCamera extends Camera> {
  73461. /**
  73462. * Defines the list of inputs attahed to the camera.
  73463. */
  73464. attached: CameraInputsMap<TCamera>;
  73465. /**
  73466. * Defines the dom element the camera is collecting inputs from.
  73467. * This is null if the controls have not been attached.
  73468. */
  73469. attachedElement: Nullable<HTMLElement>;
  73470. /**
  73471. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73472. */
  73473. noPreventDefault: boolean;
  73474. /**
  73475. * Defined the camera the input manager belongs to.
  73476. */
  73477. camera: TCamera;
  73478. /**
  73479. * Update the current camera state depending on the inputs that have been used this frame.
  73480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73481. */
  73482. checkInputs: () => void;
  73483. /**
  73484. * Instantiate a new Camera Input Manager.
  73485. * @param camera Defines the camera the input manager blongs to
  73486. */
  73487. constructor(camera: TCamera);
  73488. /**
  73489. * Add an input method to a camera
  73490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73491. * @param input camera input method
  73492. */
  73493. add(input: ICameraInput<TCamera>): void;
  73494. /**
  73495. * Remove a specific input method from a camera
  73496. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73497. * @param inputToRemove camera input method
  73498. */
  73499. remove(inputToRemove: ICameraInput<TCamera>): void;
  73500. /**
  73501. * Remove a specific input type from a camera
  73502. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73503. * @param inputType the type of the input to remove
  73504. */
  73505. removeByType(inputType: string): void;
  73506. private _addCheckInputs;
  73507. /**
  73508. * Attach the input controls to the currently attached dom element to listen the events from.
  73509. * @param input Defines the input to attach
  73510. */
  73511. attachInput(input: ICameraInput<TCamera>): void;
  73512. /**
  73513. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73514. * @param element Defines the dom element to collect the events from
  73515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73516. */
  73517. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73518. /**
  73519. * Detach the current manager inputs controls from a specific dom element.
  73520. * @param element Defines the dom element to collect the events from
  73521. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73522. */
  73523. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73524. /**
  73525. * Rebuild the dynamic inputCheck function from the current list of
  73526. * defined inputs in the manager.
  73527. */
  73528. rebuildInputCheck(): void;
  73529. /**
  73530. * Remove all attached input methods from a camera
  73531. */
  73532. clear(): void;
  73533. /**
  73534. * Serialize the current input manager attached to a camera.
  73535. * This ensures than once parsed,
  73536. * the input associated to the camera will be identical to the current ones
  73537. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73538. */
  73539. serialize(serializedCamera: any): void;
  73540. /**
  73541. * Parses an input manager serialized JSON to restore the previous list of inputs
  73542. * and states associated to a camera.
  73543. * @param parsedCamera Defines the JSON to parse
  73544. */
  73545. parse(parsedCamera: any): void;
  73546. }
  73547. }
  73548. declare module BABYLON {
  73549. /**
  73550. * Class used to store data that will be store in GPU memory
  73551. */
  73552. export class Buffer {
  73553. private _engine;
  73554. private _buffer;
  73555. /** @hidden */
  73556. _data: Nullable<DataArray>;
  73557. private _updatable;
  73558. private _instanced;
  73559. private _divisor;
  73560. /**
  73561. * Gets the byte stride.
  73562. */
  73563. readonly byteStride: number;
  73564. /**
  73565. * Constructor
  73566. * @param engine the engine
  73567. * @param data the data to use for this buffer
  73568. * @param updatable whether the data is updatable
  73569. * @param stride the stride (optional)
  73570. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73571. * @param instanced whether the buffer is instanced (optional)
  73572. * @param useBytes set to true if the stride in in bytes (optional)
  73573. * @param divisor sets an optional divisor for instances (1 by default)
  73574. */
  73575. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73576. /**
  73577. * Create a new VertexBuffer based on the current buffer
  73578. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73579. * @param offset defines offset in the buffer (0 by default)
  73580. * @param size defines the size in floats of attributes (position is 3 for instance)
  73581. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73582. * @param instanced defines if the vertex buffer contains indexed data
  73583. * @param useBytes defines if the offset and stride are in bytes *
  73584. * @param divisor sets an optional divisor for instances (1 by default)
  73585. * @returns the new vertex buffer
  73586. */
  73587. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73588. /**
  73589. * Gets a boolean indicating if the Buffer is updatable?
  73590. * @returns true if the buffer is updatable
  73591. */
  73592. isUpdatable(): boolean;
  73593. /**
  73594. * Gets current buffer's data
  73595. * @returns a DataArray or null
  73596. */
  73597. getData(): Nullable<DataArray>;
  73598. /**
  73599. * Gets underlying native buffer
  73600. * @returns underlying native buffer
  73601. */
  73602. getBuffer(): Nullable<DataBuffer>;
  73603. /**
  73604. * Gets the stride in float32 units (i.e. byte stride / 4).
  73605. * May not be an integer if the byte stride is not divisible by 4.
  73606. * DEPRECATED. Use byteStride instead.
  73607. * @returns the stride in float32 units
  73608. */
  73609. getStrideSize(): number;
  73610. /**
  73611. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73612. * @param data defines the data to store
  73613. */
  73614. create(data?: Nullable<DataArray>): void;
  73615. /** @hidden */
  73616. _rebuild(): void;
  73617. /**
  73618. * Update current buffer data
  73619. * @param data defines the data to store
  73620. */
  73621. update(data: DataArray): void;
  73622. /**
  73623. * Updates the data directly.
  73624. * @param data the new data
  73625. * @param offset the new offset
  73626. * @param vertexCount the vertex count (optional)
  73627. * @param useBytes set to true if the offset is in bytes
  73628. */
  73629. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73630. /**
  73631. * Release all resources
  73632. */
  73633. dispose(): void;
  73634. }
  73635. /**
  73636. * Specialized buffer used to store vertex data
  73637. */
  73638. export class VertexBuffer {
  73639. /** @hidden */
  73640. _buffer: Buffer;
  73641. private _kind;
  73642. private _size;
  73643. private _ownsBuffer;
  73644. private _instanced;
  73645. private _instanceDivisor;
  73646. /**
  73647. * The byte type.
  73648. */
  73649. static readonly BYTE: number;
  73650. /**
  73651. * The unsigned byte type.
  73652. */
  73653. static readonly UNSIGNED_BYTE: number;
  73654. /**
  73655. * The short type.
  73656. */
  73657. static readonly SHORT: number;
  73658. /**
  73659. * The unsigned short type.
  73660. */
  73661. static readonly UNSIGNED_SHORT: number;
  73662. /**
  73663. * The integer type.
  73664. */
  73665. static readonly INT: number;
  73666. /**
  73667. * The unsigned integer type.
  73668. */
  73669. static readonly UNSIGNED_INT: number;
  73670. /**
  73671. * The float type.
  73672. */
  73673. static readonly FLOAT: number;
  73674. /**
  73675. * Gets or sets the instance divisor when in instanced mode
  73676. */
  73677. instanceDivisor: number;
  73678. /**
  73679. * Gets the byte stride.
  73680. */
  73681. readonly byteStride: number;
  73682. /**
  73683. * Gets the byte offset.
  73684. */
  73685. readonly byteOffset: number;
  73686. /**
  73687. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73688. */
  73689. readonly normalized: boolean;
  73690. /**
  73691. * Gets the data type of each component in the array.
  73692. */
  73693. readonly type: number;
  73694. /**
  73695. * Constructor
  73696. * @param engine the engine
  73697. * @param data the data to use for this vertex buffer
  73698. * @param kind the vertex buffer kind
  73699. * @param updatable whether the data is updatable
  73700. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73701. * @param stride the stride (optional)
  73702. * @param instanced whether the buffer is instanced (optional)
  73703. * @param offset the offset of the data (optional)
  73704. * @param size the number of components (optional)
  73705. * @param type the type of the component (optional)
  73706. * @param normalized whether the data contains normalized data (optional)
  73707. * @param useBytes set to true if stride and offset are in bytes (optional)
  73708. * @param divisor defines the instance divisor to use (1 by default)
  73709. */
  73710. 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, divisor?: number);
  73711. /** @hidden */
  73712. _rebuild(): void;
  73713. /**
  73714. * Returns the kind of the VertexBuffer (string)
  73715. * @returns a string
  73716. */
  73717. getKind(): string;
  73718. /**
  73719. * Gets a boolean indicating if the VertexBuffer is updatable?
  73720. * @returns true if the buffer is updatable
  73721. */
  73722. isUpdatable(): boolean;
  73723. /**
  73724. * Gets current buffer's data
  73725. * @returns a DataArray or null
  73726. */
  73727. getData(): Nullable<DataArray>;
  73728. /**
  73729. * Gets underlying native buffer
  73730. * @returns underlying native buffer
  73731. */
  73732. getBuffer(): Nullable<DataBuffer>;
  73733. /**
  73734. * Gets the stride in float32 units (i.e. byte stride / 4).
  73735. * May not be an integer if the byte stride is not divisible by 4.
  73736. * DEPRECATED. Use byteStride instead.
  73737. * @returns the stride in float32 units
  73738. */
  73739. getStrideSize(): number;
  73740. /**
  73741. * Returns the offset as a multiple of the type byte length.
  73742. * DEPRECATED. Use byteOffset instead.
  73743. * @returns the offset in bytes
  73744. */
  73745. getOffset(): number;
  73746. /**
  73747. * Returns the number of components per vertex attribute (integer)
  73748. * @returns the size in float
  73749. */
  73750. getSize(): number;
  73751. /**
  73752. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73753. * @returns true if this buffer is instanced
  73754. */
  73755. getIsInstanced(): boolean;
  73756. /**
  73757. * Returns the instancing divisor, zero for non-instanced (integer).
  73758. * @returns a number
  73759. */
  73760. getInstanceDivisor(): number;
  73761. /**
  73762. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73763. * @param data defines the data to store
  73764. */
  73765. create(data?: DataArray): void;
  73766. /**
  73767. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73768. * This function will create a new buffer if the current one is not updatable
  73769. * @param data defines the data to store
  73770. */
  73771. update(data: DataArray): void;
  73772. /**
  73773. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73774. * Returns the directly updated WebGLBuffer.
  73775. * @param data the new data
  73776. * @param offset the new offset
  73777. * @param useBytes set to true if the offset is in bytes
  73778. */
  73779. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73780. /**
  73781. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73782. */
  73783. dispose(): void;
  73784. /**
  73785. * Enumerates each value of this vertex buffer as numbers.
  73786. * @param count the number of values to enumerate
  73787. * @param callback the callback function called for each value
  73788. */
  73789. forEach(count: number, callback: (value: number, index: number) => void): void;
  73790. /**
  73791. * Positions
  73792. */
  73793. static readonly PositionKind: string;
  73794. /**
  73795. * Normals
  73796. */
  73797. static readonly NormalKind: string;
  73798. /**
  73799. * Tangents
  73800. */
  73801. static readonly TangentKind: string;
  73802. /**
  73803. * Texture coordinates
  73804. */
  73805. static readonly UVKind: string;
  73806. /**
  73807. * Texture coordinates 2
  73808. */
  73809. static readonly UV2Kind: string;
  73810. /**
  73811. * Texture coordinates 3
  73812. */
  73813. static readonly UV3Kind: string;
  73814. /**
  73815. * Texture coordinates 4
  73816. */
  73817. static readonly UV4Kind: string;
  73818. /**
  73819. * Texture coordinates 5
  73820. */
  73821. static readonly UV5Kind: string;
  73822. /**
  73823. * Texture coordinates 6
  73824. */
  73825. static readonly UV6Kind: string;
  73826. /**
  73827. * Colors
  73828. */
  73829. static readonly ColorKind: string;
  73830. /**
  73831. * Matrix indices (for bones)
  73832. */
  73833. static readonly MatricesIndicesKind: string;
  73834. /**
  73835. * Matrix weights (for bones)
  73836. */
  73837. static readonly MatricesWeightsKind: string;
  73838. /**
  73839. * Additional matrix indices (for bones)
  73840. */
  73841. static readonly MatricesIndicesExtraKind: string;
  73842. /**
  73843. * Additional matrix weights (for bones)
  73844. */
  73845. static readonly MatricesWeightsExtraKind: string;
  73846. /**
  73847. * Deduces the stride given a kind.
  73848. * @param kind The kind string to deduce
  73849. * @returns The deduced stride
  73850. */
  73851. static DeduceStride(kind: string): number;
  73852. /**
  73853. * Gets the byte length of the given type.
  73854. * @param type the type
  73855. * @returns the number of bytes
  73856. */
  73857. static GetTypeByteLength(type: number): number;
  73858. /**
  73859. * Enumerates each value of the given parameters as numbers.
  73860. * @param data the data to enumerate
  73861. * @param byteOffset the byte offset of the data
  73862. * @param byteStride the byte stride of the data
  73863. * @param componentCount the number of components per element
  73864. * @param componentType the type of the component
  73865. * @param count the number of values to enumerate
  73866. * @param normalized whether the data is normalized
  73867. * @param callback the callback function called for each value
  73868. */
  73869. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73870. private static _GetFloatValue;
  73871. }
  73872. }
  73873. declare module BABYLON {
  73874. /**
  73875. * @hidden
  73876. */
  73877. export class IntersectionInfo {
  73878. bu: Nullable<number>;
  73879. bv: Nullable<number>;
  73880. distance: number;
  73881. faceId: number;
  73882. subMeshId: number;
  73883. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73884. }
  73885. }
  73886. declare module BABYLON {
  73887. /**
  73888. * Represens a plane by the equation ax + by + cz + d = 0
  73889. */
  73890. export class Plane {
  73891. private static _TmpMatrix;
  73892. /**
  73893. * Normal of the plane (a,b,c)
  73894. */
  73895. normal: Vector3;
  73896. /**
  73897. * d component of the plane
  73898. */
  73899. d: number;
  73900. /**
  73901. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73902. * @param a a component of the plane
  73903. * @param b b component of the plane
  73904. * @param c c component of the plane
  73905. * @param d d component of the plane
  73906. */
  73907. constructor(a: number, b: number, c: number, d: number);
  73908. /**
  73909. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73910. */
  73911. asArray(): number[];
  73912. /**
  73913. * @returns a new plane copied from the current Plane.
  73914. */
  73915. clone(): Plane;
  73916. /**
  73917. * @returns the string "Plane".
  73918. */
  73919. getClassName(): string;
  73920. /**
  73921. * @returns the Plane hash code.
  73922. */
  73923. getHashCode(): number;
  73924. /**
  73925. * Normalize the current Plane in place.
  73926. * @returns the updated Plane.
  73927. */
  73928. normalize(): Plane;
  73929. /**
  73930. * Applies a transformation the plane and returns the result
  73931. * @param transformation the transformation matrix to be applied to the plane
  73932. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73933. */
  73934. transform(transformation: DeepImmutable<Matrix>): Plane;
  73935. /**
  73936. * Calcualtte the dot product between the point and the plane normal
  73937. * @param point point to calculate the dot product with
  73938. * @returns the dot product (float) of the point coordinates and the plane normal.
  73939. */
  73940. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73941. /**
  73942. * Updates the current Plane from the plane defined by the three given points.
  73943. * @param point1 one of the points used to contruct the plane
  73944. * @param point2 one of the points used to contruct the plane
  73945. * @param point3 one of the points used to contruct the plane
  73946. * @returns the updated Plane.
  73947. */
  73948. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73949. /**
  73950. * Checks if the plane is facing a given direction
  73951. * @param direction the direction to check if the plane is facing
  73952. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73953. * @returns True is the vector "direction" is the same side than the plane normal.
  73954. */
  73955. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73956. /**
  73957. * Calculates the distance to a point
  73958. * @param point point to calculate distance to
  73959. * @returns the signed distance (float) from the given point to the Plane.
  73960. */
  73961. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73962. /**
  73963. * Creates a plane from an array
  73964. * @param array the array to create a plane from
  73965. * @returns a new Plane from the given array.
  73966. */
  73967. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73968. /**
  73969. * Creates a plane from three points
  73970. * @param point1 point used to create the plane
  73971. * @param point2 point used to create the plane
  73972. * @param point3 point used to create the plane
  73973. * @returns a new Plane defined by the three given points.
  73974. */
  73975. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73976. /**
  73977. * Creates a plane from an origin point and a normal
  73978. * @param origin origin of the plane to be constructed
  73979. * @param normal normal of the plane to be constructed
  73980. * @returns a new Plane the normal vector to this plane at the given origin point.
  73981. * Note : the vector "normal" is updated because normalized.
  73982. */
  73983. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73984. /**
  73985. * Calculates the distance from a plane and a point
  73986. * @param origin origin of the plane to be constructed
  73987. * @param normal normal of the plane to be constructed
  73988. * @param point point to calculate distance to
  73989. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73990. */
  73991. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73992. }
  73993. }
  73994. declare module BABYLON {
  73995. /**
  73996. * Class used to store bounding sphere information
  73997. */
  73998. export class BoundingSphere {
  73999. /**
  74000. * Gets the center of the bounding sphere in local space
  74001. */
  74002. readonly center: Vector3;
  74003. /**
  74004. * Radius of the bounding sphere in local space
  74005. */
  74006. radius: number;
  74007. /**
  74008. * Gets the center of the bounding sphere in world space
  74009. */
  74010. readonly centerWorld: Vector3;
  74011. /**
  74012. * Radius of the bounding sphere in world space
  74013. */
  74014. radiusWorld: number;
  74015. /**
  74016. * Gets the minimum vector in local space
  74017. */
  74018. readonly minimum: Vector3;
  74019. /**
  74020. * Gets the maximum vector in local space
  74021. */
  74022. readonly maximum: Vector3;
  74023. private _worldMatrix;
  74024. private static readonly TmpVector3;
  74025. /**
  74026. * Creates a new bounding sphere
  74027. * @param min defines the minimum vector (in local space)
  74028. * @param max defines the maximum vector (in local space)
  74029. * @param worldMatrix defines the new world matrix
  74030. */
  74031. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74032. /**
  74033. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74034. * @param min defines the new minimum vector (in local space)
  74035. * @param max defines the new maximum vector (in local space)
  74036. * @param worldMatrix defines the new world matrix
  74037. */
  74038. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74039. /**
  74040. * Scale the current bounding sphere by applying a scale factor
  74041. * @param factor defines the scale factor to apply
  74042. * @returns the current bounding box
  74043. */
  74044. scale(factor: number): BoundingSphere;
  74045. /**
  74046. * Gets the world matrix of the bounding box
  74047. * @returns a matrix
  74048. */
  74049. getWorldMatrix(): DeepImmutable<Matrix>;
  74050. /** @hidden */
  74051. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74052. /**
  74053. * Tests if the bounding sphere is intersecting the frustum planes
  74054. * @param frustumPlanes defines the frustum planes to test
  74055. * @returns true if there is an intersection
  74056. */
  74057. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74058. /**
  74059. * Tests if the bounding sphere center is in between the frustum planes.
  74060. * Used for optimistic fast inclusion.
  74061. * @param frustumPlanes defines the frustum planes to test
  74062. * @returns true if the sphere center is in between the frustum planes
  74063. */
  74064. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74065. /**
  74066. * Tests if a point is inside the bounding sphere
  74067. * @param point defines the point to test
  74068. * @returns true if the point is inside the bounding sphere
  74069. */
  74070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74071. /**
  74072. * Checks if two sphere intersct
  74073. * @param sphere0 sphere 0
  74074. * @param sphere1 sphere 1
  74075. * @returns true if the speres intersect
  74076. */
  74077. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74078. }
  74079. }
  74080. declare module BABYLON {
  74081. /**
  74082. * Class used to store bounding box information
  74083. */
  74084. export class BoundingBox implements ICullable {
  74085. /**
  74086. * Gets the 8 vectors representing the bounding box in local space
  74087. */
  74088. readonly vectors: Vector3[];
  74089. /**
  74090. * Gets the center of the bounding box in local space
  74091. */
  74092. readonly center: Vector3;
  74093. /**
  74094. * Gets the center of the bounding box in world space
  74095. */
  74096. readonly centerWorld: Vector3;
  74097. /**
  74098. * Gets the extend size in local space
  74099. */
  74100. readonly extendSize: Vector3;
  74101. /**
  74102. * Gets the extend size in world space
  74103. */
  74104. readonly extendSizeWorld: Vector3;
  74105. /**
  74106. * Gets the OBB (object bounding box) directions
  74107. */
  74108. readonly directions: Vector3[];
  74109. /**
  74110. * Gets the 8 vectors representing the bounding box in world space
  74111. */
  74112. readonly vectorsWorld: Vector3[];
  74113. /**
  74114. * Gets the minimum vector in world space
  74115. */
  74116. readonly minimumWorld: Vector3;
  74117. /**
  74118. * Gets the maximum vector in world space
  74119. */
  74120. readonly maximumWorld: Vector3;
  74121. /**
  74122. * Gets the minimum vector in local space
  74123. */
  74124. readonly minimum: Vector3;
  74125. /**
  74126. * Gets the maximum vector in local space
  74127. */
  74128. readonly maximum: Vector3;
  74129. private _worldMatrix;
  74130. private static readonly TmpVector3;
  74131. /**
  74132. * @hidden
  74133. */
  74134. _tag: number;
  74135. /**
  74136. * Creates a new bounding box
  74137. * @param min defines the minimum vector (in local space)
  74138. * @param max defines the maximum vector (in local space)
  74139. * @param worldMatrix defines the new world matrix
  74140. */
  74141. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74142. /**
  74143. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74144. * @param min defines the new minimum vector (in local space)
  74145. * @param max defines the new maximum vector (in local space)
  74146. * @param worldMatrix defines the new world matrix
  74147. */
  74148. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74149. /**
  74150. * Scale the current bounding box by applying a scale factor
  74151. * @param factor defines the scale factor to apply
  74152. * @returns the current bounding box
  74153. */
  74154. scale(factor: number): BoundingBox;
  74155. /**
  74156. * Gets the world matrix of the bounding box
  74157. * @returns a matrix
  74158. */
  74159. getWorldMatrix(): DeepImmutable<Matrix>;
  74160. /** @hidden */
  74161. _update(world: DeepImmutable<Matrix>): void;
  74162. /**
  74163. * Tests if the bounding box is intersecting the frustum planes
  74164. * @param frustumPlanes defines the frustum planes to test
  74165. * @returns true if there is an intersection
  74166. */
  74167. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74168. /**
  74169. * Tests if the bounding box is entirely inside the frustum planes
  74170. * @param frustumPlanes defines the frustum planes to test
  74171. * @returns true if there is an inclusion
  74172. */
  74173. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74174. /**
  74175. * Tests if a point is inside the bounding box
  74176. * @param point defines the point to test
  74177. * @returns true if the point is inside the bounding box
  74178. */
  74179. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74180. /**
  74181. * Tests if the bounding box intersects with a bounding sphere
  74182. * @param sphere defines the sphere to test
  74183. * @returns true if there is an intersection
  74184. */
  74185. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74186. /**
  74187. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74188. * @param min defines the min vector to use
  74189. * @param max defines the max vector to use
  74190. * @returns true if there is an intersection
  74191. */
  74192. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74193. /**
  74194. * Tests if two bounding boxes are intersections
  74195. * @param box0 defines the first box to test
  74196. * @param box1 defines the second box to test
  74197. * @returns true if there is an intersection
  74198. */
  74199. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74200. /**
  74201. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74202. * @param minPoint defines the minimum vector of the bounding box
  74203. * @param maxPoint defines the maximum vector of the bounding box
  74204. * @param sphereCenter defines the sphere center
  74205. * @param sphereRadius defines the sphere radius
  74206. * @returns true if there is an intersection
  74207. */
  74208. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74209. /**
  74210. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74211. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74212. * @param frustumPlanes defines the frustum planes to test
  74213. * @return true if there is an inclusion
  74214. */
  74215. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74216. /**
  74217. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74218. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74219. * @param frustumPlanes defines the frustum planes to test
  74220. * @return true if there is an intersection
  74221. */
  74222. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /** @hidden */
  74227. export class Collider {
  74228. /** Define if a collision was found */
  74229. collisionFound: boolean;
  74230. /**
  74231. * Define last intersection point in local space
  74232. */
  74233. intersectionPoint: Vector3;
  74234. /**
  74235. * Define last collided mesh
  74236. */
  74237. collidedMesh: Nullable<AbstractMesh>;
  74238. private _collisionPoint;
  74239. private _planeIntersectionPoint;
  74240. private _tempVector;
  74241. private _tempVector2;
  74242. private _tempVector3;
  74243. private _tempVector4;
  74244. private _edge;
  74245. private _baseToVertex;
  74246. private _destinationPoint;
  74247. private _slidePlaneNormal;
  74248. private _displacementVector;
  74249. /** @hidden */
  74250. _radius: Vector3;
  74251. /** @hidden */
  74252. _retry: number;
  74253. private _velocity;
  74254. private _basePoint;
  74255. private _epsilon;
  74256. /** @hidden */
  74257. _velocityWorldLength: number;
  74258. /** @hidden */
  74259. _basePointWorld: Vector3;
  74260. private _velocityWorld;
  74261. private _normalizedVelocity;
  74262. /** @hidden */
  74263. _initialVelocity: Vector3;
  74264. /** @hidden */
  74265. _initialPosition: Vector3;
  74266. private _nearestDistance;
  74267. private _collisionMask;
  74268. collisionMask: number;
  74269. /**
  74270. * Gets the plane normal used to compute the sliding response (in local space)
  74271. */
  74272. readonly slidePlaneNormal: Vector3;
  74273. /** @hidden */
  74274. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74275. /** @hidden */
  74276. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74277. /** @hidden */
  74278. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74279. /** @hidden */
  74280. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74281. /** @hidden */
  74282. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74283. /** @hidden */
  74284. _getResponse(pos: Vector3, vel: Vector3): void;
  74285. }
  74286. }
  74287. declare module BABYLON {
  74288. /**
  74289. * Interface for cullable objects
  74290. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74291. */
  74292. export interface ICullable {
  74293. /**
  74294. * Checks if the object or part of the object is in the frustum
  74295. * @param frustumPlanes Camera near/planes
  74296. * @returns true if the object is in frustum otherwise false
  74297. */
  74298. isInFrustum(frustumPlanes: Plane[]): boolean;
  74299. /**
  74300. * Checks if a cullable object (mesh...) is in the camera frustum
  74301. * Unlike isInFrustum this cheks the full bounding box
  74302. * @param frustumPlanes Camera near/planes
  74303. * @returns true if the object is in frustum otherwise false
  74304. */
  74305. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74306. }
  74307. /**
  74308. * Info for a bounding data of a mesh
  74309. */
  74310. export class BoundingInfo implements ICullable {
  74311. /**
  74312. * Bounding box for the mesh
  74313. */
  74314. readonly boundingBox: BoundingBox;
  74315. /**
  74316. * Bounding sphere for the mesh
  74317. */
  74318. readonly boundingSphere: BoundingSphere;
  74319. private _isLocked;
  74320. private static readonly TmpVector3;
  74321. /**
  74322. * Constructs bounding info
  74323. * @param minimum min vector of the bounding box/sphere
  74324. * @param maximum max vector of the bounding box/sphere
  74325. * @param worldMatrix defines the new world matrix
  74326. */
  74327. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74328. /**
  74329. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74330. * @param min defines the new minimum vector (in local space)
  74331. * @param max defines the new maximum vector (in local space)
  74332. * @param worldMatrix defines the new world matrix
  74333. */
  74334. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74335. /**
  74336. * min vector of the bounding box/sphere
  74337. */
  74338. readonly minimum: Vector3;
  74339. /**
  74340. * max vector of the bounding box/sphere
  74341. */
  74342. readonly maximum: Vector3;
  74343. /**
  74344. * If the info is locked and won't be updated to avoid perf overhead
  74345. */
  74346. isLocked: boolean;
  74347. /**
  74348. * Updates the bounding sphere and box
  74349. * @param world world matrix to be used to update
  74350. */
  74351. update(world: DeepImmutable<Matrix>): void;
  74352. /**
  74353. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74354. * @param center New center of the bounding info
  74355. * @param extend New extend of the bounding info
  74356. * @returns the current bounding info
  74357. */
  74358. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74359. /**
  74360. * Scale the current bounding info by applying a scale factor
  74361. * @param factor defines the scale factor to apply
  74362. * @returns the current bounding info
  74363. */
  74364. scale(factor: number): BoundingInfo;
  74365. /**
  74366. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74367. * @param frustumPlanes defines the frustum to test
  74368. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74369. * @returns true if the bounding info is in the frustum planes
  74370. */
  74371. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74372. /**
  74373. * Gets the world distance between the min and max points of the bounding box
  74374. */
  74375. readonly diagonalLength: number;
  74376. /**
  74377. * Checks if a cullable object (mesh...) is in the camera frustum
  74378. * Unlike isInFrustum this cheks the full bounding box
  74379. * @param frustumPlanes Camera near/planes
  74380. * @returns true if the object is in frustum otherwise false
  74381. */
  74382. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74383. /** @hidden */
  74384. _checkCollision(collider: Collider): boolean;
  74385. /**
  74386. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74387. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74388. * @param point the point to check intersection with
  74389. * @returns if the point intersects
  74390. */
  74391. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74392. /**
  74393. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74394. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74395. * @param boundingInfo the bounding info to check intersection with
  74396. * @param precise if the intersection should be done using OBB
  74397. * @returns if the bounding info intersects
  74398. */
  74399. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74400. }
  74401. }
  74402. declare module BABYLON {
  74403. /**
  74404. * Extracts minimum and maximum values from a list of indexed positions
  74405. * @param positions defines the positions to use
  74406. * @param indices defines the indices to the positions
  74407. * @param indexStart defines the start index
  74408. * @param indexCount defines the end index
  74409. * @param bias defines bias value to add to the result
  74410. * @return minimum and maximum values
  74411. */
  74412. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74413. minimum: Vector3;
  74414. maximum: Vector3;
  74415. };
  74416. /**
  74417. * Extracts minimum and maximum values from a list of positions
  74418. * @param positions defines the positions to use
  74419. * @param start defines the start index in the positions array
  74420. * @param count defines the number of positions to handle
  74421. * @param bias defines bias value to add to the result
  74422. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74423. * @return minimum and maximum values
  74424. */
  74425. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74426. minimum: Vector3;
  74427. maximum: Vector3;
  74428. };
  74429. }
  74430. declare module BABYLON {
  74431. /** @hidden */
  74432. export class WebGLDataBuffer extends DataBuffer {
  74433. private _buffer;
  74434. constructor(resource: WebGLBuffer);
  74435. readonly underlyingResource: any;
  74436. }
  74437. }
  74438. declare module BABYLON {
  74439. /** @hidden */
  74440. export class WebGLPipelineContext implements IPipelineContext {
  74441. engine: ThinEngine;
  74442. program: Nullable<WebGLProgram>;
  74443. context?: WebGLRenderingContext;
  74444. vertexShader?: WebGLShader;
  74445. fragmentShader?: WebGLShader;
  74446. isParallelCompiled: boolean;
  74447. onCompiled?: () => void;
  74448. transformFeedback?: WebGLTransformFeedback | null;
  74449. readonly isAsync: boolean;
  74450. readonly isReady: boolean;
  74451. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74452. }
  74453. }
  74454. declare module BABYLON {
  74455. interface ThinEngine {
  74456. /**
  74457. * Create an uniform buffer
  74458. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74459. * @param elements defines the content of the uniform buffer
  74460. * @returns the webGL uniform buffer
  74461. */
  74462. createUniformBuffer(elements: FloatArray): DataBuffer;
  74463. /**
  74464. * Create a dynamic uniform buffer
  74465. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74466. * @param elements defines the content of the uniform buffer
  74467. * @returns the webGL uniform buffer
  74468. */
  74469. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74470. /**
  74471. * Update an existing uniform buffer
  74472. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74473. * @param uniformBuffer defines the target uniform buffer
  74474. * @param elements defines the content to update
  74475. * @param offset defines the offset in the uniform buffer where update should start
  74476. * @param count defines the size of the data to update
  74477. */
  74478. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74479. /**
  74480. * Bind an uniform buffer to the current webGL context
  74481. * @param buffer defines the buffer to bind
  74482. */
  74483. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74484. /**
  74485. * Bind a buffer to the current webGL context at a given location
  74486. * @param buffer defines the buffer to bind
  74487. * @param location defines the index where to bind the buffer
  74488. */
  74489. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74490. /**
  74491. * Bind a specific block at a given index in a specific shader program
  74492. * @param pipelineContext defines the pipeline context to use
  74493. * @param blockName defines the block name
  74494. * @param index defines the index where to bind the block
  74495. */
  74496. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74497. }
  74498. }
  74499. declare module BABYLON {
  74500. /**
  74501. * Uniform buffer objects.
  74502. *
  74503. * Handles blocks of uniform on the GPU.
  74504. *
  74505. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74506. *
  74507. * For more information, please refer to :
  74508. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74509. */
  74510. export class UniformBuffer {
  74511. private _engine;
  74512. private _buffer;
  74513. private _data;
  74514. private _bufferData;
  74515. private _dynamic?;
  74516. private _uniformLocations;
  74517. private _uniformSizes;
  74518. private _uniformLocationPointer;
  74519. private _needSync;
  74520. private _noUBO;
  74521. private _currentEffect;
  74522. /** @hidden */
  74523. _alreadyBound: boolean;
  74524. private static _MAX_UNIFORM_SIZE;
  74525. private static _tempBuffer;
  74526. /**
  74527. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74528. * This is dynamic to allow compat with webgl 1 and 2.
  74529. * You will need to pass the name of the uniform as well as the value.
  74530. */
  74531. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74532. /**
  74533. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74534. * This is dynamic to allow compat with webgl 1 and 2.
  74535. * You will need to pass the name of the uniform as well as the value.
  74536. */
  74537. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74538. /**
  74539. * Lambda to Update a single float in a uniform buffer.
  74540. * This is dynamic to allow compat with webgl 1 and 2.
  74541. * You will need to pass the name of the uniform as well as the value.
  74542. */
  74543. updateFloat: (name: string, x: number) => void;
  74544. /**
  74545. * Lambda to Update a vec2 of float in a uniform buffer.
  74546. * This is dynamic to allow compat with webgl 1 and 2.
  74547. * You will need to pass the name of the uniform as well as the value.
  74548. */
  74549. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74550. /**
  74551. * Lambda to Update a vec3 of float in a uniform buffer.
  74552. * This is dynamic to allow compat with webgl 1 and 2.
  74553. * You will need to pass the name of the uniform as well as the value.
  74554. */
  74555. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74556. /**
  74557. * Lambda to Update a vec4 of float in a uniform buffer.
  74558. * This is dynamic to allow compat with webgl 1 and 2.
  74559. * You will need to pass the name of the uniform as well as the value.
  74560. */
  74561. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74562. /**
  74563. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74564. * This is dynamic to allow compat with webgl 1 and 2.
  74565. * You will need to pass the name of the uniform as well as the value.
  74566. */
  74567. updateMatrix: (name: string, mat: Matrix) => void;
  74568. /**
  74569. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74570. * This is dynamic to allow compat with webgl 1 and 2.
  74571. * You will need to pass the name of the uniform as well as the value.
  74572. */
  74573. updateVector3: (name: string, vector: Vector3) => void;
  74574. /**
  74575. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74576. * This is dynamic to allow compat with webgl 1 and 2.
  74577. * You will need to pass the name of the uniform as well as the value.
  74578. */
  74579. updateVector4: (name: string, vector: Vector4) => void;
  74580. /**
  74581. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74582. * This is dynamic to allow compat with webgl 1 and 2.
  74583. * You will need to pass the name of the uniform as well as the value.
  74584. */
  74585. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74586. /**
  74587. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74588. * This is dynamic to allow compat with webgl 1 and 2.
  74589. * You will need to pass the name of the uniform as well as the value.
  74590. */
  74591. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74592. /**
  74593. * Instantiates a new Uniform buffer objects.
  74594. *
  74595. * Handles blocks of uniform on the GPU.
  74596. *
  74597. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74598. *
  74599. * For more information, please refer to :
  74600. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74601. * @param engine Define the engine the buffer is associated with
  74602. * @param data Define the data contained in the buffer
  74603. * @param dynamic Define if the buffer is updatable
  74604. */
  74605. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74606. /**
  74607. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74608. * or just falling back on setUniformXXX calls.
  74609. */
  74610. readonly useUbo: boolean;
  74611. /**
  74612. * Indicates if the WebGL underlying uniform buffer is in sync
  74613. * with the javascript cache data.
  74614. */
  74615. readonly isSync: boolean;
  74616. /**
  74617. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74618. * Also, a dynamic UniformBuffer will disable cache verification and always
  74619. * update the underlying WebGL uniform buffer to the GPU.
  74620. * @returns if Dynamic, otherwise false
  74621. */
  74622. isDynamic(): boolean;
  74623. /**
  74624. * The data cache on JS side.
  74625. * @returns the underlying data as a float array
  74626. */
  74627. getData(): Float32Array;
  74628. /**
  74629. * The underlying WebGL Uniform buffer.
  74630. * @returns the webgl buffer
  74631. */
  74632. getBuffer(): Nullable<DataBuffer>;
  74633. /**
  74634. * std140 layout specifies how to align data within an UBO structure.
  74635. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74636. * for specs.
  74637. */
  74638. private _fillAlignment;
  74639. /**
  74640. * Adds an uniform in the buffer.
  74641. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74642. * for the layout to be correct !
  74643. * @param name Name of the uniform, as used in the uniform block in the shader.
  74644. * @param size Data size, or data directly.
  74645. */
  74646. addUniform(name: string, size: number | number[]): void;
  74647. /**
  74648. * Adds a Matrix 4x4 to the uniform buffer.
  74649. * @param name Name of the uniform, as used in the uniform block in the shader.
  74650. * @param mat A 4x4 matrix.
  74651. */
  74652. addMatrix(name: string, mat: Matrix): void;
  74653. /**
  74654. * Adds a vec2 to the uniform buffer.
  74655. * @param name Name of the uniform, as used in the uniform block in the shader.
  74656. * @param x Define the x component value of the vec2
  74657. * @param y Define the y component value of the vec2
  74658. */
  74659. addFloat2(name: string, x: number, y: number): void;
  74660. /**
  74661. * Adds a vec3 to the uniform buffer.
  74662. * @param name Name of the uniform, as used in the uniform block in the shader.
  74663. * @param x Define the x component value of the vec3
  74664. * @param y Define the y component value of the vec3
  74665. * @param z Define the z component value of the vec3
  74666. */
  74667. addFloat3(name: string, x: number, y: number, z: number): void;
  74668. /**
  74669. * Adds a vec3 to the uniform buffer.
  74670. * @param name Name of the uniform, as used in the uniform block in the shader.
  74671. * @param color Define the vec3 from a Color
  74672. */
  74673. addColor3(name: string, color: Color3): void;
  74674. /**
  74675. * Adds a vec4 to the uniform buffer.
  74676. * @param name Name of the uniform, as used in the uniform block in the shader.
  74677. * @param color Define the rgb components from a Color
  74678. * @param alpha Define the a component of the vec4
  74679. */
  74680. addColor4(name: string, color: Color3, alpha: number): void;
  74681. /**
  74682. * Adds a vec3 to the uniform buffer.
  74683. * @param name Name of the uniform, as used in the uniform block in the shader.
  74684. * @param vector Define the vec3 components from a Vector
  74685. */
  74686. addVector3(name: string, vector: Vector3): void;
  74687. /**
  74688. * Adds a Matrix 3x3 to the uniform buffer.
  74689. * @param name Name of the uniform, as used in the uniform block in the shader.
  74690. */
  74691. addMatrix3x3(name: string): void;
  74692. /**
  74693. * Adds a Matrix 2x2 to the uniform buffer.
  74694. * @param name Name of the uniform, as used in the uniform block in the shader.
  74695. */
  74696. addMatrix2x2(name: string): void;
  74697. /**
  74698. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74699. */
  74700. create(): void;
  74701. /** @hidden */
  74702. _rebuild(): void;
  74703. /**
  74704. * Updates the WebGL Uniform Buffer on the GPU.
  74705. * If the `dynamic` flag is set to true, no cache comparison is done.
  74706. * Otherwise, the buffer will be updated only if the cache differs.
  74707. */
  74708. update(): void;
  74709. /**
  74710. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74711. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74712. * @param data Define the flattened data
  74713. * @param size Define the size of the data.
  74714. */
  74715. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74716. private _valueCache;
  74717. private _cacheMatrix;
  74718. private _updateMatrix3x3ForUniform;
  74719. private _updateMatrix3x3ForEffect;
  74720. private _updateMatrix2x2ForEffect;
  74721. private _updateMatrix2x2ForUniform;
  74722. private _updateFloatForEffect;
  74723. private _updateFloatForUniform;
  74724. private _updateFloat2ForEffect;
  74725. private _updateFloat2ForUniform;
  74726. private _updateFloat3ForEffect;
  74727. private _updateFloat3ForUniform;
  74728. private _updateFloat4ForEffect;
  74729. private _updateFloat4ForUniform;
  74730. private _updateMatrixForEffect;
  74731. private _updateMatrixForUniform;
  74732. private _updateVector3ForEffect;
  74733. private _updateVector3ForUniform;
  74734. private _updateVector4ForEffect;
  74735. private _updateVector4ForUniform;
  74736. private _updateColor3ForEffect;
  74737. private _updateColor3ForUniform;
  74738. private _updateColor4ForEffect;
  74739. private _updateColor4ForUniform;
  74740. /**
  74741. * Sets a sampler uniform on the effect.
  74742. * @param name Define the name of the sampler.
  74743. * @param texture Define the texture to set in the sampler
  74744. */
  74745. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74746. /**
  74747. * Directly updates the value of the uniform in the cache AND on the GPU.
  74748. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74749. * @param data Define the flattened data
  74750. */
  74751. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74752. /**
  74753. * Binds this uniform buffer to an effect.
  74754. * @param effect Define the effect to bind the buffer to
  74755. * @param name Name of the uniform block in the shader.
  74756. */
  74757. bindToEffect(effect: Effect, name: string): void;
  74758. /**
  74759. * Disposes the uniform buffer.
  74760. */
  74761. dispose(): void;
  74762. }
  74763. }
  74764. declare module BABYLON {
  74765. /**
  74766. * Enum that determines the text-wrapping mode to use.
  74767. */
  74768. export enum InspectableType {
  74769. /**
  74770. * Checkbox for booleans
  74771. */
  74772. Checkbox = 0,
  74773. /**
  74774. * Sliders for numbers
  74775. */
  74776. Slider = 1,
  74777. /**
  74778. * Vector3
  74779. */
  74780. Vector3 = 2,
  74781. /**
  74782. * Quaternions
  74783. */
  74784. Quaternion = 3,
  74785. /**
  74786. * Color3
  74787. */
  74788. Color3 = 4,
  74789. /**
  74790. * String
  74791. */
  74792. String = 5
  74793. }
  74794. /**
  74795. * Interface used to define custom inspectable properties.
  74796. * This interface is used by the inspector to display custom property grids
  74797. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74798. */
  74799. export interface IInspectable {
  74800. /**
  74801. * Gets the label to display
  74802. */
  74803. label: string;
  74804. /**
  74805. * Gets the name of the property to edit
  74806. */
  74807. propertyName: string;
  74808. /**
  74809. * Gets the type of the editor to use
  74810. */
  74811. type: InspectableType;
  74812. /**
  74813. * Gets the minimum value of the property when using in "slider" mode
  74814. */
  74815. min?: number;
  74816. /**
  74817. * Gets the maximum value of the property when using in "slider" mode
  74818. */
  74819. max?: number;
  74820. /**
  74821. * Gets the setp to use when using in "slider" mode
  74822. */
  74823. step?: number;
  74824. }
  74825. }
  74826. declare module BABYLON {
  74827. /**
  74828. * Class used to provide helper for timing
  74829. */
  74830. export class TimingTools {
  74831. /**
  74832. * Polyfill for setImmediate
  74833. * @param action defines the action to execute after the current execution block
  74834. */
  74835. static SetImmediate(action: () => void): void;
  74836. }
  74837. }
  74838. declare module BABYLON {
  74839. /**
  74840. * Class used to enable instatition of objects by class name
  74841. */
  74842. export class InstantiationTools {
  74843. /**
  74844. * Use this object to register external classes like custom textures or material
  74845. * to allow the laoders to instantiate them
  74846. */
  74847. static RegisteredExternalClasses: {
  74848. [key: string]: Object;
  74849. };
  74850. /**
  74851. * Tries to instantiate a new object from a given class name
  74852. * @param className defines the class name to instantiate
  74853. * @returns the new object or null if the system was not able to do the instantiation
  74854. */
  74855. static Instantiate(className: string): any;
  74856. }
  74857. }
  74858. declare module BABYLON {
  74859. /**
  74860. * Define options used to create a depth texture
  74861. */
  74862. export class DepthTextureCreationOptions {
  74863. /** Specifies whether or not a stencil should be allocated in the texture */
  74864. generateStencil?: boolean;
  74865. /** Specifies whether or not bilinear filtering is enable on the texture */
  74866. bilinearFiltering?: boolean;
  74867. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74868. comparisonFunction?: number;
  74869. /** Specifies if the created texture is a cube texture */
  74870. isCube?: boolean;
  74871. }
  74872. }
  74873. declare module BABYLON {
  74874. interface ThinEngine {
  74875. /**
  74876. * Creates a depth stencil cube texture.
  74877. * This is only available in WebGL 2.
  74878. * @param size The size of face edge in the cube texture.
  74879. * @param options The options defining the cube texture.
  74880. * @returns The cube texture
  74881. */
  74882. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74883. /**
  74884. * Creates a cube texture
  74885. * @param rootUrl defines the url where the files to load is located
  74886. * @param scene defines the current scene
  74887. * @param files defines the list of files to load (1 per face)
  74888. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74889. * @param onLoad defines an optional callback raised when the texture is loaded
  74890. * @param onError defines an optional callback raised if there is an issue to load the texture
  74891. * @param format defines the format of the data
  74892. * @param forcedExtension defines the extension to use to pick the right loader
  74893. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74896. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74897. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74898. * @returns the cube texture as an InternalTexture
  74899. */
  74900. 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;
  74901. /**
  74902. * Creates a cube texture
  74903. * @param rootUrl defines the url where the files to load is located
  74904. * @param scene defines the current scene
  74905. * @param files defines the list of files to load (1 per face)
  74906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74907. * @param onLoad defines an optional callback raised when the texture is loaded
  74908. * @param onError defines an optional callback raised if there is an issue to load the texture
  74909. * @param format defines the format of the data
  74910. * @param forcedExtension defines the extension to use to pick the right loader
  74911. * @returns the cube texture as an InternalTexture
  74912. */
  74913. 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;
  74914. /**
  74915. * Creates a cube texture
  74916. * @param rootUrl defines the url where the files to load is located
  74917. * @param scene defines the current scene
  74918. * @param files defines the list of files to load (1 per face)
  74919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74920. * @param onLoad defines an optional callback raised when the texture is loaded
  74921. * @param onError defines an optional callback raised if there is an issue to load the texture
  74922. * @param format defines the format of the data
  74923. * @param forcedExtension defines the extension to use to pick the right loader
  74924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74927. * @returns the cube texture as an InternalTexture
  74928. */
  74929. 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;
  74930. /** @hidden */
  74931. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74932. /** @hidden */
  74933. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74934. /** @hidden */
  74935. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74936. /** @hidden */
  74937. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74938. }
  74939. }
  74940. declare module BABYLON {
  74941. /**
  74942. * Class for creating a cube texture
  74943. */
  74944. export class CubeTexture extends BaseTexture {
  74945. private _delayedOnLoad;
  74946. /**
  74947. * The url of the texture
  74948. */
  74949. url: string;
  74950. /**
  74951. * Gets or sets the center of the bounding box associated with the cube texture.
  74952. * It must define where the camera used to render the texture was set
  74953. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74954. */
  74955. boundingBoxPosition: Vector3;
  74956. private _boundingBoxSize;
  74957. /**
  74958. * Gets or sets the size of the bounding box associated with the cube texture
  74959. * When defined, the cubemap will switch to local mode
  74960. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74961. * @example https://www.babylonjs-playground.com/#RNASML
  74962. */
  74963. /**
  74964. * Returns the bounding box size
  74965. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74966. */
  74967. boundingBoxSize: Vector3;
  74968. protected _rotationY: number;
  74969. /**
  74970. * Sets texture matrix rotation angle around Y axis in radians.
  74971. */
  74972. /**
  74973. * Gets texture matrix rotation angle around Y axis radians.
  74974. */
  74975. rotationY: number;
  74976. /**
  74977. * Are mip maps generated for this texture or not.
  74978. */
  74979. readonly noMipmap: boolean;
  74980. private _noMipmap;
  74981. private _files;
  74982. protected _forcedExtension: Nullable<string>;
  74983. private _extensions;
  74984. private _textureMatrix;
  74985. private _format;
  74986. private _createPolynomials;
  74987. /** @hidden */
  74988. _prefiltered: boolean;
  74989. /**
  74990. * Creates a cube texture from an array of image urls
  74991. * @param files defines an array of image urls
  74992. * @param scene defines the hosting scene
  74993. * @param noMipmap specifies if mip maps are not used
  74994. * @returns a cube texture
  74995. */
  74996. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74997. /**
  74998. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74999. * @param url defines the url of the prefiltered texture
  75000. * @param scene defines the scene the texture is attached to
  75001. * @param forcedExtension defines the extension of the file if different from the url
  75002. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75003. * @return the prefiltered texture
  75004. */
  75005. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75006. /**
  75007. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75008. * as prefiltered data.
  75009. * @param rootUrl defines the url of the texture or the root name of the six images
  75010. * @param scene defines the scene the texture is attached to
  75011. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75012. * @param noMipmap defines if mipmaps should be created or not
  75013. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75014. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75015. * @param onError defines a callback triggered in case of error during load
  75016. * @param format defines the internal format to use for the texture once loaded
  75017. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75018. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75019. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75020. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75021. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75022. * @return the cube texture
  75023. */
  75024. 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);
  75025. /**
  75026. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75027. */
  75028. readonly isPrefiltered: boolean;
  75029. /**
  75030. * Get the current class name of the texture useful for serialization or dynamic coding.
  75031. * @returns "CubeTexture"
  75032. */
  75033. getClassName(): string;
  75034. /**
  75035. * Update the url (and optional buffer) of this texture if url was null during construction.
  75036. * @param url the url of the texture
  75037. * @param forcedExtension defines the extension to use
  75038. * @param onLoad callback called when the texture is loaded (defaults to null)
  75039. */
  75040. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75041. /**
  75042. * Delays loading of the cube texture
  75043. * @param forcedExtension defines the extension to use
  75044. */
  75045. delayLoad(forcedExtension?: string): void;
  75046. /**
  75047. * Returns the reflection texture matrix
  75048. * @returns the reflection texture matrix
  75049. */
  75050. getReflectionTextureMatrix(): Matrix;
  75051. /**
  75052. * Sets the reflection texture matrix
  75053. * @param value Reflection texture matrix
  75054. */
  75055. setReflectionTextureMatrix(value: Matrix): void;
  75056. /**
  75057. * Parses text to create a cube texture
  75058. * @param parsedTexture define the serialized text to read from
  75059. * @param scene defines the hosting scene
  75060. * @param rootUrl defines the root url of the cube texture
  75061. * @returns a cube texture
  75062. */
  75063. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75064. /**
  75065. * Makes a clone, or deep copy, of the cube texture
  75066. * @returns a new cube texture
  75067. */
  75068. clone(): CubeTexture;
  75069. }
  75070. }
  75071. declare module BABYLON {
  75072. /**
  75073. * Manages the defines for the Material
  75074. */
  75075. export class MaterialDefines {
  75076. /** @hidden */
  75077. protected _keys: string[];
  75078. private _isDirty;
  75079. /** @hidden */
  75080. _renderId: number;
  75081. /** @hidden */
  75082. _areLightsDirty: boolean;
  75083. /** @hidden */
  75084. _areLightsDisposed: boolean;
  75085. /** @hidden */
  75086. _areAttributesDirty: boolean;
  75087. /** @hidden */
  75088. _areTexturesDirty: boolean;
  75089. /** @hidden */
  75090. _areFresnelDirty: boolean;
  75091. /** @hidden */
  75092. _areMiscDirty: boolean;
  75093. /** @hidden */
  75094. _areImageProcessingDirty: boolean;
  75095. /** @hidden */
  75096. _normals: boolean;
  75097. /** @hidden */
  75098. _uvs: boolean;
  75099. /** @hidden */
  75100. _needNormals: boolean;
  75101. /** @hidden */
  75102. _needUVs: boolean;
  75103. [id: string]: any;
  75104. /**
  75105. * Specifies if the material needs to be re-calculated
  75106. */
  75107. readonly isDirty: boolean;
  75108. /**
  75109. * Marks the material to indicate that it has been re-calculated
  75110. */
  75111. markAsProcessed(): void;
  75112. /**
  75113. * Marks the material to indicate that it needs to be re-calculated
  75114. */
  75115. markAsUnprocessed(): void;
  75116. /**
  75117. * Marks the material to indicate all of its defines need to be re-calculated
  75118. */
  75119. markAllAsDirty(): void;
  75120. /**
  75121. * Marks the material to indicate that image processing needs to be re-calculated
  75122. */
  75123. markAsImageProcessingDirty(): void;
  75124. /**
  75125. * Marks the material to indicate the lights need to be re-calculated
  75126. * @param disposed Defines whether the light is dirty due to dispose or not
  75127. */
  75128. markAsLightDirty(disposed?: boolean): void;
  75129. /**
  75130. * Marks the attribute state as changed
  75131. */
  75132. markAsAttributesDirty(): void;
  75133. /**
  75134. * Marks the texture state as changed
  75135. */
  75136. markAsTexturesDirty(): void;
  75137. /**
  75138. * Marks the fresnel state as changed
  75139. */
  75140. markAsFresnelDirty(): void;
  75141. /**
  75142. * Marks the misc state as changed
  75143. */
  75144. markAsMiscDirty(): void;
  75145. /**
  75146. * Rebuilds the material defines
  75147. */
  75148. rebuild(): void;
  75149. /**
  75150. * Specifies if two material defines are equal
  75151. * @param other - A material define instance to compare to
  75152. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75153. */
  75154. isEqual(other: MaterialDefines): boolean;
  75155. /**
  75156. * Clones this instance's defines to another instance
  75157. * @param other - material defines to clone values to
  75158. */
  75159. cloneTo(other: MaterialDefines): void;
  75160. /**
  75161. * Resets the material define values
  75162. */
  75163. reset(): void;
  75164. /**
  75165. * Converts the material define values to a string
  75166. * @returns - String of material define information
  75167. */
  75168. toString(): string;
  75169. }
  75170. }
  75171. declare module BABYLON {
  75172. /**
  75173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75175. * 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;
  75176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75177. */
  75178. export class ColorCurves {
  75179. private _dirty;
  75180. private _tempColor;
  75181. private _globalCurve;
  75182. private _highlightsCurve;
  75183. private _midtonesCurve;
  75184. private _shadowsCurve;
  75185. private _positiveCurve;
  75186. private _negativeCurve;
  75187. private _globalHue;
  75188. private _globalDensity;
  75189. private _globalSaturation;
  75190. private _globalExposure;
  75191. /**
  75192. * Gets the global Hue value.
  75193. * 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).
  75194. */
  75195. /**
  75196. * Sets the global Hue value.
  75197. * 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).
  75198. */
  75199. globalHue: number;
  75200. /**
  75201. * Gets the global Density value.
  75202. * 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.
  75203. * Values less than zero provide a filter of opposite hue.
  75204. */
  75205. /**
  75206. * Sets the global Density value.
  75207. * 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.
  75208. * Values less than zero provide a filter of opposite hue.
  75209. */
  75210. globalDensity: number;
  75211. /**
  75212. * Gets the global Saturation value.
  75213. * 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.
  75214. */
  75215. /**
  75216. * Sets the global Saturation value.
  75217. * 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.
  75218. */
  75219. globalSaturation: number;
  75220. /**
  75221. * Gets the global Exposure value.
  75222. * 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.
  75223. */
  75224. /**
  75225. * Sets the global Exposure value.
  75226. * 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.
  75227. */
  75228. globalExposure: number;
  75229. private _highlightsHue;
  75230. private _highlightsDensity;
  75231. private _highlightsSaturation;
  75232. private _highlightsExposure;
  75233. /**
  75234. * Gets the highlights Hue value.
  75235. * 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).
  75236. */
  75237. /**
  75238. * Sets the highlights Hue value.
  75239. * 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).
  75240. */
  75241. highlightsHue: number;
  75242. /**
  75243. * Gets the highlights Density value.
  75244. * 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.
  75245. * Values less than zero provide a filter of opposite hue.
  75246. */
  75247. /**
  75248. * Sets the highlights Density value.
  75249. * 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.
  75250. * Values less than zero provide a filter of opposite hue.
  75251. */
  75252. highlightsDensity: number;
  75253. /**
  75254. * Gets the highlights Saturation value.
  75255. * 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.
  75256. */
  75257. /**
  75258. * Sets the highlights Saturation value.
  75259. * 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.
  75260. */
  75261. highlightsSaturation: number;
  75262. /**
  75263. * Gets the highlights Exposure value.
  75264. * 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.
  75265. */
  75266. /**
  75267. * Sets the highlights Exposure value.
  75268. * 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.
  75269. */
  75270. highlightsExposure: number;
  75271. private _midtonesHue;
  75272. private _midtonesDensity;
  75273. private _midtonesSaturation;
  75274. private _midtonesExposure;
  75275. /**
  75276. * Gets the midtones Hue value.
  75277. * 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).
  75278. */
  75279. /**
  75280. * Sets the midtones Hue value.
  75281. * 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).
  75282. */
  75283. midtonesHue: number;
  75284. /**
  75285. * Gets the midtones Density value.
  75286. * 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.
  75287. * Values less than zero provide a filter of opposite hue.
  75288. */
  75289. /**
  75290. * Sets the midtones Density value.
  75291. * 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.
  75292. * Values less than zero provide a filter of opposite hue.
  75293. */
  75294. midtonesDensity: number;
  75295. /**
  75296. * Gets the midtones Saturation value.
  75297. * 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.
  75298. */
  75299. /**
  75300. * Sets the midtones Saturation value.
  75301. * 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.
  75302. */
  75303. midtonesSaturation: number;
  75304. /**
  75305. * Gets the midtones Exposure value.
  75306. * 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.
  75307. */
  75308. /**
  75309. * Sets the midtones Exposure value.
  75310. * 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.
  75311. */
  75312. midtonesExposure: number;
  75313. private _shadowsHue;
  75314. private _shadowsDensity;
  75315. private _shadowsSaturation;
  75316. private _shadowsExposure;
  75317. /**
  75318. * Gets the shadows Hue value.
  75319. * 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).
  75320. */
  75321. /**
  75322. * Sets the shadows Hue value.
  75323. * 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).
  75324. */
  75325. shadowsHue: number;
  75326. /**
  75327. * Gets the shadows Density value.
  75328. * 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.
  75329. * Values less than zero provide a filter of opposite hue.
  75330. */
  75331. /**
  75332. * Sets the shadows Density value.
  75333. * 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.
  75334. * Values less than zero provide a filter of opposite hue.
  75335. */
  75336. shadowsDensity: number;
  75337. /**
  75338. * Gets the shadows Saturation value.
  75339. * 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.
  75340. */
  75341. /**
  75342. * Sets the shadows Saturation value.
  75343. * 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.
  75344. */
  75345. shadowsSaturation: number;
  75346. /**
  75347. * Gets the shadows Exposure value.
  75348. * 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.
  75349. */
  75350. /**
  75351. * Sets the shadows Exposure value.
  75352. * 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.
  75353. */
  75354. shadowsExposure: number;
  75355. /**
  75356. * Returns the class name
  75357. * @returns The class name
  75358. */
  75359. getClassName(): string;
  75360. /**
  75361. * Binds the color curves to the shader.
  75362. * @param colorCurves The color curve to bind
  75363. * @param effect The effect to bind to
  75364. * @param positiveUniform The positive uniform shader parameter
  75365. * @param neutralUniform The neutral uniform shader parameter
  75366. * @param negativeUniform The negative uniform shader parameter
  75367. */
  75368. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75369. /**
  75370. * Prepare the list of uniforms associated with the ColorCurves effects.
  75371. * @param uniformsList The list of uniforms used in the effect
  75372. */
  75373. static PrepareUniforms(uniformsList: string[]): void;
  75374. /**
  75375. * Returns color grading data based on a hue, density, saturation and exposure value.
  75376. * @param filterHue The hue of the color filter.
  75377. * @param filterDensity The density of the color filter.
  75378. * @param saturation The saturation.
  75379. * @param exposure The exposure.
  75380. * @param result The result data container.
  75381. */
  75382. private getColorGradingDataToRef;
  75383. /**
  75384. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75385. * @param value The input slider value in range [-100,100].
  75386. * @returns Adjusted value.
  75387. */
  75388. private static applyColorGradingSliderNonlinear;
  75389. /**
  75390. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75391. * @param hue The hue (H) input.
  75392. * @param saturation The saturation (S) input.
  75393. * @param brightness The brightness (B) input.
  75394. * @result An RGBA color represented as Vector4.
  75395. */
  75396. private static fromHSBToRef;
  75397. /**
  75398. * Returns a value clamped between min and max
  75399. * @param value The value to clamp
  75400. * @param min The minimum of value
  75401. * @param max The maximum of value
  75402. * @returns The clamped value.
  75403. */
  75404. private static clamp;
  75405. /**
  75406. * Clones the current color curve instance.
  75407. * @return The cloned curves
  75408. */
  75409. clone(): ColorCurves;
  75410. /**
  75411. * Serializes the current color curve instance to a json representation.
  75412. * @return a JSON representation
  75413. */
  75414. serialize(): any;
  75415. /**
  75416. * Parses the color curve from a json representation.
  75417. * @param source the JSON source to parse
  75418. * @return The parsed curves
  75419. */
  75420. static Parse(source: any): ColorCurves;
  75421. }
  75422. }
  75423. declare module BABYLON {
  75424. /**
  75425. * Interface to follow in your material defines to integrate easily the
  75426. * Image proccessing functions.
  75427. * @hidden
  75428. */
  75429. export interface IImageProcessingConfigurationDefines {
  75430. IMAGEPROCESSING: boolean;
  75431. VIGNETTE: boolean;
  75432. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75433. VIGNETTEBLENDMODEOPAQUE: boolean;
  75434. TONEMAPPING: boolean;
  75435. TONEMAPPING_ACES: boolean;
  75436. CONTRAST: boolean;
  75437. EXPOSURE: boolean;
  75438. COLORCURVES: boolean;
  75439. COLORGRADING: boolean;
  75440. COLORGRADING3D: boolean;
  75441. SAMPLER3DGREENDEPTH: boolean;
  75442. SAMPLER3DBGRMAP: boolean;
  75443. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75444. }
  75445. /**
  75446. * @hidden
  75447. */
  75448. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75449. IMAGEPROCESSING: boolean;
  75450. VIGNETTE: boolean;
  75451. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75452. VIGNETTEBLENDMODEOPAQUE: boolean;
  75453. TONEMAPPING: boolean;
  75454. TONEMAPPING_ACES: boolean;
  75455. CONTRAST: boolean;
  75456. COLORCURVES: boolean;
  75457. COLORGRADING: boolean;
  75458. COLORGRADING3D: boolean;
  75459. SAMPLER3DGREENDEPTH: boolean;
  75460. SAMPLER3DBGRMAP: boolean;
  75461. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75462. EXPOSURE: boolean;
  75463. constructor();
  75464. }
  75465. /**
  75466. * This groups together the common properties used for image processing either in direct forward pass
  75467. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75468. * or not.
  75469. */
  75470. export class ImageProcessingConfiguration {
  75471. /**
  75472. * Default tone mapping applied in BabylonJS.
  75473. */
  75474. static readonly TONEMAPPING_STANDARD: number;
  75475. /**
  75476. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75477. * to other engines rendering to increase portability.
  75478. */
  75479. static readonly TONEMAPPING_ACES: number;
  75480. /**
  75481. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75482. */
  75483. colorCurves: Nullable<ColorCurves>;
  75484. private _colorCurvesEnabled;
  75485. /**
  75486. * Gets wether the color curves effect is enabled.
  75487. */
  75488. /**
  75489. * Sets wether the color curves effect is enabled.
  75490. */
  75491. colorCurvesEnabled: boolean;
  75492. private _colorGradingTexture;
  75493. /**
  75494. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75495. */
  75496. /**
  75497. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75498. */
  75499. colorGradingTexture: Nullable<BaseTexture>;
  75500. private _colorGradingEnabled;
  75501. /**
  75502. * Gets wether the color grading effect is enabled.
  75503. */
  75504. /**
  75505. * Sets wether the color grading effect is enabled.
  75506. */
  75507. colorGradingEnabled: boolean;
  75508. private _colorGradingWithGreenDepth;
  75509. /**
  75510. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75511. */
  75512. /**
  75513. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75514. */
  75515. colorGradingWithGreenDepth: boolean;
  75516. private _colorGradingBGR;
  75517. /**
  75518. * Gets wether the color grading texture contains BGR values.
  75519. */
  75520. /**
  75521. * Sets wether the color grading texture contains BGR values.
  75522. */
  75523. colorGradingBGR: boolean;
  75524. /** @hidden */
  75525. _exposure: number;
  75526. /**
  75527. * Gets the Exposure used in the effect.
  75528. */
  75529. /**
  75530. * Sets the Exposure used in the effect.
  75531. */
  75532. exposure: number;
  75533. private _toneMappingEnabled;
  75534. /**
  75535. * Gets wether the tone mapping effect is enabled.
  75536. */
  75537. /**
  75538. * Sets wether the tone mapping effect is enabled.
  75539. */
  75540. toneMappingEnabled: boolean;
  75541. private _toneMappingType;
  75542. /**
  75543. * Gets the type of tone mapping effect.
  75544. */
  75545. /**
  75546. * Sets the type of tone mapping effect used in BabylonJS.
  75547. */
  75548. toneMappingType: number;
  75549. protected _contrast: number;
  75550. /**
  75551. * Gets the contrast used in the effect.
  75552. */
  75553. /**
  75554. * Sets the contrast used in the effect.
  75555. */
  75556. contrast: number;
  75557. /**
  75558. * Vignette stretch size.
  75559. */
  75560. vignetteStretch: number;
  75561. /**
  75562. * Vignette centre X Offset.
  75563. */
  75564. vignetteCentreX: number;
  75565. /**
  75566. * Vignette centre Y Offset.
  75567. */
  75568. vignetteCentreY: number;
  75569. /**
  75570. * Vignette weight or intensity of the vignette effect.
  75571. */
  75572. vignetteWeight: number;
  75573. /**
  75574. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75575. * if vignetteEnabled is set to true.
  75576. */
  75577. vignetteColor: Color4;
  75578. /**
  75579. * Camera field of view used by the Vignette effect.
  75580. */
  75581. vignetteCameraFov: number;
  75582. private _vignetteBlendMode;
  75583. /**
  75584. * Gets the vignette blend mode allowing different kind of effect.
  75585. */
  75586. /**
  75587. * Sets the vignette blend mode allowing different kind of effect.
  75588. */
  75589. vignetteBlendMode: number;
  75590. private _vignetteEnabled;
  75591. /**
  75592. * Gets wether the vignette effect is enabled.
  75593. */
  75594. /**
  75595. * Sets wether the vignette effect is enabled.
  75596. */
  75597. vignetteEnabled: boolean;
  75598. private _applyByPostProcess;
  75599. /**
  75600. * Gets wether the image processing is applied through a post process or not.
  75601. */
  75602. /**
  75603. * Sets wether the image processing is applied through a post process or not.
  75604. */
  75605. applyByPostProcess: boolean;
  75606. private _isEnabled;
  75607. /**
  75608. * Gets wether the image processing is enabled or not.
  75609. */
  75610. /**
  75611. * Sets wether the image processing is enabled or not.
  75612. */
  75613. isEnabled: boolean;
  75614. /**
  75615. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75616. */
  75617. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75618. /**
  75619. * Method called each time the image processing information changes requires to recompile the effect.
  75620. */
  75621. protected _updateParameters(): void;
  75622. /**
  75623. * Gets the current class name.
  75624. * @return "ImageProcessingConfiguration"
  75625. */
  75626. getClassName(): string;
  75627. /**
  75628. * Prepare the list of uniforms associated with the Image Processing effects.
  75629. * @param uniforms The list of uniforms used in the effect
  75630. * @param defines the list of defines currently in use
  75631. */
  75632. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75633. /**
  75634. * Prepare the list of samplers associated with the Image Processing effects.
  75635. * @param samplersList The list of uniforms used in the effect
  75636. * @param defines the list of defines currently in use
  75637. */
  75638. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75639. /**
  75640. * Prepare the list of defines associated to the shader.
  75641. * @param defines the list of defines to complete
  75642. * @param forPostProcess Define if we are currently in post process mode or not
  75643. */
  75644. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75645. /**
  75646. * Returns true if all the image processing information are ready.
  75647. * @returns True if ready, otherwise, false
  75648. */
  75649. isReady(): boolean;
  75650. /**
  75651. * Binds the image processing to the shader.
  75652. * @param effect The effect to bind to
  75653. * @param aspectRatio Define the current aspect ratio of the effect
  75654. */
  75655. bind(effect: Effect, aspectRatio?: number): void;
  75656. /**
  75657. * Clones the current image processing instance.
  75658. * @return The cloned image processing
  75659. */
  75660. clone(): ImageProcessingConfiguration;
  75661. /**
  75662. * Serializes the current image processing instance to a json representation.
  75663. * @return a JSON representation
  75664. */
  75665. serialize(): any;
  75666. /**
  75667. * Parses the image processing from a json representation.
  75668. * @param source the JSON source to parse
  75669. * @return The parsed image processing
  75670. */
  75671. static Parse(source: any): ImageProcessingConfiguration;
  75672. private static _VIGNETTEMODE_MULTIPLY;
  75673. private static _VIGNETTEMODE_OPAQUE;
  75674. /**
  75675. * Used to apply the vignette as a mix with the pixel color.
  75676. */
  75677. static readonly VIGNETTEMODE_MULTIPLY: number;
  75678. /**
  75679. * Used to apply the vignette as a replacement of the pixel color.
  75680. */
  75681. static readonly VIGNETTEMODE_OPAQUE: number;
  75682. }
  75683. }
  75684. declare module BABYLON {
  75685. /** @hidden */
  75686. export var postprocessVertexShader: {
  75687. name: string;
  75688. shader: string;
  75689. };
  75690. }
  75691. declare module BABYLON {
  75692. interface ThinEngine {
  75693. /**
  75694. * Creates a new render target texture
  75695. * @param size defines the size of the texture
  75696. * @param options defines the options used to create the texture
  75697. * @returns a new render target texture stored in an InternalTexture
  75698. */
  75699. createRenderTargetTexture(size: number | {
  75700. width: number;
  75701. height: number;
  75702. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75703. }
  75704. }
  75705. declare module BABYLON {
  75706. /** Defines supported spaces */
  75707. export enum Space {
  75708. /** Local (object) space */
  75709. LOCAL = 0,
  75710. /** World space */
  75711. WORLD = 1,
  75712. /** Bone space */
  75713. BONE = 2
  75714. }
  75715. /** Defines the 3 main axes */
  75716. export class Axis {
  75717. /** X axis */
  75718. static X: Vector3;
  75719. /** Y axis */
  75720. static Y: Vector3;
  75721. /** Z axis */
  75722. static Z: Vector3;
  75723. }
  75724. }
  75725. declare module BABYLON {
  75726. /**
  75727. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75728. * This is the base of the follow, arc rotate cameras and Free camera
  75729. * @see http://doc.babylonjs.com/features/cameras
  75730. */
  75731. export class TargetCamera extends Camera {
  75732. private static _RigCamTransformMatrix;
  75733. private static _TargetTransformMatrix;
  75734. private static _TargetFocalPoint;
  75735. /**
  75736. * Define the current direction the camera is moving to
  75737. */
  75738. cameraDirection: Vector3;
  75739. /**
  75740. * Define the current rotation the camera is rotating to
  75741. */
  75742. cameraRotation: Vector2;
  75743. /**
  75744. * When set, the up vector of the camera will be updated by the rotation of the camera
  75745. */
  75746. updateUpVectorFromRotation: boolean;
  75747. private _tmpQuaternion;
  75748. /**
  75749. * Define the current rotation of the camera
  75750. */
  75751. rotation: Vector3;
  75752. /**
  75753. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75754. */
  75755. rotationQuaternion: Quaternion;
  75756. /**
  75757. * Define the current speed of the camera
  75758. */
  75759. speed: number;
  75760. /**
  75761. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75762. * around all axis.
  75763. */
  75764. noRotationConstraint: boolean;
  75765. /**
  75766. * Define the current target of the camera as an object or a position.
  75767. */
  75768. lockedTarget: any;
  75769. /** @hidden */
  75770. _currentTarget: Vector3;
  75771. /** @hidden */
  75772. _initialFocalDistance: number;
  75773. /** @hidden */
  75774. _viewMatrix: Matrix;
  75775. /** @hidden */
  75776. _camMatrix: Matrix;
  75777. /** @hidden */
  75778. _cameraTransformMatrix: Matrix;
  75779. /** @hidden */
  75780. _cameraRotationMatrix: Matrix;
  75781. /** @hidden */
  75782. _referencePoint: Vector3;
  75783. /** @hidden */
  75784. _transformedReferencePoint: Vector3;
  75785. protected _globalCurrentTarget: Vector3;
  75786. protected _globalCurrentUpVector: Vector3;
  75787. /** @hidden */
  75788. _reset: () => void;
  75789. private _defaultUp;
  75790. /**
  75791. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75792. * This is the base of the follow, arc rotate cameras and Free camera
  75793. * @see http://doc.babylonjs.com/features/cameras
  75794. * @param name Defines the name of the camera in the scene
  75795. * @param position Defines the start position of the camera in the scene
  75796. * @param scene Defines the scene the camera belongs to
  75797. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75798. */
  75799. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75800. /**
  75801. * Gets the position in front of the camera at a given distance.
  75802. * @param distance The distance from the camera we want the position to be
  75803. * @returns the position
  75804. */
  75805. getFrontPosition(distance: number): Vector3;
  75806. /** @hidden */
  75807. _getLockedTargetPosition(): Nullable<Vector3>;
  75808. private _storedPosition;
  75809. private _storedRotation;
  75810. private _storedRotationQuaternion;
  75811. /**
  75812. * Store current camera state of the camera (fov, position, rotation, etc..)
  75813. * @returns the camera
  75814. */
  75815. storeState(): Camera;
  75816. /**
  75817. * Restored camera state. You must call storeState() first
  75818. * @returns whether it was successful or not
  75819. * @hidden
  75820. */
  75821. _restoreStateValues(): boolean;
  75822. /** @hidden */
  75823. _initCache(): void;
  75824. /** @hidden */
  75825. _updateCache(ignoreParentClass?: boolean): void;
  75826. /** @hidden */
  75827. _isSynchronizedViewMatrix(): boolean;
  75828. /** @hidden */
  75829. _computeLocalCameraSpeed(): number;
  75830. /**
  75831. * Defines the target the camera should look at.
  75832. * @param target Defines the new target as a Vector or a mesh
  75833. */
  75834. setTarget(target: Vector3): void;
  75835. /**
  75836. * Return the current target position of the camera. This value is expressed in local space.
  75837. * @returns the target position
  75838. */
  75839. getTarget(): Vector3;
  75840. /** @hidden */
  75841. _decideIfNeedsToMove(): boolean;
  75842. /** @hidden */
  75843. _updatePosition(): void;
  75844. /** @hidden */
  75845. _checkInputs(): void;
  75846. protected _updateCameraRotationMatrix(): void;
  75847. /**
  75848. * 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)
  75849. * @returns the current camera
  75850. */
  75851. private _rotateUpVectorWithCameraRotationMatrix;
  75852. private _cachedRotationZ;
  75853. private _cachedQuaternionRotationZ;
  75854. /** @hidden */
  75855. _getViewMatrix(): Matrix;
  75856. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75857. /**
  75858. * @hidden
  75859. */
  75860. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75861. /**
  75862. * @hidden
  75863. */
  75864. _updateRigCameras(): void;
  75865. private _getRigCamPositionAndTarget;
  75866. /**
  75867. * Gets the current object class name.
  75868. * @return the class name
  75869. */
  75870. getClassName(): string;
  75871. }
  75872. }
  75873. declare module BABYLON {
  75874. /**
  75875. * Gather the list of keyboard event types as constants.
  75876. */
  75877. export class KeyboardEventTypes {
  75878. /**
  75879. * The keydown event is fired when a key becomes active (pressed).
  75880. */
  75881. static readonly KEYDOWN: number;
  75882. /**
  75883. * The keyup event is fired when a key has been released.
  75884. */
  75885. static readonly KEYUP: number;
  75886. }
  75887. /**
  75888. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75889. */
  75890. export class KeyboardInfo {
  75891. /**
  75892. * Defines the type of event (KeyboardEventTypes)
  75893. */
  75894. type: number;
  75895. /**
  75896. * Defines the related dom event
  75897. */
  75898. event: KeyboardEvent;
  75899. /**
  75900. * Instantiates a new keyboard info.
  75901. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75902. * @param type Defines the type of event (KeyboardEventTypes)
  75903. * @param event Defines the related dom event
  75904. */
  75905. constructor(
  75906. /**
  75907. * Defines the type of event (KeyboardEventTypes)
  75908. */
  75909. type: number,
  75910. /**
  75911. * Defines the related dom event
  75912. */
  75913. event: KeyboardEvent);
  75914. }
  75915. /**
  75916. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75917. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75918. */
  75919. export class KeyboardInfoPre extends KeyboardInfo {
  75920. /**
  75921. * Defines the type of event (KeyboardEventTypes)
  75922. */
  75923. type: number;
  75924. /**
  75925. * Defines the related dom event
  75926. */
  75927. event: KeyboardEvent;
  75928. /**
  75929. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75930. */
  75931. skipOnPointerObservable: boolean;
  75932. /**
  75933. * Instantiates a new keyboard pre info.
  75934. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75935. * @param type Defines the type of event (KeyboardEventTypes)
  75936. * @param event Defines the related dom event
  75937. */
  75938. constructor(
  75939. /**
  75940. * Defines the type of event (KeyboardEventTypes)
  75941. */
  75942. type: number,
  75943. /**
  75944. * Defines the related dom event
  75945. */
  75946. event: KeyboardEvent);
  75947. }
  75948. }
  75949. declare module BABYLON {
  75950. /**
  75951. * Manage the keyboard inputs to control the movement of a free camera.
  75952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75953. */
  75954. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75955. /**
  75956. * Defines the camera the input is attached to.
  75957. */
  75958. camera: FreeCamera;
  75959. /**
  75960. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75961. */
  75962. keysUp: number[];
  75963. /**
  75964. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75965. */
  75966. keysDown: number[];
  75967. /**
  75968. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75969. */
  75970. keysLeft: number[];
  75971. /**
  75972. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75973. */
  75974. keysRight: number[];
  75975. private _keys;
  75976. private _onCanvasBlurObserver;
  75977. private _onKeyboardObserver;
  75978. private _engine;
  75979. private _scene;
  75980. /**
  75981. * Attach the input controls to a specific dom element to get the input from.
  75982. * @param element Defines the element the controls should be listened from
  75983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75984. */
  75985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75986. /**
  75987. * Detach the current controls from the specified dom element.
  75988. * @param element Defines the element to stop listening the inputs from
  75989. */
  75990. detachControl(element: Nullable<HTMLElement>): void;
  75991. /**
  75992. * Update the current camera state depending on the inputs that have been used this frame.
  75993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75994. */
  75995. checkInputs(): void;
  75996. /**
  75997. * Gets the class name of the current intput.
  75998. * @returns the class name
  75999. */
  76000. getClassName(): string;
  76001. /** @hidden */
  76002. _onLostFocus(): void;
  76003. /**
  76004. * Get the friendly name associated with the input class.
  76005. * @returns the input friendly name
  76006. */
  76007. getSimpleName(): string;
  76008. }
  76009. }
  76010. declare module BABYLON {
  76011. /**
  76012. * Interface describing all the common properties and methods a shadow light needs to implement.
  76013. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76014. * as well as binding the different shadow properties to the effects.
  76015. */
  76016. export interface IShadowLight extends Light {
  76017. /**
  76018. * The light id in the scene (used in scene.findLighById for instance)
  76019. */
  76020. id: string;
  76021. /**
  76022. * The position the shdow will be casted from.
  76023. */
  76024. position: Vector3;
  76025. /**
  76026. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76027. */
  76028. direction: Vector3;
  76029. /**
  76030. * The transformed position. Position of the light in world space taking parenting in account.
  76031. */
  76032. transformedPosition: Vector3;
  76033. /**
  76034. * The transformed direction. Direction of the light in world space taking parenting in account.
  76035. */
  76036. transformedDirection: Vector3;
  76037. /**
  76038. * The friendly name of the light in the scene.
  76039. */
  76040. name: string;
  76041. /**
  76042. * Defines the shadow projection clipping minimum z value.
  76043. */
  76044. shadowMinZ: number;
  76045. /**
  76046. * Defines the shadow projection clipping maximum z value.
  76047. */
  76048. shadowMaxZ: number;
  76049. /**
  76050. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76051. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76052. */
  76053. computeTransformedInformation(): boolean;
  76054. /**
  76055. * Gets the scene the light belongs to.
  76056. * @returns The scene
  76057. */
  76058. getScene(): Scene;
  76059. /**
  76060. * Callback defining a custom Projection Matrix Builder.
  76061. * This can be used to override the default projection matrix computation.
  76062. */
  76063. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76064. /**
  76065. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76066. * @param matrix The materix to updated with the projection information
  76067. * @param viewMatrix The transform matrix of the light
  76068. * @param renderList The list of mesh to render in the map
  76069. * @returns The current light
  76070. */
  76071. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76072. /**
  76073. * Gets the current depth scale used in ESM.
  76074. * @returns The scale
  76075. */
  76076. getDepthScale(): number;
  76077. /**
  76078. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76079. * @returns true if a cube texture needs to be use
  76080. */
  76081. needCube(): boolean;
  76082. /**
  76083. * Detects if the projection matrix requires to be recomputed this frame.
  76084. * @returns true if it requires to be recomputed otherwise, false.
  76085. */
  76086. needProjectionMatrixCompute(): boolean;
  76087. /**
  76088. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76089. */
  76090. forceProjectionMatrixCompute(): void;
  76091. /**
  76092. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76093. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76094. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76095. */
  76096. getShadowDirection(faceIndex?: number): Vector3;
  76097. /**
  76098. * Gets the minZ used for shadow according to both the scene and the light.
  76099. * @param activeCamera The camera we are returning the min for
  76100. * @returns the depth min z
  76101. */
  76102. getDepthMinZ(activeCamera: Camera): number;
  76103. /**
  76104. * Gets the maxZ used for shadow according to both the scene and the light.
  76105. * @param activeCamera The camera we are returning the max for
  76106. * @returns the depth max z
  76107. */
  76108. getDepthMaxZ(activeCamera: Camera): number;
  76109. }
  76110. /**
  76111. * Base implementation IShadowLight
  76112. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76113. */
  76114. export abstract class ShadowLight extends Light implements IShadowLight {
  76115. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76116. protected _position: Vector3;
  76117. protected _setPosition(value: Vector3): void;
  76118. /**
  76119. * Sets the position the shadow will be casted from. Also use as the light position for both
  76120. * point and spot lights.
  76121. */
  76122. /**
  76123. * Sets the position the shadow will be casted from. Also use as the light position for both
  76124. * point and spot lights.
  76125. */
  76126. position: Vector3;
  76127. protected _direction: Vector3;
  76128. protected _setDirection(value: Vector3): void;
  76129. /**
  76130. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76131. * Also use as the light direction on spot and directional lights.
  76132. */
  76133. /**
  76134. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76135. * Also use as the light direction on spot and directional lights.
  76136. */
  76137. direction: Vector3;
  76138. private _shadowMinZ;
  76139. /**
  76140. * Gets the shadow projection clipping minimum z value.
  76141. */
  76142. /**
  76143. * Sets the shadow projection clipping minimum z value.
  76144. */
  76145. shadowMinZ: number;
  76146. private _shadowMaxZ;
  76147. /**
  76148. * Sets the shadow projection clipping maximum z value.
  76149. */
  76150. /**
  76151. * Gets the shadow projection clipping maximum z value.
  76152. */
  76153. shadowMaxZ: number;
  76154. /**
  76155. * Callback defining a custom Projection Matrix Builder.
  76156. * This can be used to override the default projection matrix computation.
  76157. */
  76158. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76159. /**
  76160. * The transformed position. Position of the light in world space taking parenting in account.
  76161. */
  76162. transformedPosition: Vector3;
  76163. /**
  76164. * The transformed direction. Direction of the light in world space taking parenting in account.
  76165. */
  76166. transformedDirection: Vector3;
  76167. private _needProjectionMatrixCompute;
  76168. /**
  76169. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76170. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76171. */
  76172. computeTransformedInformation(): boolean;
  76173. /**
  76174. * Return the depth scale used for the shadow map.
  76175. * @returns the depth scale.
  76176. */
  76177. getDepthScale(): number;
  76178. /**
  76179. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76180. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76181. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76182. */
  76183. getShadowDirection(faceIndex?: number): Vector3;
  76184. /**
  76185. * Returns the ShadowLight absolute position in the World.
  76186. * @returns the position vector in world space
  76187. */
  76188. getAbsolutePosition(): Vector3;
  76189. /**
  76190. * Sets the ShadowLight direction toward the passed target.
  76191. * @param target The point to target in local space
  76192. * @returns the updated ShadowLight direction
  76193. */
  76194. setDirectionToTarget(target: Vector3): Vector3;
  76195. /**
  76196. * Returns the light rotation in euler definition.
  76197. * @returns the x y z rotation in local space.
  76198. */
  76199. getRotation(): Vector3;
  76200. /**
  76201. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76202. * @returns true if a cube texture needs to be use
  76203. */
  76204. needCube(): boolean;
  76205. /**
  76206. * Detects if the projection matrix requires to be recomputed this frame.
  76207. * @returns true if it requires to be recomputed otherwise, false.
  76208. */
  76209. needProjectionMatrixCompute(): boolean;
  76210. /**
  76211. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76212. */
  76213. forceProjectionMatrixCompute(): void;
  76214. /** @hidden */
  76215. _initCache(): void;
  76216. /** @hidden */
  76217. _isSynchronized(): boolean;
  76218. /**
  76219. * Computes the world matrix of the node
  76220. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76221. * @returns the world matrix
  76222. */
  76223. computeWorldMatrix(force?: boolean): Matrix;
  76224. /**
  76225. * Gets the minZ used for shadow according to both the scene and the light.
  76226. * @param activeCamera The camera we are returning the min for
  76227. * @returns the depth min z
  76228. */
  76229. getDepthMinZ(activeCamera: Camera): number;
  76230. /**
  76231. * Gets the maxZ used for shadow according to both the scene and the light.
  76232. * @param activeCamera The camera we are returning the max for
  76233. * @returns the depth max z
  76234. */
  76235. getDepthMaxZ(activeCamera: Camera): number;
  76236. /**
  76237. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76238. * @param matrix The materix to updated with the projection information
  76239. * @param viewMatrix The transform matrix of the light
  76240. * @param renderList The list of mesh to render in the map
  76241. * @returns The current light
  76242. */
  76243. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76244. }
  76245. }
  76246. declare module BABYLON {
  76247. /**
  76248. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76249. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76250. */
  76251. export class EffectFallbacks implements IEffectFallbacks {
  76252. private _defines;
  76253. private _currentRank;
  76254. private _maxRank;
  76255. private _mesh;
  76256. /**
  76257. * Removes the fallback from the bound mesh.
  76258. */
  76259. unBindMesh(): void;
  76260. /**
  76261. * Adds a fallback on the specified property.
  76262. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76263. * @param define The name of the define in the shader
  76264. */
  76265. addFallback(rank: number, define: string): void;
  76266. /**
  76267. * Sets the mesh to use CPU skinning when needing to fallback.
  76268. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76269. * @param mesh The mesh to use the fallbacks.
  76270. */
  76271. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76272. /**
  76273. * Checks to see if more fallbacks are still availible.
  76274. */
  76275. readonly hasMoreFallbacks: boolean;
  76276. /**
  76277. * Removes the defines that should be removed when falling back.
  76278. * @param currentDefines defines the current define statements for the shader.
  76279. * @param effect defines the current effect we try to compile
  76280. * @returns The resulting defines with defines of the current rank removed.
  76281. */
  76282. reduce(currentDefines: string, effect: Effect): string;
  76283. }
  76284. }
  76285. declare module BABYLON {
  76286. /**
  76287. * "Static Class" containing the most commonly used helper while dealing with material for
  76288. * rendering purpose.
  76289. *
  76290. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76291. *
  76292. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76293. */
  76294. export class MaterialHelper {
  76295. /**
  76296. * Bind the current view position to an effect.
  76297. * @param effect The effect to be bound
  76298. * @param scene The scene the eyes position is used from
  76299. */
  76300. static BindEyePosition(effect: Effect, scene: Scene): void;
  76301. /**
  76302. * Helps preparing the defines values about the UVs in used in the effect.
  76303. * UVs are shared as much as we can accross channels in the shaders.
  76304. * @param texture The texture we are preparing the UVs for
  76305. * @param defines The defines to update
  76306. * @param key The channel key "diffuse", "specular"... used in the shader
  76307. */
  76308. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76309. /**
  76310. * Binds a texture matrix value to its corrsponding uniform
  76311. * @param texture The texture to bind the matrix for
  76312. * @param uniformBuffer The uniform buffer receivin the data
  76313. * @param key The channel key "diffuse", "specular"... used in the shader
  76314. */
  76315. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76316. /**
  76317. * Gets the current status of the fog (should it be enabled?)
  76318. * @param mesh defines the mesh to evaluate for fog support
  76319. * @param scene defines the hosting scene
  76320. * @returns true if fog must be enabled
  76321. */
  76322. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76323. /**
  76324. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76325. * @param mesh defines the current mesh
  76326. * @param scene defines the current scene
  76327. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76328. * @param pointsCloud defines if point cloud rendering has to be turned on
  76329. * @param fogEnabled defines if fog has to be turned on
  76330. * @param alphaTest defines if alpha testing has to be turned on
  76331. * @param defines defines the current list of defines
  76332. */
  76333. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76334. /**
  76335. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76336. * @param scene defines the current scene
  76337. * @param engine defines the current engine
  76338. * @param defines specifies the list of active defines
  76339. * @param useInstances defines if instances have to be turned on
  76340. * @param useClipPlane defines if clip plane have to be turned on
  76341. */
  76342. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76343. /**
  76344. * Prepares the defines for bones
  76345. * @param mesh The mesh containing the geometry data we will draw
  76346. * @param defines The defines to update
  76347. */
  76348. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76349. /**
  76350. * Prepares the defines for morph targets
  76351. * @param mesh The mesh containing the geometry data we will draw
  76352. * @param defines The defines to update
  76353. */
  76354. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76355. /**
  76356. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76357. * @param mesh The mesh containing the geometry data we will draw
  76358. * @param defines The defines to update
  76359. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76360. * @param useBones Precise whether bones should be used or not (override mesh info)
  76361. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76362. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76363. * @returns false if defines are considered not dirty and have not been checked
  76364. */
  76365. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76366. /**
  76367. * Prepares the defines related to multiview
  76368. * @param scene The scene we are intending to draw
  76369. * @param defines The defines to update
  76370. */
  76371. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76372. /**
  76373. * Prepares the defines related to the light information passed in parameter
  76374. * @param scene The scene we are intending to draw
  76375. * @param mesh The mesh the effect is compiling for
  76376. * @param light The light the effect is compiling for
  76377. * @param lightIndex The index of the light
  76378. * @param defines The defines to update
  76379. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76380. * @param state Defines the current state regarding what is needed (normals, etc...)
  76381. */
  76382. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76383. needNormals: boolean;
  76384. needRebuild: boolean;
  76385. shadowEnabled: boolean;
  76386. specularEnabled: boolean;
  76387. lightmapMode: boolean;
  76388. }): void;
  76389. /**
  76390. * Prepares the defines related to the light information passed in parameter
  76391. * @param scene The scene we are intending to draw
  76392. * @param mesh The mesh the effect is compiling for
  76393. * @param defines The defines to update
  76394. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76395. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76396. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76397. * @returns true if normals will be required for the rest of the effect
  76398. */
  76399. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76400. /**
  76401. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76402. * @param lightIndex defines the light index
  76403. * @param uniformsList The uniform list
  76404. * @param samplersList The sampler list
  76405. * @param projectedLightTexture defines if projected texture must be used
  76406. * @param uniformBuffersList defines an optional list of uniform buffers
  76407. */
  76408. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76409. /**
  76410. * Prepares the uniforms and samplers list to be used in the effect
  76411. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76412. * @param samplersList The sampler list
  76413. * @param defines The defines helping in the list generation
  76414. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76415. */
  76416. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76417. /**
  76418. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76419. * @param defines The defines to update while falling back
  76420. * @param fallbacks The authorized effect fallbacks
  76421. * @param maxSimultaneousLights The maximum number of lights allowed
  76422. * @param rank the current rank of the Effect
  76423. * @returns The newly affected rank
  76424. */
  76425. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76426. private static _TmpMorphInfluencers;
  76427. /**
  76428. * Prepares the list of attributes required for morph targets according to the effect defines.
  76429. * @param attribs The current list of supported attribs
  76430. * @param mesh The mesh to prepare the morph targets attributes for
  76431. * @param influencers The number of influencers
  76432. */
  76433. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76434. /**
  76435. * Prepares the list of attributes required for morph targets according to the effect defines.
  76436. * @param attribs The current list of supported attribs
  76437. * @param mesh The mesh to prepare the morph targets attributes for
  76438. * @param defines The current Defines of the effect
  76439. */
  76440. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76441. /**
  76442. * Prepares the list of attributes required for bones according to the effect defines.
  76443. * @param attribs The current list of supported attribs
  76444. * @param mesh The mesh to prepare the bones attributes for
  76445. * @param defines The current Defines of the effect
  76446. * @param fallbacks The current efffect fallback strategy
  76447. */
  76448. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76449. /**
  76450. * Check and prepare the list of attributes required for instances according to the effect defines.
  76451. * @param attribs The current list of supported attribs
  76452. * @param defines The current MaterialDefines of the effect
  76453. */
  76454. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76455. /**
  76456. * Add the list of attributes required for instances to the attribs array.
  76457. * @param attribs The current list of supported attribs
  76458. */
  76459. static PushAttributesForInstances(attribs: string[]): void;
  76460. /**
  76461. * Binds the light information to the effect.
  76462. * @param light The light containing the generator
  76463. * @param effect The effect we are binding the data to
  76464. * @param lightIndex The light index in the effect used to render
  76465. */
  76466. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76467. /**
  76468. * Binds the lights information from the scene to the effect for the given mesh.
  76469. * @param light Light to bind
  76470. * @param lightIndex Light index
  76471. * @param scene The scene where the light belongs to
  76472. * @param effect The effect we are binding the data to
  76473. * @param useSpecular Defines if specular is supported
  76474. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76475. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76476. */
  76477. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76478. /**
  76479. * Binds the lights information from the scene to the effect for the given mesh.
  76480. * @param scene The scene the lights belongs to
  76481. * @param mesh The mesh we are binding the information to render
  76482. * @param effect The effect we are binding the data to
  76483. * @param defines The generated defines for the effect
  76484. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76485. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76486. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76487. */
  76488. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76489. private static _tempFogColor;
  76490. /**
  76491. * Binds the fog information from the scene to the effect for the given mesh.
  76492. * @param scene The scene the lights belongs to
  76493. * @param mesh The mesh we are binding the information to render
  76494. * @param effect The effect we are binding the data to
  76495. * @param linearSpace Defines if the fog effect is applied in linear space
  76496. */
  76497. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76498. /**
  76499. * Binds the bones information from the mesh to the effect.
  76500. * @param mesh The mesh we are binding the information to render
  76501. * @param effect The effect we are binding the data to
  76502. */
  76503. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76504. /**
  76505. * Binds the morph targets information from the mesh to the effect.
  76506. * @param abstractMesh The mesh we are binding the information to render
  76507. * @param effect The effect we are binding the data to
  76508. */
  76509. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76510. /**
  76511. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76512. * @param defines The generated defines used in the effect
  76513. * @param effect The effect we are binding the data to
  76514. * @param scene The scene we are willing to render with logarithmic scale for
  76515. */
  76516. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76517. /**
  76518. * Binds the clip plane information from the scene to the effect.
  76519. * @param scene The scene the clip plane information are extracted from
  76520. * @param effect The effect we are binding the data to
  76521. */
  76522. static BindClipPlane(effect: Effect, scene: Scene): void;
  76523. }
  76524. }
  76525. declare module BABYLON {
  76526. /** @hidden */
  76527. export var packingFunctions: {
  76528. name: string;
  76529. shader: string;
  76530. };
  76531. }
  76532. declare module BABYLON {
  76533. /** @hidden */
  76534. export var shadowMapPixelShader: {
  76535. name: string;
  76536. shader: string;
  76537. };
  76538. }
  76539. declare module BABYLON {
  76540. /** @hidden */
  76541. export var bonesDeclaration: {
  76542. name: string;
  76543. shader: string;
  76544. };
  76545. }
  76546. declare module BABYLON {
  76547. /** @hidden */
  76548. export var morphTargetsVertexGlobalDeclaration: {
  76549. name: string;
  76550. shader: string;
  76551. };
  76552. }
  76553. declare module BABYLON {
  76554. /** @hidden */
  76555. export var morphTargetsVertexDeclaration: {
  76556. name: string;
  76557. shader: string;
  76558. };
  76559. }
  76560. declare module BABYLON {
  76561. /** @hidden */
  76562. export var instancesDeclaration: {
  76563. name: string;
  76564. shader: string;
  76565. };
  76566. }
  76567. declare module BABYLON {
  76568. /** @hidden */
  76569. export var helperFunctions: {
  76570. name: string;
  76571. shader: string;
  76572. };
  76573. }
  76574. declare module BABYLON {
  76575. /** @hidden */
  76576. export var morphTargetsVertex: {
  76577. name: string;
  76578. shader: string;
  76579. };
  76580. }
  76581. declare module BABYLON {
  76582. /** @hidden */
  76583. export var instancesVertex: {
  76584. name: string;
  76585. shader: string;
  76586. };
  76587. }
  76588. declare module BABYLON {
  76589. /** @hidden */
  76590. export var bonesVertex: {
  76591. name: string;
  76592. shader: string;
  76593. };
  76594. }
  76595. declare module BABYLON {
  76596. /** @hidden */
  76597. export var shadowMapVertexShader: {
  76598. name: string;
  76599. shader: string;
  76600. };
  76601. }
  76602. declare module BABYLON {
  76603. /** @hidden */
  76604. export var depthBoxBlurPixelShader: {
  76605. name: string;
  76606. shader: string;
  76607. };
  76608. }
  76609. declare module BABYLON {
  76610. /**
  76611. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76612. */
  76613. export interface ICustomShaderOptions {
  76614. /**
  76615. * Gets or sets the custom shader name to use
  76616. */
  76617. shaderName: string;
  76618. /**
  76619. * The list of attribute names used in the shader
  76620. */
  76621. attributes?: string[];
  76622. /**
  76623. * The list of unifrom names used in the shader
  76624. */
  76625. uniforms?: string[];
  76626. /**
  76627. * The list of sampler names used in the shader
  76628. */
  76629. samplers?: string[];
  76630. /**
  76631. * The list of defines used in the shader
  76632. */
  76633. defines?: string[];
  76634. }
  76635. /**
  76636. * Interface to implement to create a shadow generator compatible with BJS.
  76637. */
  76638. export interface IShadowGenerator {
  76639. /**
  76640. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76641. * @returns The render target texture if present otherwise, null
  76642. */
  76643. getShadowMap(): Nullable<RenderTargetTexture>;
  76644. /**
  76645. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76646. * @returns The render target texture if the shadow map is present otherwise, null
  76647. */
  76648. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76649. /**
  76650. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76651. * @param subMesh The submesh we want to render in the shadow map
  76652. * @param useInstances Defines wether will draw in the map using instances
  76653. * @returns true if ready otherwise, false
  76654. */
  76655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76656. /**
  76657. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76658. * @param defines Defines of the material we want to update
  76659. * @param lightIndex Index of the light in the enabled light list of the material
  76660. */
  76661. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76662. /**
  76663. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76664. * defined in the generator but impacting the effect).
  76665. * It implies the unifroms available on the materials are the standard BJS ones.
  76666. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76667. * @param effect The effect we are binfing the information for
  76668. */
  76669. bindShadowLight(lightIndex: string, effect: Effect): void;
  76670. /**
  76671. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76672. * (eq to shadow prjection matrix * light transform matrix)
  76673. * @returns The transform matrix used to create the shadow map
  76674. */
  76675. getTransformMatrix(): Matrix;
  76676. /**
  76677. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76678. * Cube and 2D textures for instance.
  76679. */
  76680. recreateShadowMap(): void;
  76681. /**
  76682. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76683. * @param onCompiled Callback triggered at the and of the effects compilation
  76684. * @param options Sets of optional options forcing the compilation with different modes
  76685. */
  76686. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76687. useInstances: boolean;
  76688. }>): void;
  76689. /**
  76690. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76691. * @param options Sets of optional options forcing the compilation with different modes
  76692. * @returns A promise that resolves when the compilation completes
  76693. */
  76694. forceCompilationAsync(options?: Partial<{
  76695. useInstances: boolean;
  76696. }>): Promise<void>;
  76697. /**
  76698. * Serializes the shadow generator setup to a json object.
  76699. * @returns The serialized JSON object
  76700. */
  76701. serialize(): any;
  76702. /**
  76703. * Disposes the Shadow map and related Textures and effects.
  76704. */
  76705. dispose(): void;
  76706. }
  76707. /**
  76708. * Default implementation IShadowGenerator.
  76709. * This is the main object responsible of generating shadows in the framework.
  76710. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76711. */
  76712. export class ShadowGenerator implements IShadowGenerator {
  76713. /**
  76714. * Shadow generator mode None: no filtering applied.
  76715. */
  76716. static readonly FILTER_NONE: number;
  76717. /**
  76718. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76719. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76720. */
  76721. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76722. /**
  76723. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76724. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76725. */
  76726. static readonly FILTER_POISSONSAMPLING: number;
  76727. /**
  76728. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76729. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76730. */
  76731. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76732. /**
  76733. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76734. * edge artifacts on steep falloff.
  76735. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76736. */
  76737. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76738. /**
  76739. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76740. * edge artifacts on steep falloff.
  76741. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76742. */
  76743. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76744. /**
  76745. * Shadow generator mode PCF: Percentage Closer Filtering
  76746. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76747. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76748. */
  76749. static readonly FILTER_PCF: number;
  76750. /**
  76751. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76752. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76753. * Contact Hardening
  76754. */
  76755. static readonly FILTER_PCSS: number;
  76756. /**
  76757. * Reserved for PCF and PCSS
  76758. * Highest Quality.
  76759. *
  76760. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76761. *
  76762. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76763. */
  76764. static readonly QUALITY_HIGH: number;
  76765. /**
  76766. * Reserved for PCF and PCSS
  76767. * Good tradeoff for quality/perf cross devices
  76768. *
  76769. * Execute PCF on a 3*3 kernel.
  76770. *
  76771. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76772. */
  76773. static readonly QUALITY_MEDIUM: number;
  76774. /**
  76775. * Reserved for PCF and PCSS
  76776. * The lowest quality but the fastest.
  76777. *
  76778. * Execute PCF on a 1*1 kernel.
  76779. *
  76780. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76781. */
  76782. static readonly QUALITY_LOW: number;
  76783. /** Gets or sets the custom shader name to use */
  76784. customShaderOptions: ICustomShaderOptions;
  76785. /**
  76786. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76787. */
  76788. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76789. /**
  76790. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76791. */
  76792. onAfterShadowMapRenderObservable: Observable<Effect>;
  76793. /**
  76794. * Observable triggered before a mesh is rendered in the shadow map.
  76795. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76796. */
  76797. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76798. /**
  76799. * Observable triggered after a mesh is rendered in the shadow map.
  76800. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76801. */
  76802. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76803. private _bias;
  76804. /**
  76805. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76806. */
  76807. /**
  76808. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76809. */
  76810. bias: number;
  76811. private _normalBias;
  76812. /**
  76813. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76814. */
  76815. /**
  76816. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76817. */
  76818. normalBias: number;
  76819. private _blurBoxOffset;
  76820. /**
  76821. * Gets the blur box offset: offset applied during the blur pass.
  76822. * Only useful if useKernelBlur = false
  76823. */
  76824. /**
  76825. * Sets the blur box offset: offset applied during the blur pass.
  76826. * Only useful if useKernelBlur = false
  76827. */
  76828. blurBoxOffset: number;
  76829. private _blurScale;
  76830. /**
  76831. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76832. * 2 means half of the size.
  76833. */
  76834. /**
  76835. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76836. * 2 means half of the size.
  76837. */
  76838. blurScale: number;
  76839. private _blurKernel;
  76840. /**
  76841. * Gets the blur kernel: kernel size of the blur pass.
  76842. * Only useful if useKernelBlur = true
  76843. */
  76844. /**
  76845. * Sets the blur kernel: kernel size of the blur pass.
  76846. * Only useful if useKernelBlur = true
  76847. */
  76848. blurKernel: number;
  76849. private _useKernelBlur;
  76850. /**
  76851. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76852. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76853. */
  76854. /**
  76855. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76856. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76857. */
  76858. useKernelBlur: boolean;
  76859. private _depthScale;
  76860. /**
  76861. * Gets the depth scale used in ESM mode.
  76862. */
  76863. /**
  76864. * Sets the depth scale used in ESM mode.
  76865. * This can override the scale stored on the light.
  76866. */
  76867. depthScale: number;
  76868. private _filter;
  76869. /**
  76870. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76871. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76872. */
  76873. /**
  76874. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76875. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76876. */
  76877. filter: number;
  76878. /**
  76879. * Gets if the current filter is set to Poisson Sampling.
  76880. */
  76881. /**
  76882. * Sets the current filter to Poisson Sampling.
  76883. */
  76884. usePoissonSampling: boolean;
  76885. /**
  76886. * Gets if the current filter is set to ESM.
  76887. */
  76888. /**
  76889. * Sets the current filter is to ESM.
  76890. */
  76891. useExponentialShadowMap: boolean;
  76892. /**
  76893. * Gets if the current filter is set to filtered ESM.
  76894. */
  76895. /**
  76896. * Gets if the current filter is set to filtered ESM.
  76897. */
  76898. useBlurExponentialShadowMap: boolean;
  76899. /**
  76900. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76901. * exponential to prevent steep falloff artifacts).
  76902. */
  76903. /**
  76904. * Sets the current filter to "close ESM" (using the inverse of the
  76905. * exponential to prevent steep falloff artifacts).
  76906. */
  76907. useCloseExponentialShadowMap: boolean;
  76908. /**
  76909. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76910. * exponential to prevent steep falloff artifacts).
  76911. */
  76912. /**
  76913. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76914. * exponential to prevent steep falloff artifacts).
  76915. */
  76916. useBlurCloseExponentialShadowMap: boolean;
  76917. /**
  76918. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76919. */
  76920. /**
  76921. * Sets the current filter to "PCF" (percentage closer filtering).
  76922. */
  76923. usePercentageCloserFiltering: boolean;
  76924. private _filteringQuality;
  76925. /**
  76926. * Gets the PCF or PCSS Quality.
  76927. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76928. */
  76929. /**
  76930. * Sets the PCF or PCSS Quality.
  76931. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76932. */
  76933. filteringQuality: number;
  76934. /**
  76935. * Gets if the current filter is set to "PCSS" (contact hardening).
  76936. */
  76937. /**
  76938. * Sets the current filter to "PCSS" (contact hardening).
  76939. */
  76940. useContactHardeningShadow: boolean;
  76941. private _contactHardeningLightSizeUVRatio;
  76942. /**
  76943. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76944. * Using a ratio helps keeping shape stability independently of the map size.
  76945. *
  76946. * It does not account for the light projection as it was having too much
  76947. * instability during the light setup or during light position changes.
  76948. *
  76949. * Only valid if useContactHardeningShadow is true.
  76950. */
  76951. /**
  76952. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76953. * Using a ratio helps keeping shape stability independently of the map size.
  76954. *
  76955. * It does not account for the light projection as it was having too much
  76956. * instability during the light setup or during light position changes.
  76957. *
  76958. * Only valid if useContactHardeningShadow is true.
  76959. */
  76960. contactHardeningLightSizeUVRatio: number;
  76961. private _darkness;
  76962. /** Gets or sets the actual darkness of a shadow */
  76963. darkness: number;
  76964. /**
  76965. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76966. * 0 means strongest and 1 would means no shadow.
  76967. * @returns the darkness.
  76968. */
  76969. getDarkness(): number;
  76970. /**
  76971. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76972. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76973. * @returns the shadow generator allowing fluent coding.
  76974. */
  76975. setDarkness(darkness: number): ShadowGenerator;
  76976. private _transparencyShadow;
  76977. /** Gets or sets the ability to have transparent shadow */
  76978. transparencyShadow: boolean;
  76979. /**
  76980. * Sets the ability to have transparent shadow (boolean).
  76981. * @param transparent True if transparent else False
  76982. * @returns the shadow generator allowing fluent coding
  76983. */
  76984. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76985. private _shadowMap;
  76986. private _shadowMap2;
  76987. /**
  76988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76989. * @returns The render target texture if present otherwise, null
  76990. */
  76991. getShadowMap(): Nullable<RenderTargetTexture>;
  76992. /**
  76993. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76994. * @returns The render target texture if the shadow map is present otherwise, null
  76995. */
  76996. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76997. /**
  76998. * Gets the class name of that object
  76999. * @returns "ShadowGenerator"
  77000. */
  77001. getClassName(): string;
  77002. /**
  77003. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77004. * @param mesh Mesh to add
  77005. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77006. * @returns the Shadow Generator itself
  77007. */
  77008. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77009. /**
  77010. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77011. * @param mesh Mesh to remove
  77012. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77013. * @returns the Shadow Generator itself
  77014. */
  77015. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77016. /**
  77017. * Controls the extent to which the shadows fade out at the edge of the frustum
  77018. * Used only by directionals and spots
  77019. */
  77020. frustumEdgeFalloff: number;
  77021. private _light;
  77022. /**
  77023. * Returns the associated light object.
  77024. * @returns the light generating the shadow
  77025. */
  77026. getLight(): IShadowLight;
  77027. /**
  77028. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77029. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77030. * It might on the other hand introduce peter panning.
  77031. */
  77032. forceBackFacesOnly: boolean;
  77033. private _scene;
  77034. private _lightDirection;
  77035. private _effect;
  77036. private _viewMatrix;
  77037. private _projectionMatrix;
  77038. private _transformMatrix;
  77039. private _cachedPosition;
  77040. private _cachedDirection;
  77041. private _cachedDefines;
  77042. private _currentRenderID;
  77043. private _boxBlurPostprocess;
  77044. private _kernelBlurXPostprocess;
  77045. private _kernelBlurYPostprocess;
  77046. private _blurPostProcesses;
  77047. private _mapSize;
  77048. private _currentFaceIndex;
  77049. private _currentFaceIndexCache;
  77050. private _textureType;
  77051. private _defaultTextureMatrix;
  77052. private _storedUniqueId;
  77053. /** @hidden */
  77054. static _SceneComponentInitialization: (scene: Scene) => void;
  77055. /**
  77056. * Creates a ShadowGenerator object.
  77057. * A ShadowGenerator is the required tool to use the shadows.
  77058. * Each light casting shadows needs to use its own ShadowGenerator.
  77059. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77060. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77061. * @param light The light object generating the shadows.
  77062. * @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.
  77063. */
  77064. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77065. private _initializeGenerator;
  77066. private _initializeShadowMap;
  77067. private _initializeBlurRTTAndPostProcesses;
  77068. private _renderForShadowMap;
  77069. private _renderSubMeshForShadowMap;
  77070. private _applyFilterValues;
  77071. /**
  77072. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77073. * @param onCompiled Callback triggered at the and of the effects compilation
  77074. * @param options Sets of optional options forcing the compilation with different modes
  77075. */
  77076. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77077. useInstances: boolean;
  77078. }>): void;
  77079. /**
  77080. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77081. * @param options Sets of optional options forcing the compilation with different modes
  77082. * @returns A promise that resolves when the compilation completes
  77083. */
  77084. forceCompilationAsync(options?: Partial<{
  77085. useInstances: boolean;
  77086. }>): Promise<void>;
  77087. /**
  77088. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77089. * @param subMesh The submesh we want to render in the shadow map
  77090. * @param useInstances Defines wether will draw in the map using instances
  77091. * @returns true if ready otherwise, false
  77092. */
  77093. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77094. /**
  77095. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77096. * @param defines Defines of the material we want to update
  77097. * @param lightIndex Index of the light in the enabled light list of the material
  77098. */
  77099. prepareDefines(defines: any, lightIndex: number): void;
  77100. /**
  77101. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77102. * defined in the generator but impacting the effect).
  77103. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77104. * @param effect The effect we are binfing the information for
  77105. */
  77106. bindShadowLight(lightIndex: string, effect: Effect): void;
  77107. /**
  77108. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77109. * (eq to shadow prjection matrix * light transform matrix)
  77110. * @returns The transform matrix used to create the shadow map
  77111. */
  77112. getTransformMatrix(): Matrix;
  77113. /**
  77114. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77115. * Cube and 2D textures for instance.
  77116. */
  77117. recreateShadowMap(): void;
  77118. private _disposeBlurPostProcesses;
  77119. private _disposeRTTandPostProcesses;
  77120. /**
  77121. * Disposes the ShadowGenerator.
  77122. * Returns nothing.
  77123. */
  77124. dispose(): void;
  77125. /**
  77126. * Serializes the shadow generator setup to a json object.
  77127. * @returns The serialized JSON object
  77128. */
  77129. serialize(): any;
  77130. /**
  77131. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77132. * @param parsedShadowGenerator The JSON object to parse
  77133. * @param scene The scene to create the shadow map for
  77134. * @returns The parsed shadow generator
  77135. */
  77136. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77137. }
  77138. }
  77139. declare module BABYLON {
  77140. /**
  77141. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77142. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77143. * 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.
  77144. */
  77145. export abstract class Light extends Node {
  77146. /**
  77147. * Falloff Default: light is falling off following the material specification:
  77148. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77149. */
  77150. static readonly FALLOFF_DEFAULT: number;
  77151. /**
  77152. * Falloff Physical: light is falling off following the inverse squared distance law.
  77153. */
  77154. static readonly FALLOFF_PHYSICAL: number;
  77155. /**
  77156. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77157. * to enhance interoperability with other engines.
  77158. */
  77159. static readonly FALLOFF_GLTF: number;
  77160. /**
  77161. * Falloff Standard: light is falling off like in the standard material
  77162. * to enhance interoperability with other materials.
  77163. */
  77164. static readonly FALLOFF_STANDARD: number;
  77165. /**
  77166. * If every light affecting the material is in this lightmapMode,
  77167. * material.lightmapTexture adds or multiplies
  77168. * (depends on material.useLightmapAsShadowmap)
  77169. * after every other light calculations.
  77170. */
  77171. static readonly LIGHTMAP_DEFAULT: number;
  77172. /**
  77173. * material.lightmapTexture as only diffuse lighting from this light
  77174. * adds only specular lighting from this light
  77175. * adds dynamic shadows
  77176. */
  77177. static readonly LIGHTMAP_SPECULAR: number;
  77178. /**
  77179. * material.lightmapTexture as only lighting
  77180. * no light calculation from this light
  77181. * only adds dynamic shadows from this light
  77182. */
  77183. static readonly LIGHTMAP_SHADOWSONLY: number;
  77184. /**
  77185. * Each light type uses the default quantity according to its type:
  77186. * point/spot lights use luminous intensity
  77187. * directional lights use illuminance
  77188. */
  77189. static readonly INTENSITYMODE_AUTOMATIC: number;
  77190. /**
  77191. * lumen (lm)
  77192. */
  77193. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77194. /**
  77195. * candela (lm/sr)
  77196. */
  77197. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77198. /**
  77199. * lux (lm/m^2)
  77200. */
  77201. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77202. /**
  77203. * nit (cd/m^2)
  77204. */
  77205. static readonly INTENSITYMODE_LUMINANCE: number;
  77206. /**
  77207. * Light type const id of the point light.
  77208. */
  77209. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77210. /**
  77211. * Light type const id of the directional light.
  77212. */
  77213. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77214. /**
  77215. * Light type const id of the spot light.
  77216. */
  77217. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77218. /**
  77219. * Light type const id of the hemispheric light.
  77220. */
  77221. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77222. /**
  77223. * Diffuse gives the basic color to an object.
  77224. */
  77225. diffuse: Color3;
  77226. /**
  77227. * Specular produces a highlight color on an object.
  77228. * Note: This is note affecting PBR materials.
  77229. */
  77230. specular: Color3;
  77231. /**
  77232. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77233. * falling off base on range or angle.
  77234. * This can be set to any values in Light.FALLOFF_x.
  77235. *
  77236. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77237. * other types of materials.
  77238. */
  77239. falloffType: number;
  77240. /**
  77241. * Strength of the light.
  77242. * Note: By default it is define in the framework own unit.
  77243. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77244. */
  77245. intensity: number;
  77246. private _range;
  77247. protected _inverseSquaredRange: number;
  77248. /**
  77249. * Defines how far from the source the light is impacting in scene units.
  77250. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77251. */
  77252. /**
  77253. * Defines how far from the source the light is impacting in scene units.
  77254. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77255. */
  77256. range: number;
  77257. /**
  77258. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77259. * of light.
  77260. */
  77261. private _photometricScale;
  77262. private _intensityMode;
  77263. /**
  77264. * Gets the photometric scale used to interpret the intensity.
  77265. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77266. */
  77267. /**
  77268. * Sets the photometric scale used to interpret the intensity.
  77269. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77270. */
  77271. intensityMode: number;
  77272. private _radius;
  77273. /**
  77274. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77275. */
  77276. /**
  77277. * sets the light radius used by PBR Materials to simulate soft area lights.
  77278. */
  77279. radius: number;
  77280. private _renderPriority;
  77281. /**
  77282. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77283. * exceeding the number allowed of the materials.
  77284. */
  77285. renderPriority: number;
  77286. private _shadowEnabled;
  77287. /**
  77288. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77289. * the current shadow generator.
  77290. */
  77291. /**
  77292. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77293. * the current shadow generator.
  77294. */
  77295. shadowEnabled: boolean;
  77296. private _includedOnlyMeshes;
  77297. /**
  77298. * Gets the only meshes impacted by this light.
  77299. */
  77300. /**
  77301. * Sets the only meshes impacted by this light.
  77302. */
  77303. includedOnlyMeshes: AbstractMesh[];
  77304. private _excludedMeshes;
  77305. /**
  77306. * Gets the meshes not impacted by this light.
  77307. */
  77308. /**
  77309. * Sets the meshes not impacted by this light.
  77310. */
  77311. excludedMeshes: AbstractMesh[];
  77312. private _excludeWithLayerMask;
  77313. /**
  77314. * Gets the layer id use to find what meshes are not impacted by the light.
  77315. * Inactive if 0
  77316. */
  77317. /**
  77318. * Sets the layer id use to find what meshes are not impacted by the light.
  77319. * Inactive if 0
  77320. */
  77321. excludeWithLayerMask: number;
  77322. private _includeOnlyWithLayerMask;
  77323. /**
  77324. * Gets the layer id use to find what meshes are impacted by the light.
  77325. * Inactive if 0
  77326. */
  77327. /**
  77328. * Sets the layer id use to find what meshes are impacted by the light.
  77329. * Inactive if 0
  77330. */
  77331. includeOnlyWithLayerMask: number;
  77332. private _lightmapMode;
  77333. /**
  77334. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77335. */
  77336. /**
  77337. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77338. */
  77339. lightmapMode: number;
  77340. /**
  77341. * Shadow generator associted to the light.
  77342. * @hidden Internal use only.
  77343. */
  77344. _shadowGenerator: Nullable<IShadowGenerator>;
  77345. /**
  77346. * @hidden Internal use only.
  77347. */
  77348. _excludedMeshesIds: string[];
  77349. /**
  77350. * @hidden Internal use only.
  77351. */
  77352. _includedOnlyMeshesIds: string[];
  77353. /**
  77354. * The current light unifom buffer.
  77355. * @hidden Internal use only.
  77356. */
  77357. _uniformBuffer: UniformBuffer;
  77358. /** @hidden */
  77359. _renderId: number;
  77360. /**
  77361. * Creates a Light object in the scene.
  77362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77363. * @param name The firendly name of the light
  77364. * @param scene The scene the light belongs too
  77365. */
  77366. constructor(name: string, scene: Scene);
  77367. protected abstract _buildUniformLayout(): void;
  77368. /**
  77369. * Sets the passed Effect "effect" with the Light information.
  77370. * @param effect The effect to update
  77371. * @param lightIndex The index of the light in the effect to update
  77372. * @returns The light
  77373. */
  77374. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77375. /**
  77376. * Sets the passed Effect "effect" with the Light information.
  77377. * @param effect The effect to update
  77378. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77379. * @returns The light
  77380. */
  77381. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77382. /**
  77383. * Returns the string "Light".
  77384. * @returns the class name
  77385. */
  77386. getClassName(): string;
  77387. /** @hidden */
  77388. readonly _isLight: boolean;
  77389. /**
  77390. * Converts the light information to a readable string for debug purpose.
  77391. * @param fullDetails Supports for multiple levels of logging within scene loading
  77392. * @returns the human readable light info
  77393. */
  77394. toString(fullDetails?: boolean): string;
  77395. /** @hidden */
  77396. protected _syncParentEnabledState(): void;
  77397. /**
  77398. * Set the enabled state of this node.
  77399. * @param value - the new enabled state
  77400. */
  77401. setEnabled(value: boolean): void;
  77402. /**
  77403. * Returns the Light associated shadow generator if any.
  77404. * @return the associated shadow generator.
  77405. */
  77406. getShadowGenerator(): Nullable<IShadowGenerator>;
  77407. /**
  77408. * Returns a Vector3, the absolute light position in the World.
  77409. * @returns the world space position of the light
  77410. */
  77411. getAbsolutePosition(): Vector3;
  77412. /**
  77413. * Specifies if the light will affect the passed mesh.
  77414. * @param mesh The mesh to test against the light
  77415. * @return true the mesh is affected otherwise, false.
  77416. */
  77417. canAffectMesh(mesh: AbstractMesh): boolean;
  77418. /**
  77419. * Sort function to order lights for rendering.
  77420. * @param a First Light object to compare to second.
  77421. * @param b Second Light object to compare first.
  77422. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77423. */
  77424. static CompareLightsPriority(a: Light, b: Light): number;
  77425. /**
  77426. * Releases resources associated with this node.
  77427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77429. */
  77430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77431. /**
  77432. * Returns the light type ID (integer).
  77433. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77434. */
  77435. getTypeID(): number;
  77436. /**
  77437. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77438. * @returns the scaled intensity in intensity mode unit
  77439. */
  77440. getScaledIntensity(): number;
  77441. /**
  77442. * Returns a new Light object, named "name", from the current one.
  77443. * @param name The name of the cloned light
  77444. * @returns the new created light
  77445. */
  77446. clone(name: string): Nullable<Light>;
  77447. /**
  77448. * Serializes the current light into a Serialization object.
  77449. * @returns the serialized object.
  77450. */
  77451. serialize(): any;
  77452. /**
  77453. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77454. * This new light is named "name" and added to the passed scene.
  77455. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77456. * @param name The friendly name of the light
  77457. * @param scene The scene the new light will belong to
  77458. * @returns the constructor function
  77459. */
  77460. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77461. /**
  77462. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77463. * @param parsedLight The JSON representation of the light
  77464. * @param scene The scene to create the parsed light in
  77465. * @returns the created light after parsing
  77466. */
  77467. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77468. private _hookArrayForExcluded;
  77469. private _hookArrayForIncludedOnly;
  77470. private _resyncMeshes;
  77471. /**
  77472. * Forces the meshes to update their light related information in their rendering used effects
  77473. * @hidden Internal Use Only
  77474. */
  77475. _markMeshesAsLightDirty(): void;
  77476. /**
  77477. * Recomputes the cached photometric scale if needed.
  77478. */
  77479. private _computePhotometricScale;
  77480. /**
  77481. * Returns the Photometric Scale according to the light type and intensity mode.
  77482. */
  77483. private _getPhotometricScale;
  77484. /**
  77485. * Reorder the light in the scene according to their defined priority.
  77486. * @hidden Internal Use Only
  77487. */
  77488. _reorderLightsInScene(): void;
  77489. /**
  77490. * Prepares the list of defines specific to the light type.
  77491. * @param defines the list of defines
  77492. * @param lightIndex defines the index of the light for the effect
  77493. */
  77494. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77495. }
  77496. }
  77497. declare module BABYLON {
  77498. /**
  77499. * Interface used to define Action
  77500. */
  77501. export interface IAction {
  77502. /**
  77503. * Trigger for the action
  77504. */
  77505. trigger: number;
  77506. /** Options of the trigger */
  77507. triggerOptions: any;
  77508. /**
  77509. * Gets the trigger parameters
  77510. * @returns the trigger parameters
  77511. */
  77512. getTriggerParameter(): any;
  77513. /**
  77514. * Internal only - executes current action event
  77515. * @hidden
  77516. */
  77517. _executeCurrent(evt?: ActionEvent): void;
  77518. /**
  77519. * Serialize placeholder for child classes
  77520. * @param parent of child
  77521. * @returns the serialized object
  77522. */
  77523. serialize(parent: any): any;
  77524. /**
  77525. * Internal only
  77526. * @hidden
  77527. */
  77528. _prepare(): void;
  77529. /**
  77530. * Internal only - manager for action
  77531. * @hidden
  77532. */
  77533. _actionManager: AbstractActionManager;
  77534. /**
  77535. * Adds action to chain of actions, may be a DoNothingAction
  77536. * @param action defines the next action to execute
  77537. * @returns The action passed in
  77538. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77539. */
  77540. then(action: IAction): IAction;
  77541. }
  77542. /**
  77543. * The action to be carried out following a trigger
  77544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77545. */
  77546. export class Action implements IAction {
  77547. /** the trigger, with or without parameters, for the action */
  77548. triggerOptions: any;
  77549. /**
  77550. * Trigger for the action
  77551. */
  77552. trigger: number;
  77553. /**
  77554. * Internal only - manager for action
  77555. * @hidden
  77556. */
  77557. _actionManager: ActionManager;
  77558. private _nextActiveAction;
  77559. private _child;
  77560. private _condition?;
  77561. private _triggerParameter;
  77562. /**
  77563. * An event triggered prior to action being executed.
  77564. */
  77565. onBeforeExecuteObservable: Observable<Action>;
  77566. /**
  77567. * Creates a new Action
  77568. * @param triggerOptions the trigger, with or without parameters, for the action
  77569. * @param condition an optional determinant of action
  77570. */
  77571. constructor(
  77572. /** the trigger, with or without parameters, for the action */
  77573. triggerOptions: any, condition?: Condition);
  77574. /**
  77575. * Internal only
  77576. * @hidden
  77577. */
  77578. _prepare(): void;
  77579. /**
  77580. * Gets the trigger parameters
  77581. * @returns the trigger parameters
  77582. */
  77583. getTriggerParameter(): any;
  77584. /**
  77585. * Internal only - executes current action event
  77586. * @hidden
  77587. */
  77588. _executeCurrent(evt?: ActionEvent): void;
  77589. /**
  77590. * Execute placeholder for child classes
  77591. * @param evt optional action event
  77592. */
  77593. execute(evt?: ActionEvent): void;
  77594. /**
  77595. * Skips to next active action
  77596. */
  77597. skipToNextActiveAction(): void;
  77598. /**
  77599. * Adds action to chain of actions, may be a DoNothingAction
  77600. * @param action defines the next action to execute
  77601. * @returns The action passed in
  77602. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77603. */
  77604. then(action: Action): Action;
  77605. /**
  77606. * Internal only
  77607. * @hidden
  77608. */
  77609. _getProperty(propertyPath: string): string;
  77610. /**
  77611. * Internal only
  77612. * @hidden
  77613. */
  77614. _getEffectiveTarget(target: any, propertyPath: string): any;
  77615. /**
  77616. * Serialize placeholder for child classes
  77617. * @param parent of child
  77618. * @returns the serialized object
  77619. */
  77620. serialize(parent: any): any;
  77621. /**
  77622. * Internal only called by serialize
  77623. * @hidden
  77624. */
  77625. protected _serialize(serializedAction: any, parent?: any): any;
  77626. /**
  77627. * Internal only
  77628. * @hidden
  77629. */
  77630. static _SerializeValueAsString: (value: any) => string;
  77631. /**
  77632. * Internal only
  77633. * @hidden
  77634. */
  77635. static _GetTargetProperty: (target: Node | Scene) => {
  77636. name: string;
  77637. targetType: string;
  77638. value: string;
  77639. };
  77640. }
  77641. }
  77642. declare module BABYLON {
  77643. /**
  77644. * A Condition applied to an Action
  77645. */
  77646. export class Condition {
  77647. /**
  77648. * Internal only - manager for action
  77649. * @hidden
  77650. */
  77651. _actionManager: ActionManager;
  77652. /**
  77653. * Internal only
  77654. * @hidden
  77655. */
  77656. _evaluationId: number;
  77657. /**
  77658. * Internal only
  77659. * @hidden
  77660. */
  77661. _currentResult: boolean;
  77662. /**
  77663. * Creates a new Condition
  77664. * @param actionManager the manager of the action the condition is applied to
  77665. */
  77666. constructor(actionManager: ActionManager);
  77667. /**
  77668. * Check if the current condition is valid
  77669. * @returns a boolean
  77670. */
  77671. isValid(): boolean;
  77672. /**
  77673. * Internal only
  77674. * @hidden
  77675. */
  77676. _getProperty(propertyPath: string): string;
  77677. /**
  77678. * Internal only
  77679. * @hidden
  77680. */
  77681. _getEffectiveTarget(target: any, propertyPath: string): any;
  77682. /**
  77683. * Serialize placeholder for child classes
  77684. * @returns the serialized object
  77685. */
  77686. serialize(): any;
  77687. /**
  77688. * Internal only
  77689. * @hidden
  77690. */
  77691. protected _serialize(serializedCondition: any): any;
  77692. }
  77693. /**
  77694. * Defines specific conditional operators as extensions of Condition
  77695. */
  77696. export class ValueCondition extends Condition {
  77697. /** path to specify the property of the target the conditional operator uses */
  77698. propertyPath: string;
  77699. /** the value compared by the conditional operator against the current value of the property */
  77700. value: any;
  77701. /** the conditional operator, default ValueCondition.IsEqual */
  77702. operator: number;
  77703. /**
  77704. * Internal only
  77705. * @hidden
  77706. */
  77707. private static _IsEqual;
  77708. /**
  77709. * Internal only
  77710. * @hidden
  77711. */
  77712. private static _IsDifferent;
  77713. /**
  77714. * Internal only
  77715. * @hidden
  77716. */
  77717. private static _IsGreater;
  77718. /**
  77719. * Internal only
  77720. * @hidden
  77721. */
  77722. private static _IsLesser;
  77723. /**
  77724. * returns the number for IsEqual
  77725. */
  77726. static readonly IsEqual: number;
  77727. /**
  77728. * Returns the number for IsDifferent
  77729. */
  77730. static readonly IsDifferent: number;
  77731. /**
  77732. * Returns the number for IsGreater
  77733. */
  77734. static readonly IsGreater: number;
  77735. /**
  77736. * Returns the number for IsLesser
  77737. */
  77738. static readonly IsLesser: number;
  77739. /**
  77740. * Internal only The action manager for the condition
  77741. * @hidden
  77742. */
  77743. _actionManager: ActionManager;
  77744. /**
  77745. * Internal only
  77746. * @hidden
  77747. */
  77748. private _target;
  77749. /**
  77750. * Internal only
  77751. * @hidden
  77752. */
  77753. private _effectiveTarget;
  77754. /**
  77755. * Internal only
  77756. * @hidden
  77757. */
  77758. private _property;
  77759. /**
  77760. * Creates a new ValueCondition
  77761. * @param actionManager manager for the action the condition applies to
  77762. * @param target for the action
  77763. * @param propertyPath path to specify the property of the target the conditional operator uses
  77764. * @param value the value compared by the conditional operator against the current value of the property
  77765. * @param operator the conditional operator, default ValueCondition.IsEqual
  77766. */
  77767. constructor(actionManager: ActionManager, target: any,
  77768. /** path to specify the property of the target the conditional operator uses */
  77769. propertyPath: string,
  77770. /** the value compared by the conditional operator against the current value of the property */
  77771. value: any,
  77772. /** the conditional operator, default ValueCondition.IsEqual */
  77773. operator?: number);
  77774. /**
  77775. * Compares the given value with the property value for the specified conditional operator
  77776. * @returns the result of the comparison
  77777. */
  77778. isValid(): boolean;
  77779. /**
  77780. * Serialize the ValueCondition into a JSON compatible object
  77781. * @returns serialization object
  77782. */
  77783. serialize(): any;
  77784. /**
  77785. * Gets the name of the conditional operator for the ValueCondition
  77786. * @param operator the conditional operator
  77787. * @returns the name
  77788. */
  77789. static GetOperatorName(operator: number): string;
  77790. }
  77791. /**
  77792. * Defines a predicate condition as an extension of Condition
  77793. */
  77794. export class PredicateCondition extends Condition {
  77795. /** defines the predicate function used to validate the condition */
  77796. predicate: () => boolean;
  77797. /**
  77798. * Internal only - manager for action
  77799. * @hidden
  77800. */
  77801. _actionManager: ActionManager;
  77802. /**
  77803. * Creates a new PredicateCondition
  77804. * @param actionManager manager for the action the condition applies to
  77805. * @param predicate defines the predicate function used to validate the condition
  77806. */
  77807. constructor(actionManager: ActionManager,
  77808. /** defines the predicate function used to validate the condition */
  77809. predicate: () => boolean);
  77810. /**
  77811. * @returns the validity of the predicate condition
  77812. */
  77813. isValid(): boolean;
  77814. }
  77815. /**
  77816. * Defines a state condition as an extension of Condition
  77817. */
  77818. export class StateCondition extends Condition {
  77819. /** Value to compare with target state */
  77820. value: string;
  77821. /**
  77822. * Internal only - manager for action
  77823. * @hidden
  77824. */
  77825. _actionManager: ActionManager;
  77826. /**
  77827. * Internal only
  77828. * @hidden
  77829. */
  77830. private _target;
  77831. /**
  77832. * Creates a new StateCondition
  77833. * @param actionManager manager for the action the condition applies to
  77834. * @param target of the condition
  77835. * @param value to compare with target state
  77836. */
  77837. constructor(actionManager: ActionManager, target: any,
  77838. /** Value to compare with target state */
  77839. value: string);
  77840. /**
  77841. * Gets a boolean indicating if the current condition is met
  77842. * @returns the validity of the state
  77843. */
  77844. isValid(): boolean;
  77845. /**
  77846. * Serialize the StateCondition into a JSON compatible object
  77847. * @returns serialization object
  77848. */
  77849. serialize(): any;
  77850. }
  77851. }
  77852. declare module BABYLON {
  77853. /**
  77854. * This defines an action responsible to toggle a boolean once triggered.
  77855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77856. */
  77857. export class SwitchBooleanAction extends Action {
  77858. /**
  77859. * The path to the boolean property in the target object
  77860. */
  77861. propertyPath: string;
  77862. private _target;
  77863. private _effectiveTarget;
  77864. private _property;
  77865. /**
  77866. * Instantiate the action
  77867. * @param triggerOptions defines the trigger options
  77868. * @param target defines the object containing the boolean
  77869. * @param propertyPath defines the path to the boolean property in the target object
  77870. * @param condition defines the trigger related conditions
  77871. */
  77872. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77873. /** @hidden */
  77874. _prepare(): void;
  77875. /**
  77876. * Execute the action toggle the boolean value.
  77877. */
  77878. execute(): void;
  77879. /**
  77880. * Serializes the actions and its related information.
  77881. * @param parent defines the object to serialize in
  77882. * @returns the serialized object
  77883. */
  77884. serialize(parent: any): any;
  77885. }
  77886. /**
  77887. * This defines an action responsible to set a the state field of the target
  77888. * to a desired value once triggered.
  77889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77890. */
  77891. export class SetStateAction extends Action {
  77892. /**
  77893. * The value to store in the state field.
  77894. */
  77895. value: string;
  77896. private _target;
  77897. /**
  77898. * Instantiate the action
  77899. * @param triggerOptions defines the trigger options
  77900. * @param target defines the object containing the state property
  77901. * @param value defines the value to store in the state field
  77902. * @param condition defines the trigger related conditions
  77903. */
  77904. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77905. /**
  77906. * Execute the action and store the value on the target state property.
  77907. */
  77908. execute(): void;
  77909. /**
  77910. * Serializes the actions and its related information.
  77911. * @param parent defines the object to serialize in
  77912. * @returns the serialized object
  77913. */
  77914. serialize(parent: any): any;
  77915. }
  77916. /**
  77917. * This defines an action responsible to set a property of the target
  77918. * to a desired value once triggered.
  77919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77920. */
  77921. export class SetValueAction extends Action {
  77922. /**
  77923. * The path of the property to set in the target.
  77924. */
  77925. propertyPath: string;
  77926. /**
  77927. * The value to set in the property
  77928. */
  77929. value: any;
  77930. private _target;
  77931. private _effectiveTarget;
  77932. private _property;
  77933. /**
  77934. * Instantiate the action
  77935. * @param triggerOptions defines the trigger options
  77936. * @param target defines the object containing the property
  77937. * @param propertyPath defines the path of the property to set in the target
  77938. * @param value defines the value to set in the property
  77939. * @param condition defines the trigger related conditions
  77940. */
  77941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77942. /** @hidden */
  77943. _prepare(): void;
  77944. /**
  77945. * Execute the action and set the targetted property to the desired value.
  77946. */
  77947. execute(): void;
  77948. /**
  77949. * Serializes the actions and its related information.
  77950. * @param parent defines the object to serialize in
  77951. * @returns the serialized object
  77952. */
  77953. serialize(parent: any): any;
  77954. }
  77955. /**
  77956. * This defines an action responsible to increment the target value
  77957. * to a desired value once triggered.
  77958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77959. */
  77960. export class IncrementValueAction extends Action {
  77961. /**
  77962. * The path of the property to increment in the target.
  77963. */
  77964. propertyPath: string;
  77965. /**
  77966. * The value we should increment the property by.
  77967. */
  77968. value: any;
  77969. private _target;
  77970. private _effectiveTarget;
  77971. private _property;
  77972. /**
  77973. * Instantiate the action
  77974. * @param triggerOptions defines the trigger options
  77975. * @param target defines the object containing the property
  77976. * @param propertyPath defines the path of the property to increment in the target
  77977. * @param value defines the value value we should increment the property by
  77978. * @param condition defines the trigger related conditions
  77979. */
  77980. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77981. /** @hidden */
  77982. _prepare(): void;
  77983. /**
  77984. * Execute the action and increment the target of the value amount.
  77985. */
  77986. execute(): void;
  77987. /**
  77988. * Serializes the actions and its related information.
  77989. * @param parent defines the object to serialize in
  77990. * @returns the serialized object
  77991. */
  77992. serialize(parent: any): any;
  77993. }
  77994. /**
  77995. * This defines an action responsible to start an animation once triggered.
  77996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77997. */
  77998. export class PlayAnimationAction extends Action {
  77999. /**
  78000. * Where the animation should start (animation frame)
  78001. */
  78002. from: number;
  78003. /**
  78004. * Where the animation should stop (animation frame)
  78005. */
  78006. to: number;
  78007. /**
  78008. * Define if the animation should loop or stop after the first play.
  78009. */
  78010. loop?: boolean;
  78011. private _target;
  78012. /**
  78013. * Instantiate the action
  78014. * @param triggerOptions defines the trigger options
  78015. * @param target defines the target animation or animation name
  78016. * @param from defines from where the animation should start (animation frame)
  78017. * @param end defines where the animation should stop (animation frame)
  78018. * @param loop defines if the animation should loop or stop after the first play
  78019. * @param condition defines the trigger related conditions
  78020. */
  78021. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78022. /** @hidden */
  78023. _prepare(): void;
  78024. /**
  78025. * Execute the action and play the animation.
  78026. */
  78027. execute(): void;
  78028. /**
  78029. * Serializes the actions and its related information.
  78030. * @param parent defines the object to serialize in
  78031. * @returns the serialized object
  78032. */
  78033. serialize(parent: any): any;
  78034. }
  78035. /**
  78036. * This defines an action responsible to stop an animation once triggered.
  78037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78038. */
  78039. export class StopAnimationAction extends Action {
  78040. private _target;
  78041. /**
  78042. * Instantiate the action
  78043. * @param triggerOptions defines the trigger options
  78044. * @param target defines the target animation or animation name
  78045. * @param condition defines the trigger related conditions
  78046. */
  78047. constructor(triggerOptions: any, target: any, condition?: Condition);
  78048. /** @hidden */
  78049. _prepare(): void;
  78050. /**
  78051. * Execute the action and stop the animation.
  78052. */
  78053. execute(): void;
  78054. /**
  78055. * Serializes the actions and its related information.
  78056. * @param parent defines the object to serialize in
  78057. * @returns the serialized object
  78058. */
  78059. serialize(parent: any): any;
  78060. }
  78061. /**
  78062. * This defines an action responsible that does nothing once triggered.
  78063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78064. */
  78065. export class DoNothingAction extends Action {
  78066. /**
  78067. * Instantiate the action
  78068. * @param triggerOptions defines the trigger options
  78069. * @param condition defines the trigger related conditions
  78070. */
  78071. constructor(triggerOptions?: any, condition?: Condition);
  78072. /**
  78073. * Execute the action and do nothing.
  78074. */
  78075. execute(): void;
  78076. /**
  78077. * Serializes the actions and its related information.
  78078. * @param parent defines the object to serialize in
  78079. * @returns the serialized object
  78080. */
  78081. serialize(parent: any): any;
  78082. }
  78083. /**
  78084. * This defines an action responsible to trigger several actions once triggered.
  78085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78086. */
  78087. export class CombineAction extends Action {
  78088. /**
  78089. * The list of aggregated animations to run.
  78090. */
  78091. children: Action[];
  78092. /**
  78093. * Instantiate the action
  78094. * @param triggerOptions defines the trigger options
  78095. * @param children defines the list of aggregated animations to run
  78096. * @param condition defines the trigger related conditions
  78097. */
  78098. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78099. /** @hidden */
  78100. _prepare(): void;
  78101. /**
  78102. * Execute the action and executes all the aggregated actions.
  78103. */
  78104. execute(evt: ActionEvent): void;
  78105. /**
  78106. * Serializes the actions and its related information.
  78107. * @param parent defines the object to serialize in
  78108. * @returns the serialized object
  78109. */
  78110. serialize(parent: any): any;
  78111. }
  78112. /**
  78113. * This defines an action responsible to run code (external event) once triggered.
  78114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78115. */
  78116. export class ExecuteCodeAction extends Action {
  78117. /**
  78118. * The callback function to run.
  78119. */
  78120. func: (evt: ActionEvent) => void;
  78121. /**
  78122. * Instantiate the action
  78123. * @param triggerOptions defines the trigger options
  78124. * @param func defines the callback function to run
  78125. * @param condition defines the trigger related conditions
  78126. */
  78127. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78128. /**
  78129. * Execute the action and run the attached code.
  78130. */
  78131. execute(evt: ActionEvent): void;
  78132. }
  78133. /**
  78134. * This defines an action responsible to set the parent property of the target once triggered.
  78135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78136. */
  78137. export class SetParentAction extends Action {
  78138. private _parent;
  78139. private _target;
  78140. /**
  78141. * Instantiate the action
  78142. * @param triggerOptions defines the trigger options
  78143. * @param target defines the target containing the parent property
  78144. * @param parent defines from where the animation should start (animation frame)
  78145. * @param condition defines the trigger related conditions
  78146. */
  78147. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78148. /** @hidden */
  78149. _prepare(): void;
  78150. /**
  78151. * Execute the action and set the parent property.
  78152. */
  78153. execute(): void;
  78154. /**
  78155. * Serializes the actions and its related information.
  78156. * @param parent defines the object to serialize in
  78157. * @returns the serialized object
  78158. */
  78159. serialize(parent: any): any;
  78160. }
  78161. }
  78162. declare module BABYLON {
  78163. /**
  78164. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78165. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78167. */
  78168. export class ActionManager extends AbstractActionManager {
  78169. /**
  78170. * Nothing
  78171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78172. */
  78173. static readonly NothingTrigger: number;
  78174. /**
  78175. * On pick
  78176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78177. */
  78178. static readonly OnPickTrigger: number;
  78179. /**
  78180. * On left pick
  78181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78182. */
  78183. static readonly OnLeftPickTrigger: number;
  78184. /**
  78185. * On right pick
  78186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78187. */
  78188. static readonly OnRightPickTrigger: number;
  78189. /**
  78190. * On center pick
  78191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78192. */
  78193. static readonly OnCenterPickTrigger: number;
  78194. /**
  78195. * On pick down
  78196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78197. */
  78198. static readonly OnPickDownTrigger: number;
  78199. /**
  78200. * On double pick
  78201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78202. */
  78203. static readonly OnDoublePickTrigger: number;
  78204. /**
  78205. * On pick up
  78206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78207. */
  78208. static readonly OnPickUpTrigger: number;
  78209. /**
  78210. * On pick out.
  78211. * This trigger will only be raised if you also declared a OnPickDown
  78212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78213. */
  78214. static readonly OnPickOutTrigger: number;
  78215. /**
  78216. * On long press
  78217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78218. */
  78219. static readonly OnLongPressTrigger: number;
  78220. /**
  78221. * On pointer over
  78222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78223. */
  78224. static readonly OnPointerOverTrigger: number;
  78225. /**
  78226. * On pointer out
  78227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78228. */
  78229. static readonly OnPointerOutTrigger: number;
  78230. /**
  78231. * On every frame
  78232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78233. */
  78234. static readonly OnEveryFrameTrigger: number;
  78235. /**
  78236. * On intersection enter
  78237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78238. */
  78239. static readonly OnIntersectionEnterTrigger: number;
  78240. /**
  78241. * On intersection exit
  78242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78243. */
  78244. static readonly OnIntersectionExitTrigger: number;
  78245. /**
  78246. * On key down
  78247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78248. */
  78249. static readonly OnKeyDownTrigger: number;
  78250. /**
  78251. * On key up
  78252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78253. */
  78254. static readonly OnKeyUpTrigger: number;
  78255. private _scene;
  78256. /**
  78257. * Creates a new action manager
  78258. * @param scene defines the hosting scene
  78259. */
  78260. constructor(scene: Scene);
  78261. /**
  78262. * Releases all associated resources
  78263. */
  78264. dispose(): void;
  78265. /**
  78266. * Gets hosting scene
  78267. * @returns the hosting scene
  78268. */
  78269. getScene(): Scene;
  78270. /**
  78271. * Does this action manager handles actions of any of the given triggers
  78272. * @param triggers defines the triggers to be tested
  78273. * @return a boolean indicating whether one (or more) of the triggers is handled
  78274. */
  78275. hasSpecificTriggers(triggers: number[]): boolean;
  78276. /**
  78277. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78278. * speed.
  78279. * @param triggerA defines the trigger to be tested
  78280. * @param triggerB defines the trigger to be tested
  78281. * @return a boolean indicating whether one (or more) of the triggers is handled
  78282. */
  78283. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78284. /**
  78285. * Does this action manager handles actions of a given trigger
  78286. * @param trigger defines the trigger to be tested
  78287. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78288. * @return whether the trigger is handled
  78289. */
  78290. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78291. /**
  78292. * Does this action manager has pointer triggers
  78293. */
  78294. readonly hasPointerTriggers: boolean;
  78295. /**
  78296. * Does this action manager has pick triggers
  78297. */
  78298. readonly hasPickTriggers: boolean;
  78299. /**
  78300. * Registers an action to this action manager
  78301. * @param action defines the action to be registered
  78302. * @return the action amended (prepared) after registration
  78303. */
  78304. registerAction(action: IAction): Nullable<IAction>;
  78305. /**
  78306. * Unregisters an action to this action manager
  78307. * @param action defines the action to be unregistered
  78308. * @return a boolean indicating whether the action has been unregistered
  78309. */
  78310. unregisterAction(action: IAction): Boolean;
  78311. /**
  78312. * Process a specific trigger
  78313. * @param trigger defines the trigger to process
  78314. * @param evt defines the event details to be processed
  78315. */
  78316. processTrigger(trigger: number, evt?: IActionEvent): void;
  78317. /** @hidden */
  78318. _getEffectiveTarget(target: any, propertyPath: string): any;
  78319. /** @hidden */
  78320. _getProperty(propertyPath: string): string;
  78321. /**
  78322. * Serialize this manager to a JSON object
  78323. * @param name defines the property name to store this manager
  78324. * @returns a JSON representation of this manager
  78325. */
  78326. serialize(name: string): any;
  78327. /**
  78328. * Creates a new ActionManager from a JSON data
  78329. * @param parsedActions defines the JSON data to read from
  78330. * @param object defines the hosting mesh
  78331. * @param scene defines the hosting scene
  78332. */
  78333. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78334. /**
  78335. * Get a trigger name by index
  78336. * @param trigger defines the trigger index
  78337. * @returns a trigger name
  78338. */
  78339. static GetTriggerName(trigger: number): string;
  78340. }
  78341. }
  78342. declare module BABYLON {
  78343. /**
  78344. * Class representing a ray with position and direction
  78345. */
  78346. export class Ray {
  78347. /** origin point */
  78348. origin: Vector3;
  78349. /** direction */
  78350. direction: Vector3;
  78351. /** length of the ray */
  78352. length: number;
  78353. private static readonly TmpVector3;
  78354. private _tmpRay;
  78355. /**
  78356. * Creates a new ray
  78357. * @param origin origin point
  78358. * @param direction direction
  78359. * @param length length of the ray
  78360. */
  78361. constructor(
  78362. /** origin point */
  78363. origin: Vector3,
  78364. /** direction */
  78365. direction: Vector3,
  78366. /** length of the ray */
  78367. length?: number);
  78368. /**
  78369. * Checks if the ray intersects a box
  78370. * @param minimum bound of the box
  78371. * @param maximum bound of the box
  78372. * @param intersectionTreshold extra extend to be added to the box in all direction
  78373. * @returns if the box was hit
  78374. */
  78375. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78376. /**
  78377. * Checks if the ray intersects a box
  78378. * @param box the bounding box to check
  78379. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78380. * @returns if the box was hit
  78381. */
  78382. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78383. /**
  78384. * If the ray hits a sphere
  78385. * @param sphere the bounding sphere to check
  78386. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78387. * @returns true if it hits the sphere
  78388. */
  78389. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78390. /**
  78391. * If the ray hits a triange
  78392. * @param vertex0 triangle vertex
  78393. * @param vertex1 triangle vertex
  78394. * @param vertex2 triangle vertex
  78395. * @returns intersection information if hit
  78396. */
  78397. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78398. /**
  78399. * Checks if ray intersects a plane
  78400. * @param plane the plane to check
  78401. * @returns the distance away it was hit
  78402. */
  78403. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78404. /**
  78405. * Calculate the intercept of a ray on a given axis
  78406. * @param axis to check 'x' | 'y' | 'z'
  78407. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78408. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78409. */
  78410. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78411. /**
  78412. * Checks if ray intersects a mesh
  78413. * @param mesh the mesh to check
  78414. * @param fastCheck if only the bounding box should checked
  78415. * @returns picking info of the intersecton
  78416. */
  78417. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78418. /**
  78419. * Checks if ray intersects a mesh
  78420. * @param meshes the meshes to check
  78421. * @param fastCheck if only the bounding box should checked
  78422. * @param results array to store result in
  78423. * @returns Array of picking infos
  78424. */
  78425. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78426. private _comparePickingInfo;
  78427. private static smallnum;
  78428. private static rayl;
  78429. /**
  78430. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78431. * @param sega the first point of the segment to test the intersection against
  78432. * @param segb the second point of the segment to test the intersection against
  78433. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78434. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78435. */
  78436. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78437. /**
  78438. * Update the ray from viewport position
  78439. * @param x position
  78440. * @param y y position
  78441. * @param viewportWidth viewport width
  78442. * @param viewportHeight viewport height
  78443. * @param world world matrix
  78444. * @param view view matrix
  78445. * @param projection projection matrix
  78446. * @returns this ray updated
  78447. */
  78448. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78449. /**
  78450. * Creates a ray with origin and direction of 0,0,0
  78451. * @returns the new ray
  78452. */
  78453. static Zero(): Ray;
  78454. /**
  78455. * Creates a new ray from screen space and viewport
  78456. * @param x position
  78457. * @param y y position
  78458. * @param viewportWidth viewport width
  78459. * @param viewportHeight viewport height
  78460. * @param world world matrix
  78461. * @param view view matrix
  78462. * @param projection projection matrix
  78463. * @returns new ray
  78464. */
  78465. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78466. /**
  78467. * 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
  78468. * transformed to the given world matrix.
  78469. * @param origin The origin point
  78470. * @param end The end point
  78471. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78472. * @returns the new ray
  78473. */
  78474. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78475. /**
  78476. * Transforms a ray by a matrix
  78477. * @param ray ray to transform
  78478. * @param matrix matrix to apply
  78479. * @returns the resulting new ray
  78480. */
  78481. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78482. /**
  78483. * Transforms a ray by a matrix
  78484. * @param ray ray to transform
  78485. * @param matrix matrix to apply
  78486. * @param result ray to store result in
  78487. */
  78488. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78489. /**
  78490. * Unproject a ray from screen space to object space
  78491. * @param sourceX defines the screen space x coordinate to use
  78492. * @param sourceY defines the screen space y coordinate to use
  78493. * @param viewportWidth defines the current width of the viewport
  78494. * @param viewportHeight defines the current height of the viewport
  78495. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78496. * @param view defines the view matrix to use
  78497. * @param projection defines the projection matrix to use
  78498. */
  78499. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78500. }
  78501. /**
  78502. * Type used to define predicate used to select faces when a mesh intersection is detected
  78503. */
  78504. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78505. interface Scene {
  78506. /** @hidden */
  78507. _tempPickingRay: Nullable<Ray>;
  78508. /** @hidden */
  78509. _cachedRayForTransform: Ray;
  78510. /** @hidden */
  78511. _pickWithRayInverseMatrix: Matrix;
  78512. /** @hidden */
  78513. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78514. /** @hidden */
  78515. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78516. }
  78517. }
  78518. declare module BABYLON {
  78519. /**
  78520. * Groups all the scene component constants in one place to ease maintenance.
  78521. * @hidden
  78522. */
  78523. export class SceneComponentConstants {
  78524. static readonly NAME_EFFECTLAYER: string;
  78525. static readonly NAME_LAYER: string;
  78526. static readonly NAME_LENSFLARESYSTEM: string;
  78527. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78528. static readonly NAME_PARTICLESYSTEM: string;
  78529. static readonly NAME_GAMEPAD: string;
  78530. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78531. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78532. static readonly NAME_DEPTHRENDERER: string;
  78533. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78534. static readonly NAME_SPRITE: string;
  78535. static readonly NAME_OUTLINERENDERER: string;
  78536. static readonly NAME_PROCEDURALTEXTURE: string;
  78537. static readonly NAME_SHADOWGENERATOR: string;
  78538. static readonly NAME_OCTREE: string;
  78539. static readonly NAME_PHYSICSENGINE: string;
  78540. static readonly NAME_AUDIO: string;
  78541. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78542. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78543. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78544. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78545. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78546. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78547. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78548. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78549. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78550. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78551. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78552. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78553. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78554. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78555. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78556. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78557. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78558. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78559. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78560. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78561. static readonly STEP_AFTERRENDER_AUDIO: number;
  78562. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78563. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78564. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78565. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78566. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78567. static readonly STEP_POINTERMOVE_SPRITE: number;
  78568. static readonly STEP_POINTERDOWN_SPRITE: number;
  78569. static readonly STEP_POINTERUP_SPRITE: number;
  78570. }
  78571. /**
  78572. * This represents a scene component.
  78573. *
  78574. * This is used to decouple the dependency the scene is having on the different workloads like
  78575. * layers, post processes...
  78576. */
  78577. export interface ISceneComponent {
  78578. /**
  78579. * The name of the component. Each component must have a unique name.
  78580. */
  78581. name: string;
  78582. /**
  78583. * The scene the component belongs to.
  78584. */
  78585. scene: Scene;
  78586. /**
  78587. * Register the component to one instance of a scene.
  78588. */
  78589. register(): void;
  78590. /**
  78591. * Rebuilds the elements related to this component in case of
  78592. * context lost for instance.
  78593. */
  78594. rebuild(): void;
  78595. /**
  78596. * Disposes the component and the associated ressources.
  78597. */
  78598. dispose(): void;
  78599. }
  78600. /**
  78601. * This represents a SERIALIZABLE scene component.
  78602. *
  78603. * This extends Scene Component to add Serialization methods on top.
  78604. */
  78605. export interface ISceneSerializableComponent extends ISceneComponent {
  78606. /**
  78607. * Adds all the elements from the container to the scene
  78608. * @param container the container holding the elements
  78609. */
  78610. addFromContainer(container: AbstractScene): void;
  78611. /**
  78612. * Removes all the elements in the container from the scene
  78613. * @param container contains the elements to remove
  78614. * @param dispose if the removed element should be disposed (default: false)
  78615. */
  78616. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78617. /**
  78618. * Serializes the component data to the specified json object
  78619. * @param serializationObject The object to serialize to
  78620. */
  78621. serialize(serializationObject: any): void;
  78622. }
  78623. /**
  78624. * Strong typing of a Mesh related stage step action
  78625. */
  78626. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78627. /**
  78628. * Strong typing of a Evaluate Sub Mesh related stage step action
  78629. */
  78630. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78631. /**
  78632. * Strong typing of a Active Mesh related stage step action
  78633. */
  78634. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78635. /**
  78636. * Strong typing of a Camera related stage step action
  78637. */
  78638. export type CameraStageAction = (camera: Camera) => void;
  78639. /**
  78640. * Strong typing of a Camera Frame buffer related stage step action
  78641. */
  78642. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78643. /**
  78644. * Strong typing of a Render Target related stage step action
  78645. */
  78646. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78647. /**
  78648. * Strong typing of a RenderingGroup related stage step action
  78649. */
  78650. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78651. /**
  78652. * Strong typing of a Mesh Render related stage step action
  78653. */
  78654. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78655. /**
  78656. * Strong typing of a simple stage step action
  78657. */
  78658. export type SimpleStageAction = () => void;
  78659. /**
  78660. * Strong typing of a render target action.
  78661. */
  78662. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78663. /**
  78664. * Strong typing of a pointer move action.
  78665. */
  78666. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78667. /**
  78668. * Strong typing of a pointer up/down action.
  78669. */
  78670. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78671. /**
  78672. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78673. * @hidden
  78674. */
  78675. export class Stage<T extends Function> extends Array<{
  78676. index: number;
  78677. component: ISceneComponent;
  78678. action: T;
  78679. }> {
  78680. /**
  78681. * Hide ctor from the rest of the world.
  78682. * @param items The items to add.
  78683. */
  78684. private constructor();
  78685. /**
  78686. * Creates a new Stage.
  78687. * @returns A new instance of a Stage
  78688. */
  78689. static Create<T extends Function>(): Stage<T>;
  78690. /**
  78691. * Registers a step in an ordered way in the targeted stage.
  78692. * @param index Defines the position to register the step in
  78693. * @param component Defines the component attached to the step
  78694. * @param action Defines the action to launch during the step
  78695. */
  78696. registerStep(index: number, component: ISceneComponent, action: T): void;
  78697. /**
  78698. * Clears all the steps from the stage.
  78699. */
  78700. clear(): void;
  78701. }
  78702. }
  78703. declare module BABYLON {
  78704. interface Scene {
  78705. /** @hidden */
  78706. _pointerOverSprite: Nullable<Sprite>;
  78707. /** @hidden */
  78708. _pickedDownSprite: Nullable<Sprite>;
  78709. /** @hidden */
  78710. _tempSpritePickingRay: Nullable<Ray>;
  78711. /**
  78712. * All of the sprite managers added to this scene
  78713. * @see http://doc.babylonjs.com/babylon101/sprites
  78714. */
  78715. spriteManagers: Array<ISpriteManager>;
  78716. /**
  78717. * An event triggered when sprites rendering is about to start
  78718. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78719. */
  78720. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78721. /**
  78722. * An event triggered when sprites rendering is done
  78723. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78724. */
  78725. onAfterSpritesRenderingObservable: Observable<Scene>;
  78726. /** @hidden */
  78727. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78728. /** Launch a ray to try to pick a sprite in the scene
  78729. * @param x position on screen
  78730. * @param y position on screen
  78731. * @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
  78732. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78733. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78734. * @returns a PickingInfo
  78735. */
  78736. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78737. /** Use the given ray to pick a sprite in the scene
  78738. * @param ray The ray (in world space) to use to pick meshes
  78739. * @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
  78740. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78741. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78742. * @returns a PickingInfo
  78743. */
  78744. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78745. /** @hidden */
  78746. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78747. /** Launch a ray to try to pick sprites in the scene
  78748. * @param x position on screen
  78749. * @param y position on screen
  78750. * @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
  78751. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78752. * @returns a PickingInfo array
  78753. */
  78754. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78755. /** Use the given ray to pick sprites in the scene
  78756. * @param ray The ray (in world space) to use to pick meshes
  78757. * @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
  78758. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78759. * @returns a PickingInfo array
  78760. */
  78761. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78762. /**
  78763. * Force the sprite under the pointer
  78764. * @param sprite defines the sprite to use
  78765. */
  78766. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78767. /**
  78768. * Gets the sprite under the pointer
  78769. * @returns a Sprite or null if no sprite is under the pointer
  78770. */
  78771. getPointerOverSprite(): Nullable<Sprite>;
  78772. }
  78773. /**
  78774. * Defines the sprite scene component responsible to manage sprites
  78775. * in a given scene.
  78776. */
  78777. export class SpriteSceneComponent implements ISceneComponent {
  78778. /**
  78779. * The component name helpfull to identify the component in the list of scene components.
  78780. */
  78781. readonly name: string;
  78782. /**
  78783. * The scene the component belongs to.
  78784. */
  78785. scene: Scene;
  78786. /** @hidden */
  78787. private _spritePredicate;
  78788. /**
  78789. * Creates a new instance of the component for the given scene
  78790. * @param scene Defines the scene to register the component in
  78791. */
  78792. constructor(scene: Scene);
  78793. /**
  78794. * Registers the component in a given scene
  78795. */
  78796. register(): void;
  78797. /**
  78798. * Rebuilds the elements related to this component in case of
  78799. * context lost for instance.
  78800. */
  78801. rebuild(): void;
  78802. /**
  78803. * Disposes the component and the associated ressources.
  78804. */
  78805. dispose(): void;
  78806. private _pickSpriteButKeepRay;
  78807. private _pointerMove;
  78808. private _pointerDown;
  78809. private _pointerUp;
  78810. }
  78811. }
  78812. declare module BABYLON {
  78813. /** @hidden */
  78814. export var fogFragmentDeclaration: {
  78815. name: string;
  78816. shader: string;
  78817. };
  78818. }
  78819. declare module BABYLON {
  78820. /** @hidden */
  78821. export var fogFragment: {
  78822. name: string;
  78823. shader: string;
  78824. };
  78825. }
  78826. declare module BABYLON {
  78827. /** @hidden */
  78828. export var spritesPixelShader: {
  78829. name: string;
  78830. shader: string;
  78831. };
  78832. }
  78833. declare module BABYLON {
  78834. /** @hidden */
  78835. export var fogVertexDeclaration: {
  78836. name: string;
  78837. shader: string;
  78838. };
  78839. }
  78840. declare module BABYLON {
  78841. /** @hidden */
  78842. export var spritesVertexShader: {
  78843. name: string;
  78844. shader: string;
  78845. };
  78846. }
  78847. declare module BABYLON {
  78848. /**
  78849. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78850. */
  78851. export interface ISpriteManager extends IDisposable {
  78852. /**
  78853. * Restricts the camera to viewing objects with the same layerMask.
  78854. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78855. */
  78856. layerMask: number;
  78857. /**
  78858. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78859. */
  78860. isPickable: boolean;
  78861. /**
  78862. * Specifies the rendering group id for this mesh (0 by default)
  78863. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78864. */
  78865. renderingGroupId: number;
  78866. /**
  78867. * Defines the list of sprites managed by the manager.
  78868. */
  78869. sprites: Array<Sprite>;
  78870. /**
  78871. * Tests the intersection of a sprite with a specific ray.
  78872. * @param ray The ray we are sending to test the collision
  78873. * @param camera The camera space we are sending rays in
  78874. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78875. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78876. * @returns picking info or null.
  78877. */
  78878. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78879. /**
  78880. * Intersects the sprites with a ray
  78881. * @param ray defines the ray to intersect with
  78882. * @param camera defines the current active camera
  78883. * @param predicate defines a predicate used to select candidate sprites
  78884. * @returns null if no hit or a PickingInfo array
  78885. */
  78886. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78887. /**
  78888. * Renders the list of sprites on screen.
  78889. */
  78890. render(): void;
  78891. }
  78892. /**
  78893. * Class used to manage multiple sprites on the same spritesheet
  78894. * @see http://doc.babylonjs.com/babylon101/sprites
  78895. */
  78896. export class SpriteManager implements ISpriteManager {
  78897. /** defines the manager's name */
  78898. name: string;
  78899. /** Gets the list of sprites */
  78900. sprites: Sprite[];
  78901. /** Gets or sets the rendering group id (0 by default) */
  78902. renderingGroupId: number;
  78903. /** Gets or sets camera layer mask */
  78904. layerMask: number;
  78905. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78906. fogEnabled: boolean;
  78907. /** Gets or sets a boolean indicating if the sprites are pickable */
  78908. isPickable: boolean;
  78909. /** Defines the default width of a cell in the spritesheet */
  78910. cellWidth: number;
  78911. /** Defines the default height of a cell in the spritesheet */
  78912. cellHeight: number;
  78913. /** Associative array from JSON sprite data file */
  78914. private _cellData;
  78915. /** Array of sprite names from JSON sprite data file */
  78916. private _spriteMap;
  78917. /** True when packed cell data from JSON file is ready*/
  78918. private _packedAndReady;
  78919. /**
  78920. * An event triggered when the manager is disposed.
  78921. */
  78922. onDisposeObservable: Observable<SpriteManager>;
  78923. private _onDisposeObserver;
  78924. /**
  78925. * Callback called when the manager is disposed
  78926. */
  78927. onDispose: () => void;
  78928. private _capacity;
  78929. private _fromPacked;
  78930. private _spriteTexture;
  78931. private _epsilon;
  78932. private _scene;
  78933. private _vertexData;
  78934. private _buffer;
  78935. private _vertexBuffers;
  78936. private _indexBuffer;
  78937. private _effectBase;
  78938. private _effectFog;
  78939. /**
  78940. * Gets or sets the spritesheet texture
  78941. */
  78942. texture: Texture;
  78943. /**
  78944. * Creates a new sprite manager
  78945. * @param name defines the manager's name
  78946. * @param imgUrl defines the sprite sheet url
  78947. * @param capacity defines the maximum allowed number of sprites
  78948. * @param cellSize defines the size of a sprite cell
  78949. * @param scene defines the hosting scene
  78950. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78951. * @param samplingMode defines the smapling mode to use with spritesheet
  78952. * @param fromPacked set to false; do not alter
  78953. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78954. */
  78955. constructor(
  78956. /** defines the manager's name */
  78957. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78958. private _makePacked;
  78959. private _appendSpriteVertex;
  78960. /**
  78961. * Intersects the sprites with a ray
  78962. * @param ray defines the ray to intersect with
  78963. * @param camera defines the current active camera
  78964. * @param predicate defines a predicate used to select candidate sprites
  78965. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78966. * @returns null if no hit or a PickingInfo
  78967. */
  78968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78969. /**
  78970. * Intersects the sprites with a ray
  78971. * @param ray defines the ray to intersect with
  78972. * @param camera defines the current active camera
  78973. * @param predicate defines a predicate used to select candidate sprites
  78974. * @returns null if no hit or a PickingInfo array
  78975. */
  78976. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78977. /**
  78978. * Render all child sprites
  78979. */
  78980. render(): void;
  78981. /**
  78982. * Release associated resources
  78983. */
  78984. dispose(): void;
  78985. }
  78986. }
  78987. declare module BABYLON {
  78988. /**
  78989. * Class used to represent a sprite
  78990. * @see http://doc.babylonjs.com/babylon101/sprites
  78991. */
  78992. export class Sprite {
  78993. /** defines the name */
  78994. name: string;
  78995. /** Gets or sets the current world position */
  78996. position: Vector3;
  78997. /** Gets or sets the main color */
  78998. color: Color4;
  78999. /** Gets or sets the width */
  79000. width: number;
  79001. /** Gets or sets the height */
  79002. height: number;
  79003. /** Gets or sets rotation angle */
  79004. angle: number;
  79005. /** Gets or sets the cell index in the sprite sheet */
  79006. cellIndex: number;
  79007. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79008. cellRef: string;
  79009. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79010. invertU: number;
  79011. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79012. invertV: number;
  79013. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79014. disposeWhenFinishedAnimating: boolean;
  79015. /** Gets the list of attached animations */
  79016. animations: Animation[];
  79017. /** Gets or sets a boolean indicating if the sprite can be picked */
  79018. isPickable: boolean;
  79019. /**
  79020. * Gets or sets the associated action manager
  79021. */
  79022. actionManager: Nullable<ActionManager>;
  79023. private _animationStarted;
  79024. private _loopAnimation;
  79025. private _fromIndex;
  79026. private _toIndex;
  79027. private _delay;
  79028. private _direction;
  79029. private _manager;
  79030. private _time;
  79031. private _onAnimationEnd;
  79032. /**
  79033. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79034. */
  79035. isVisible: boolean;
  79036. /**
  79037. * Gets or sets the sprite size
  79038. */
  79039. size: number;
  79040. /**
  79041. * Creates a new Sprite
  79042. * @param name defines the name
  79043. * @param manager defines the manager
  79044. */
  79045. constructor(
  79046. /** defines the name */
  79047. name: string, manager: ISpriteManager);
  79048. /**
  79049. * Starts an animation
  79050. * @param from defines the initial key
  79051. * @param to defines the end key
  79052. * @param loop defines if the animation must loop
  79053. * @param delay defines the start delay (in ms)
  79054. * @param onAnimationEnd defines a callback to call when animation ends
  79055. */
  79056. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79057. /** Stops current animation (if any) */
  79058. stopAnimation(): void;
  79059. /** @hidden */
  79060. _animate(deltaTime: number): void;
  79061. /** Release associated resources */
  79062. dispose(): void;
  79063. }
  79064. }
  79065. declare module BABYLON {
  79066. /**
  79067. * Information about the result of picking within a scene
  79068. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79069. */
  79070. export class PickingInfo {
  79071. /** @hidden */
  79072. _pickingUnavailable: boolean;
  79073. /**
  79074. * If the pick collided with an object
  79075. */
  79076. hit: boolean;
  79077. /**
  79078. * Distance away where the pick collided
  79079. */
  79080. distance: number;
  79081. /**
  79082. * The location of pick collision
  79083. */
  79084. pickedPoint: Nullable<Vector3>;
  79085. /**
  79086. * The mesh corresponding the the pick collision
  79087. */
  79088. pickedMesh: Nullable<AbstractMesh>;
  79089. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79090. bu: number;
  79091. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79092. bv: number;
  79093. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79094. faceId: number;
  79095. /** Id of the the submesh that was picked */
  79096. subMeshId: number;
  79097. /** If a sprite was picked, this will be the sprite the pick collided with */
  79098. pickedSprite: Nullable<Sprite>;
  79099. /**
  79100. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79101. */
  79102. originMesh: Nullable<AbstractMesh>;
  79103. /**
  79104. * The ray that was used to perform the picking.
  79105. */
  79106. ray: Nullable<Ray>;
  79107. /**
  79108. * Gets the normal correspodning to the face the pick collided with
  79109. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79110. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79111. * @returns The normal correspodning to the face the pick collided with
  79112. */
  79113. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79114. /**
  79115. * Gets the texture coordinates of where the pick occured
  79116. * @returns the vector containing the coordnates of the texture
  79117. */
  79118. getTextureCoordinates(): Nullable<Vector2>;
  79119. }
  79120. }
  79121. declare module BABYLON {
  79122. /**
  79123. * Gather the list of pointer event types as constants.
  79124. */
  79125. export class PointerEventTypes {
  79126. /**
  79127. * 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.
  79128. */
  79129. static readonly POINTERDOWN: number;
  79130. /**
  79131. * The pointerup event is fired when a pointer is no longer active.
  79132. */
  79133. static readonly POINTERUP: number;
  79134. /**
  79135. * The pointermove event is fired when a pointer changes coordinates.
  79136. */
  79137. static readonly POINTERMOVE: number;
  79138. /**
  79139. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79140. */
  79141. static readonly POINTERWHEEL: number;
  79142. /**
  79143. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79144. */
  79145. static readonly POINTERPICK: number;
  79146. /**
  79147. * The pointertap event is fired when a the object has been touched and released without drag.
  79148. */
  79149. static readonly POINTERTAP: number;
  79150. /**
  79151. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79152. */
  79153. static readonly POINTERDOUBLETAP: number;
  79154. }
  79155. /**
  79156. * Base class of pointer info types.
  79157. */
  79158. export class PointerInfoBase {
  79159. /**
  79160. * Defines the type of event (PointerEventTypes)
  79161. */
  79162. type: number;
  79163. /**
  79164. * Defines the related dom event
  79165. */
  79166. event: PointerEvent | MouseWheelEvent;
  79167. /**
  79168. * Instantiates the base class of pointers info.
  79169. * @param type Defines the type of event (PointerEventTypes)
  79170. * @param event Defines the related dom event
  79171. */
  79172. constructor(
  79173. /**
  79174. * Defines the type of event (PointerEventTypes)
  79175. */
  79176. type: number,
  79177. /**
  79178. * Defines the related dom event
  79179. */
  79180. event: PointerEvent | MouseWheelEvent);
  79181. }
  79182. /**
  79183. * This class is used to store pointer related info for the onPrePointerObservable event.
  79184. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79185. */
  79186. export class PointerInfoPre extends PointerInfoBase {
  79187. /**
  79188. * Ray from a pointer if availible (eg. 6dof controller)
  79189. */
  79190. ray: Nullable<Ray>;
  79191. /**
  79192. * Defines the local position of the pointer on the canvas.
  79193. */
  79194. localPosition: Vector2;
  79195. /**
  79196. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79197. */
  79198. skipOnPointerObservable: boolean;
  79199. /**
  79200. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79201. * @param type Defines the type of event (PointerEventTypes)
  79202. * @param event Defines the related dom event
  79203. * @param localX Defines the local x coordinates of the pointer when the event occured
  79204. * @param localY Defines the local y coordinates of the pointer when the event occured
  79205. */
  79206. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79207. }
  79208. /**
  79209. * This type contains all the data related to a pointer event in Babylon.js.
  79210. * 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.
  79211. */
  79212. export class PointerInfo extends PointerInfoBase {
  79213. /**
  79214. * Defines the picking info associated to the info (if any)\
  79215. */
  79216. pickInfo: Nullable<PickingInfo>;
  79217. /**
  79218. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79219. * @param type Defines the type of event (PointerEventTypes)
  79220. * @param event Defines the related dom event
  79221. * @param pickInfo Defines the picking info associated to the info (if any)\
  79222. */
  79223. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79224. /**
  79225. * Defines the picking info associated to the info (if any)\
  79226. */
  79227. pickInfo: Nullable<PickingInfo>);
  79228. }
  79229. /**
  79230. * Data relating to a touch event on the screen.
  79231. */
  79232. export interface PointerTouch {
  79233. /**
  79234. * X coordinate of touch.
  79235. */
  79236. x: number;
  79237. /**
  79238. * Y coordinate of touch.
  79239. */
  79240. y: number;
  79241. /**
  79242. * Id of touch. Unique for each finger.
  79243. */
  79244. pointerId: number;
  79245. /**
  79246. * Event type passed from DOM.
  79247. */
  79248. type: any;
  79249. }
  79250. }
  79251. declare module BABYLON {
  79252. /**
  79253. * Manage the mouse inputs to control the movement of a free camera.
  79254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79255. */
  79256. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79257. /**
  79258. * Define if touch is enabled in the mouse input
  79259. */
  79260. touchEnabled: boolean;
  79261. /**
  79262. * Defines the camera the input is attached to.
  79263. */
  79264. camera: FreeCamera;
  79265. /**
  79266. * Defines the buttons associated with the input to handle camera move.
  79267. */
  79268. buttons: number[];
  79269. /**
  79270. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79271. */
  79272. angularSensibility: number;
  79273. private _pointerInput;
  79274. private _onMouseMove;
  79275. private _observer;
  79276. private previousPosition;
  79277. /**
  79278. * Observable for when a pointer move event occurs containing the move offset
  79279. */
  79280. onPointerMovedObservable: Observable<{
  79281. offsetX: number;
  79282. offsetY: number;
  79283. }>;
  79284. /**
  79285. * @hidden
  79286. * If the camera should be rotated automatically based on pointer movement
  79287. */
  79288. _allowCameraRotation: boolean;
  79289. /**
  79290. * Manage the mouse inputs to control the movement of a free camera.
  79291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79292. * @param touchEnabled Defines if touch is enabled or not
  79293. */
  79294. constructor(
  79295. /**
  79296. * Define if touch is enabled in the mouse input
  79297. */
  79298. touchEnabled?: boolean);
  79299. /**
  79300. * Attach the input controls to a specific dom element to get the input from.
  79301. * @param element Defines the element the controls should be listened from
  79302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79303. */
  79304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79305. /**
  79306. * Called on JS contextmenu event.
  79307. * Override this method to provide functionality.
  79308. */
  79309. protected onContextMenu(evt: PointerEvent): void;
  79310. /**
  79311. * Detach the current controls from the specified dom element.
  79312. * @param element Defines the element to stop listening the inputs from
  79313. */
  79314. detachControl(element: Nullable<HTMLElement>): void;
  79315. /**
  79316. * Gets the class name of the current intput.
  79317. * @returns the class name
  79318. */
  79319. getClassName(): string;
  79320. /**
  79321. * Get the friendly name associated with the input class.
  79322. * @returns the input friendly name
  79323. */
  79324. getSimpleName(): string;
  79325. }
  79326. }
  79327. declare module BABYLON {
  79328. /**
  79329. * Manage the touch inputs to control the movement of a free camera.
  79330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79331. */
  79332. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79333. /**
  79334. * Defines the camera the input is attached to.
  79335. */
  79336. camera: FreeCamera;
  79337. /**
  79338. * Defines the touch sensibility for rotation.
  79339. * The higher the faster.
  79340. */
  79341. touchAngularSensibility: number;
  79342. /**
  79343. * Defines the touch sensibility for move.
  79344. * The higher the faster.
  79345. */
  79346. touchMoveSensibility: number;
  79347. private _offsetX;
  79348. private _offsetY;
  79349. private _pointerPressed;
  79350. private _pointerInput;
  79351. private _observer;
  79352. private _onLostFocus;
  79353. /**
  79354. * Attach the input controls to a specific dom element to get the input from.
  79355. * @param element Defines the element the controls should be listened from
  79356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79357. */
  79358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79359. /**
  79360. * Detach the current controls from the specified dom element.
  79361. * @param element Defines the element to stop listening the inputs from
  79362. */
  79363. detachControl(element: Nullable<HTMLElement>): void;
  79364. /**
  79365. * Update the current camera state depending on the inputs that have been used this frame.
  79366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79367. */
  79368. checkInputs(): void;
  79369. /**
  79370. * Gets the class name of the current intput.
  79371. * @returns the class name
  79372. */
  79373. getClassName(): string;
  79374. /**
  79375. * Get the friendly name associated with the input class.
  79376. * @returns the input friendly name
  79377. */
  79378. getSimpleName(): string;
  79379. }
  79380. }
  79381. declare module BABYLON {
  79382. /**
  79383. * Default Inputs manager for the FreeCamera.
  79384. * It groups all the default supported inputs for ease of use.
  79385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79386. */
  79387. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79388. /**
  79389. * @hidden
  79390. */
  79391. _mouseInput: Nullable<FreeCameraMouseInput>;
  79392. /**
  79393. * Instantiates a new FreeCameraInputsManager.
  79394. * @param camera Defines the camera the inputs belong to
  79395. */
  79396. constructor(camera: FreeCamera);
  79397. /**
  79398. * Add keyboard input support to the input manager.
  79399. * @returns the current input manager
  79400. */
  79401. addKeyboard(): FreeCameraInputsManager;
  79402. /**
  79403. * Add mouse input support to the input manager.
  79404. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79405. * @returns the current input manager
  79406. */
  79407. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79408. /**
  79409. * Removes the mouse input support from the manager
  79410. * @returns the current input manager
  79411. */
  79412. removeMouse(): FreeCameraInputsManager;
  79413. /**
  79414. * Add touch input support to the input manager.
  79415. * @returns the current input manager
  79416. */
  79417. addTouch(): FreeCameraInputsManager;
  79418. /**
  79419. * Remove all attached input methods from a camera
  79420. */
  79421. clear(): void;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /**
  79426. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79427. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79429. */
  79430. export class FreeCamera extends TargetCamera {
  79431. /**
  79432. * Define the collision ellipsoid of the camera.
  79433. * This is helpful to simulate a camera body like the player body around the camera
  79434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79435. */
  79436. ellipsoid: Vector3;
  79437. /**
  79438. * Define an offset for the position of the ellipsoid around the camera.
  79439. * This can be helpful to determine the center of the body near the gravity center of the body
  79440. * instead of its head.
  79441. */
  79442. ellipsoidOffset: Vector3;
  79443. /**
  79444. * Enable or disable collisions of the camera with the rest of the scene objects.
  79445. */
  79446. checkCollisions: boolean;
  79447. /**
  79448. * Enable or disable gravity on the camera.
  79449. */
  79450. applyGravity: boolean;
  79451. /**
  79452. * Define the input manager associated to the camera.
  79453. */
  79454. inputs: FreeCameraInputsManager;
  79455. /**
  79456. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79457. * Higher values reduce sensitivity.
  79458. */
  79459. /**
  79460. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79461. * Higher values reduce sensitivity.
  79462. */
  79463. angularSensibility: number;
  79464. /**
  79465. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79466. */
  79467. keysUp: number[];
  79468. /**
  79469. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79470. */
  79471. keysDown: number[];
  79472. /**
  79473. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79474. */
  79475. keysLeft: number[];
  79476. /**
  79477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79478. */
  79479. keysRight: number[];
  79480. /**
  79481. * Event raised when the camera collide with a mesh in the scene.
  79482. */
  79483. onCollide: (collidedMesh: AbstractMesh) => void;
  79484. private _collider;
  79485. private _needMoveForGravity;
  79486. private _oldPosition;
  79487. private _diffPosition;
  79488. private _newPosition;
  79489. /** @hidden */
  79490. _localDirection: Vector3;
  79491. /** @hidden */
  79492. _transformedDirection: Vector3;
  79493. /**
  79494. * Instantiates a Free Camera.
  79495. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79496. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79498. * @param name Define the name of the camera in the scene
  79499. * @param position Define the start position of the camera in the scene
  79500. * @param scene Define the scene the camera belongs to
  79501. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79502. */
  79503. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79504. /**
  79505. * Attached controls to the current camera.
  79506. * @param element Defines the element the controls should be listened from
  79507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79508. */
  79509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79510. /**
  79511. * Detach the current controls from the camera.
  79512. * The camera will stop reacting to inputs.
  79513. * @param element Defines the element to stop listening the inputs from
  79514. */
  79515. detachControl(element: HTMLElement): void;
  79516. private _collisionMask;
  79517. /**
  79518. * Define a collision mask to limit the list of object the camera can collide with
  79519. */
  79520. collisionMask: number;
  79521. /** @hidden */
  79522. _collideWithWorld(displacement: Vector3): void;
  79523. private _onCollisionPositionChange;
  79524. /** @hidden */
  79525. _checkInputs(): void;
  79526. /** @hidden */
  79527. _decideIfNeedsToMove(): boolean;
  79528. /** @hidden */
  79529. _updatePosition(): void;
  79530. /**
  79531. * Destroy the camera and release the current resources hold by it.
  79532. */
  79533. dispose(): void;
  79534. /**
  79535. * Gets the current object class name.
  79536. * @return the class name
  79537. */
  79538. getClassName(): string;
  79539. }
  79540. }
  79541. declare module BABYLON {
  79542. /**
  79543. * Represents a gamepad control stick position
  79544. */
  79545. export class StickValues {
  79546. /**
  79547. * The x component of the control stick
  79548. */
  79549. x: number;
  79550. /**
  79551. * The y component of the control stick
  79552. */
  79553. y: number;
  79554. /**
  79555. * Initializes the gamepad x and y control stick values
  79556. * @param x The x component of the gamepad control stick value
  79557. * @param y The y component of the gamepad control stick value
  79558. */
  79559. constructor(
  79560. /**
  79561. * The x component of the control stick
  79562. */
  79563. x: number,
  79564. /**
  79565. * The y component of the control stick
  79566. */
  79567. y: number);
  79568. }
  79569. /**
  79570. * An interface which manages callbacks for gamepad button changes
  79571. */
  79572. export interface GamepadButtonChanges {
  79573. /**
  79574. * Called when a gamepad has been changed
  79575. */
  79576. changed: boolean;
  79577. /**
  79578. * Called when a gamepad press event has been triggered
  79579. */
  79580. pressChanged: boolean;
  79581. /**
  79582. * Called when a touch event has been triggered
  79583. */
  79584. touchChanged: boolean;
  79585. /**
  79586. * Called when a value has changed
  79587. */
  79588. valueChanged: boolean;
  79589. }
  79590. /**
  79591. * Represents a gamepad
  79592. */
  79593. export class Gamepad {
  79594. /**
  79595. * The id of the gamepad
  79596. */
  79597. id: string;
  79598. /**
  79599. * The index of the gamepad
  79600. */
  79601. index: number;
  79602. /**
  79603. * The browser gamepad
  79604. */
  79605. browserGamepad: any;
  79606. /**
  79607. * Specifies what type of gamepad this represents
  79608. */
  79609. type: number;
  79610. private _leftStick;
  79611. private _rightStick;
  79612. /** @hidden */
  79613. _isConnected: boolean;
  79614. private _leftStickAxisX;
  79615. private _leftStickAxisY;
  79616. private _rightStickAxisX;
  79617. private _rightStickAxisY;
  79618. /**
  79619. * Triggered when the left control stick has been changed
  79620. */
  79621. private _onleftstickchanged;
  79622. /**
  79623. * Triggered when the right control stick has been changed
  79624. */
  79625. private _onrightstickchanged;
  79626. /**
  79627. * Represents a gamepad controller
  79628. */
  79629. static GAMEPAD: number;
  79630. /**
  79631. * Represents a generic controller
  79632. */
  79633. static GENERIC: number;
  79634. /**
  79635. * Represents an XBox controller
  79636. */
  79637. static XBOX: number;
  79638. /**
  79639. * Represents a pose-enabled controller
  79640. */
  79641. static POSE_ENABLED: number;
  79642. /**
  79643. * Represents an Dual Shock controller
  79644. */
  79645. static DUALSHOCK: number;
  79646. /**
  79647. * Specifies whether the left control stick should be Y-inverted
  79648. */
  79649. protected _invertLeftStickY: boolean;
  79650. /**
  79651. * Specifies if the gamepad has been connected
  79652. */
  79653. readonly isConnected: boolean;
  79654. /**
  79655. * Initializes the gamepad
  79656. * @param id The id of the gamepad
  79657. * @param index The index of the gamepad
  79658. * @param browserGamepad The browser gamepad
  79659. * @param leftStickX The x component of the left joystick
  79660. * @param leftStickY The y component of the left joystick
  79661. * @param rightStickX The x component of the right joystick
  79662. * @param rightStickY The y component of the right joystick
  79663. */
  79664. constructor(
  79665. /**
  79666. * The id of the gamepad
  79667. */
  79668. id: string,
  79669. /**
  79670. * The index of the gamepad
  79671. */
  79672. index: number,
  79673. /**
  79674. * The browser gamepad
  79675. */
  79676. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79677. /**
  79678. * Callback triggered when the left joystick has changed
  79679. * @param callback
  79680. */
  79681. onleftstickchanged(callback: (values: StickValues) => void): void;
  79682. /**
  79683. * Callback triggered when the right joystick has changed
  79684. * @param callback
  79685. */
  79686. onrightstickchanged(callback: (values: StickValues) => void): void;
  79687. /**
  79688. * Gets the left joystick
  79689. */
  79690. /**
  79691. * Sets the left joystick values
  79692. */
  79693. leftStick: StickValues;
  79694. /**
  79695. * Gets the right joystick
  79696. */
  79697. /**
  79698. * Sets the right joystick value
  79699. */
  79700. rightStick: StickValues;
  79701. /**
  79702. * Updates the gamepad joystick positions
  79703. */
  79704. update(): void;
  79705. /**
  79706. * Disposes the gamepad
  79707. */
  79708. dispose(): void;
  79709. }
  79710. /**
  79711. * Represents a generic gamepad
  79712. */
  79713. export class GenericPad extends Gamepad {
  79714. private _buttons;
  79715. private _onbuttondown;
  79716. private _onbuttonup;
  79717. /**
  79718. * Observable triggered when a button has been pressed
  79719. */
  79720. onButtonDownObservable: Observable<number>;
  79721. /**
  79722. * Observable triggered when a button has been released
  79723. */
  79724. onButtonUpObservable: Observable<number>;
  79725. /**
  79726. * Callback triggered when a button has been pressed
  79727. * @param callback Called when a button has been pressed
  79728. */
  79729. onbuttondown(callback: (buttonPressed: number) => void): void;
  79730. /**
  79731. * Callback triggered when a button has been released
  79732. * @param callback Called when a button has been released
  79733. */
  79734. onbuttonup(callback: (buttonReleased: number) => void): void;
  79735. /**
  79736. * Initializes the generic gamepad
  79737. * @param id The id of the generic gamepad
  79738. * @param index The index of the generic gamepad
  79739. * @param browserGamepad The browser gamepad
  79740. */
  79741. constructor(id: string, index: number, browserGamepad: any);
  79742. private _setButtonValue;
  79743. /**
  79744. * Updates the generic gamepad
  79745. */
  79746. update(): void;
  79747. /**
  79748. * Disposes the generic gamepad
  79749. */
  79750. dispose(): void;
  79751. }
  79752. }
  79753. declare module BABYLON {
  79754. interface Engine {
  79755. /**
  79756. * Creates a raw texture
  79757. * @param data defines the data to store in the texture
  79758. * @param width defines the width of the texture
  79759. * @param height defines the height of the texture
  79760. * @param format defines the format of the data
  79761. * @param generateMipMaps defines if the engine should generate the mip levels
  79762. * @param invertY defines if data must be stored with Y axis inverted
  79763. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79764. * @param compression defines the compression used (null by default)
  79765. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79766. * @returns the raw texture inside an InternalTexture
  79767. */
  79768. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79769. /**
  79770. * Update a raw texture
  79771. * @param texture defines the texture to update
  79772. * @param data defines the data to store in the texture
  79773. * @param format defines the format of the data
  79774. * @param invertY defines if data must be stored with Y axis inverted
  79775. */
  79776. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79777. /**
  79778. * Update a raw texture
  79779. * @param texture defines the texture to update
  79780. * @param data defines the data to store in the texture
  79781. * @param format defines the format of the data
  79782. * @param invertY defines if data must be stored with Y axis inverted
  79783. * @param compression defines the compression used (null by default)
  79784. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79785. */
  79786. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79787. /**
  79788. * Creates a new raw cube texture
  79789. * @param data defines the array of data to use to create each face
  79790. * @param size defines the size of the textures
  79791. * @param format defines the format of the data
  79792. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79793. * @param generateMipMaps defines if the engine should generate the mip levels
  79794. * @param invertY defines if data must be stored with Y axis inverted
  79795. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79796. * @param compression defines the compression used (null by default)
  79797. * @returns the cube texture as an InternalTexture
  79798. */
  79799. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79800. /**
  79801. * Update a raw cube texture
  79802. * @param texture defines the texture to udpdate
  79803. * @param data defines the data to store
  79804. * @param format defines the data format
  79805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79806. * @param invertY defines if data must be stored with Y axis inverted
  79807. */
  79808. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79809. /**
  79810. * Update a raw cube texture
  79811. * @param texture defines the texture to udpdate
  79812. * @param data defines the data to store
  79813. * @param format defines the data format
  79814. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79815. * @param invertY defines if data must be stored with Y axis inverted
  79816. * @param compression defines the compression used (null by default)
  79817. */
  79818. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79819. /**
  79820. * Update a raw cube texture
  79821. * @param texture defines the texture to udpdate
  79822. * @param data defines the data to store
  79823. * @param format defines the data format
  79824. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79825. * @param invertY defines if data must be stored with Y axis inverted
  79826. * @param compression defines the compression used (null by default)
  79827. * @param level defines which level of the texture to update
  79828. */
  79829. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79830. /**
  79831. * Creates a new raw cube texture from a specified url
  79832. * @param url defines the url where the data is located
  79833. * @param scene defines the current scene
  79834. * @param size defines the size of the textures
  79835. * @param format defines the format of the data
  79836. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79837. * @param noMipmap defines if the engine should avoid generating the mip levels
  79838. * @param callback defines a callback used to extract texture data from loaded data
  79839. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79840. * @param onLoad defines a callback called when texture is loaded
  79841. * @param onError defines a callback called if there is an error
  79842. * @returns the cube texture as an InternalTexture
  79843. */
  79844. 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;
  79845. /**
  79846. * Creates a new raw cube texture from a specified url
  79847. * @param url defines the url where the data is located
  79848. * @param scene defines the current scene
  79849. * @param size defines the size of the textures
  79850. * @param format defines the format of the data
  79851. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79852. * @param noMipmap defines if the engine should avoid generating the mip levels
  79853. * @param callback defines a callback used to extract texture data from loaded data
  79854. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79855. * @param onLoad defines a callback called when texture is loaded
  79856. * @param onError defines a callback called if there is an error
  79857. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79858. * @param invertY defines if data must be stored with Y axis inverted
  79859. * @returns the cube texture as an InternalTexture
  79860. */
  79861. 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;
  79862. /**
  79863. * Creates a new raw 3D texture
  79864. * @param data defines the data used to create the texture
  79865. * @param width defines the width of the texture
  79866. * @param height defines the height of the texture
  79867. * @param depth defines the depth of the texture
  79868. * @param format defines the format of the texture
  79869. * @param generateMipMaps defines if the engine must generate mip levels
  79870. * @param invertY defines if data must be stored with Y axis inverted
  79871. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79872. * @param compression defines the compressed used (can be null)
  79873. * @param textureType defines the compressed used (can be null)
  79874. * @returns a new raw 3D texture (stored in an InternalTexture)
  79875. */
  79876. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79877. /**
  79878. * Update a raw 3D texture
  79879. * @param texture defines the texture to update
  79880. * @param data defines the data to store
  79881. * @param format defines the data format
  79882. * @param invertY defines if data must be stored with Y axis inverted
  79883. */
  79884. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79885. /**
  79886. * Update a raw 3D texture
  79887. * @param texture defines the texture to update
  79888. * @param data defines the data to store
  79889. * @param format defines the data format
  79890. * @param invertY defines if data must be stored with Y axis inverted
  79891. * @param compression defines the used compression (can be null)
  79892. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79893. */
  79894. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /**
  79899. * Raw texture can help creating a texture directly from an array of data.
  79900. * This can be super useful if you either get the data from an uncompressed source or
  79901. * if you wish to create your texture pixel by pixel.
  79902. */
  79903. export class RawTexture extends Texture {
  79904. /**
  79905. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79906. */
  79907. format: number;
  79908. private _engine;
  79909. /**
  79910. * Instantiates a new RawTexture.
  79911. * Raw texture can help creating a texture directly from an array of data.
  79912. * This can be super useful if you either get the data from an uncompressed source or
  79913. * if you wish to create your texture pixel by pixel.
  79914. * @param data define the array of data to use to create the texture
  79915. * @param width define the width of the texture
  79916. * @param height define the height of the texture
  79917. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79918. * @param scene define the scene the texture belongs to
  79919. * @param generateMipMaps define whether mip maps should be generated or not
  79920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79923. */
  79924. constructor(data: ArrayBufferView, width: number, height: number,
  79925. /**
  79926. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79927. */
  79928. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79929. /**
  79930. * Updates the texture underlying data.
  79931. * @param data Define the new data of the texture
  79932. */
  79933. update(data: ArrayBufferView): void;
  79934. /**
  79935. * Creates a luminance texture from some data.
  79936. * @param data Define the texture data
  79937. * @param width Define the width of the texture
  79938. * @param height Define the height of the texture
  79939. * @param scene Define the scene the texture belongs to
  79940. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79941. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79942. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79943. * @returns the luminance texture
  79944. */
  79945. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79946. /**
  79947. * Creates a luminance alpha texture from some data.
  79948. * @param data Define the texture data
  79949. * @param width Define the width of the texture
  79950. * @param height Define the height of the texture
  79951. * @param scene Define the scene the texture belongs to
  79952. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79953. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79954. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79955. * @returns the luminance alpha texture
  79956. */
  79957. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79958. /**
  79959. * Creates an alpha texture from some data.
  79960. * @param data Define the texture data
  79961. * @param width Define the width of the texture
  79962. * @param height Define the height of the texture
  79963. * @param scene Define the scene the texture belongs to
  79964. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79965. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79966. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79967. * @returns the alpha texture
  79968. */
  79969. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79970. /**
  79971. * Creates a RGB texture from some data.
  79972. * @param data Define the texture data
  79973. * @param width Define the width of the texture
  79974. * @param height Define the height of the texture
  79975. * @param scene Define the scene the texture belongs to
  79976. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79977. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79978. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79979. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79980. * @returns the RGB alpha texture
  79981. */
  79982. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79983. /**
  79984. * Creates a RGBA texture from some data.
  79985. * @param data Define the texture data
  79986. * @param width Define the width of the texture
  79987. * @param height Define the height of the texture
  79988. * @param scene Define the scene the texture belongs to
  79989. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79990. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79991. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79992. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79993. * @returns the RGBA texture
  79994. */
  79995. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79996. /**
  79997. * Creates a R texture from some data.
  79998. * @param data Define the texture data
  79999. * @param width Define the width of the texture
  80000. * @param height Define the height of the texture
  80001. * @param scene Define the scene the texture belongs to
  80002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80005. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80006. * @returns the R texture
  80007. */
  80008. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80009. }
  80010. }
  80011. declare module BABYLON {
  80012. /**
  80013. * Interface for the size containing width and height
  80014. */
  80015. export interface ISize {
  80016. /**
  80017. * Width
  80018. */
  80019. width: number;
  80020. /**
  80021. * Heighht
  80022. */
  80023. height: number;
  80024. }
  80025. /**
  80026. * Size containing widht and height
  80027. */
  80028. export class Size implements ISize {
  80029. /**
  80030. * Width
  80031. */
  80032. width: number;
  80033. /**
  80034. * Height
  80035. */
  80036. height: number;
  80037. /**
  80038. * Creates a Size object from the given width and height (floats).
  80039. * @param width width of the new size
  80040. * @param height height of the new size
  80041. */
  80042. constructor(width: number, height: number);
  80043. /**
  80044. * Returns a string with the Size width and height
  80045. * @returns a string with the Size width and height
  80046. */
  80047. toString(): string;
  80048. /**
  80049. * "Size"
  80050. * @returns the string "Size"
  80051. */
  80052. getClassName(): string;
  80053. /**
  80054. * Returns the Size hash code.
  80055. * @returns a hash code for a unique width and height
  80056. */
  80057. getHashCode(): number;
  80058. /**
  80059. * Updates the current size from the given one.
  80060. * @param src the given size
  80061. */
  80062. copyFrom(src: Size): void;
  80063. /**
  80064. * Updates in place the current Size from the given floats.
  80065. * @param width width of the new size
  80066. * @param height height of the new size
  80067. * @returns the updated Size.
  80068. */
  80069. copyFromFloats(width: number, height: number): Size;
  80070. /**
  80071. * Updates in place the current Size from the given floats.
  80072. * @param width width to set
  80073. * @param height height to set
  80074. * @returns the updated Size.
  80075. */
  80076. set(width: number, height: number): Size;
  80077. /**
  80078. * Multiplies the width and height by numbers
  80079. * @param w factor to multiple the width by
  80080. * @param h factor to multiple the height by
  80081. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80082. */
  80083. multiplyByFloats(w: number, h: number): Size;
  80084. /**
  80085. * Clones the size
  80086. * @returns a new Size copied from the given one.
  80087. */
  80088. clone(): Size;
  80089. /**
  80090. * True if the current Size and the given one width and height are strictly equal.
  80091. * @param other the other size to compare against
  80092. * @returns True if the current Size and the given one width and height are strictly equal.
  80093. */
  80094. equals(other: Size): boolean;
  80095. /**
  80096. * The surface of the Size : width * height (float).
  80097. */
  80098. readonly surface: number;
  80099. /**
  80100. * Create a new size of zero
  80101. * @returns a new Size set to (0.0, 0.0)
  80102. */
  80103. static Zero(): Size;
  80104. /**
  80105. * Sums the width and height of two sizes
  80106. * @param otherSize size to add to this size
  80107. * @returns a new Size set as the addition result of the current Size and the given one.
  80108. */
  80109. add(otherSize: Size): Size;
  80110. /**
  80111. * Subtracts the width and height of two
  80112. * @param otherSize size to subtract to this size
  80113. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80114. */
  80115. subtract(otherSize: Size): Size;
  80116. /**
  80117. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80118. * @param start starting size to lerp between
  80119. * @param end end size to lerp between
  80120. * @param amount amount to lerp between the start and end values
  80121. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80122. */
  80123. static Lerp(start: Size, end: Size, amount: number): Size;
  80124. }
  80125. }
  80126. declare module BABYLON {
  80127. /**
  80128. * Defines a runtime animation
  80129. */
  80130. export class RuntimeAnimation {
  80131. private _events;
  80132. /**
  80133. * The current frame of the runtime animation
  80134. */
  80135. private _currentFrame;
  80136. /**
  80137. * The animation used by the runtime animation
  80138. */
  80139. private _animation;
  80140. /**
  80141. * The target of the runtime animation
  80142. */
  80143. private _target;
  80144. /**
  80145. * The initiating animatable
  80146. */
  80147. private _host;
  80148. /**
  80149. * The original value of the runtime animation
  80150. */
  80151. private _originalValue;
  80152. /**
  80153. * The original blend value of the runtime animation
  80154. */
  80155. private _originalBlendValue;
  80156. /**
  80157. * The offsets cache of the runtime animation
  80158. */
  80159. private _offsetsCache;
  80160. /**
  80161. * The high limits cache of the runtime animation
  80162. */
  80163. private _highLimitsCache;
  80164. /**
  80165. * Specifies if the runtime animation has been stopped
  80166. */
  80167. private _stopped;
  80168. /**
  80169. * The blending factor of the runtime animation
  80170. */
  80171. private _blendingFactor;
  80172. /**
  80173. * The BabylonJS scene
  80174. */
  80175. private _scene;
  80176. /**
  80177. * The current value of the runtime animation
  80178. */
  80179. private _currentValue;
  80180. /** @hidden */
  80181. _animationState: _IAnimationState;
  80182. /**
  80183. * The active target of the runtime animation
  80184. */
  80185. private _activeTargets;
  80186. private _currentActiveTarget;
  80187. private _directTarget;
  80188. /**
  80189. * The target path of the runtime animation
  80190. */
  80191. private _targetPath;
  80192. /**
  80193. * The weight of the runtime animation
  80194. */
  80195. private _weight;
  80196. /**
  80197. * The ratio offset of the runtime animation
  80198. */
  80199. private _ratioOffset;
  80200. /**
  80201. * The previous delay of the runtime animation
  80202. */
  80203. private _previousDelay;
  80204. /**
  80205. * The previous ratio of the runtime animation
  80206. */
  80207. private _previousRatio;
  80208. private _enableBlending;
  80209. private _keys;
  80210. private _minFrame;
  80211. private _maxFrame;
  80212. private _minValue;
  80213. private _maxValue;
  80214. private _targetIsArray;
  80215. /**
  80216. * Gets the current frame of the runtime animation
  80217. */
  80218. readonly currentFrame: number;
  80219. /**
  80220. * Gets the weight of the runtime animation
  80221. */
  80222. readonly weight: number;
  80223. /**
  80224. * Gets the current value of the runtime animation
  80225. */
  80226. readonly currentValue: any;
  80227. /**
  80228. * Gets the target path of the runtime animation
  80229. */
  80230. readonly targetPath: string;
  80231. /**
  80232. * Gets the actual target of the runtime animation
  80233. */
  80234. readonly target: any;
  80235. /** @hidden */
  80236. _onLoop: () => void;
  80237. /**
  80238. * Create a new RuntimeAnimation object
  80239. * @param target defines the target of the animation
  80240. * @param animation defines the source animation object
  80241. * @param scene defines the hosting scene
  80242. * @param host defines the initiating Animatable
  80243. */
  80244. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80245. private _preparePath;
  80246. /**
  80247. * Gets the animation from the runtime animation
  80248. */
  80249. readonly animation: Animation;
  80250. /**
  80251. * Resets the runtime animation to the beginning
  80252. * @param restoreOriginal defines whether to restore the target property to the original value
  80253. */
  80254. reset(restoreOriginal?: boolean): void;
  80255. /**
  80256. * Specifies if the runtime animation is stopped
  80257. * @returns Boolean specifying if the runtime animation is stopped
  80258. */
  80259. isStopped(): boolean;
  80260. /**
  80261. * Disposes of the runtime animation
  80262. */
  80263. dispose(): void;
  80264. /**
  80265. * Apply the interpolated value to the target
  80266. * @param currentValue defines the value computed by the animation
  80267. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80268. */
  80269. setValue(currentValue: any, weight: number): void;
  80270. private _getOriginalValues;
  80271. private _setValue;
  80272. /**
  80273. * Gets the loop pmode of the runtime animation
  80274. * @returns Loop Mode
  80275. */
  80276. private _getCorrectLoopMode;
  80277. /**
  80278. * Move the current animation to a given frame
  80279. * @param frame defines the frame to move to
  80280. */
  80281. goToFrame(frame: number): void;
  80282. /**
  80283. * @hidden Internal use only
  80284. */
  80285. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80286. /**
  80287. * Execute the current animation
  80288. * @param delay defines the delay to add to the current frame
  80289. * @param from defines the lower bound of the animation range
  80290. * @param to defines the upper bound of the animation range
  80291. * @param loop defines if the current animation must loop
  80292. * @param speedRatio defines the current speed ratio
  80293. * @param weight defines the weight of the animation (default is -1 so no weight)
  80294. * @param onLoop optional callback called when animation loops
  80295. * @returns a boolean indicating if the animation is running
  80296. */
  80297. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80298. }
  80299. }
  80300. declare module BABYLON {
  80301. /**
  80302. * Class used to store an actual running animation
  80303. */
  80304. export class Animatable {
  80305. /** defines the target object */
  80306. target: any;
  80307. /** defines the starting frame number (default is 0) */
  80308. fromFrame: number;
  80309. /** defines the ending frame number (default is 100) */
  80310. toFrame: number;
  80311. /** defines if the animation must loop (default is false) */
  80312. loopAnimation: boolean;
  80313. /** defines a callback to call when animation ends if it is not looping */
  80314. onAnimationEnd?: (() => void) | null | undefined;
  80315. /** defines a callback to call when animation loops */
  80316. onAnimationLoop?: (() => void) | null | undefined;
  80317. private _localDelayOffset;
  80318. private _pausedDelay;
  80319. private _runtimeAnimations;
  80320. private _paused;
  80321. private _scene;
  80322. private _speedRatio;
  80323. private _weight;
  80324. private _syncRoot;
  80325. /**
  80326. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80327. * This will only apply for non looping animation (default is true)
  80328. */
  80329. disposeOnEnd: boolean;
  80330. /**
  80331. * Gets a boolean indicating if the animation has started
  80332. */
  80333. animationStarted: boolean;
  80334. /**
  80335. * Observer raised when the animation ends
  80336. */
  80337. onAnimationEndObservable: Observable<Animatable>;
  80338. /**
  80339. * Observer raised when the animation loops
  80340. */
  80341. onAnimationLoopObservable: Observable<Animatable>;
  80342. /**
  80343. * Gets the root Animatable used to synchronize and normalize animations
  80344. */
  80345. readonly syncRoot: Nullable<Animatable>;
  80346. /**
  80347. * Gets the current frame of the first RuntimeAnimation
  80348. * Used to synchronize Animatables
  80349. */
  80350. readonly masterFrame: number;
  80351. /**
  80352. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80353. */
  80354. weight: number;
  80355. /**
  80356. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80357. */
  80358. speedRatio: number;
  80359. /**
  80360. * Creates a new Animatable
  80361. * @param scene defines the hosting scene
  80362. * @param target defines the target object
  80363. * @param fromFrame defines the starting frame number (default is 0)
  80364. * @param toFrame defines the ending frame number (default is 100)
  80365. * @param loopAnimation defines if the animation must loop (default is false)
  80366. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80367. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80368. * @param animations defines a group of animation to add to the new Animatable
  80369. * @param onAnimationLoop defines a callback to call when animation loops
  80370. */
  80371. constructor(scene: Scene,
  80372. /** defines the target object */
  80373. target: any,
  80374. /** defines the starting frame number (default is 0) */
  80375. fromFrame?: number,
  80376. /** defines the ending frame number (default is 100) */
  80377. toFrame?: number,
  80378. /** defines if the animation must loop (default is false) */
  80379. loopAnimation?: boolean, speedRatio?: number,
  80380. /** defines a callback to call when animation ends if it is not looping */
  80381. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80382. /** defines a callback to call when animation loops */
  80383. onAnimationLoop?: (() => void) | null | undefined);
  80384. /**
  80385. * Synchronize and normalize current Animatable with a source Animatable
  80386. * This is useful when using animation weights and when animations are not of the same length
  80387. * @param root defines the root Animatable to synchronize with
  80388. * @returns the current Animatable
  80389. */
  80390. syncWith(root: Animatable): Animatable;
  80391. /**
  80392. * Gets the list of runtime animations
  80393. * @returns an array of RuntimeAnimation
  80394. */
  80395. getAnimations(): RuntimeAnimation[];
  80396. /**
  80397. * Adds more animations to the current animatable
  80398. * @param target defines the target of the animations
  80399. * @param animations defines the new animations to add
  80400. */
  80401. appendAnimations(target: any, animations: Animation[]): void;
  80402. /**
  80403. * Gets the source animation for a specific property
  80404. * @param property defines the propertyu to look for
  80405. * @returns null or the source animation for the given property
  80406. */
  80407. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80408. /**
  80409. * Gets the runtime animation for a specific property
  80410. * @param property defines the propertyu to look for
  80411. * @returns null or the runtime animation for the given property
  80412. */
  80413. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80414. /**
  80415. * Resets the animatable to its original state
  80416. */
  80417. reset(): void;
  80418. /**
  80419. * Allows the animatable to blend with current running animations
  80420. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80421. * @param blendingSpeed defines the blending speed to use
  80422. */
  80423. enableBlending(blendingSpeed: number): void;
  80424. /**
  80425. * Disable animation blending
  80426. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80427. */
  80428. disableBlending(): void;
  80429. /**
  80430. * Jump directly to a given frame
  80431. * @param frame defines the frame to jump to
  80432. */
  80433. goToFrame(frame: number): void;
  80434. /**
  80435. * Pause the animation
  80436. */
  80437. pause(): void;
  80438. /**
  80439. * Restart the animation
  80440. */
  80441. restart(): void;
  80442. private _raiseOnAnimationEnd;
  80443. /**
  80444. * Stop and delete the current animation
  80445. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80446. * @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)
  80447. */
  80448. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80449. /**
  80450. * Wait asynchronously for the animation to end
  80451. * @returns a promise which will be fullfilled when the animation ends
  80452. */
  80453. waitAsync(): Promise<Animatable>;
  80454. /** @hidden */
  80455. _animate(delay: number): boolean;
  80456. }
  80457. interface Scene {
  80458. /** @hidden */
  80459. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80460. /** @hidden */
  80461. _processLateAnimationBindingsForMatrices(holder: {
  80462. totalWeight: number;
  80463. animations: RuntimeAnimation[];
  80464. originalValue: Matrix;
  80465. }): any;
  80466. /** @hidden */
  80467. _processLateAnimationBindingsForQuaternions(holder: {
  80468. totalWeight: number;
  80469. animations: RuntimeAnimation[];
  80470. originalValue: Quaternion;
  80471. }, refQuaternion: Quaternion): Quaternion;
  80472. /** @hidden */
  80473. _processLateAnimationBindings(): void;
  80474. /**
  80475. * Will start the animation sequence of a given target
  80476. * @param target defines the target
  80477. * @param from defines from which frame should animation start
  80478. * @param to defines until which frame should animation run.
  80479. * @param weight defines the weight to apply to the animation (1.0 by default)
  80480. * @param loop defines if the animation loops
  80481. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80482. * @param onAnimationEnd defines the function to be executed when the animation ends
  80483. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80484. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80485. * @param onAnimationLoop defines the callback to call when an animation loops
  80486. * @returns the animatable object created for this animation
  80487. */
  80488. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80489. /**
  80490. * Will start the animation sequence of a given target
  80491. * @param target defines the target
  80492. * @param from defines from which frame should animation start
  80493. * @param to defines until which frame should animation run.
  80494. * @param loop defines if the animation loops
  80495. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80496. * @param onAnimationEnd defines the function to be executed when the animation ends
  80497. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80498. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80499. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80500. * @param onAnimationLoop defines the callback to call when an animation loops
  80501. * @returns the animatable object created for this animation
  80502. */
  80503. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80504. /**
  80505. * Will start the animation sequence of a given target and its hierarchy
  80506. * @param target defines the target
  80507. * @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.
  80508. * @param from defines from which frame should animation start
  80509. * @param to defines until which frame should animation run.
  80510. * @param loop defines if the animation loops
  80511. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80512. * @param onAnimationEnd defines the function to be executed when the animation ends
  80513. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80514. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80515. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80516. * @param onAnimationLoop defines the callback to call when an animation loops
  80517. * @returns the list of created animatables
  80518. */
  80519. 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[];
  80520. /**
  80521. * Begin a new animation on a given node
  80522. * @param target defines the target where the animation will take place
  80523. * @param animations defines the list of animations to start
  80524. * @param from defines the initial value
  80525. * @param to defines the final value
  80526. * @param loop defines if you want animation to loop (off by default)
  80527. * @param speedRatio defines the speed ratio to apply to all animations
  80528. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80529. * @param onAnimationLoop defines the callback to call when an animation loops
  80530. * @returns the list of created animatables
  80531. */
  80532. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80533. /**
  80534. * Begin a new animation on a given node and its hierarchy
  80535. * @param target defines the root node where the animation will take place
  80536. * @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.
  80537. * @param animations defines the list of animations to start
  80538. * @param from defines the initial value
  80539. * @param to defines the final value
  80540. * @param loop defines if you want animation to loop (off by default)
  80541. * @param speedRatio defines the speed ratio to apply to all animations
  80542. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80543. * @param onAnimationLoop defines the callback to call when an animation loops
  80544. * @returns the list of animatables created for all nodes
  80545. */
  80546. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80547. /**
  80548. * Gets the animatable associated with a specific target
  80549. * @param target defines the target of the animatable
  80550. * @returns the required animatable if found
  80551. */
  80552. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80553. /**
  80554. * Gets all animatables associated with a given target
  80555. * @param target defines the target to look animatables for
  80556. * @returns an array of Animatables
  80557. */
  80558. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80559. /**
  80560. * Stops and removes all animations that have been applied to the scene
  80561. */
  80562. stopAllAnimations(): void;
  80563. /**
  80564. * Gets the current delta time used by animation engine
  80565. */
  80566. deltaTime: number;
  80567. }
  80568. interface Bone {
  80569. /**
  80570. * Copy an animation range from another bone
  80571. * @param source defines the source bone
  80572. * @param rangeName defines the range name to copy
  80573. * @param frameOffset defines the frame offset
  80574. * @param rescaleAsRequired defines if rescaling must be applied if required
  80575. * @param skelDimensionsRatio defines the scaling ratio
  80576. * @returns true if operation was successful
  80577. */
  80578. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80579. }
  80580. }
  80581. declare module BABYLON {
  80582. /**
  80583. * Class used to override all child animations of a given target
  80584. */
  80585. export class AnimationPropertiesOverride {
  80586. /**
  80587. * Gets or sets a value indicating if animation blending must be used
  80588. */
  80589. enableBlending: boolean;
  80590. /**
  80591. * Gets or sets the blending speed to use when enableBlending is true
  80592. */
  80593. blendingSpeed: number;
  80594. /**
  80595. * Gets or sets the default loop mode to use
  80596. */
  80597. loopMode: number;
  80598. }
  80599. }
  80600. declare module BABYLON {
  80601. /**
  80602. * Class used to handle skinning animations
  80603. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80604. */
  80605. export class Skeleton implements IAnimatable {
  80606. /** defines the skeleton name */
  80607. name: string;
  80608. /** defines the skeleton Id */
  80609. id: string;
  80610. /**
  80611. * Defines the list of child bones
  80612. */
  80613. bones: Bone[];
  80614. /**
  80615. * Defines an estimate of the dimension of the skeleton at rest
  80616. */
  80617. dimensionsAtRest: Vector3;
  80618. /**
  80619. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80620. */
  80621. needInitialSkinMatrix: boolean;
  80622. /**
  80623. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80624. */
  80625. overrideMesh: Nullable<AbstractMesh>;
  80626. /**
  80627. * Gets the list of animations attached to this skeleton
  80628. */
  80629. animations: Array<Animation>;
  80630. private _scene;
  80631. private _isDirty;
  80632. private _transformMatrices;
  80633. private _transformMatrixTexture;
  80634. private _meshesWithPoseMatrix;
  80635. private _animatables;
  80636. private _identity;
  80637. private _synchronizedWithMesh;
  80638. private _ranges;
  80639. private _lastAbsoluteTransformsUpdateId;
  80640. private _canUseTextureForBones;
  80641. private _uniqueId;
  80642. /** @hidden */
  80643. _numBonesWithLinkedTransformNode: number;
  80644. /** @hidden */
  80645. _hasWaitingData: Nullable<boolean>;
  80646. /**
  80647. * Specifies if the skeleton should be serialized
  80648. */
  80649. doNotSerialize: boolean;
  80650. private _useTextureToStoreBoneMatrices;
  80651. /**
  80652. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80653. * Please note that this option is not available if the hardware does not support it
  80654. */
  80655. useTextureToStoreBoneMatrices: boolean;
  80656. private _animationPropertiesOverride;
  80657. /**
  80658. * Gets or sets the animation properties override
  80659. */
  80660. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80661. /**
  80662. * List of inspectable custom properties (used by the Inspector)
  80663. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80664. */
  80665. inspectableCustomProperties: IInspectable[];
  80666. /**
  80667. * An observable triggered before computing the skeleton's matrices
  80668. */
  80669. onBeforeComputeObservable: Observable<Skeleton>;
  80670. /**
  80671. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80672. */
  80673. readonly isUsingTextureForMatrices: boolean;
  80674. /**
  80675. * Gets the unique ID of this skeleton
  80676. */
  80677. readonly uniqueId: number;
  80678. /**
  80679. * Creates a new skeleton
  80680. * @param name defines the skeleton name
  80681. * @param id defines the skeleton Id
  80682. * @param scene defines the hosting scene
  80683. */
  80684. constructor(
  80685. /** defines the skeleton name */
  80686. name: string,
  80687. /** defines the skeleton Id */
  80688. id: string, scene: Scene);
  80689. /**
  80690. * Gets the current object class name.
  80691. * @return the class name
  80692. */
  80693. getClassName(): string;
  80694. /**
  80695. * Returns an array containing the root bones
  80696. * @returns an array containing the root bones
  80697. */
  80698. getChildren(): Array<Bone>;
  80699. /**
  80700. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80701. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80702. * @returns a Float32Array containing matrices data
  80703. */
  80704. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80705. /**
  80706. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80707. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80708. * @returns a raw texture containing the data
  80709. */
  80710. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80711. /**
  80712. * Gets the current hosting scene
  80713. * @returns a scene object
  80714. */
  80715. getScene(): Scene;
  80716. /**
  80717. * Gets a string representing the current skeleton data
  80718. * @param fullDetails defines a boolean indicating if we want a verbose version
  80719. * @returns a string representing the current skeleton data
  80720. */
  80721. toString(fullDetails?: boolean): string;
  80722. /**
  80723. * Get bone's index searching by name
  80724. * @param name defines bone's name to search for
  80725. * @return the indice of the bone. Returns -1 if not found
  80726. */
  80727. getBoneIndexByName(name: string): number;
  80728. /**
  80729. * Creater a new animation range
  80730. * @param name defines the name of the range
  80731. * @param from defines the start key
  80732. * @param to defines the end key
  80733. */
  80734. createAnimationRange(name: string, from: number, to: number): void;
  80735. /**
  80736. * Delete a specific animation range
  80737. * @param name defines the name of the range
  80738. * @param deleteFrames defines if frames must be removed as well
  80739. */
  80740. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80741. /**
  80742. * Gets a specific animation range
  80743. * @param name defines the name of the range to look for
  80744. * @returns the requested animation range or null if not found
  80745. */
  80746. getAnimationRange(name: string): Nullable<AnimationRange>;
  80747. /**
  80748. * Gets the list of all animation ranges defined on this skeleton
  80749. * @returns an array
  80750. */
  80751. getAnimationRanges(): Nullable<AnimationRange>[];
  80752. /**
  80753. * Copy animation range from a source skeleton.
  80754. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80755. * @param source defines the source skeleton
  80756. * @param name defines the name of the range to copy
  80757. * @param rescaleAsRequired defines if rescaling must be applied if required
  80758. * @returns true if operation was successful
  80759. */
  80760. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80761. /**
  80762. * Forces the skeleton to go to rest pose
  80763. */
  80764. returnToRest(): void;
  80765. private _getHighestAnimationFrame;
  80766. /**
  80767. * Begin a specific animation range
  80768. * @param name defines the name of the range to start
  80769. * @param loop defines if looping must be turned on (false by default)
  80770. * @param speedRatio defines the speed ratio to apply (1 by default)
  80771. * @param onAnimationEnd defines a callback which will be called when animation will end
  80772. * @returns a new animatable
  80773. */
  80774. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80775. /** @hidden */
  80776. _markAsDirty(): void;
  80777. /** @hidden */
  80778. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80779. /** @hidden */
  80780. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80781. private _computeTransformMatrices;
  80782. /**
  80783. * Build all resources required to render a skeleton
  80784. */
  80785. prepare(): void;
  80786. /**
  80787. * Gets the list of animatables currently running for this skeleton
  80788. * @returns an array of animatables
  80789. */
  80790. getAnimatables(): IAnimatable[];
  80791. /**
  80792. * Clone the current skeleton
  80793. * @param name defines the name of the new skeleton
  80794. * @param id defines the id of the new skeleton
  80795. * @returns the new skeleton
  80796. */
  80797. clone(name: string, id: string): Skeleton;
  80798. /**
  80799. * Enable animation blending for this skeleton
  80800. * @param blendingSpeed defines the blending speed to apply
  80801. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80802. */
  80803. enableBlending(blendingSpeed?: number): void;
  80804. /**
  80805. * Releases all resources associated with the current skeleton
  80806. */
  80807. dispose(): void;
  80808. /**
  80809. * Serialize the skeleton in a JSON object
  80810. * @returns a JSON object
  80811. */
  80812. serialize(): any;
  80813. /**
  80814. * Creates a new skeleton from serialized data
  80815. * @param parsedSkeleton defines the serialized data
  80816. * @param scene defines the hosting scene
  80817. * @returns a new skeleton
  80818. */
  80819. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80820. /**
  80821. * Compute all node absolute transforms
  80822. * @param forceUpdate defines if computation must be done even if cache is up to date
  80823. */
  80824. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80825. /**
  80826. * Gets the root pose matrix
  80827. * @returns a matrix
  80828. */
  80829. getPoseMatrix(): Nullable<Matrix>;
  80830. /**
  80831. * Sorts bones per internal index
  80832. */
  80833. sortBones(): void;
  80834. private _sortBones;
  80835. }
  80836. }
  80837. declare module BABYLON {
  80838. /**
  80839. * Class used to store bone information
  80840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80841. */
  80842. export class Bone extends Node {
  80843. /**
  80844. * defines the bone name
  80845. */
  80846. name: string;
  80847. private static _tmpVecs;
  80848. private static _tmpQuat;
  80849. private static _tmpMats;
  80850. /**
  80851. * Gets the list of child bones
  80852. */
  80853. children: Bone[];
  80854. /** Gets the animations associated with this bone */
  80855. animations: Animation[];
  80856. /**
  80857. * Gets or sets bone length
  80858. */
  80859. length: number;
  80860. /**
  80861. * @hidden Internal only
  80862. * Set this value to map this bone to a different index in the transform matrices
  80863. * Set this value to -1 to exclude the bone from the transform matrices
  80864. */
  80865. _index: Nullable<number>;
  80866. private _skeleton;
  80867. private _localMatrix;
  80868. private _restPose;
  80869. private _baseMatrix;
  80870. private _absoluteTransform;
  80871. private _invertedAbsoluteTransform;
  80872. private _parent;
  80873. private _scalingDeterminant;
  80874. private _worldTransform;
  80875. private _localScaling;
  80876. private _localRotation;
  80877. private _localPosition;
  80878. private _needToDecompose;
  80879. private _needToCompose;
  80880. /** @hidden */
  80881. _linkedTransformNode: Nullable<TransformNode>;
  80882. /** @hidden */
  80883. _waitingTransformNodeId: Nullable<string>;
  80884. /** @hidden */
  80885. /** @hidden */
  80886. _matrix: Matrix;
  80887. /**
  80888. * Create a new bone
  80889. * @param name defines the bone name
  80890. * @param skeleton defines the parent skeleton
  80891. * @param parentBone defines the parent (can be null if the bone is the root)
  80892. * @param localMatrix defines the local matrix
  80893. * @param restPose defines the rest pose matrix
  80894. * @param baseMatrix defines the base matrix
  80895. * @param index defines index of the bone in the hiearchy
  80896. */
  80897. constructor(
  80898. /**
  80899. * defines the bone name
  80900. */
  80901. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80902. /**
  80903. * Gets the current object class name.
  80904. * @return the class name
  80905. */
  80906. getClassName(): string;
  80907. /**
  80908. * Gets the parent skeleton
  80909. * @returns a skeleton
  80910. */
  80911. getSkeleton(): Skeleton;
  80912. /**
  80913. * Gets parent bone
  80914. * @returns a bone or null if the bone is the root of the bone hierarchy
  80915. */
  80916. getParent(): Nullable<Bone>;
  80917. /**
  80918. * Returns an array containing the root bones
  80919. * @returns an array containing the root bones
  80920. */
  80921. getChildren(): Array<Bone>;
  80922. /**
  80923. * Sets the parent bone
  80924. * @param parent defines the parent (can be null if the bone is the root)
  80925. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80926. */
  80927. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80928. /**
  80929. * Gets the local matrix
  80930. * @returns a matrix
  80931. */
  80932. getLocalMatrix(): Matrix;
  80933. /**
  80934. * Gets the base matrix (initial matrix which remains unchanged)
  80935. * @returns a matrix
  80936. */
  80937. getBaseMatrix(): Matrix;
  80938. /**
  80939. * Gets the rest pose matrix
  80940. * @returns a matrix
  80941. */
  80942. getRestPose(): Matrix;
  80943. /**
  80944. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80945. */
  80946. getWorldMatrix(): Matrix;
  80947. /**
  80948. * Sets the local matrix to rest pose matrix
  80949. */
  80950. returnToRest(): void;
  80951. /**
  80952. * Gets the inverse of the absolute transform matrix.
  80953. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80954. * @returns a matrix
  80955. */
  80956. getInvertedAbsoluteTransform(): Matrix;
  80957. /**
  80958. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80959. * @returns a matrix
  80960. */
  80961. getAbsoluteTransform(): Matrix;
  80962. /**
  80963. * Links with the given transform node.
  80964. * The local matrix of this bone is copied from the transform node every frame.
  80965. * @param transformNode defines the transform node to link to
  80966. */
  80967. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80968. /**
  80969. * Gets the node used to drive the bone's transformation
  80970. * @returns a transform node or null
  80971. */
  80972. getTransformNode(): Nullable<TransformNode>;
  80973. /** Gets or sets current position (in local space) */
  80974. position: Vector3;
  80975. /** Gets or sets current rotation (in local space) */
  80976. rotation: Vector3;
  80977. /** Gets or sets current rotation quaternion (in local space) */
  80978. rotationQuaternion: Quaternion;
  80979. /** Gets or sets current scaling (in local space) */
  80980. scaling: Vector3;
  80981. /**
  80982. * Gets the animation properties override
  80983. */
  80984. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80985. private _decompose;
  80986. private _compose;
  80987. /**
  80988. * Update the base and local matrices
  80989. * @param matrix defines the new base or local matrix
  80990. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80991. * @param updateLocalMatrix defines if the local matrix should be updated
  80992. */
  80993. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80994. /** @hidden */
  80995. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80996. /**
  80997. * Flag the bone as dirty (Forcing it to update everything)
  80998. */
  80999. markAsDirty(): void;
  81000. /** @hidden */
  81001. _markAsDirtyAndCompose(): void;
  81002. private _markAsDirtyAndDecompose;
  81003. /**
  81004. * Translate the bone in local or world space
  81005. * @param vec The amount to translate the bone
  81006. * @param space The space that the translation is in
  81007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81008. */
  81009. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81010. /**
  81011. * Set the postion of the bone in local or world space
  81012. * @param position The position to set the bone
  81013. * @param space The space that the position is in
  81014. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81015. */
  81016. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81017. /**
  81018. * Set the absolute position of the bone (world space)
  81019. * @param position The position to set the bone
  81020. * @param mesh The mesh that this bone is attached to
  81021. */
  81022. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81023. /**
  81024. * Scale the bone on the x, y and z axes (in local space)
  81025. * @param x The amount to scale the bone on the x axis
  81026. * @param y The amount to scale the bone on the y axis
  81027. * @param z The amount to scale the bone on the z axis
  81028. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81029. */
  81030. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81031. /**
  81032. * Set the bone scaling in local space
  81033. * @param scale defines the scaling vector
  81034. */
  81035. setScale(scale: Vector3): void;
  81036. /**
  81037. * Gets the current scaling in local space
  81038. * @returns the current scaling vector
  81039. */
  81040. getScale(): Vector3;
  81041. /**
  81042. * Gets the current scaling in local space and stores it in a target vector
  81043. * @param result defines the target vector
  81044. */
  81045. getScaleToRef(result: Vector3): void;
  81046. /**
  81047. * Set the yaw, pitch, and roll of the bone in local or world space
  81048. * @param yaw The rotation of the bone on the y axis
  81049. * @param pitch The rotation of the bone on the x axis
  81050. * @param roll The rotation of the bone on the z axis
  81051. * @param space The space that the axes of rotation are in
  81052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81053. */
  81054. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81055. /**
  81056. * Add a rotation to the bone on an axis in local or world space
  81057. * @param axis The axis to rotate the bone on
  81058. * @param amount The amount to rotate the bone
  81059. * @param space The space that the axis is in
  81060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81061. */
  81062. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81063. /**
  81064. * Set the rotation of the bone to a particular axis angle in local or world space
  81065. * @param axis The axis to rotate the bone on
  81066. * @param angle The angle that the bone should be rotated to
  81067. * @param space The space that the axis is in
  81068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81069. */
  81070. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81071. /**
  81072. * Set the euler rotation of the bone in local of world space
  81073. * @param rotation The euler rotation that the bone should be set to
  81074. * @param space The space that the rotation is in
  81075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81076. */
  81077. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81078. /**
  81079. * Set the quaternion rotation of the bone in local of world space
  81080. * @param quat The quaternion rotation that the bone should be set to
  81081. * @param space The space that the rotation is in
  81082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81083. */
  81084. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81085. /**
  81086. * Set the rotation matrix of the bone in local of world space
  81087. * @param rotMat The rotation matrix that the bone should be set to
  81088. * @param space The space that the rotation is in
  81089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81090. */
  81091. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81092. private _rotateWithMatrix;
  81093. private _getNegativeRotationToRef;
  81094. /**
  81095. * Get the position of the bone in local or world space
  81096. * @param space The space that the returned position is in
  81097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81098. * @returns The position of the bone
  81099. */
  81100. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81101. /**
  81102. * Copy the position of the bone to a vector3 in local or world space
  81103. * @param space The space that the returned position is in
  81104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81105. * @param result The vector3 to copy the position to
  81106. */
  81107. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81108. /**
  81109. * Get the absolute position of the bone (world space)
  81110. * @param mesh The mesh that this bone is attached to
  81111. * @returns The absolute position of the bone
  81112. */
  81113. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81114. /**
  81115. * Copy the absolute position of the bone (world space) to the result param
  81116. * @param mesh The mesh that this bone is attached to
  81117. * @param result The vector3 to copy the absolute position to
  81118. */
  81119. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81120. /**
  81121. * Compute the absolute transforms of this bone and its children
  81122. */
  81123. computeAbsoluteTransforms(): void;
  81124. /**
  81125. * Get the world direction from an axis that is in the local space of the bone
  81126. * @param localAxis The local direction that is used to compute the world direction
  81127. * @param mesh The mesh that this bone is attached to
  81128. * @returns The world direction
  81129. */
  81130. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81131. /**
  81132. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81133. * @param localAxis The local direction that is used to compute the world direction
  81134. * @param mesh The mesh that this bone is attached to
  81135. * @param result The vector3 that the world direction will be copied to
  81136. */
  81137. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81138. /**
  81139. * Get the euler rotation of the bone in local or world space
  81140. * @param space The space that the rotation should be in
  81141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81142. * @returns The euler rotation
  81143. */
  81144. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81145. /**
  81146. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81147. * @param space The space that the rotation should be in
  81148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81149. * @param result The vector3 that the rotation should be copied to
  81150. */
  81151. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81152. /**
  81153. * Get the quaternion rotation of the bone in either local or world space
  81154. * @param space The space that the rotation should be in
  81155. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81156. * @returns The quaternion rotation
  81157. */
  81158. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81159. /**
  81160. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81161. * @param space The space that the rotation should be in
  81162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81163. * @param result The quaternion that the rotation should be copied to
  81164. */
  81165. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81166. /**
  81167. * Get the rotation matrix of the bone in local or world space
  81168. * @param space The space that the rotation should be in
  81169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81170. * @returns The rotation matrix
  81171. */
  81172. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81173. /**
  81174. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81175. * @param space The space that the rotation should be in
  81176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81177. * @param result The quaternion that the rotation should be copied to
  81178. */
  81179. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81180. /**
  81181. * Get the world position of a point that is in the local space of the bone
  81182. * @param position The local position
  81183. * @param mesh The mesh that this bone is attached to
  81184. * @returns The world position
  81185. */
  81186. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81187. /**
  81188. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81189. * @param position The local position
  81190. * @param mesh The mesh that this bone is attached to
  81191. * @param result The vector3 that the world position should be copied to
  81192. */
  81193. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81194. /**
  81195. * Get the local position of a point that is in world space
  81196. * @param position The world position
  81197. * @param mesh The mesh that this bone is attached to
  81198. * @returns The local position
  81199. */
  81200. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81201. /**
  81202. * Get the local position of a point that is in world space and copy it to the result param
  81203. * @param position The world position
  81204. * @param mesh The mesh that this bone is attached to
  81205. * @param result The vector3 that the local position should be copied to
  81206. */
  81207. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81208. }
  81209. }
  81210. declare module BABYLON {
  81211. /**
  81212. * 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.
  81213. * @see https://doc.babylonjs.com/how_to/transformnode
  81214. */
  81215. export class TransformNode extends Node {
  81216. /**
  81217. * Object will not rotate to face the camera
  81218. */
  81219. static BILLBOARDMODE_NONE: number;
  81220. /**
  81221. * Object will rotate to face the camera but only on the x axis
  81222. */
  81223. static BILLBOARDMODE_X: number;
  81224. /**
  81225. * Object will rotate to face the camera but only on the y axis
  81226. */
  81227. static BILLBOARDMODE_Y: number;
  81228. /**
  81229. * Object will rotate to face the camera but only on the z axis
  81230. */
  81231. static BILLBOARDMODE_Z: number;
  81232. /**
  81233. * Object will rotate to face the camera
  81234. */
  81235. static BILLBOARDMODE_ALL: number;
  81236. /**
  81237. * Object will rotate to face the camera's position instead of orientation
  81238. */
  81239. static BILLBOARDMODE_USE_POSITION: number;
  81240. private _forward;
  81241. private _forwardInverted;
  81242. private _up;
  81243. private _right;
  81244. private _rightInverted;
  81245. private _position;
  81246. private _rotation;
  81247. private _rotationQuaternion;
  81248. protected _scaling: Vector3;
  81249. protected _isDirty: boolean;
  81250. private _transformToBoneReferal;
  81251. private _isAbsoluteSynced;
  81252. private _billboardMode;
  81253. /**
  81254. * Gets or sets the billboard mode. Default is 0.
  81255. *
  81256. * | Value | Type | Description |
  81257. * | --- | --- | --- |
  81258. * | 0 | BILLBOARDMODE_NONE | |
  81259. * | 1 | BILLBOARDMODE_X | |
  81260. * | 2 | BILLBOARDMODE_Y | |
  81261. * | 4 | BILLBOARDMODE_Z | |
  81262. * | 7 | BILLBOARDMODE_ALL | |
  81263. *
  81264. */
  81265. billboardMode: number;
  81266. private _preserveParentRotationForBillboard;
  81267. /**
  81268. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81269. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81270. */
  81271. preserveParentRotationForBillboard: boolean;
  81272. /**
  81273. * 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
  81274. */
  81275. scalingDeterminant: number;
  81276. private _infiniteDistance;
  81277. /**
  81278. * Gets or sets the distance of the object to max, often used by skybox
  81279. */
  81280. infiniteDistance: boolean;
  81281. /**
  81282. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81283. * By default the system will update normals to compensate
  81284. */
  81285. ignoreNonUniformScaling: boolean;
  81286. /**
  81287. * 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
  81288. */
  81289. reIntegrateRotationIntoRotationQuaternion: boolean;
  81290. /** @hidden */
  81291. _poseMatrix: Nullable<Matrix>;
  81292. /** @hidden */
  81293. _localMatrix: Matrix;
  81294. private _usePivotMatrix;
  81295. private _absolutePosition;
  81296. private _absoluteScaling;
  81297. private _absoluteRotationQuaternion;
  81298. private _pivotMatrix;
  81299. private _pivotMatrixInverse;
  81300. protected _postMultiplyPivotMatrix: boolean;
  81301. protected _isWorldMatrixFrozen: boolean;
  81302. /** @hidden */
  81303. _indexInSceneTransformNodesArray: number;
  81304. /**
  81305. * An event triggered after the world matrix is updated
  81306. */
  81307. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81308. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81309. /**
  81310. * Gets a string identifying the name of the class
  81311. * @returns "TransformNode" string
  81312. */
  81313. getClassName(): string;
  81314. /**
  81315. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81316. */
  81317. position: Vector3;
  81318. /**
  81319. * 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)).
  81320. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81321. */
  81322. rotation: Vector3;
  81323. /**
  81324. * 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)).
  81325. */
  81326. scaling: Vector3;
  81327. /**
  81328. * 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).
  81329. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81330. */
  81331. rotationQuaternion: Nullable<Quaternion>;
  81332. /**
  81333. * The forward direction of that transform in world space.
  81334. */
  81335. readonly forward: Vector3;
  81336. /**
  81337. * The up direction of that transform in world space.
  81338. */
  81339. readonly up: Vector3;
  81340. /**
  81341. * The right direction of that transform in world space.
  81342. */
  81343. readonly right: Vector3;
  81344. /**
  81345. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81346. * @param matrix the matrix to copy the pose from
  81347. * @returns this TransformNode.
  81348. */
  81349. updatePoseMatrix(matrix: Matrix): TransformNode;
  81350. /**
  81351. * Returns the mesh Pose matrix.
  81352. * @returns the pose matrix
  81353. */
  81354. getPoseMatrix(): Matrix;
  81355. /** @hidden */
  81356. _isSynchronized(): boolean;
  81357. /** @hidden */
  81358. _initCache(): void;
  81359. /**
  81360. * Flag the transform node as dirty (Forcing it to update everything)
  81361. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81362. * @returns this transform node
  81363. */
  81364. markAsDirty(property: string): TransformNode;
  81365. /**
  81366. * Returns the current mesh absolute position.
  81367. * Returns a Vector3.
  81368. */
  81369. readonly absolutePosition: Vector3;
  81370. /**
  81371. * Returns the current mesh absolute scaling.
  81372. * Returns a Vector3.
  81373. */
  81374. readonly absoluteScaling: Vector3;
  81375. /**
  81376. * Returns the current mesh absolute rotation.
  81377. * Returns a Quaternion.
  81378. */
  81379. readonly absoluteRotationQuaternion: Quaternion;
  81380. /**
  81381. * Sets a new matrix to apply before all other transformation
  81382. * @param matrix defines the transform matrix
  81383. * @returns the current TransformNode
  81384. */
  81385. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81386. /**
  81387. * Sets a new pivot matrix to the current node
  81388. * @param matrix defines the new pivot matrix to use
  81389. * @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
  81390. * @returns the current TransformNode
  81391. */
  81392. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81393. /**
  81394. * Returns the mesh pivot matrix.
  81395. * Default : Identity.
  81396. * @returns the matrix
  81397. */
  81398. getPivotMatrix(): Matrix;
  81399. /**
  81400. * Instantiate (when possible) or clone that node with its hierarchy
  81401. * @param newParent defines the new parent to use for the instance (or clone)
  81402. * @returns an instance (or a clone) of the current node with its hiearchy
  81403. */
  81404. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81405. /**
  81406. * Prevents the World matrix to be computed any longer
  81407. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81408. * @returns the TransformNode.
  81409. */
  81410. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81411. /**
  81412. * Allows back the World matrix computation.
  81413. * @returns the TransformNode.
  81414. */
  81415. unfreezeWorldMatrix(): this;
  81416. /**
  81417. * True if the World matrix has been frozen.
  81418. */
  81419. readonly isWorldMatrixFrozen: boolean;
  81420. /**
  81421. * Retuns the mesh absolute position in the World.
  81422. * @returns a Vector3.
  81423. */
  81424. getAbsolutePosition(): Vector3;
  81425. /**
  81426. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81427. * @param absolutePosition the absolute position to set
  81428. * @returns the TransformNode.
  81429. */
  81430. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81431. /**
  81432. * Sets the mesh position in its local space.
  81433. * @param vector3 the position to set in localspace
  81434. * @returns the TransformNode.
  81435. */
  81436. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81437. /**
  81438. * Returns the mesh position in the local space from the current World matrix values.
  81439. * @returns a new Vector3.
  81440. */
  81441. getPositionExpressedInLocalSpace(): Vector3;
  81442. /**
  81443. * Translates the mesh along the passed Vector3 in its local space.
  81444. * @param vector3 the distance to translate in localspace
  81445. * @returns the TransformNode.
  81446. */
  81447. locallyTranslate(vector3: Vector3): TransformNode;
  81448. private static _lookAtVectorCache;
  81449. /**
  81450. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81451. * @param targetPoint the position (must be in same space as current mesh) to look at
  81452. * @param yawCor optional yaw (y-axis) correction in radians
  81453. * @param pitchCor optional pitch (x-axis) correction in radians
  81454. * @param rollCor optional roll (z-axis) correction in radians
  81455. * @param space the choosen space of the target
  81456. * @returns the TransformNode.
  81457. */
  81458. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81459. /**
  81460. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81461. * This Vector3 is expressed in the World space.
  81462. * @param localAxis axis to rotate
  81463. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81464. */
  81465. getDirection(localAxis: Vector3): Vector3;
  81466. /**
  81467. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81468. * localAxis is expressed in the mesh local space.
  81469. * result is computed in the Wordl space from the mesh World matrix.
  81470. * @param localAxis axis to rotate
  81471. * @param result the resulting transformnode
  81472. * @returns this TransformNode.
  81473. */
  81474. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81475. /**
  81476. * Sets this transform node rotation to the given local axis.
  81477. * @param localAxis the axis in local space
  81478. * @param yawCor optional yaw (y-axis) correction in radians
  81479. * @param pitchCor optional pitch (x-axis) correction in radians
  81480. * @param rollCor optional roll (z-axis) correction in radians
  81481. * @returns this TransformNode
  81482. */
  81483. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81484. /**
  81485. * Sets a new pivot point to the current node
  81486. * @param point defines the new pivot point to use
  81487. * @param space defines if the point is in world or local space (local by default)
  81488. * @returns the current TransformNode
  81489. */
  81490. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81491. /**
  81492. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81493. * @returns the pivot point
  81494. */
  81495. getPivotPoint(): Vector3;
  81496. /**
  81497. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81498. * @param result the vector3 to store the result
  81499. * @returns this TransformNode.
  81500. */
  81501. getPivotPointToRef(result: Vector3): TransformNode;
  81502. /**
  81503. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81504. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81505. */
  81506. getAbsolutePivotPoint(): Vector3;
  81507. /**
  81508. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81509. * @param result vector3 to store the result
  81510. * @returns this TransformNode.
  81511. */
  81512. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81513. /**
  81514. * Defines the passed node as the parent of the current node.
  81515. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81516. * @see https://doc.babylonjs.com/how_to/parenting
  81517. * @param node the node ot set as the parent
  81518. * @returns this TransformNode.
  81519. */
  81520. setParent(node: Nullable<Node>): TransformNode;
  81521. private _nonUniformScaling;
  81522. /**
  81523. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81524. */
  81525. readonly nonUniformScaling: boolean;
  81526. /** @hidden */
  81527. _updateNonUniformScalingState(value: boolean): boolean;
  81528. /**
  81529. * Attach the current TransformNode to another TransformNode associated with a bone
  81530. * @param bone Bone affecting the TransformNode
  81531. * @param affectedTransformNode TransformNode associated with the bone
  81532. * @returns this object
  81533. */
  81534. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81535. /**
  81536. * Detach the transform node if its associated with a bone
  81537. * @returns this object
  81538. */
  81539. detachFromBone(): TransformNode;
  81540. private static _rotationAxisCache;
  81541. /**
  81542. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81543. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81544. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81545. * The passed axis is also normalized.
  81546. * @param axis the axis to rotate around
  81547. * @param amount the amount to rotate in radians
  81548. * @param space Space to rotate in (Default: local)
  81549. * @returns the TransformNode.
  81550. */
  81551. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81552. /**
  81553. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81554. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81555. * The passed axis is also normalized. .
  81556. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81557. * @param point the point to rotate around
  81558. * @param axis the axis to rotate around
  81559. * @param amount the amount to rotate in radians
  81560. * @returns the TransformNode
  81561. */
  81562. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81563. /**
  81564. * Translates the mesh along the axis vector for the passed distance in the given space.
  81565. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81566. * @param axis the axis to translate in
  81567. * @param distance the distance to translate
  81568. * @param space Space to rotate in (Default: local)
  81569. * @returns the TransformNode.
  81570. */
  81571. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81572. /**
  81573. * Adds a rotation step to the mesh current rotation.
  81574. * x, y, z are Euler angles expressed in radians.
  81575. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81576. * This means this rotation is made in the mesh local space only.
  81577. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81578. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81579. * ```javascript
  81580. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81581. * ```
  81582. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81583. * 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.
  81584. * @param x Rotation to add
  81585. * @param y Rotation to add
  81586. * @param z Rotation to add
  81587. * @returns the TransformNode.
  81588. */
  81589. addRotation(x: number, y: number, z: number): TransformNode;
  81590. /**
  81591. * @hidden
  81592. */
  81593. protected _getEffectiveParent(): Nullable<Node>;
  81594. /**
  81595. * Computes the world matrix of the node
  81596. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81597. * @returns the world matrix
  81598. */
  81599. computeWorldMatrix(force?: boolean): Matrix;
  81600. protected _afterComputeWorldMatrix(): void;
  81601. /**
  81602. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81603. * @param func callback function to add
  81604. *
  81605. * @returns the TransformNode.
  81606. */
  81607. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81608. /**
  81609. * Removes a registered callback function.
  81610. * @param func callback function to remove
  81611. * @returns the TransformNode.
  81612. */
  81613. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81614. /**
  81615. * Gets the position of the current mesh in camera space
  81616. * @param camera defines the camera to use
  81617. * @returns a position
  81618. */
  81619. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81620. /**
  81621. * Returns the distance from the mesh to the active camera
  81622. * @param camera defines the camera to use
  81623. * @returns the distance
  81624. */
  81625. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81626. /**
  81627. * Clone the current transform node
  81628. * @param name Name of the new clone
  81629. * @param newParent New parent for the clone
  81630. * @param doNotCloneChildren Do not clone children hierarchy
  81631. * @returns the new transform node
  81632. */
  81633. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81634. /**
  81635. * Serializes the objects information.
  81636. * @param currentSerializationObject defines the object to serialize in
  81637. * @returns the serialized object
  81638. */
  81639. serialize(currentSerializationObject?: any): any;
  81640. /**
  81641. * Returns a new TransformNode object parsed from the source provided.
  81642. * @param parsedTransformNode is the source.
  81643. * @param scene the scne the object belongs to
  81644. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81645. * @returns a new TransformNode object parsed from the source provided.
  81646. */
  81647. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81648. /**
  81649. * Get all child-transformNodes of this node
  81650. * @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
  81651. * @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
  81652. * @returns an array of TransformNode
  81653. */
  81654. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81655. /**
  81656. * Releases resources associated with this transform node.
  81657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81659. */
  81660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81661. /**
  81662. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81663. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81664. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81665. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81666. * @returns the current mesh
  81667. */
  81668. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81669. private _syncAbsoluteScalingAndRotation;
  81670. }
  81671. }
  81672. declare module BABYLON {
  81673. /**
  81674. * Defines the types of pose enabled controllers that are supported
  81675. */
  81676. export enum PoseEnabledControllerType {
  81677. /**
  81678. * HTC Vive
  81679. */
  81680. VIVE = 0,
  81681. /**
  81682. * Oculus Rift
  81683. */
  81684. OCULUS = 1,
  81685. /**
  81686. * Windows mixed reality
  81687. */
  81688. WINDOWS = 2,
  81689. /**
  81690. * Samsung gear VR
  81691. */
  81692. GEAR_VR = 3,
  81693. /**
  81694. * Google Daydream
  81695. */
  81696. DAYDREAM = 4,
  81697. /**
  81698. * Generic
  81699. */
  81700. GENERIC = 5
  81701. }
  81702. /**
  81703. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81704. */
  81705. export interface MutableGamepadButton {
  81706. /**
  81707. * Value of the button/trigger
  81708. */
  81709. value: number;
  81710. /**
  81711. * If the button/trigger is currently touched
  81712. */
  81713. touched: boolean;
  81714. /**
  81715. * If the button/trigger is currently pressed
  81716. */
  81717. pressed: boolean;
  81718. }
  81719. /**
  81720. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81721. * @hidden
  81722. */
  81723. export interface ExtendedGamepadButton extends GamepadButton {
  81724. /**
  81725. * If the button/trigger is currently pressed
  81726. */
  81727. readonly pressed: boolean;
  81728. /**
  81729. * If the button/trigger is currently touched
  81730. */
  81731. readonly touched: boolean;
  81732. /**
  81733. * Value of the button/trigger
  81734. */
  81735. readonly value: number;
  81736. }
  81737. /** @hidden */
  81738. export interface _GamePadFactory {
  81739. /**
  81740. * Returns wether or not the current gamepad can be created for this type of controller.
  81741. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81742. * @returns true if it can be created, otherwise false
  81743. */
  81744. canCreate(gamepadInfo: any): boolean;
  81745. /**
  81746. * Creates a new instance of the Gamepad.
  81747. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81748. * @returns the new gamepad instance
  81749. */
  81750. create(gamepadInfo: any): Gamepad;
  81751. }
  81752. /**
  81753. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81754. */
  81755. export class PoseEnabledControllerHelper {
  81756. /** @hidden */
  81757. static _ControllerFactories: _GamePadFactory[];
  81758. /** @hidden */
  81759. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81760. /**
  81761. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81762. * @param vrGamepad the gamepad to initialized
  81763. * @returns a vr controller of the type the gamepad identified as
  81764. */
  81765. static InitiateController(vrGamepad: any): Gamepad;
  81766. }
  81767. /**
  81768. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81769. */
  81770. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81771. /**
  81772. * If the controller is used in a webXR session
  81773. */
  81774. isXR: boolean;
  81775. private _deviceRoomPosition;
  81776. private _deviceRoomRotationQuaternion;
  81777. /**
  81778. * The device position in babylon space
  81779. */
  81780. devicePosition: Vector3;
  81781. /**
  81782. * The device rotation in babylon space
  81783. */
  81784. deviceRotationQuaternion: Quaternion;
  81785. /**
  81786. * The scale factor of the device in babylon space
  81787. */
  81788. deviceScaleFactor: number;
  81789. /**
  81790. * (Likely devicePosition should be used instead) The device position in its room space
  81791. */
  81792. position: Vector3;
  81793. /**
  81794. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81795. */
  81796. rotationQuaternion: Quaternion;
  81797. /**
  81798. * The type of controller (Eg. Windows mixed reality)
  81799. */
  81800. controllerType: PoseEnabledControllerType;
  81801. protected _calculatedPosition: Vector3;
  81802. private _calculatedRotation;
  81803. /**
  81804. * The raw pose from the device
  81805. */
  81806. rawPose: DevicePose;
  81807. private _trackPosition;
  81808. private _maxRotationDistFromHeadset;
  81809. private _draggedRoomRotation;
  81810. /**
  81811. * @hidden
  81812. */
  81813. _disableTrackPosition(fixedPosition: Vector3): void;
  81814. /**
  81815. * Internal, the mesh attached to the controller
  81816. * @hidden
  81817. */
  81818. _mesh: Nullable<AbstractMesh>;
  81819. private _poseControlledCamera;
  81820. private _leftHandSystemQuaternion;
  81821. /**
  81822. * Internal, matrix used to convert room space to babylon space
  81823. * @hidden
  81824. */
  81825. _deviceToWorld: Matrix;
  81826. /**
  81827. * Node to be used when casting a ray from the controller
  81828. * @hidden
  81829. */
  81830. _pointingPoseNode: Nullable<TransformNode>;
  81831. /**
  81832. * Name of the child mesh that can be used to cast a ray from the controller
  81833. */
  81834. static readonly POINTING_POSE: string;
  81835. /**
  81836. * Creates a new PoseEnabledController from a gamepad
  81837. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81838. */
  81839. constructor(browserGamepad: any);
  81840. private _workingMatrix;
  81841. /**
  81842. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81843. */
  81844. update(): void;
  81845. /**
  81846. * Updates only the pose device and mesh without doing any button event checking
  81847. */
  81848. protected _updatePoseAndMesh(): void;
  81849. /**
  81850. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81851. * @param poseData raw pose fromthe device
  81852. */
  81853. updateFromDevice(poseData: DevicePose): void;
  81854. /**
  81855. * @hidden
  81856. */
  81857. _meshAttachedObservable: Observable<AbstractMesh>;
  81858. /**
  81859. * Attaches a mesh to the controller
  81860. * @param mesh the mesh to be attached
  81861. */
  81862. attachToMesh(mesh: AbstractMesh): void;
  81863. /**
  81864. * Attaches the controllers mesh to a camera
  81865. * @param camera the camera the mesh should be attached to
  81866. */
  81867. attachToPoseControlledCamera(camera: TargetCamera): void;
  81868. /**
  81869. * Disposes of the controller
  81870. */
  81871. dispose(): void;
  81872. /**
  81873. * The mesh that is attached to the controller
  81874. */
  81875. readonly mesh: Nullable<AbstractMesh>;
  81876. /**
  81877. * Gets the ray of the controller in the direction the controller is pointing
  81878. * @param length the length the resulting ray should be
  81879. * @returns a ray in the direction the controller is pointing
  81880. */
  81881. getForwardRay(length?: number): Ray;
  81882. }
  81883. }
  81884. declare module BABYLON {
  81885. /**
  81886. * Defines the WebVRController object that represents controllers tracked in 3D space
  81887. */
  81888. export abstract class WebVRController extends PoseEnabledController {
  81889. /**
  81890. * Internal, the default controller model for the controller
  81891. */
  81892. protected _defaultModel: Nullable<AbstractMesh>;
  81893. /**
  81894. * Fired when the trigger state has changed
  81895. */
  81896. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81897. /**
  81898. * Fired when the main button state has changed
  81899. */
  81900. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81901. /**
  81902. * Fired when the secondary button state has changed
  81903. */
  81904. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81905. /**
  81906. * Fired when the pad state has changed
  81907. */
  81908. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81909. /**
  81910. * Fired when controllers stick values have changed
  81911. */
  81912. onPadValuesChangedObservable: Observable<StickValues>;
  81913. /**
  81914. * Array of button availible on the controller
  81915. */
  81916. protected _buttons: Array<MutableGamepadButton>;
  81917. private _onButtonStateChange;
  81918. /**
  81919. * Fired when a controller button's state has changed
  81920. * @param callback the callback containing the button that was modified
  81921. */
  81922. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81923. /**
  81924. * X and Y axis corresponding to the controllers joystick
  81925. */
  81926. pad: StickValues;
  81927. /**
  81928. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81929. */
  81930. hand: string;
  81931. /**
  81932. * The default controller model for the controller
  81933. */
  81934. readonly defaultModel: Nullable<AbstractMesh>;
  81935. /**
  81936. * Creates a new WebVRController from a gamepad
  81937. * @param vrGamepad the gamepad that the WebVRController should be created from
  81938. */
  81939. constructor(vrGamepad: any);
  81940. /**
  81941. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81942. */
  81943. update(): void;
  81944. /**
  81945. * Function to be called when a button is modified
  81946. */
  81947. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81948. /**
  81949. * Loads a mesh and attaches it to the controller
  81950. * @param scene the scene the mesh should be added to
  81951. * @param meshLoaded callback for when the mesh has been loaded
  81952. */
  81953. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81954. private _setButtonValue;
  81955. private _changes;
  81956. private _checkChanges;
  81957. /**
  81958. * Disposes of th webVRCOntroller
  81959. */
  81960. dispose(): void;
  81961. }
  81962. }
  81963. declare module BABYLON {
  81964. /**
  81965. * The HemisphericLight simulates the ambient environment light,
  81966. * so the passed direction is the light reflection direction, not the incoming direction.
  81967. */
  81968. export class HemisphericLight extends Light {
  81969. /**
  81970. * The groundColor is the light in the opposite direction to the one specified during creation.
  81971. * 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.
  81972. */
  81973. groundColor: Color3;
  81974. /**
  81975. * The light reflection direction, not the incoming direction.
  81976. */
  81977. direction: Vector3;
  81978. /**
  81979. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81980. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81981. * The HemisphericLight can't cast shadows.
  81982. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81983. * @param name The friendly name of the light
  81984. * @param direction The direction of the light reflection
  81985. * @param scene The scene the light belongs to
  81986. */
  81987. constructor(name: string, direction: Vector3, scene: Scene);
  81988. protected _buildUniformLayout(): void;
  81989. /**
  81990. * Returns the string "HemisphericLight".
  81991. * @return The class name
  81992. */
  81993. getClassName(): string;
  81994. /**
  81995. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81996. * Returns the updated direction.
  81997. * @param target The target the direction should point to
  81998. * @return The computed direction
  81999. */
  82000. setDirectionToTarget(target: Vector3): Vector3;
  82001. /**
  82002. * Returns the shadow generator associated to the light.
  82003. * @returns Always null for hemispheric lights because it does not support shadows.
  82004. */
  82005. getShadowGenerator(): Nullable<IShadowGenerator>;
  82006. /**
  82007. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82008. * @param effect The effect to update
  82009. * @param lightIndex The index of the light in the effect to update
  82010. * @returns The hemispheric light
  82011. */
  82012. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82013. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82014. /**
  82015. * Computes the world matrix of the node
  82016. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82017. * @param useWasUpdatedFlag defines a reserved property
  82018. * @returns the world matrix
  82019. */
  82020. computeWorldMatrix(): Matrix;
  82021. /**
  82022. * Returns the integer 3.
  82023. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82024. */
  82025. getTypeID(): number;
  82026. /**
  82027. * Prepares the list of defines specific to the light type.
  82028. * @param defines the list of defines
  82029. * @param lightIndex defines the index of the light for the effect
  82030. */
  82031. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82032. }
  82033. }
  82034. declare module BABYLON {
  82035. /** @hidden */
  82036. export var vrMultiviewToSingleviewPixelShader: {
  82037. name: string;
  82038. shader: string;
  82039. };
  82040. }
  82041. declare module BABYLON {
  82042. /**
  82043. * Renders to multiple views with a single draw call
  82044. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82045. */
  82046. export class MultiviewRenderTarget extends RenderTargetTexture {
  82047. /**
  82048. * Creates a multiview render target
  82049. * @param scene scene used with the render target
  82050. * @param size the size of the render target (used for each view)
  82051. */
  82052. constructor(scene: Scene, size?: number | {
  82053. width: number;
  82054. height: number;
  82055. } | {
  82056. ratio: number;
  82057. });
  82058. /**
  82059. * @hidden
  82060. * @param faceIndex the face index, if its a cube texture
  82061. */
  82062. _bindFrameBuffer(faceIndex?: number): void;
  82063. /**
  82064. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82065. * @returns the view count
  82066. */
  82067. getViewCount(): number;
  82068. }
  82069. }
  82070. declare module BABYLON {
  82071. /**
  82072. * Represents a camera frustum
  82073. */
  82074. export class Frustum {
  82075. /**
  82076. * Gets the planes representing the frustum
  82077. * @param transform matrix to be applied to the returned planes
  82078. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82079. */
  82080. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82081. /**
  82082. * Gets the near frustum plane transformed by the transform matrix
  82083. * @param transform transformation matrix to be applied to the resulting frustum plane
  82084. * @param frustumPlane the resuling frustum plane
  82085. */
  82086. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82087. /**
  82088. * Gets the far frustum plane transformed by the transform matrix
  82089. * @param transform transformation matrix to be applied to the resulting frustum plane
  82090. * @param frustumPlane the resuling frustum plane
  82091. */
  82092. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82093. /**
  82094. * Gets the left frustum plane transformed by the transform matrix
  82095. * @param transform transformation matrix to be applied to the resulting frustum plane
  82096. * @param frustumPlane the resuling frustum plane
  82097. */
  82098. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82099. /**
  82100. * Gets the right frustum plane transformed by the transform matrix
  82101. * @param transform transformation matrix to be applied to the resulting frustum plane
  82102. * @param frustumPlane the resuling frustum plane
  82103. */
  82104. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82105. /**
  82106. * Gets the top frustum plane transformed by the transform matrix
  82107. * @param transform transformation matrix to be applied to the resulting frustum plane
  82108. * @param frustumPlane the resuling frustum plane
  82109. */
  82110. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82111. /**
  82112. * Gets the bottom frustum plane transformed by the transform matrix
  82113. * @param transform transformation matrix to be applied to the resulting frustum plane
  82114. * @param frustumPlane the resuling frustum plane
  82115. */
  82116. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82117. /**
  82118. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82119. * @param transform transformation matrix to be applied to the resulting frustum planes
  82120. * @param frustumPlanes the resuling frustum planes
  82121. */
  82122. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82123. }
  82124. }
  82125. declare module BABYLON {
  82126. interface Engine {
  82127. /**
  82128. * Creates a new multiview render target
  82129. * @param width defines the width of the texture
  82130. * @param height defines the height of the texture
  82131. * @returns the created multiview texture
  82132. */
  82133. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82134. /**
  82135. * Binds a multiview framebuffer to be drawn to
  82136. * @param multiviewTexture texture to bind
  82137. */
  82138. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82139. }
  82140. interface Camera {
  82141. /**
  82142. * @hidden
  82143. * 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)
  82144. */
  82145. _useMultiviewToSingleView: boolean;
  82146. /**
  82147. * @hidden
  82148. * 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)
  82149. */
  82150. _multiviewTexture: Nullable<RenderTargetTexture>;
  82151. /**
  82152. * @hidden
  82153. * ensures the multiview texture of the camera exists and has the specified width/height
  82154. * @param width height to set on the multiview texture
  82155. * @param height width to set on the multiview texture
  82156. */
  82157. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82158. }
  82159. interface Scene {
  82160. /** @hidden */
  82161. _transformMatrixR: Matrix;
  82162. /** @hidden */
  82163. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82164. /** @hidden */
  82165. _createMultiviewUbo(): void;
  82166. /** @hidden */
  82167. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82168. /** @hidden */
  82169. _renderMultiviewToSingleView(camera: Camera): void;
  82170. }
  82171. }
  82172. declare module BABYLON {
  82173. /**
  82174. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82175. * This will not be used for webXR as it supports displaying texture arrays directly
  82176. */
  82177. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82178. /**
  82179. * Initializes a VRMultiviewToSingleview
  82180. * @param name name of the post process
  82181. * @param camera camera to be applied to
  82182. * @param scaleFactor scaling factor to the size of the output texture
  82183. */
  82184. constructor(name: string, camera: Camera, scaleFactor: number);
  82185. }
  82186. }
  82187. declare module BABYLON {
  82188. interface Engine {
  82189. /** @hidden */
  82190. _vrDisplay: any;
  82191. /** @hidden */
  82192. _vrSupported: boolean;
  82193. /** @hidden */
  82194. _oldSize: Size;
  82195. /** @hidden */
  82196. _oldHardwareScaleFactor: number;
  82197. /** @hidden */
  82198. _vrExclusivePointerMode: boolean;
  82199. /** @hidden */
  82200. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82201. /** @hidden */
  82202. _onVRDisplayPointerRestricted: () => void;
  82203. /** @hidden */
  82204. _onVRDisplayPointerUnrestricted: () => void;
  82205. /** @hidden */
  82206. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82207. /** @hidden */
  82208. _onVrDisplayDisconnect: Nullable<() => void>;
  82209. /** @hidden */
  82210. _onVrDisplayPresentChange: Nullable<() => void>;
  82211. /**
  82212. * Observable signaled when VR display mode changes
  82213. */
  82214. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82215. /**
  82216. * Observable signaled when VR request present is complete
  82217. */
  82218. onVRRequestPresentComplete: Observable<boolean>;
  82219. /**
  82220. * Observable signaled when VR request present starts
  82221. */
  82222. onVRRequestPresentStart: Observable<Engine>;
  82223. /**
  82224. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82225. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82226. */
  82227. isInVRExclusivePointerMode: boolean;
  82228. /**
  82229. * Gets a boolean indicating if a webVR device was detected
  82230. * @returns true if a webVR device was detected
  82231. */
  82232. isVRDevicePresent(): boolean;
  82233. /**
  82234. * Gets the current webVR device
  82235. * @returns the current webVR device (or null)
  82236. */
  82237. getVRDevice(): any;
  82238. /**
  82239. * Initializes a webVR display and starts listening to display change events
  82240. * The onVRDisplayChangedObservable will be notified upon these changes
  82241. * @returns A promise containing a VRDisplay and if vr is supported
  82242. */
  82243. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82244. /** @hidden */
  82245. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82246. /**
  82247. * Call this function to switch to webVR mode
  82248. * Will do nothing if webVR is not supported or if there is no webVR device
  82249. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82250. */
  82251. enableVR(): void;
  82252. /** @hidden */
  82253. _onVRFullScreenTriggered(): void;
  82254. }
  82255. }
  82256. declare module BABYLON {
  82257. /**
  82258. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82259. * IMPORTANT!! The data is right-hand data.
  82260. * @export
  82261. * @interface DevicePose
  82262. */
  82263. export interface DevicePose {
  82264. /**
  82265. * The position of the device, values in array are [x,y,z].
  82266. */
  82267. readonly position: Nullable<Float32Array>;
  82268. /**
  82269. * The linearVelocity of the device, values in array are [x,y,z].
  82270. */
  82271. readonly linearVelocity: Nullable<Float32Array>;
  82272. /**
  82273. * The linearAcceleration of the device, values in array are [x,y,z].
  82274. */
  82275. readonly linearAcceleration: Nullable<Float32Array>;
  82276. /**
  82277. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82278. */
  82279. readonly orientation: Nullable<Float32Array>;
  82280. /**
  82281. * The angularVelocity of the device, values in array are [x,y,z].
  82282. */
  82283. readonly angularVelocity: Nullable<Float32Array>;
  82284. /**
  82285. * The angularAcceleration of the device, values in array are [x,y,z].
  82286. */
  82287. readonly angularAcceleration: Nullable<Float32Array>;
  82288. }
  82289. /**
  82290. * Interface representing a pose controlled object in Babylon.
  82291. * A pose controlled object has both regular pose values as well as pose values
  82292. * from an external device such as a VR head mounted display
  82293. */
  82294. export interface PoseControlled {
  82295. /**
  82296. * The position of the object in babylon space.
  82297. */
  82298. position: Vector3;
  82299. /**
  82300. * The rotation quaternion of the object in babylon space.
  82301. */
  82302. rotationQuaternion: Quaternion;
  82303. /**
  82304. * The position of the device in babylon space.
  82305. */
  82306. devicePosition?: Vector3;
  82307. /**
  82308. * The rotation quaternion of the device in babylon space.
  82309. */
  82310. deviceRotationQuaternion: Quaternion;
  82311. /**
  82312. * The raw pose coming from the device.
  82313. */
  82314. rawPose: Nullable<DevicePose>;
  82315. /**
  82316. * The scale of the device to be used when translating from device space to babylon space.
  82317. */
  82318. deviceScaleFactor: number;
  82319. /**
  82320. * Updates the poseControlled values based on the input device pose.
  82321. * @param poseData the pose data to update the object with
  82322. */
  82323. updateFromDevice(poseData: DevicePose): void;
  82324. }
  82325. /**
  82326. * Set of options to customize the webVRCamera
  82327. */
  82328. export interface WebVROptions {
  82329. /**
  82330. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82331. */
  82332. trackPosition?: boolean;
  82333. /**
  82334. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82335. */
  82336. positionScale?: number;
  82337. /**
  82338. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82339. */
  82340. displayName?: string;
  82341. /**
  82342. * Should the native controller meshes be initialized. (default: true)
  82343. */
  82344. controllerMeshes?: boolean;
  82345. /**
  82346. * Creating a default HemiLight only on controllers. (default: true)
  82347. */
  82348. defaultLightingOnControllers?: boolean;
  82349. /**
  82350. * If you don't want to use the default VR button of the helper. (default: false)
  82351. */
  82352. useCustomVRButton?: boolean;
  82353. /**
  82354. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82355. */
  82356. customVRButton?: HTMLButtonElement;
  82357. /**
  82358. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82359. */
  82360. rayLength?: number;
  82361. /**
  82362. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82363. */
  82364. defaultHeight?: number;
  82365. /**
  82366. * If multiview should be used if availible (default: false)
  82367. */
  82368. useMultiview?: boolean;
  82369. }
  82370. /**
  82371. * This represents a WebVR camera.
  82372. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82373. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82374. */
  82375. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82376. private webVROptions;
  82377. /**
  82378. * @hidden
  82379. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82380. */
  82381. _vrDevice: any;
  82382. /**
  82383. * The rawPose of the vrDevice.
  82384. */
  82385. rawPose: Nullable<DevicePose>;
  82386. private _onVREnabled;
  82387. private _specsVersion;
  82388. private _attached;
  82389. private _frameData;
  82390. protected _descendants: Array<Node>;
  82391. private _deviceRoomPosition;
  82392. /** @hidden */
  82393. _deviceRoomRotationQuaternion: Quaternion;
  82394. private _standingMatrix;
  82395. /**
  82396. * Represents device position in babylon space.
  82397. */
  82398. devicePosition: Vector3;
  82399. /**
  82400. * Represents device rotation in babylon space.
  82401. */
  82402. deviceRotationQuaternion: Quaternion;
  82403. /**
  82404. * The scale of the device to be used when translating from device space to babylon space.
  82405. */
  82406. deviceScaleFactor: number;
  82407. private _deviceToWorld;
  82408. private _worldToDevice;
  82409. /**
  82410. * References to the webVR controllers for the vrDevice.
  82411. */
  82412. controllers: Array<WebVRController>;
  82413. /**
  82414. * Emits an event when a controller is attached.
  82415. */
  82416. onControllersAttachedObservable: Observable<WebVRController[]>;
  82417. /**
  82418. * Emits an event when a controller's mesh has been loaded;
  82419. */
  82420. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82421. /**
  82422. * Emits an event when the HMD's pose has been updated.
  82423. */
  82424. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82425. private _poseSet;
  82426. /**
  82427. * If the rig cameras be used as parent instead of this camera.
  82428. */
  82429. rigParenting: boolean;
  82430. private _lightOnControllers;
  82431. private _defaultHeight?;
  82432. /**
  82433. * Instantiates a WebVRFreeCamera.
  82434. * @param name The name of the WebVRFreeCamera
  82435. * @param position The starting anchor position for the camera
  82436. * @param scene The scene the camera belongs to
  82437. * @param webVROptions a set of customizable options for the webVRCamera
  82438. */
  82439. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82440. /**
  82441. * Gets the device distance from the ground in meters.
  82442. * @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.
  82443. */
  82444. deviceDistanceToRoomGround(): number;
  82445. /**
  82446. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82447. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82448. */
  82449. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82450. /**
  82451. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82452. * @returns A promise with a boolean set to if the standing matrix is supported.
  82453. */
  82454. useStandingMatrixAsync(): Promise<boolean>;
  82455. /**
  82456. * Disposes the camera
  82457. */
  82458. dispose(): void;
  82459. /**
  82460. * Gets a vrController by name.
  82461. * @param name The name of the controller to retreive
  82462. * @returns the controller matching the name specified or null if not found
  82463. */
  82464. getControllerByName(name: string): Nullable<WebVRController>;
  82465. private _leftController;
  82466. /**
  82467. * The controller corresponding to the users left hand.
  82468. */
  82469. readonly leftController: Nullable<WebVRController>;
  82470. private _rightController;
  82471. /**
  82472. * The controller corresponding to the users right hand.
  82473. */
  82474. readonly rightController: Nullable<WebVRController>;
  82475. /**
  82476. * Casts a ray forward from the vrCamera's gaze.
  82477. * @param length Length of the ray (default: 100)
  82478. * @returns the ray corresponding to the gaze
  82479. */
  82480. getForwardRay(length?: number): Ray;
  82481. /**
  82482. * @hidden
  82483. * Updates the camera based on device's frame data
  82484. */
  82485. _checkInputs(): void;
  82486. /**
  82487. * Updates the poseControlled values based on the input device pose.
  82488. * @param poseData Pose coming from the device
  82489. */
  82490. updateFromDevice(poseData: DevicePose): void;
  82491. private _htmlElementAttached;
  82492. private _detachIfAttached;
  82493. /**
  82494. * WebVR's attach control will start broadcasting frames to the device.
  82495. * Note that in certain browsers (chrome for example) this function must be called
  82496. * within a user-interaction callback. Example:
  82497. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82498. *
  82499. * @param element html element to attach the vrDevice to
  82500. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82501. */
  82502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82503. /**
  82504. * Detaches the camera from the html element and disables VR
  82505. *
  82506. * @param element html element to detach from
  82507. */
  82508. detachControl(element: HTMLElement): void;
  82509. /**
  82510. * @returns the name of this class
  82511. */
  82512. getClassName(): string;
  82513. /**
  82514. * Calls resetPose on the vrDisplay
  82515. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82516. */
  82517. resetToCurrentRotation(): void;
  82518. /**
  82519. * @hidden
  82520. * Updates the rig cameras (left and right eye)
  82521. */
  82522. _updateRigCameras(): void;
  82523. private _workingVector;
  82524. private _oneVector;
  82525. private _workingMatrix;
  82526. private updateCacheCalled;
  82527. private _correctPositionIfNotTrackPosition;
  82528. /**
  82529. * @hidden
  82530. * Updates the cached values of the camera
  82531. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82532. */
  82533. _updateCache(ignoreParentClass?: boolean): void;
  82534. /**
  82535. * @hidden
  82536. * Get current device position in babylon world
  82537. */
  82538. _computeDevicePosition(): void;
  82539. /**
  82540. * Updates the current device position and rotation in the babylon world
  82541. */
  82542. update(): void;
  82543. /**
  82544. * @hidden
  82545. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82546. * @returns an identity matrix
  82547. */
  82548. _getViewMatrix(): Matrix;
  82549. private _tmpMatrix;
  82550. /**
  82551. * This function is called by the two RIG cameras.
  82552. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82553. * @hidden
  82554. */
  82555. _getWebVRViewMatrix(): Matrix;
  82556. /** @hidden */
  82557. _getWebVRProjectionMatrix(): Matrix;
  82558. private _onGamepadConnectedObserver;
  82559. private _onGamepadDisconnectedObserver;
  82560. private _updateCacheWhenTrackingDisabledObserver;
  82561. /**
  82562. * Initializes the controllers and their meshes
  82563. */
  82564. initControllers(): void;
  82565. }
  82566. }
  82567. declare module BABYLON {
  82568. /**
  82569. * Size options for a post process
  82570. */
  82571. export type PostProcessOptions = {
  82572. width: number;
  82573. height: number;
  82574. };
  82575. /**
  82576. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82577. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82578. */
  82579. export class PostProcess {
  82580. /** Name of the PostProcess. */
  82581. name: string;
  82582. /**
  82583. * Gets or sets the unique id of the post process
  82584. */
  82585. uniqueId: number;
  82586. /**
  82587. * Width of the texture to apply the post process on
  82588. */
  82589. width: number;
  82590. /**
  82591. * Height of the texture to apply the post process on
  82592. */
  82593. height: number;
  82594. /**
  82595. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82596. * @hidden
  82597. */
  82598. _outputTexture: Nullable<InternalTexture>;
  82599. /**
  82600. * Sampling mode used by the shader
  82601. * See https://doc.babylonjs.com/classes/3.1/texture
  82602. */
  82603. renderTargetSamplingMode: number;
  82604. /**
  82605. * Clear color to use when screen clearing
  82606. */
  82607. clearColor: Color4;
  82608. /**
  82609. * If the buffer needs to be cleared before applying the post process. (default: true)
  82610. * Should be set to false if shader will overwrite all previous pixels.
  82611. */
  82612. autoClear: boolean;
  82613. /**
  82614. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82615. */
  82616. alphaMode: number;
  82617. /**
  82618. * Sets the setAlphaBlendConstants of the babylon engine
  82619. */
  82620. alphaConstants: Color4;
  82621. /**
  82622. * Animations to be used for the post processing
  82623. */
  82624. animations: Animation[];
  82625. /**
  82626. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82627. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82628. */
  82629. enablePixelPerfectMode: boolean;
  82630. /**
  82631. * Force the postprocess to be applied without taking in account viewport
  82632. */
  82633. forceFullscreenViewport: boolean;
  82634. /**
  82635. * List of inspectable custom properties (used by the Inspector)
  82636. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82637. */
  82638. inspectableCustomProperties: IInspectable[];
  82639. /**
  82640. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82641. *
  82642. * | Value | Type | Description |
  82643. * | ----- | ----------------------------------- | ----------- |
  82644. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82645. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82646. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82647. *
  82648. */
  82649. scaleMode: number;
  82650. /**
  82651. * Force textures to be a power of two (default: false)
  82652. */
  82653. alwaysForcePOT: boolean;
  82654. private _samples;
  82655. /**
  82656. * Number of sample textures (default: 1)
  82657. */
  82658. samples: number;
  82659. /**
  82660. * Modify the scale of the post process to be the same as the viewport (default: false)
  82661. */
  82662. adaptScaleToCurrentViewport: boolean;
  82663. private _camera;
  82664. private _scene;
  82665. private _engine;
  82666. private _options;
  82667. private _reusable;
  82668. private _textureType;
  82669. /**
  82670. * Smart array of input and output textures for the post process.
  82671. * @hidden
  82672. */
  82673. _textures: SmartArray<InternalTexture>;
  82674. /**
  82675. * The index in _textures that corresponds to the output texture.
  82676. * @hidden
  82677. */
  82678. _currentRenderTextureInd: number;
  82679. private _effect;
  82680. private _samplers;
  82681. private _fragmentUrl;
  82682. private _vertexUrl;
  82683. private _parameters;
  82684. private _scaleRatio;
  82685. protected _indexParameters: any;
  82686. private _shareOutputWithPostProcess;
  82687. private _texelSize;
  82688. private _forcedOutputTexture;
  82689. /**
  82690. * Returns the fragment url or shader name used in the post process.
  82691. * @returns the fragment url or name in the shader store.
  82692. */
  82693. getEffectName(): string;
  82694. /**
  82695. * An event triggered when the postprocess is activated.
  82696. */
  82697. onActivateObservable: Observable<Camera>;
  82698. private _onActivateObserver;
  82699. /**
  82700. * A function that is added to the onActivateObservable
  82701. */
  82702. onActivate: Nullable<(camera: Camera) => void>;
  82703. /**
  82704. * An event triggered when the postprocess changes its size.
  82705. */
  82706. onSizeChangedObservable: Observable<PostProcess>;
  82707. private _onSizeChangedObserver;
  82708. /**
  82709. * A function that is added to the onSizeChangedObservable
  82710. */
  82711. onSizeChanged: (postProcess: PostProcess) => void;
  82712. /**
  82713. * An event triggered when the postprocess applies its effect.
  82714. */
  82715. onApplyObservable: Observable<Effect>;
  82716. private _onApplyObserver;
  82717. /**
  82718. * A function that is added to the onApplyObservable
  82719. */
  82720. onApply: (effect: Effect) => void;
  82721. /**
  82722. * An event triggered before rendering the postprocess
  82723. */
  82724. onBeforeRenderObservable: Observable<Effect>;
  82725. private _onBeforeRenderObserver;
  82726. /**
  82727. * A function that is added to the onBeforeRenderObservable
  82728. */
  82729. onBeforeRender: (effect: Effect) => void;
  82730. /**
  82731. * An event triggered after rendering the postprocess
  82732. */
  82733. onAfterRenderObservable: Observable<Effect>;
  82734. private _onAfterRenderObserver;
  82735. /**
  82736. * A function that is added to the onAfterRenderObservable
  82737. */
  82738. onAfterRender: (efect: Effect) => void;
  82739. /**
  82740. * 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
  82741. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82742. */
  82743. inputTexture: InternalTexture;
  82744. /**
  82745. * Gets the camera which post process is applied to.
  82746. * @returns The camera the post process is applied to.
  82747. */
  82748. getCamera(): Camera;
  82749. /**
  82750. * Gets the texel size of the postprocess.
  82751. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82752. */
  82753. readonly texelSize: Vector2;
  82754. /**
  82755. * Creates a new instance PostProcess
  82756. * @param name The name of the PostProcess.
  82757. * @param fragmentUrl The url of the fragment shader to be used.
  82758. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82759. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82760. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82761. * @param camera The camera to apply the render pass to.
  82762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82763. * @param engine The engine which the post process will be applied. (default: current engine)
  82764. * @param reusable If the post process can be reused on the same frame. (default: false)
  82765. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82766. * @param textureType Type of textures used when performing the post process. (default: 0)
  82767. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82768. * @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
  82769. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82770. */
  82771. constructor(
  82772. /** Name of the PostProcess. */
  82773. 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);
  82774. /**
  82775. * Gets a string idenfifying the name of the class
  82776. * @returns "PostProcess" string
  82777. */
  82778. getClassName(): string;
  82779. /**
  82780. * Gets the engine which this post process belongs to.
  82781. * @returns The engine the post process was enabled with.
  82782. */
  82783. getEngine(): Engine;
  82784. /**
  82785. * The effect that is created when initializing the post process.
  82786. * @returns The created effect corresponding the the postprocess.
  82787. */
  82788. getEffect(): Effect;
  82789. /**
  82790. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82791. * @param postProcess The post process to share the output with.
  82792. * @returns This post process.
  82793. */
  82794. shareOutputWith(postProcess: PostProcess): PostProcess;
  82795. /**
  82796. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82797. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82798. */
  82799. useOwnOutput(): void;
  82800. /**
  82801. * Updates the effect with the current post process compile time values and recompiles the shader.
  82802. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82803. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82804. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82805. * @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
  82806. * @param onCompiled Called when the shader has been compiled.
  82807. * @param onError Called if there is an error when compiling a shader.
  82808. */
  82809. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82810. /**
  82811. * The post process is reusable if it can be used multiple times within one frame.
  82812. * @returns If the post process is reusable
  82813. */
  82814. isReusable(): boolean;
  82815. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82816. markTextureDirty(): void;
  82817. /**
  82818. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82819. * 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.
  82820. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82821. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82822. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82823. * @returns The target texture that was bound to be written to.
  82824. */
  82825. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82826. /**
  82827. * If the post process is supported.
  82828. */
  82829. readonly isSupported: boolean;
  82830. /**
  82831. * The aspect ratio of the output texture.
  82832. */
  82833. readonly aspectRatio: number;
  82834. /**
  82835. * Get a value indicating if the post-process is ready to be used
  82836. * @returns true if the post-process is ready (shader is compiled)
  82837. */
  82838. isReady(): boolean;
  82839. /**
  82840. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82841. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82842. */
  82843. apply(): Nullable<Effect>;
  82844. private _disposeTextures;
  82845. /**
  82846. * Disposes the post process.
  82847. * @param camera The camera to dispose the post process on.
  82848. */
  82849. dispose(camera?: Camera): void;
  82850. }
  82851. }
  82852. declare module BABYLON {
  82853. /** @hidden */
  82854. export var kernelBlurVaryingDeclaration: {
  82855. name: string;
  82856. shader: string;
  82857. };
  82858. }
  82859. declare module BABYLON {
  82860. /** @hidden */
  82861. export var kernelBlurFragment: {
  82862. name: string;
  82863. shader: string;
  82864. };
  82865. }
  82866. declare module BABYLON {
  82867. /** @hidden */
  82868. export var kernelBlurFragment2: {
  82869. name: string;
  82870. shader: string;
  82871. };
  82872. }
  82873. declare module BABYLON {
  82874. /** @hidden */
  82875. export var kernelBlurPixelShader: {
  82876. name: string;
  82877. shader: string;
  82878. };
  82879. }
  82880. declare module BABYLON {
  82881. /** @hidden */
  82882. export var kernelBlurVertex: {
  82883. name: string;
  82884. shader: string;
  82885. };
  82886. }
  82887. declare module BABYLON {
  82888. /** @hidden */
  82889. export var kernelBlurVertexShader: {
  82890. name: string;
  82891. shader: string;
  82892. };
  82893. }
  82894. declare module BABYLON {
  82895. /**
  82896. * The Blur Post Process which blurs an image based on a kernel and direction.
  82897. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82898. */
  82899. export class BlurPostProcess extends PostProcess {
  82900. /** The direction in which to blur the image. */
  82901. direction: Vector2;
  82902. private blockCompilation;
  82903. protected _kernel: number;
  82904. protected _idealKernel: number;
  82905. protected _packedFloat: boolean;
  82906. private _staticDefines;
  82907. /**
  82908. * Sets the length in pixels of the blur sample region
  82909. */
  82910. /**
  82911. * Gets the length in pixels of the blur sample region
  82912. */
  82913. kernel: number;
  82914. /**
  82915. * Sets wether or not the blur needs to unpack/repack floats
  82916. */
  82917. /**
  82918. * Gets wether or not the blur is unpacking/repacking floats
  82919. */
  82920. packedFloat: boolean;
  82921. /**
  82922. * Creates a new instance BlurPostProcess
  82923. * @param name The name of the effect.
  82924. * @param direction The direction in which to blur the image.
  82925. * @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.
  82926. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82927. * @param camera The camera to apply the render pass to.
  82928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82929. * @param engine The engine which the post process will be applied. (default: current engine)
  82930. * @param reusable If the post process can be reused on the same frame. (default: false)
  82931. * @param textureType Type of textures used when performing the post process. (default: 0)
  82932. * @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)
  82933. */
  82934. constructor(name: string,
  82935. /** The direction in which to blur the image. */
  82936. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82937. /**
  82938. * Updates the effect with the current post process compile time values and recompiles the shader.
  82939. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82940. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82941. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82942. * @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
  82943. * @param onCompiled Called when the shader has been compiled.
  82944. * @param onError Called if there is an error when compiling a shader.
  82945. */
  82946. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82947. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82948. /**
  82949. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82950. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82951. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82952. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82953. * The gaps between physical kernels are compensated for in the weighting of the samples
  82954. * @param idealKernel Ideal blur kernel.
  82955. * @return Nearest best kernel.
  82956. */
  82957. protected _nearestBestKernel(idealKernel: number): number;
  82958. /**
  82959. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82960. * @param x The point on the Gaussian distribution to sample.
  82961. * @return the value of the Gaussian function at x.
  82962. */
  82963. protected _gaussianWeight(x: number): number;
  82964. /**
  82965. * Generates a string that can be used as a floating point number in GLSL.
  82966. * @param x Value to print.
  82967. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82968. * @return GLSL float string.
  82969. */
  82970. protected _glslFloat(x: number, decimalFigures?: number): string;
  82971. }
  82972. }
  82973. declare module BABYLON {
  82974. /**
  82975. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82976. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82977. * You can then easily use it as a reflectionTexture on a flat surface.
  82978. * In case the surface is not a plane, please consider relying on reflection probes.
  82979. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82980. */
  82981. export class MirrorTexture extends RenderTargetTexture {
  82982. private scene;
  82983. /**
  82984. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82985. * 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.
  82986. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82987. */
  82988. mirrorPlane: Plane;
  82989. /**
  82990. * Define the blur ratio used to blur the reflection if needed.
  82991. */
  82992. blurRatio: number;
  82993. /**
  82994. * Define the adaptive blur kernel used to blur the reflection if needed.
  82995. * This will autocompute the closest best match for the `blurKernel`
  82996. */
  82997. adaptiveBlurKernel: number;
  82998. /**
  82999. * Define the blur kernel used to blur the reflection if needed.
  83000. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83001. */
  83002. blurKernel: number;
  83003. /**
  83004. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83005. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83006. */
  83007. blurKernelX: number;
  83008. /**
  83009. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83010. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83011. */
  83012. blurKernelY: number;
  83013. private _autoComputeBlurKernel;
  83014. protected _onRatioRescale(): void;
  83015. private _updateGammaSpace;
  83016. private _imageProcessingConfigChangeObserver;
  83017. private _transformMatrix;
  83018. private _mirrorMatrix;
  83019. private _savedViewMatrix;
  83020. private _blurX;
  83021. private _blurY;
  83022. private _adaptiveBlurKernel;
  83023. private _blurKernelX;
  83024. private _blurKernelY;
  83025. private _blurRatio;
  83026. /**
  83027. * Instantiates a Mirror Texture.
  83028. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83029. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83030. * You can then easily use it as a reflectionTexture on a flat surface.
  83031. * In case the surface is not a plane, please consider relying on reflection probes.
  83032. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83033. * @param name
  83034. * @param size
  83035. * @param scene
  83036. * @param generateMipMaps
  83037. * @param type
  83038. * @param samplingMode
  83039. * @param generateDepthBuffer
  83040. */
  83041. constructor(name: string, size: number | {
  83042. width: number;
  83043. height: number;
  83044. } | {
  83045. ratio: number;
  83046. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83047. private _preparePostProcesses;
  83048. /**
  83049. * Clone the mirror texture.
  83050. * @returns the cloned texture
  83051. */
  83052. clone(): MirrorTexture;
  83053. /**
  83054. * Serialize the texture to a JSON representation you could use in Parse later on
  83055. * @returns the serialized JSON representation
  83056. */
  83057. serialize(): any;
  83058. /**
  83059. * Dispose the texture and release its associated resources.
  83060. */
  83061. dispose(): void;
  83062. }
  83063. }
  83064. declare module BABYLON {
  83065. /**
  83066. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83067. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83068. */
  83069. export class Texture extends BaseTexture {
  83070. /**
  83071. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83072. */
  83073. static SerializeBuffers: boolean;
  83074. /** @hidden */
  83075. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83076. /** @hidden */
  83077. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83078. /** @hidden */
  83079. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83080. /** nearest is mag = nearest and min = nearest and mip = linear */
  83081. static readonly NEAREST_SAMPLINGMODE: number;
  83082. /** nearest is mag = nearest and min = nearest and mip = linear */
  83083. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83084. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83085. static readonly BILINEAR_SAMPLINGMODE: number;
  83086. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83087. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83088. /** Trilinear is mag = linear and min = linear and mip = linear */
  83089. static readonly TRILINEAR_SAMPLINGMODE: number;
  83090. /** Trilinear is mag = linear and min = linear and mip = linear */
  83091. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83092. /** mag = nearest and min = nearest and mip = nearest */
  83093. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83094. /** mag = nearest and min = linear and mip = nearest */
  83095. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83096. /** mag = nearest and min = linear and mip = linear */
  83097. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83098. /** mag = nearest and min = linear and mip = none */
  83099. static readonly NEAREST_LINEAR: number;
  83100. /** mag = nearest and min = nearest and mip = none */
  83101. static readonly NEAREST_NEAREST: number;
  83102. /** mag = linear and min = nearest and mip = nearest */
  83103. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83104. /** mag = linear and min = nearest and mip = linear */
  83105. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83106. /** mag = linear and min = linear and mip = none */
  83107. static readonly LINEAR_LINEAR: number;
  83108. /** mag = linear and min = nearest and mip = none */
  83109. static readonly LINEAR_NEAREST: number;
  83110. /** Explicit coordinates mode */
  83111. static readonly EXPLICIT_MODE: number;
  83112. /** Spherical coordinates mode */
  83113. static readonly SPHERICAL_MODE: number;
  83114. /** Planar coordinates mode */
  83115. static readonly PLANAR_MODE: number;
  83116. /** Cubic coordinates mode */
  83117. static readonly CUBIC_MODE: number;
  83118. /** Projection coordinates mode */
  83119. static readonly PROJECTION_MODE: number;
  83120. /** Inverse Cubic coordinates mode */
  83121. static readonly SKYBOX_MODE: number;
  83122. /** Inverse Cubic coordinates mode */
  83123. static readonly INVCUBIC_MODE: number;
  83124. /** Equirectangular coordinates mode */
  83125. static readonly EQUIRECTANGULAR_MODE: number;
  83126. /** Equirectangular Fixed coordinates mode */
  83127. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83128. /** Equirectangular Fixed Mirrored coordinates mode */
  83129. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83130. /** Texture is not repeating outside of 0..1 UVs */
  83131. static readonly CLAMP_ADDRESSMODE: number;
  83132. /** Texture is repeating outside of 0..1 UVs */
  83133. static readonly WRAP_ADDRESSMODE: number;
  83134. /** Texture is repeating and mirrored */
  83135. static readonly MIRROR_ADDRESSMODE: number;
  83136. /**
  83137. * 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
  83138. */
  83139. static UseSerializedUrlIfAny: boolean;
  83140. /**
  83141. * Define the url of the texture.
  83142. */
  83143. url: Nullable<string>;
  83144. /**
  83145. * Define an offset on the texture to offset the u coordinates of the UVs
  83146. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83147. */
  83148. uOffset: number;
  83149. /**
  83150. * Define an offset on the texture to offset the v coordinates of the UVs
  83151. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83152. */
  83153. vOffset: number;
  83154. /**
  83155. * Define an offset on the texture to scale the u coordinates of the UVs
  83156. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83157. */
  83158. uScale: number;
  83159. /**
  83160. * Define an offset on the texture to scale the v coordinates of the UVs
  83161. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83162. */
  83163. vScale: number;
  83164. /**
  83165. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83166. * @see http://doc.babylonjs.com/how_to/more_materials
  83167. */
  83168. uAng: number;
  83169. /**
  83170. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83171. * @see http://doc.babylonjs.com/how_to/more_materials
  83172. */
  83173. vAng: number;
  83174. /**
  83175. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83176. * @see http://doc.babylonjs.com/how_to/more_materials
  83177. */
  83178. wAng: number;
  83179. /**
  83180. * Defines the center of rotation (U)
  83181. */
  83182. uRotationCenter: number;
  83183. /**
  83184. * Defines the center of rotation (V)
  83185. */
  83186. vRotationCenter: number;
  83187. /**
  83188. * Defines the center of rotation (W)
  83189. */
  83190. wRotationCenter: number;
  83191. /**
  83192. * Are mip maps generated for this texture or not.
  83193. */
  83194. readonly noMipmap: boolean;
  83195. /**
  83196. * List of inspectable custom properties (used by the Inspector)
  83197. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83198. */
  83199. inspectableCustomProperties: Nullable<IInspectable[]>;
  83200. private _noMipmap;
  83201. /** @hidden */
  83202. _invertY: boolean;
  83203. private _rowGenerationMatrix;
  83204. private _cachedTextureMatrix;
  83205. private _projectionModeMatrix;
  83206. private _t0;
  83207. private _t1;
  83208. private _t2;
  83209. private _cachedUOffset;
  83210. private _cachedVOffset;
  83211. private _cachedUScale;
  83212. private _cachedVScale;
  83213. private _cachedUAng;
  83214. private _cachedVAng;
  83215. private _cachedWAng;
  83216. private _cachedProjectionMatrixId;
  83217. private _cachedCoordinatesMode;
  83218. /** @hidden */
  83219. protected _initialSamplingMode: number;
  83220. /** @hidden */
  83221. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83222. private _deleteBuffer;
  83223. protected _format: Nullable<number>;
  83224. private _delayedOnLoad;
  83225. private _delayedOnError;
  83226. private _mimeType?;
  83227. /**
  83228. * Observable triggered once the texture has been loaded.
  83229. */
  83230. onLoadObservable: Observable<Texture>;
  83231. protected _isBlocking: boolean;
  83232. /**
  83233. * Is the texture preventing material to render while loading.
  83234. * If false, a default texture will be used instead of the loading one during the preparation step.
  83235. */
  83236. isBlocking: boolean;
  83237. /**
  83238. * Get the current sampling mode associated with the texture.
  83239. */
  83240. readonly samplingMode: number;
  83241. /**
  83242. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83243. */
  83244. readonly invertY: boolean;
  83245. /**
  83246. * Instantiates a new texture.
  83247. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83248. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83249. * @param url defines the url of the picture to load as a texture
  83250. * @param scene defines the scene or engine the texture will belong to
  83251. * @param noMipmap defines if the texture will require mip maps or not
  83252. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83253. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83254. * @param onLoad defines a callback triggered when the texture has been loaded
  83255. * @param onError defines a callback triggered when an error occurred during the loading session
  83256. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83257. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83258. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83259. * @param mimeType defines an optional mime type information
  83260. */
  83261. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83262. /**
  83263. * Update the url (and optional buffer) of this texture if url was null during construction.
  83264. * @param url the url of the texture
  83265. * @param buffer the buffer of the texture (defaults to null)
  83266. * @param onLoad callback called when the texture is loaded (defaults to null)
  83267. */
  83268. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83269. /**
  83270. * Finish the loading sequence of a texture flagged as delayed load.
  83271. * @hidden
  83272. */
  83273. delayLoad(): void;
  83274. private _prepareRowForTextureGeneration;
  83275. /**
  83276. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83277. * @returns the transform matrix of the texture.
  83278. */
  83279. getTextureMatrix(): Matrix;
  83280. /**
  83281. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83282. * @returns The reflection texture transform
  83283. */
  83284. getReflectionTextureMatrix(): Matrix;
  83285. /**
  83286. * Clones the texture.
  83287. * @returns the cloned texture
  83288. */
  83289. clone(): Texture;
  83290. /**
  83291. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83292. * @returns The JSON representation of the texture
  83293. */
  83294. serialize(): any;
  83295. /**
  83296. * Get the current class name of the texture useful for serialization or dynamic coding.
  83297. * @returns "Texture"
  83298. */
  83299. getClassName(): string;
  83300. /**
  83301. * Dispose the texture and release its associated resources.
  83302. */
  83303. dispose(): void;
  83304. /**
  83305. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83306. * @param parsedTexture Define the JSON representation of the texture
  83307. * @param scene Define the scene the parsed texture should be instantiated in
  83308. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83309. * @returns The parsed texture if successful
  83310. */
  83311. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83312. /**
  83313. * Creates a texture from its base 64 representation.
  83314. * @param data Define the base64 payload without the data: prefix
  83315. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83316. * @param scene Define the scene the texture should belong to
  83317. * @param noMipmap Forces the texture to not create mip map information if true
  83318. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83319. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83320. * @param onLoad define a callback triggered when the texture has been loaded
  83321. * @param onError define a callback triggered when an error occurred during the loading session
  83322. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83323. * @returns the created texture
  83324. */
  83325. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83326. /**
  83327. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83328. * @param data Define the base64 payload without the data: prefix
  83329. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83330. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83331. * @param scene Define the scene the texture should belong to
  83332. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83333. * @param noMipmap Forces the texture to not create mip map information if true
  83334. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83335. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83336. * @param onLoad define a callback triggered when the texture has been loaded
  83337. * @param onError define a callback triggered when an error occurred during the loading session
  83338. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83339. * @returns the created texture
  83340. */
  83341. 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;
  83342. }
  83343. }
  83344. declare module BABYLON {
  83345. /**
  83346. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83347. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83348. */
  83349. export class PostProcessManager {
  83350. private _scene;
  83351. private _indexBuffer;
  83352. private _vertexBuffers;
  83353. /**
  83354. * Creates a new instance PostProcess
  83355. * @param scene The scene that the post process is associated with.
  83356. */
  83357. constructor(scene: Scene);
  83358. private _prepareBuffers;
  83359. private _buildIndexBuffer;
  83360. /**
  83361. * Rebuilds the vertex buffers of the manager.
  83362. * @hidden
  83363. */
  83364. _rebuild(): void;
  83365. /**
  83366. * Prepares a frame to be run through a post process.
  83367. * @param sourceTexture The input texture to the post procesess. (default: null)
  83368. * @param postProcesses An array of post processes to be run. (default: null)
  83369. * @returns True if the post processes were able to be run.
  83370. * @hidden
  83371. */
  83372. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83373. /**
  83374. * Manually render a set of post processes to a texture.
  83375. * @param postProcesses An array of post processes to be run.
  83376. * @param targetTexture The target texture to render to.
  83377. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83378. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83379. * @param lodLevel defines which lod of the texture to render to
  83380. */
  83381. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83382. /**
  83383. * Finalize the result of the output of the postprocesses.
  83384. * @param doNotPresent If true the result will not be displayed to the screen.
  83385. * @param targetTexture The target texture to render to.
  83386. * @param faceIndex The index of the face to bind the target texture to.
  83387. * @param postProcesses The array of post processes to render.
  83388. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83389. * @hidden
  83390. */
  83391. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83392. /**
  83393. * Disposes of the post process manager.
  83394. */
  83395. dispose(): void;
  83396. }
  83397. }
  83398. declare module BABYLON {
  83399. /** Interface used by value gradients (color, factor, ...) */
  83400. export interface IValueGradient {
  83401. /**
  83402. * Gets or sets the gradient value (between 0 and 1)
  83403. */
  83404. gradient: number;
  83405. }
  83406. /** Class used to store color4 gradient */
  83407. export class ColorGradient implements IValueGradient {
  83408. /**
  83409. * Gets or sets the gradient value (between 0 and 1)
  83410. */
  83411. gradient: number;
  83412. /**
  83413. * Gets or sets first associated color
  83414. */
  83415. color1: Color4;
  83416. /**
  83417. * Gets or sets second associated color
  83418. */
  83419. color2?: Color4;
  83420. /**
  83421. * Will get a color picked randomly between color1 and color2.
  83422. * If color2 is undefined then color1 will be used
  83423. * @param result defines the target Color4 to store the result in
  83424. */
  83425. getColorToRef(result: Color4): void;
  83426. }
  83427. /** Class used to store color 3 gradient */
  83428. export class Color3Gradient implements IValueGradient {
  83429. /**
  83430. * Gets or sets the gradient value (between 0 and 1)
  83431. */
  83432. gradient: number;
  83433. /**
  83434. * Gets or sets the associated color
  83435. */
  83436. color: Color3;
  83437. }
  83438. /** Class used to store factor gradient */
  83439. export class FactorGradient implements IValueGradient {
  83440. /**
  83441. * Gets or sets the gradient value (between 0 and 1)
  83442. */
  83443. gradient: number;
  83444. /**
  83445. * Gets or sets first associated factor
  83446. */
  83447. factor1: number;
  83448. /**
  83449. * Gets or sets second associated factor
  83450. */
  83451. factor2?: number;
  83452. /**
  83453. * Will get a number picked randomly between factor1 and factor2.
  83454. * If factor2 is undefined then factor1 will be used
  83455. * @returns the picked number
  83456. */
  83457. getFactor(): number;
  83458. }
  83459. /**
  83460. * Helper used to simplify some generic gradient tasks
  83461. */
  83462. export class GradientHelper {
  83463. /**
  83464. * Gets the current gradient from an array of IValueGradient
  83465. * @param ratio defines the current ratio to get
  83466. * @param gradients defines the array of IValueGradient
  83467. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83468. */
  83469. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83470. }
  83471. }
  83472. declare module BABYLON {
  83473. interface ThinEngine {
  83474. /**
  83475. * Creates a dynamic texture
  83476. * @param width defines the width of the texture
  83477. * @param height defines the height of the texture
  83478. * @param generateMipMaps defines if the engine should generate the mip levels
  83479. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83480. * @returns the dynamic texture inside an InternalTexture
  83481. */
  83482. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83483. /**
  83484. * Update the content of a dynamic texture
  83485. * @param texture defines the texture to update
  83486. * @param canvas defines the canvas containing the source
  83487. * @param invertY defines if data must be stored with Y axis inverted
  83488. * @param premulAlpha defines if alpha is stored as premultiplied
  83489. * @param format defines the format of the data
  83490. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83491. */
  83492. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83493. }
  83494. }
  83495. declare module BABYLON {
  83496. /**
  83497. * Helper class used to generate a canvas to manipulate images
  83498. */
  83499. export class CanvasGenerator {
  83500. /**
  83501. * Create a new canvas (or offscreen canvas depending on the context)
  83502. * @param width defines the expected width
  83503. * @param height defines the expected height
  83504. * @return a new canvas or offscreen canvas
  83505. */
  83506. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83507. }
  83508. }
  83509. declare module BABYLON {
  83510. /**
  83511. * A class extending Texture allowing drawing on a texture
  83512. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83513. */
  83514. export class DynamicTexture extends Texture {
  83515. private _generateMipMaps;
  83516. private _canvas;
  83517. private _context;
  83518. private _engine;
  83519. /**
  83520. * Creates a DynamicTexture
  83521. * @param name defines the name of the texture
  83522. * @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
  83523. * @param scene defines the scene where you want the texture
  83524. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83525. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83526. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83527. */
  83528. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83529. /**
  83530. * Get the current class name of the texture useful for serialization or dynamic coding.
  83531. * @returns "DynamicTexture"
  83532. */
  83533. getClassName(): string;
  83534. /**
  83535. * Gets the current state of canRescale
  83536. */
  83537. readonly canRescale: boolean;
  83538. private _recreate;
  83539. /**
  83540. * Scales the texture
  83541. * @param ratio the scale factor to apply to both width and height
  83542. */
  83543. scale(ratio: number): void;
  83544. /**
  83545. * Resizes the texture
  83546. * @param width the new width
  83547. * @param height the new height
  83548. */
  83549. scaleTo(width: number, height: number): void;
  83550. /**
  83551. * Gets the context of the canvas used by the texture
  83552. * @returns the canvas context of the dynamic texture
  83553. */
  83554. getContext(): CanvasRenderingContext2D;
  83555. /**
  83556. * Clears the texture
  83557. */
  83558. clear(): void;
  83559. /**
  83560. * Updates the texture
  83561. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83562. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83563. */
  83564. update(invertY?: boolean, premulAlpha?: boolean): void;
  83565. /**
  83566. * Draws text onto the texture
  83567. * @param text defines the text to be drawn
  83568. * @param x defines the placement of the text from the left
  83569. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83570. * @param font defines the font to be used with font-style, font-size, font-name
  83571. * @param color defines the color used for the text
  83572. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83573. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83574. * @param update defines whether texture is immediately update (default is true)
  83575. */
  83576. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83577. /**
  83578. * Clones the texture
  83579. * @returns the clone of the texture.
  83580. */
  83581. clone(): DynamicTexture;
  83582. /**
  83583. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83584. * @returns a serialized dynamic texture object
  83585. */
  83586. serialize(): any;
  83587. /** @hidden */
  83588. _rebuild(): void;
  83589. }
  83590. }
  83591. declare module BABYLON {
  83592. interface AbstractScene {
  83593. /**
  83594. * The list of procedural textures added to the scene
  83595. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83596. */
  83597. proceduralTextures: Array<ProceduralTexture>;
  83598. }
  83599. /**
  83600. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83601. * in a given scene.
  83602. */
  83603. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83604. /**
  83605. * The component name helpfull to identify the component in the list of scene components.
  83606. */
  83607. readonly name: string;
  83608. /**
  83609. * The scene the component belongs to.
  83610. */
  83611. scene: Scene;
  83612. /**
  83613. * Creates a new instance of the component for the given scene
  83614. * @param scene Defines the scene to register the component in
  83615. */
  83616. constructor(scene: Scene);
  83617. /**
  83618. * Registers the component in a given scene
  83619. */
  83620. register(): void;
  83621. /**
  83622. * Rebuilds the elements related to this component in case of
  83623. * context lost for instance.
  83624. */
  83625. rebuild(): void;
  83626. /**
  83627. * Disposes the component and the associated ressources.
  83628. */
  83629. dispose(): void;
  83630. private _beforeClear;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. interface ThinEngine {
  83635. /**
  83636. * Creates a new render target cube texture
  83637. * @param size defines the size of the texture
  83638. * @param options defines the options used to create the texture
  83639. * @returns a new render target cube texture stored in an InternalTexture
  83640. */
  83641. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83642. }
  83643. }
  83644. declare module BABYLON {
  83645. /** @hidden */
  83646. export var proceduralVertexShader: {
  83647. name: string;
  83648. shader: string;
  83649. };
  83650. }
  83651. declare module BABYLON {
  83652. /**
  83653. * 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.
  83654. * This is the base class of any Procedural texture and contains most of the shareable code.
  83655. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83656. */
  83657. export class ProceduralTexture extends Texture {
  83658. isCube: boolean;
  83659. /**
  83660. * Define if the texture is enabled or not (disabled texture will not render)
  83661. */
  83662. isEnabled: boolean;
  83663. /**
  83664. * Define if the texture must be cleared before rendering (default is true)
  83665. */
  83666. autoClear: boolean;
  83667. /**
  83668. * Callback called when the texture is generated
  83669. */
  83670. onGenerated: () => void;
  83671. /**
  83672. * Event raised when the texture is generated
  83673. */
  83674. onGeneratedObservable: Observable<ProceduralTexture>;
  83675. /** @hidden */
  83676. _generateMipMaps: boolean;
  83677. /** @hidden **/
  83678. _effect: Effect;
  83679. /** @hidden */
  83680. _textures: {
  83681. [key: string]: Texture;
  83682. };
  83683. private _size;
  83684. private _currentRefreshId;
  83685. private _refreshRate;
  83686. private _vertexBuffers;
  83687. private _indexBuffer;
  83688. private _uniforms;
  83689. private _samplers;
  83690. private _fragment;
  83691. private _floats;
  83692. private _ints;
  83693. private _floatsArrays;
  83694. private _colors3;
  83695. private _colors4;
  83696. private _vectors2;
  83697. private _vectors3;
  83698. private _matrices;
  83699. private _fallbackTexture;
  83700. private _fallbackTextureUsed;
  83701. private _engine;
  83702. private _cachedDefines;
  83703. private _contentUpdateId;
  83704. private _contentData;
  83705. /**
  83706. * Instantiates a new procedural texture.
  83707. * 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.
  83708. * This is the base class of any Procedural texture and contains most of the shareable code.
  83709. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83710. * @param name Define the name of the texture
  83711. * @param size Define the size of the texture to create
  83712. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83713. * @param scene Define the scene the texture belongs to
  83714. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83715. * @param generateMipMaps Define if the texture should creates mip maps or not
  83716. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83717. */
  83718. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83719. /**
  83720. * The effect that is created when initializing the post process.
  83721. * @returns The created effect corresponding the the postprocess.
  83722. */
  83723. getEffect(): Effect;
  83724. /**
  83725. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83726. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83727. */
  83728. getContent(): Nullable<ArrayBufferView>;
  83729. private _createIndexBuffer;
  83730. /** @hidden */
  83731. _rebuild(): void;
  83732. /**
  83733. * Resets the texture in order to recreate its associated resources.
  83734. * This can be called in case of context loss
  83735. */
  83736. reset(): void;
  83737. protected _getDefines(): string;
  83738. /**
  83739. * Is the texture ready to be used ? (rendered at least once)
  83740. * @returns true if ready, otherwise, false.
  83741. */
  83742. isReady(): boolean;
  83743. /**
  83744. * Resets the refresh counter of the texture and start bak from scratch.
  83745. * Could be useful to regenerate the texture if it is setup to render only once.
  83746. */
  83747. resetRefreshCounter(): void;
  83748. /**
  83749. * Set the fragment shader to use in order to render the texture.
  83750. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83751. */
  83752. setFragment(fragment: any): void;
  83753. /**
  83754. * Define the refresh rate of the texture or the rendering frequency.
  83755. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83756. */
  83757. refreshRate: number;
  83758. /** @hidden */
  83759. _shouldRender(): boolean;
  83760. /**
  83761. * Get the size the texture is rendering at.
  83762. * @returns the size (texture is always squared)
  83763. */
  83764. getRenderSize(): number;
  83765. /**
  83766. * Resize the texture to new value.
  83767. * @param size Define the new size the texture should have
  83768. * @param generateMipMaps Define whether the new texture should create mip maps
  83769. */
  83770. resize(size: number, generateMipMaps: boolean): void;
  83771. private _checkUniform;
  83772. /**
  83773. * Set a texture in the shader program used to render.
  83774. * @param name Define the name of the uniform samplers as defined in the shader
  83775. * @param texture Define the texture to bind to this sampler
  83776. * @return the texture itself allowing "fluent" like uniform updates
  83777. */
  83778. setTexture(name: string, texture: Texture): ProceduralTexture;
  83779. /**
  83780. * Set a float in the shader.
  83781. * @param name Define the name of the uniform as defined in the shader
  83782. * @param value Define the value to give to the uniform
  83783. * @return the texture itself allowing "fluent" like uniform updates
  83784. */
  83785. setFloat(name: string, value: number): ProceduralTexture;
  83786. /**
  83787. * Set a int in the shader.
  83788. * @param name Define the name of the uniform as defined in the shader
  83789. * @param value Define the value to give to the uniform
  83790. * @return the texture itself allowing "fluent" like uniform updates
  83791. */
  83792. setInt(name: string, value: number): ProceduralTexture;
  83793. /**
  83794. * Set an array of floats in the shader.
  83795. * @param name Define the name of the uniform as defined in the shader
  83796. * @param value Define the value to give to the uniform
  83797. * @return the texture itself allowing "fluent" like uniform updates
  83798. */
  83799. setFloats(name: string, value: number[]): ProceduralTexture;
  83800. /**
  83801. * Set a vec3 in the shader from a Color3.
  83802. * @param name Define the name of the uniform as defined in the shader
  83803. * @param value Define the value to give to the uniform
  83804. * @return the texture itself allowing "fluent" like uniform updates
  83805. */
  83806. setColor3(name: string, value: Color3): ProceduralTexture;
  83807. /**
  83808. * Set a vec4 in the shader from a Color4.
  83809. * @param name Define the name of the uniform as defined in the shader
  83810. * @param value Define the value to give to the uniform
  83811. * @return the texture itself allowing "fluent" like uniform updates
  83812. */
  83813. setColor4(name: string, value: Color4): ProceduralTexture;
  83814. /**
  83815. * Set a vec2 in the shader from a Vector2.
  83816. * @param name Define the name of the uniform as defined in the shader
  83817. * @param value Define the value to give to the uniform
  83818. * @return the texture itself allowing "fluent" like uniform updates
  83819. */
  83820. setVector2(name: string, value: Vector2): ProceduralTexture;
  83821. /**
  83822. * Set a vec3 in the shader from a Vector3.
  83823. * @param name Define the name of the uniform as defined in the shader
  83824. * @param value Define the value to give to the uniform
  83825. * @return the texture itself allowing "fluent" like uniform updates
  83826. */
  83827. setVector3(name: string, value: Vector3): ProceduralTexture;
  83828. /**
  83829. * Set a mat4 in the shader from a MAtrix.
  83830. * @param name Define the name of the uniform as defined in the shader
  83831. * @param value Define the value to give to the uniform
  83832. * @return the texture itself allowing "fluent" like uniform updates
  83833. */
  83834. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83835. /**
  83836. * Render the texture to its associated render target.
  83837. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83838. */
  83839. render(useCameraPostProcess?: boolean): void;
  83840. /**
  83841. * Clone the texture.
  83842. * @returns the cloned texture
  83843. */
  83844. clone(): ProceduralTexture;
  83845. /**
  83846. * Dispose the texture and release its asoociated resources.
  83847. */
  83848. dispose(): void;
  83849. }
  83850. }
  83851. declare module BABYLON {
  83852. /**
  83853. * This represents the base class for particle system in Babylon.
  83854. * 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.
  83855. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83856. * @example https://doc.babylonjs.com/babylon101/particles
  83857. */
  83858. export class BaseParticleSystem {
  83859. /**
  83860. * Source color is added to the destination color without alpha affecting the result
  83861. */
  83862. static BLENDMODE_ONEONE: number;
  83863. /**
  83864. * Blend current color and particle color using particle’s alpha
  83865. */
  83866. static BLENDMODE_STANDARD: number;
  83867. /**
  83868. * Add current color and particle color multiplied by particle’s alpha
  83869. */
  83870. static BLENDMODE_ADD: number;
  83871. /**
  83872. * Multiply current color with particle color
  83873. */
  83874. static BLENDMODE_MULTIPLY: number;
  83875. /**
  83876. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83877. */
  83878. static BLENDMODE_MULTIPLYADD: number;
  83879. /**
  83880. * List of animations used by the particle system.
  83881. */
  83882. animations: Animation[];
  83883. /**
  83884. * The id of the Particle system.
  83885. */
  83886. id: string;
  83887. /**
  83888. * The friendly name of the Particle system.
  83889. */
  83890. name: string;
  83891. /**
  83892. * The rendering group used by the Particle system to chose when to render.
  83893. */
  83894. renderingGroupId: number;
  83895. /**
  83896. * The emitter represents the Mesh or position we are attaching the particle system to.
  83897. */
  83898. emitter: Nullable<AbstractMesh | Vector3>;
  83899. /**
  83900. * The maximum number of particles to emit per frame
  83901. */
  83902. emitRate: number;
  83903. /**
  83904. * If you want to launch only a few particles at once, that can be done, as well.
  83905. */
  83906. manualEmitCount: number;
  83907. /**
  83908. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83909. */
  83910. updateSpeed: number;
  83911. /**
  83912. * The amount of time the particle system is running (depends of the overall update speed).
  83913. */
  83914. targetStopDuration: number;
  83915. /**
  83916. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83917. */
  83918. disposeOnStop: boolean;
  83919. /**
  83920. * Minimum power of emitting particles.
  83921. */
  83922. minEmitPower: number;
  83923. /**
  83924. * Maximum power of emitting particles.
  83925. */
  83926. maxEmitPower: number;
  83927. /**
  83928. * Minimum life time of emitting particles.
  83929. */
  83930. minLifeTime: number;
  83931. /**
  83932. * Maximum life time of emitting particles.
  83933. */
  83934. maxLifeTime: number;
  83935. /**
  83936. * Minimum Size of emitting particles.
  83937. */
  83938. minSize: number;
  83939. /**
  83940. * Maximum Size of emitting particles.
  83941. */
  83942. maxSize: number;
  83943. /**
  83944. * Minimum scale of emitting particles on X axis.
  83945. */
  83946. minScaleX: number;
  83947. /**
  83948. * Maximum scale of emitting particles on X axis.
  83949. */
  83950. maxScaleX: number;
  83951. /**
  83952. * Minimum scale of emitting particles on Y axis.
  83953. */
  83954. minScaleY: number;
  83955. /**
  83956. * Maximum scale of emitting particles on Y axis.
  83957. */
  83958. maxScaleY: number;
  83959. /**
  83960. * Gets or sets the minimal initial rotation in radians.
  83961. */
  83962. minInitialRotation: number;
  83963. /**
  83964. * Gets or sets the maximal initial rotation in radians.
  83965. */
  83966. maxInitialRotation: number;
  83967. /**
  83968. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83969. */
  83970. minAngularSpeed: number;
  83971. /**
  83972. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83973. */
  83974. maxAngularSpeed: number;
  83975. /**
  83976. * The texture used to render each particle. (this can be a spritesheet)
  83977. */
  83978. particleTexture: Nullable<Texture>;
  83979. /**
  83980. * The layer mask we are rendering the particles through.
  83981. */
  83982. layerMask: number;
  83983. /**
  83984. * This can help using your own shader to render the particle system.
  83985. * The according effect will be created
  83986. */
  83987. customShader: any;
  83988. /**
  83989. * By default particle system starts as soon as they are created. This prevents the
  83990. * automatic start to happen and let you decide when to start emitting particles.
  83991. */
  83992. preventAutoStart: boolean;
  83993. private _noiseTexture;
  83994. /**
  83995. * Gets or sets a texture used to add random noise to particle positions
  83996. */
  83997. noiseTexture: Nullable<ProceduralTexture>;
  83998. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83999. noiseStrength: Vector3;
  84000. /**
  84001. * Callback triggered when the particle animation is ending.
  84002. */
  84003. onAnimationEnd: Nullable<() => void>;
  84004. /**
  84005. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84006. */
  84007. blendMode: number;
  84008. /**
  84009. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84010. * to override the particles.
  84011. */
  84012. forceDepthWrite: boolean;
  84013. /** 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 */
  84014. preWarmCycles: number;
  84015. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84016. preWarmStepOffset: number;
  84017. /**
  84018. * 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)
  84019. */
  84020. spriteCellChangeSpeed: number;
  84021. /**
  84022. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84023. */
  84024. startSpriteCellID: number;
  84025. /**
  84026. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84027. */
  84028. endSpriteCellID: number;
  84029. /**
  84030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84031. */
  84032. spriteCellWidth: number;
  84033. /**
  84034. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84035. */
  84036. spriteCellHeight: number;
  84037. /**
  84038. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84039. */
  84040. spriteRandomStartCell: boolean;
  84041. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84042. translationPivot: Vector2;
  84043. /** @hidden */
  84044. protected _isAnimationSheetEnabled: boolean;
  84045. /**
  84046. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84047. */
  84048. beginAnimationOnStart: boolean;
  84049. /**
  84050. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84051. */
  84052. beginAnimationFrom: number;
  84053. /**
  84054. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84055. */
  84056. beginAnimationTo: number;
  84057. /**
  84058. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84059. */
  84060. beginAnimationLoop: boolean;
  84061. /**
  84062. * Gets or sets a world offset applied to all particles
  84063. */
  84064. worldOffset: Vector3;
  84065. /**
  84066. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84067. */
  84068. isAnimationSheetEnabled: boolean;
  84069. /**
  84070. * Get hosting scene
  84071. * @returns the scene
  84072. */
  84073. getScene(): Scene;
  84074. /**
  84075. * You can use gravity if you want to give an orientation to your particles.
  84076. */
  84077. gravity: Vector3;
  84078. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84079. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84080. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84081. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84082. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84083. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84084. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84085. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84086. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84087. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84088. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84089. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84090. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84091. /**
  84092. * Defines the delay in milliseconds before starting the system (0 by default)
  84093. */
  84094. startDelay: number;
  84095. /**
  84096. * Gets the current list of drag gradients.
  84097. * You must use addDragGradient and removeDragGradient to udpate this list
  84098. * @returns the list of drag gradients
  84099. */
  84100. getDragGradients(): Nullable<Array<FactorGradient>>;
  84101. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84102. limitVelocityDamping: number;
  84103. /**
  84104. * Gets the current list of limit velocity gradients.
  84105. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84106. * @returns the list of limit velocity gradients
  84107. */
  84108. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84109. /**
  84110. * Gets the current list of color gradients.
  84111. * You must use addColorGradient and removeColorGradient to udpate this list
  84112. * @returns the list of color gradients
  84113. */
  84114. getColorGradients(): Nullable<Array<ColorGradient>>;
  84115. /**
  84116. * Gets the current list of size gradients.
  84117. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84118. * @returns the list of size gradients
  84119. */
  84120. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84121. /**
  84122. * Gets the current list of color remap gradients.
  84123. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84124. * @returns the list of color remap gradients
  84125. */
  84126. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84127. /**
  84128. * Gets the current list of alpha remap gradients.
  84129. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84130. * @returns the list of alpha remap gradients
  84131. */
  84132. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84133. /**
  84134. * Gets the current list of life time gradients.
  84135. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84136. * @returns the list of life time gradients
  84137. */
  84138. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84139. /**
  84140. * Gets the current list of angular speed gradients.
  84141. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84142. * @returns the list of angular speed gradients
  84143. */
  84144. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84145. /**
  84146. * Gets the current list of velocity gradients.
  84147. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84148. * @returns the list of velocity gradients
  84149. */
  84150. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84151. /**
  84152. * Gets the current list of start size gradients.
  84153. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84154. * @returns the list of start size gradients
  84155. */
  84156. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84157. /**
  84158. * Gets the current list of emit rate gradients.
  84159. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84160. * @returns the list of emit rate gradients
  84161. */
  84162. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84163. /**
  84164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84165. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84166. */
  84167. direction1: Vector3;
  84168. /**
  84169. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84170. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84171. */
  84172. direction2: Vector3;
  84173. /**
  84174. * 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.
  84175. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84176. */
  84177. minEmitBox: Vector3;
  84178. /**
  84179. * 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.
  84180. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84181. */
  84182. maxEmitBox: Vector3;
  84183. /**
  84184. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84185. */
  84186. color1: Color4;
  84187. /**
  84188. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84189. */
  84190. color2: Color4;
  84191. /**
  84192. * Color the particle will have at the end of its lifetime
  84193. */
  84194. colorDead: Color4;
  84195. /**
  84196. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84197. */
  84198. textureMask: Color4;
  84199. /**
  84200. * The particle emitter type defines the emitter used by the particle system.
  84201. * It can be for example box, sphere, or cone...
  84202. */
  84203. particleEmitterType: IParticleEmitterType;
  84204. /** @hidden */
  84205. _isSubEmitter: boolean;
  84206. /**
  84207. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84208. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84209. */
  84210. billboardMode: number;
  84211. protected _isBillboardBased: boolean;
  84212. /**
  84213. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84214. */
  84215. isBillboardBased: boolean;
  84216. /**
  84217. * The scene the particle system belongs to.
  84218. */
  84219. protected _scene: Scene;
  84220. /**
  84221. * Local cache of defines for image processing.
  84222. */
  84223. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84224. /**
  84225. * Default configuration related to image processing available in the standard Material.
  84226. */
  84227. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84228. /**
  84229. * Gets the image processing configuration used either in this material.
  84230. */
  84231. /**
  84232. * Sets the Default image processing configuration used either in the this material.
  84233. *
  84234. * If sets to null, the scene one is in use.
  84235. */
  84236. imageProcessingConfiguration: ImageProcessingConfiguration;
  84237. /**
  84238. * Attaches a new image processing configuration to the Standard Material.
  84239. * @param configuration
  84240. */
  84241. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84242. /** @hidden */
  84243. protected _reset(): void;
  84244. /** @hidden */
  84245. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84246. /**
  84247. * Instantiates a particle system.
  84248. * 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.
  84249. * @param name The name of the particle system
  84250. */
  84251. constructor(name: string);
  84252. /**
  84253. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84254. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84255. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84256. * @returns the emitter
  84257. */
  84258. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84259. /**
  84260. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84261. * @param radius The radius of the hemisphere to emit from
  84262. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84263. * @returns the emitter
  84264. */
  84265. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84266. /**
  84267. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84268. * @param radius The radius of the sphere to emit from
  84269. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84270. * @returns the emitter
  84271. */
  84272. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84273. /**
  84274. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84275. * @param radius The radius of the sphere to emit from
  84276. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84277. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84278. * @returns the emitter
  84279. */
  84280. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84281. /**
  84282. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84283. * @param radius The radius of the emission cylinder
  84284. * @param height The height of the emission cylinder
  84285. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84286. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84287. * @returns the emitter
  84288. */
  84289. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84290. /**
  84291. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84292. * @param radius The radius of the cylinder to emit from
  84293. * @param height The height of the emission cylinder
  84294. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84295. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84296. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84297. * @returns the emitter
  84298. */
  84299. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84300. /**
  84301. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84302. * @param radius The radius of the cone to emit from
  84303. * @param angle The base angle of the cone
  84304. * @returns the emitter
  84305. */
  84306. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84307. /**
  84308. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84309. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84310. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84311. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84312. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84313. * @returns the emitter
  84314. */
  84315. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84316. }
  84317. }
  84318. declare module BABYLON {
  84319. /**
  84320. * Type of sub emitter
  84321. */
  84322. export enum SubEmitterType {
  84323. /**
  84324. * Attached to the particle over it's lifetime
  84325. */
  84326. ATTACHED = 0,
  84327. /**
  84328. * Created when the particle dies
  84329. */
  84330. END = 1
  84331. }
  84332. /**
  84333. * Sub emitter class used to emit particles from an existing particle
  84334. */
  84335. export class SubEmitter {
  84336. /**
  84337. * the particle system to be used by the sub emitter
  84338. */
  84339. particleSystem: ParticleSystem;
  84340. /**
  84341. * Type of the submitter (Default: END)
  84342. */
  84343. type: SubEmitterType;
  84344. /**
  84345. * 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)
  84346. * Note: This only is supported when using an emitter of type Mesh
  84347. */
  84348. inheritDirection: boolean;
  84349. /**
  84350. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84351. */
  84352. inheritedVelocityAmount: number;
  84353. /**
  84354. * Creates a sub emitter
  84355. * @param particleSystem the particle system to be used by the sub emitter
  84356. */
  84357. constructor(
  84358. /**
  84359. * the particle system to be used by the sub emitter
  84360. */
  84361. particleSystem: ParticleSystem);
  84362. /**
  84363. * Clones the sub emitter
  84364. * @returns the cloned sub emitter
  84365. */
  84366. clone(): SubEmitter;
  84367. /**
  84368. * Serialize current object to a JSON object
  84369. * @returns the serialized object
  84370. */
  84371. serialize(): any;
  84372. /** @hidden */
  84373. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84374. /**
  84375. * Creates a new SubEmitter from a serialized JSON version
  84376. * @param serializationObject defines the JSON object to read from
  84377. * @param scene defines the hosting scene
  84378. * @param rootUrl defines the rootUrl for data loading
  84379. * @returns a new SubEmitter
  84380. */
  84381. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84382. /** Release associated resources */
  84383. dispose(): void;
  84384. }
  84385. }
  84386. declare module BABYLON {
  84387. /** @hidden */
  84388. export var clipPlaneFragmentDeclaration: {
  84389. name: string;
  84390. shader: string;
  84391. };
  84392. }
  84393. declare module BABYLON {
  84394. /** @hidden */
  84395. export var imageProcessingDeclaration: {
  84396. name: string;
  84397. shader: string;
  84398. };
  84399. }
  84400. declare module BABYLON {
  84401. /** @hidden */
  84402. export var imageProcessingFunctions: {
  84403. name: string;
  84404. shader: string;
  84405. };
  84406. }
  84407. declare module BABYLON {
  84408. /** @hidden */
  84409. export var clipPlaneFragment: {
  84410. name: string;
  84411. shader: string;
  84412. };
  84413. }
  84414. declare module BABYLON {
  84415. /** @hidden */
  84416. export var particlesPixelShader: {
  84417. name: string;
  84418. shader: string;
  84419. };
  84420. }
  84421. declare module BABYLON {
  84422. /** @hidden */
  84423. export var clipPlaneVertexDeclaration: {
  84424. name: string;
  84425. shader: string;
  84426. };
  84427. }
  84428. declare module BABYLON {
  84429. /** @hidden */
  84430. export var clipPlaneVertex: {
  84431. name: string;
  84432. shader: string;
  84433. };
  84434. }
  84435. declare module BABYLON {
  84436. /** @hidden */
  84437. export var particlesVertexShader: {
  84438. name: string;
  84439. shader: string;
  84440. };
  84441. }
  84442. declare module BABYLON {
  84443. /**
  84444. * This represents a particle system in Babylon.
  84445. * 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.
  84446. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84447. * @example https://doc.babylonjs.com/babylon101/particles
  84448. */
  84449. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84450. /**
  84451. * Billboard mode will only apply to Y axis
  84452. */
  84453. static readonly BILLBOARDMODE_Y: number;
  84454. /**
  84455. * Billboard mode will apply to all axes
  84456. */
  84457. static readonly BILLBOARDMODE_ALL: number;
  84458. /**
  84459. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84460. */
  84461. static readonly BILLBOARDMODE_STRETCHED: number;
  84462. /**
  84463. * This function can be defined to provide custom update for active particles.
  84464. * This function will be called instead of regular update (age, position, color, etc.).
  84465. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84466. */
  84467. updateFunction: (particles: Particle[]) => void;
  84468. private _emitterWorldMatrix;
  84469. /**
  84470. * This function can be defined to specify initial direction for every new particle.
  84471. * It by default use the emitterType defined function
  84472. */
  84473. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84474. /**
  84475. * This function can be defined to specify initial position for every new particle.
  84476. * It by default use the emitterType defined function
  84477. */
  84478. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84479. /**
  84480. * @hidden
  84481. */
  84482. _inheritedVelocityOffset: Vector3;
  84483. /**
  84484. * An event triggered when the system is disposed
  84485. */
  84486. onDisposeObservable: Observable<ParticleSystem>;
  84487. private _onDisposeObserver;
  84488. /**
  84489. * Sets a callback that will be triggered when the system is disposed
  84490. */
  84491. onDispose: () => void;
  84492. private _particles;
  84493. private _epsilon;
  84494. private _capacity;
  84495. private _stockParticles;
  84496. private _newPartsExcess;
  84497. private _vertexData;
  84498. private _vertexBuffer;
  84499. private _vertexBuffers;
  84500. private _spriteBuffer;
  84501. private _indexBuffer;
  84502. private _effect;
  84503. private _customEffect;
  84504. private _cachedDefines;
  84505. private _scaledColorStep;
  84506. private _colorDiff;
  84507. private _scaledDirection;
  84508. private _scaledGravity;
  84509. private _currentRenderId;
  84510. private _alive;
  84511. private _useInstancing;
  84512. private _started;
  84513. private _stopped;
  84514. private _actualFrame;
  84515. private _scaledUpdateSpeed;
  84516. private _vertexBufferSize;
  84517. /** @hidden */
  84518. _currentEmitRateGradient: Nullable<FactorGradient>;
  84519. /** @hidden */
  84520. _currentEmitRate1: number;
  84521. /** @hidden */
  84522. _currentEmitRate2: number;
  84523. /** @hidden */
  84524. _currentStartSizeGradient: Nullable<FactorGradient>;
  84525. /** @hidden */
  84526. _currentStartSize1: number;
  84527. /** @hidden */
  84528. _currentStartSize2: number;
  84529. private readonly _rawTextureWidth;
  84530. private _rampGradientsTexture;
  84531. private _useRampGradients;
  84532. /** Gets or sets a boolean indicating that ramp gradients must be used
  84533. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84534. */
  84535. useRampGradients: boolean;
  84536. /**
  84537. * 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.
  84538. * 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: [])
  84539. */
  84540. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84541. private _subEmitters;
  84542. /**
  84543. * @hidden
  84544. * If the particle systems emitter should be disposed when the particle system is disposed
  84545. */
  84546. _disposeEmitterOnDispose: boolean;
  84547. /**
  84548. * The current active Sub-systems, this property is used by the root particle system only.
  84549. */
  84550. activeSubSystems: Array<ParticleSystem>;
  84551. private _rootParticleSystem;
  84552. /**
  84553. * Gets the current list of active particles
  84554. */
  84555. readonly particles: Particle[];
  84556. /**
  84557. * Returns the string "ParticleSystem"
  84558. * @returns a string containing the class name
  84559. */
  84560. getClassName(): string;
  84561. /**
  84562. * Instantiates a particle system.
  84563. * 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.
  84564. * @param name The name of the particle system
  84565. * @param capacity The max number of particles alive at the same time
  84566. * @param scene The scene the particle system belongs to
  84567. * @param customEffect a custom effect used to change the way particles are rendered by default
  84568. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84569. * @param epsilon Offset used to render the particles
  84570. */
  84571. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84572. private _addFactorGradient;
  84573. private _removeFactorGradient;
  84574. /**
  84575. * Adds a new life time gradient
  84576. * @param gradient defines the gradient to use (between 0 and 1)
  84577. * @param factor defines the life time factor to affect to the specified gradient
  84578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84579. * @returns the current particle system
  84580. */
  84581. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84582. /**
  84583. * Remove a specific life time gradient
  84584. * @param gradient defines the gradient to remove
  84585. * @returns the current particle system
  84586. */
  84587. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84588. /**
  84589. * Adds a new size gradient
  84590. * @param gradient defines the gradient to use (between 0 and 1)
  84591. * @param factor defines the size factor to affect to the specified gradient
  84592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84593. * @returns the current particle system
  84594. */
  84595. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84596. /**
  84597. * Remove a specific size gradient
  84598. * @param gradient defines the gradient to remove
  84599. * @returns the current particle system
  84600. */
  84601. removeSizeGradient(gradient: number): IParticleSystem;
  84602. /**
  84603. * Adds a new color remap gradient
  84604. * @param gradient defines the gradient to use (between 0 and 1)
  84605. * @param min defines the color remap minimal range
  84606. * @param max defines the color remap maximal range
  84607. * @returns the current particle system
  84608. */
  84609. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84610. /**
  84611. * Remove a specific color remap gradient
  84612. * @param gradient defines the gradient to remove
  84613. * @returns the current particle system
  84614. */
  84615. removeColorRemapGradient(gradient: number): IParticleSystem;
  84616. /**
  84617. * Adds a new alpha remap gradient
  84618. * @param gradient defines the gradient to use (between 0 and 1)
  84619. * @param min defines the alpha remap minimal range
  84620. * @param max defines the alpha remap maximal range
  84621. * @returns the current particle system
  84622. */
  84623. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84624. /**
  84625. * Remove a specific alpha remap gradient
  84626. * @param gradient defines the gradient to remove
  84627. * @returns the current particle system
  84628. */
  84629. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84630. /**
  84631. * Adds a new angular speed gradient
  84632. * @param gradient defines the gradient to use (between 0 and 1)
  84633. * @param factor defines the angular speed to affect to the specified gradient
  84634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84635. * @returns the current particle system
  84636. */
  84637. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84638. /**
  84639. * Remove a specific angular speed gradient
  84640. * @param gradient defines the gradient to remove
  84641. * @returns the current particle system
  84642. */
  84643. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84644. /**
  84645. * Adds a new velocity gradient
  84646. * @param gradient defines the gradient to use (between 0 and 1)
  84647. * @param factor defines the velocity to affect to the specified gradient
  84648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84649. * @returns the current particle system
  84650. */
  84651. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84652. /**
  84653. * Remove a specific velocity gradient
  84654. * @param gradient defines the gradient to remove
  84655. * @returns the current particle system
  84656. */
  84657. removeVelocityGradient(gradient: number): IParticleSystem;
  84658. /**
  84659. * Adds a new limit velocity gradient
  84660. * @param gradient defines the gradient to use (between 0 and 1)
  84661. * @param factor defines the limit velocity value to affect to the specified gradient
  84662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84663. * @returns the current particle system
  84664. */
  84665. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84666. /**
  84667. * Remove a specific limit velocity gradient
  84668. * @param gradient defines the gradient to remove
  84669. * @returns the current particle system
  84670. */
  84671. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84672. /**
  84673. * Adds a new drag gradient
  84674. * @param gradient defines the gradient to use (between 0 and 1)
  84675. * @param factor defines the drag value to affect to the specified gradient
  84676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84677. * @returns the current particle system
  84678. */
  84679. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84680. /**
  84681. * Remove a specific drag gradient
  84682. * @param gradient defines the gradient to remove
  84683. * @returns the current particle system
  84684. */
  84685. removeDragGradient(gradient: number): IParticleSystem;
  84686. /**
  84687. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84688. * @param gradient defines the gradient to use (between 0 and 1)
  84689. * @param factor defines the emit rate value to affect to the specified gradient
  84690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84691. * @returns the current particle system
  84692. */
  84693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84694. /**
  84695. * Remove a specific emit rate gradient
  84696. * @param gradient defines the gradient to remove
  84697. * @returns the current particle system
  84698. */
  84699. removeEmitRateGradient(gradient: number): IParticleSystem;
  84700. /**
  84701. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84702. * @param gradient defines the gradient to use (between 0 and 1)
  84703. * @param factor defines the start size value to affect to the specified gradient
  84704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84705. * @returns the current particle system
  84706. */
  84707. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84708. /**
  84709. * Remove a specific start size gradient
  84710. * @param gradient defines the gradient to remove
  84711. * @returns the current particle system
  84712. */
  84713. removeStartSizeGradient(gradient: number): IParticleSystem;
  84714. private _createRampGradientTexture;
  84715. /**
  84716. * Gets the current list of ramp gradients.
  84717. * You must use addRampGradient and removeRampGradient to udpate this list
  84718. * @returns the list of ramp gradients
  84719. */
  84720. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84721. /**
  84722. * Adds a new ramp gradient used to remap particle colors
  84723. * @param gradient defines the gradient to use (between 0 and 1)
  84724. * @param color defines the color to affect to the specified gradient
  84725. * @returns the current particle system
  84726. */
  84727. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84728. /**
  84729. * Remove a specific ramp gradient
  84730. * @param gradient defines the gradient to remove
  84731. * @returns the current particle system
  84732. */
  84733. removeRampGradient(gradient: number): ParticleSystem;
  84734. /**
  84735. * Adds a new color gradient
  84736. * @param gradient defines the gradient to use (between 0 and 1)
  84737. * @param color1 defines the color to affect to the specified gradient
  84738. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84739. * @returns this particle system
  84740. */
  84741. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84742. /**
  84743. * Remove a specific color gradient
  84744. * @param gradient defines the gradient to remove
  84745. * @returns this particle system
  84746. */
  84747. removeColorGradient(gradient: number): IParticleSystem;
  84748. private _fetchR;
  84749. protected _reset(): void;
  84750. private _resetEffect;
  84751. private _createVertexBuffers;
  84752. private _createIndexBuffer;
  84753. /**
  84754. * Gets the maximum number of particles active at the same time.
  84755. * @returns The max number of active particles.
  84756. */
  84757. getCapacity(): number;
  84758. /**
  84759. * Gets whether there are still active particles in the system.
  84760. * @returns True if it is alive, otherwise false.
  84761. */
  84762. isAlive(): boolean;
  84763. /**
  84764. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84765. * @returns True if it has been started, otherwise false.
  84766. */
  84767. isStarted(): boolean;
  84768. private _prepareSubEmitterInternalArray;
  84769. /**
  84770. * Starts the particle system and begins to emit
  84771. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84772. */
  84773. start(delay?: number): void;
  84774. /**
  84775. * Stops the particle system.
  84776. * @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.
  84777. */
  84778. stop(stopSubEmitters?: boolean): void;
  84779. /**
  84780. * Remove all active particles
  84781. */
  84782. reset(): void;
  84783. /**
  84784. * @hidden (for internal use only)
  84785. */
  84786. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84787. /**
  84788. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84789. * Its lifetime will start back at 0.
  84790. */
  84791. recycleParticle: (particle: Particle) => void;
  84792. private _stopSubEmitters;
  84793. private _createParticle;
  84794. private _removeFromRoot;
  84795. private _emitFromParticle;
  84796. private _update;
  84797. /** @hidden */
  84798. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84799. /** @hidden */
  84800. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84801. /** @hidden */
  84802. private _getEffect;
  84803. /**
  84804. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84805. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84806. */
  84807. animate(preWarmOnly?: boolean): void;
  84808. private _appendParticleVertices;
  84809. /**
  84810. * Rebuilds the particle system.
  84811. */
  84812. rebuild(): void;
  84813. /**
  84814. * Is this system ready to be used/rendered
  84815. * @return true if the system is ready
  84816. */
  84817. isReady(): boolean;
  84818. private _render;
  84819. /**
  84820. * Renders the particle system in its current state.
  84821. * @returns the current number of particles
  84822. */
  84823. render(): number;
  84824. /**
  84825. * Disposes the particle system and free the associated resources
  84826. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84827. */
  84828. dispose(disposeTexture?: boolean): void;
  84829. /**
  84830. * Clones the particle system.
  84831. * @param name The name of the cloned object
  84832. * @param newEmitter The new emitter to use
  84833. * @returns the cloned particle system
  84834. */
  84835. clone(name: string, newEmitter: any): ParticleSystem;
  84836. /**
  84837. * Serializes the particle system to a JSON object.
  84838. * @returns the JSON object
  84839. */
  84840. serialize(): any;
  84841. /** @hidden */
  84842. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84843. /** @hidden */
  84844. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84845. /**
  84846. * Parses a JSON object to create a particle system.
  84847. * @param parsedParticleSystem The JSON object to parse
  84848. * @param scene The scene to create the particle system in
  84849. * @param rootUrl The root url to use to load external dependencies like texture
  84850. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84851. * @returns the Parsed particle system
  84852. */
  84853. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84854. }
  84855. }
  84856. declare module BABYLON {
  84857. /**
  84858. * A particle represents one of the element emitted by a particle system.
  84859. * This is mainly define by its coordinates, direction, velocity and age.
  84860. */
  84861. export class Particle {
  84862. /**
  84863. * The particle system the particle belongs to.
  84864. */
  84865. particleSystem: ParticleSystem;
  84866. private static _Count;
  84867. /**
  84868. * Unique ID of the particle
  84869. */
  84870. id: number;
  84871. /**
  84872. * The world position of the particle in the scene.
  84873. */
  84874. position: Vector3;
  84875. /**
  84876. * The world direction of the particle in the scene.
  84877. */
  84878. direction: Vector3;
  84879. /**
  84880. * The color of the particle.
  84881. */
  84882. color: Color4;
  84883. /**
  84884. * The color change of the particle per step.
  84885. */
  84886. colorStep: Color4;
  84887. /**
  84888. * Defines how long will the life of the particle be.
  84889. */
  84890. lifeTime: number;
  84891. /**
  84892. * The current age of the particle.
  84893. */
  84894. age: number;
  84895. /**
  84896. * The current size of the particle.
  84897. */
  84898. size: number;
  84899. /**
  84900. * The current scale of the particle.
  84901. */
  84902. scale: Vector2;
  84903. /**
  84904. * The current angle of the particle.
  84905. */
  84906. angle: number;
  84907. /**
  84908. * Defines how fast is the angle changing.
  84909. */
  84910. angularSpeed: number;
  84911. /**
  84912. * Defines the cell index used by the particle to be rendered from a sprite.
  84913. */
  84914. cellIndex: number;
  84915. /**
  84916. * The information required to support color remapping
  84917. */
  84918. remapData: Vector4;
  84919. /** @hidden */
  84920. _randomCellOffset?: number;
  84921. /** @hidden */
  84922. _initialDirection: Nullable<Vector3>;
  84923. /** @hidden */
  84924. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84925. /** @hidden */
  84926. _initialStartSpriteCellID: number;
  84927. /** @hidden */
  84928. _initialEndSpriteCellID: number;
  84929. /** @hidden */
  84930. _currentColorGradient: Nullable<ColorGradient>;
  84931. /** @hidden */
  84932. _currentColor1: Color4;
  84933. /** @hidden */
  84934. _currentColor2: Color4;
  84935. /** @hidden */
  84936. _currentSizeGradient: Nullable<FactorGradient>;
  84937. /** @hidden */
  84938. _currentSize1: number;
  84939. /** @hidden */
  84940. _currentSize2: number;
  84941. /** @hidden */
  84942. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84943. /** @hidden */
  84944. _currentAngularSpeed1: number;
  84945. /** @hidden */
  84946. _currentAngularSpeed2: number;
  84947. /** @hidden */
  84948. _currentVelocityGradient: Nullable<FactorGradient>;
  84949. /** @hidden */
  84950. _currentVelocity1: number;
  84951. /** @hidden */
  84952. _currentVelocity2: number;
  84953. /** @hidden */
  84954. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84955. /** @hidden */
  84956. _currentLimitVelocity1: number;
  84957. /** @hidden */
  84958. _currentLimitVelocity2: number;
  84959. /** @hidden */
  84960. _currentDragGradient: Nullable<FactorGradient>;
  84961. /** @hidden */
  84962. _currentDrag1: number;
  84963. /** @hidden */
  84964. _currentDrag2: number;
  84965. /** @hidden */
  84966. _randomNoiseCoordinates1: Vector3;
  84967. /** @hidden */
  84968. _randomNoiseCoordinates2: Vector3;
  84969. /**
  84970. * Creates a new instance Particle
  84971. * @param particleSystem the particle system the particle belongs to
  84972. */
  84973. constructor(
  84974. /**
  84975. * The particle system the particle belongs to.
  84976. */
  84977. particleSystem: ParticleSystem);
  84978. private updateCellInfoFromSystem;
  84979. /**
  84980. * Defines how the sprite cell index is updated for the particle
  84981. */
  84982. updateCellIndex(): void;
  84983. /** @hidden */
  84984. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84985. /** @hidden */
  84986. _inheritParticleInfoToSubEmitters(): void;
  84987. /** @hidden */
  84988. _reset(): void;
  84989. /**
  84990. * Copy the properties of particle to another one.
  84991. * @param other the particle to copy the information to.
  84992. */
  84993. copyTo(other: Particle): void;
  84994. }
  84995. }
  84996. declare module BABYLON {
  84997. /**
  84998. * Particle emitter represents a volume emitting particles.
  84999. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85000. */
  85001. export interface IParticleEmitterType {
  85002. /**
  85003. * Called by the particle System when the direction is computed for the created particle.
  85004. * @param worldMatrix is the world matrix of the particle system
  85005. * @param directionToUpdate is the direction vector to update with the result
  85006. * @param particle is the particle we are computed the direction for
  85007. */
  85008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85009. /**
  85010. * Called by the particle System when the position is computed for the created particle.
  85011. * @param worldMatrix is the world matrix of the particle system
  85012. * @param positionToUpdate is the position vector to update with the result
  85013. * @param particle is the particle we are computed the position for
  85014. */
  85015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85016. /**
  85017. * Clones the current emitter and returns a copy of it
  85018. * @returns the new emitter
  85019. */
  85020. clone(): IParticleEmitterType;
  85021. /**
  85022. * Called by the GPUParticleSystem to setup the update shader
  85023. * @param effect defines the update shader
  85024. */
  85025. applyToShader(effect: Effect): void;
  85026. /**
  85027. * Returns a string to use to update the GPU particles update shader
  85028. * @returns the effect defines string
  85029. */
  85030. getEffectDefines(): string;
  85031. /**
  85032. * Returns a string representing the class name
  85033. * @returns a string containing the class name
  85034. */
  85035. getClassName(): string;
  85036. /**
  85037. * Serializes the particle system to a JSON object.
  85038. * @returns the JSON object
  85039. */
  85040. serialize(): any;
  85041. /**
  85042. * Parse properties from a JSON object
  85043. * @param serializationObject defines the JSON object
  85044. */
  85045. parse(serializationObject: any): void;
  85046. }
  85047. }
  85048. declare module BABYLON {
  85049. /**
  85050. * Particle emitter emitting particles from the inside of a box.
  85051. * It emits the particles randomly between 2 given directions.
  85052. */
  85053. export class BoxParticleEmitter implements IParticleEmitterType {
  85054. /**
  85055. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85056. */
  85057. direction1: Vector3;
  85058. /**
  85059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85060. */
  85061. direction2: Vector3;
  85062. /**
  85063. * 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.
  85064. */
  85065. minEmitBox: Vector3;
  85066. /**
  85067. * 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.
  85068. */
  85069. maxEmitBox: Vector3;
  85070. /**
  85071. * Creates a new instance BoxParticleEmitter
  85072. */
  85073. constructor();
  85074. /**
  85075. * Called by the particle System when the direction is computed for the created particle.
  85076. * @param worldMatrix is the world matrix of the particle system
  85077. * @param directionToUpdate is the direction vector to update with the result
  85078. * @param particle is the particle we are computed the direction for
  85079. */
  85080. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85081. /**
  85082. * Called by the particle System when the position is computed for the created particle.
  85083. * @param worldMatrix is the world matrix of the particle system
  85084. * @param positionToUpdate is the position vector to update with the result
  85085. * @param particle is the particle we are computed the position for
  85086. */
  85087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85088. /**
  85089. * Clones the current emitter and returns a copy of it
  85090. * @returns the new emitter
  85091. */
  85092. clone(): BoxParticleEmitter;
  85093. /**
  85094. * Called by the GPUParticleSystem to setup the update shader
  85095. * @param effect defines the update shader
  85096. */
  85097. applyToShader(effect: Effect): void;
  85098. /**
  85099. * Returns a string to use to update the GPU particles update shader
  85100. * @returns a string containng the defines string
  85101. */
  85102. getEffectDefines(): string;
  85103. /**
  85104. * Returns the string "BoxParticleEmitter"
  85105. * @returns a string containing the class name
  85106. */
  85107. getClassName(): string;
  85108. /**
  85109. * Serializes the particle system to a JSON object.
  85110. * @returns the JSON object
  85111. */
  85112. serialize(): any;
  85113. /**
  85114. * Parse properties from a JSON object
  85115. * @param serializationObject defines the JSON object
  85116. */
  85117. parse(serializationObject: any): void;
  85118. }
  85119. }
  85120. declare module BABYLON {
  85121. /**
  85122. * Particle emitter emitting particles from the inside of a cone.
  85123. * It emits the particles alongside the cone volume from the base to the particle.
  85124. * The emission direction might be randomized.
  85125. */
  85126. export class ConeParticleEmitter implements IParticleEmitterType {
  85127. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85128. directionRandomizer: number;
  85129. private _radius;
  85130. private _angle;
  85131. private _height;
  85132. /**
  85133. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85134. */
  85135. radiusRange: number;
  85136. /**
  85137. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85138. */
  85139. heightRange: number;
  85140. /**
  85141. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85142. */
  85143. emitFromSpawnPointOnly: boolean;
  85144. /**
  85145. * Gets or sets the radius of the emission cone
  85146. */
  85147. radius: number;
  85148. /**
  85149. * Gets or sets the angle of the emission cone
  85150. */
  85151. angle: number;
  85152. private _buildHeight;
  85153. /**
  85154. * Creates a new instance ConeParticleEmitter
  85155. * @param radius the radius of the emission cone (1 by default)
  85156. * @param angle the cone base angle (PI by default)
  85157. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85158. */
  85159. constructor(radius?: number, angle?: number,
  85160. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85161. directionRandomizer?: number);
  85162. /**
  85163. * Called by the particle System when the direction is computed for the created particle.
  85164. * @param worldMatrix is the world matrix of the particle system
  85165. * @param directionToUpdate is the direction vector to update with the result
  85166. * @param particle is the particle we are computed the direction for
  85167. */
  85168. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85169. /**
  85170. * Called by the particle System when the position is computed for the created particle.
  85171. * @param worldMatrix is the world matrix of the particle system
  85172. * @param positionToUpdate is the position vector to update with the result
  85173. * @param particle is the particle we are computed the position for
  85174. */
  85175. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85176. /**
  85177. * Clones the current emitter and returns a copy of it
  85178. * @returns the new emitter
  85179. */
  85180. clone(): ConeParticleEmitter;
  85181. /**
  85182. * Called by the GPUParticleSystem to setup the update shader
  85183. * @param effect defines the update shader
  85184. */
  85185. applyToShader(effect: Effect): void;
  85186. /**
  85187. * Returns a string to use to update the GPU particles update shader
  85188. * @returns a string containng the defines string
  85189. */
  85190. getEffectDefines(): string;
  85191. /**
  85192. * Returns the string "ConeParticleEmitter"
  85193. * @returns a string containing the class name
  85194. */
  85195. getClassName(): string;
  85196. /**
  85197. * Serializes the particle system to a JSON object.
  85198. * @returns the JSON object
  85199. */
  85200. serialize(): any;
  85201. /**
  85202. * Parse properties from a JSON object
  85203. * @param serializationObject defines the JSON object
  85204. */
  85205. parse(serializationObject: any): void;
  85206. }
  85207. }
  85208. declare module BABYLON {
  85209. /**
  85210. * Particle emitter emitting particles from the inside of a cylinder.
  85211. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85212. */
  85213. export class CylinderParticleEmitter implements IParticleEmitterType {
  85214. /**
  85215. * The radius of the emission cylinder.
  85216. */
  85217. radius: number;
  85218. /**
  85219. * The height of the emission cylinder.
  85220. */
  85221. height: number;
  85222. /**
  85223. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85224. */
  85225. radiusRange: number;
  85226. /**
  85227. * How much to randomize the particle direction [0-1].
  85228. */
  85229. directionRandomizer: number;
  85230. /**
  85231. * Creates a new instance CylinderParticleEmitter
  85232. * @param radius the radius of the emission cylinder (1 by default)
  85233. * @param height the height of the emission cylinder (1 by default)
  85234. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85235. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85236. */
  85237. constructor(
  85238. /**
  85239. * The radius of the emission cylinder.
  85240. */
  85241. radius?: number,
  85242. /**
  85243. * The height of the emission cylinder.
  85244. */
  85245. height?: number,
  85246. /**
  85247. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85248. */
  85249. radiusRange?: number,
  85250. /**
  85251. * How much to randomize the particle direction [0-1].
  85252. */
  85253. directionRandomizer?: number);
  85254. /**
  85255. * Called by the particle System when the direction is computed for the created particle.
  85256. * @param worldMatrix is the world matrix of the particle system
  85257. * @param directionToUpdate is the direction vector to update with the result
  85258. * @param particle is the particle we are computed the direction for
  85259. */
  85260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85261. /**
  85262. * Called by the particle System when the position is computed for the created particle.
  85263. * @param worldMatrix is the world matrix of the particle system
  85264. * @param positionToUpdate is the position vector to update with the result
  85265. * @param particle is the particle we are computed the position for
  85266. */
  85267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85268. /**
  85269. * Clones the current emitter and returns a copy of it
  85270. * @returns the new emitter
  85271. */
  85272. clone(): CylinderParticleEmitter;
  85273. /**
  85274. * Called by the GPUParticleSystem to setup the update shader
  85275. * @param effect defines the update shader
  85276. */
  85277. applyToShader(effect: Effect): void;
  85278. /**
  85279. * Returns a string to use to update the GPU particles update shader
  85280. * @returns a string containng the defines string
  85281. */
  85282. getEffectDefines(): string;
  85283. /**
  85284. * Returns the string "CylinderParticleEmitter"
  85285. * @returns a string containing the class name
  85286. */
  85287. getClassName(): string;
  85288. /**
  85289. * Serializes the particle system to a JSON object.
  85290. * @returns the JSON object
  85291. */
  85292. serialize(): any;
  85293. /**
  85294. * Parse properties from a JSON object
  85295. * @param serializationObject defines the JSON object
  85296. */
  85297. parse(serializationObject: any): void;
  85298. }
  85299. /**
  85300. * Particle emitter emitting particles from the inside of a cylinder.
  85301. * It emits the particles randomly between two vectors.
  85302. */
  85303. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85304. /**
  85305. * The min limit of the emission direction.
  85306. */
  85307. direction1: Vector3;
  85308. /**
  85309. * The max limit of the emission direction.
  85310. */
  85311. direction2: Vector3;
  85312. /**
  85313. * Creates a new instance CylinderDirectedParticleEmitter
  85314. * @param radius the radius of the emission cylinder (1 by default)
  85315. * @param height the height of the emission cylinder (1 by default)
  85316. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85317. * @param direction1 the min limit of the emission direction (up vector by default)
  85318. * @param direction2 the max limit of the emission direction (up vector by default)
  85319. */
  85320. constructor(radius?: number, height?: number, radiusRange?: number,
  85321. /**
  85322. * The min limit of the emission direction.
  85323. */
  85324. direction1?: Vector3,
  85325. /**
  85326. * The max limit of the emission direction.
  85327. */
  85328. direction2?: Vector3);
  85329. /**
  85330. * Called by the particle System when the direction is computed for the created particle.
  85331. * @param worldMatrix is the world matrix of the particle system
  85332. * @param directionToUpdate is the direction vector to update with the result
  85333. * @param particle is the particle we are computed the direction for
  85334. */
  85335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85336. /**
  85337. * Clones the current emitter and returns a copy of it
  85338. * @returns the new emitter
  85339. */
  85340. clone(): CylinderDirectedParticleEmitter;
  85341. /**
  85342. * Called by the GPUParticleSystem to setup the update shader
  85343. * @param effect defines the update shader
  85344. */
  85345. applyToShader(effect: Effect): void;
  85346. /**
  85347. * Returns a string to use to update the GPU particles update shader
  85348. * @returns a string containng the defines string
  85349. */
  85350. getEffectDefines(): string;
  85351. /**
  85352. * Returns the string "CylinderDirectedParticleEmitter"
  85353. * @returns a string containing the class name
  85354. */
  85355. getClassName(): string;
  85356. /**
  85357. * Serializes the particle system to a JSON object.
  85358. * @returns the JSON object
  85359. */
  85360. serialize(): any;
  85361. /**
  85362. * Parse properties from a JSON object
  85363. * @param serializationObject defines the JSON object
  85364. */
  85365. parse(serializationObject: any): void;
  85366. }
  85367. }
  85368. declare module BABYLON {
  85369. /**
  85370. * Particle emitter emitting particles from the inside of a hemisphere.
  85371. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85372. */
  85373. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85374. /**
  85375. * The radius of the emission hemisphere.
  85376. */
  85377. radius: number;
  85378. /**
  85379. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85380. */
  85381. radiusRange: number;
  85382. /**
  85383. * How much to randomize the particle direction [0-1].
  85384. */
  85385. directionRandomizer: number;
  85386. /**
  85387. * Creates a new instance HemisphericParticleEmitter
  85388. * @param radius the radius of the emission hemisphere (1 by default)
  85389. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85390. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85391. */
  85392. constructor(
  85393. /**
  85394. * The radius of the emission hemisphere.
  85395. */
  85396. radius?: number,
  85397. /**
  85398. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85399. */
  85400. radiusRange?: number,
  85401. /**
  85402. * How much to randomize the particle direction [0-1].
  85403. */
  85404. directionRandomizer?: number);
  85405. /**
  85406. * Called by the particle System when the direction is computed for the created particle.
  85407. * @param worldMatrix is the world matrix of the particle system
  85408. * @param directionToUpdate is the direction vector to update with the result
  85409. * @param particle is the particle we are computed the direction for
  85410. */
  85411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85412. /**
  85413. * Called by the particle System when the position is computed for the created particle.
  85414. * @param worldMatrix is the world matrix of the particle system
  85415. * @param positionToUpdate is the position vector to update with the result
  85416. * @param particle is the particle we are computed the position for
  85417. */
  85418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85419. /**
  85420. * Clones the current emitter and returns a copy of it
  85421. * @returns the new emitter
  85422. */
  85423. clone(): HemisphericParticleEmitter;
  85424. /**
  85425. * Called by the GPUParticleSystem to setup the update shader
  85426. * @param effect defines the update shader
  85427. */
  85428. applyToShader(effect: Effect): void;
  85429. /**
  85430. * Returns a string to use to update the GPU particles update shader
  85431. * @returns a string containng the defines string
  85432. */
  85433. getEffectDefines(): string;
  85434. /**
  85435. * Returns the string "HemisphericParticleEmitter"
  85436. * @returns a string containing the class name
  85437. */
  85438. getClassName(): string;
  85439. /**
  85440. * Serializes the particle system to a JSON object.
  85441. * @returns the JSON object
  85442. */
  85443. serialize(): any;
  85444. /**
  85445. * Parse properties from a JSON object
  85446. * @param serializationObject defines the JSON object
  85447. */
  85448. parse(serializationObject: any): void;
  85449. }
  85450. }
  85451. declare module BABYLON {
  85452. /**
  85453. * Particle emitter emitting particles from a point.
  85454. * It emits the particles randomly between 2 given directions.
  85455. */
  85456. export class PointParticleEmitter implements IParticleEmitterType {
  85457. /**
  85458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85459. */
  85460. direction1: Vector3;
  85461. /**
  85462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85463. */
  85464. direction2: Vector3;
  85465. /**
  85466. * Creates a new instance PointParticleEmitter
  85467. */
  85468. constructor();
  85469. /**
  85470. * Called by the particle System when the direction is computed for the created particle.
  85471. * @param worldMatrix is the world matrix of the particle system
  85472. * @param directionToUpdate is the direction vector to update with the result
  85473. * @param particle is the particle we are computed the direction for
  85474. */
  85475. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85476. /**
  85477. * Called by the particle System when the position is computed for the created particle.
  85478. * @param worldMatrix is the world matrix of the particle system
  85479. * @param positionToUpdate is the position vector to update with the result
  85480. * @param particle is the particle we are computed the position for
  85481. */
  85482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85483. /**
  85484. * Clones the current emitter and returns a copy of it
  85485. * @returns the new emitter
  85486. */
  85487. clone(): PointParticleEmitter;
  85488. /**
  85489. * Called by the GPUParticleSystem to setup the update shader
  85490. * @param effect defines the update shader
  85491. */
  85492. applyToShader(effect: Effect): void;
  85493. /**
  85494. * Returns a string to use to update the GPU particles update shader
  85495. * @returns a string containng the defines string
  85496. */
  85497. getEffectDefines(): string;
  85498. /**
  85499. * Returns the string "PointParticleEmitter"
  85500. * @returns a string containing the class name
  85501. */
  85502. getClassName(): string;
  85503. /**
  85504. * Serializes the particle system to a JSON object.
  85505. * @returns the JSON object
  85506. */
  85507. serialize(): any;
  85508. /**
  85509. * Parse properties from a JSON object
  85510. * @param serializationObject defines the JSON object
  85511. */
  85512. parse(serializationObject: any): void;
  85513. }
  85514. }
  85515. declare module BABYLON {
  85516. /**
  85517. * Particle emitter emitting particles from the inside of a sphere.
  85518. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85519. */
  85520. export class SphereParticleEmitter implements IParticleEmitterType {
  85521. /**
  85522. * The radius of the emission sphere.
  85523. */
  85524. radius: number;
  85525. /**
  85526. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85527. */
  85528. radiusRange: number;
  85529. /**
  85530. * How much to randomize the particle direction [0-1].
  85531. */
  85532. directionRandomizer: number;
  85533. /**
  85534. * Creates a new instance SphereParticleEmitter
  85535. * @param radius the radius of the emission sphere (1 by default)
  85536. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85537. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85538. */
  85539. constructor(
  85540. /**
  85541. * The radius of the emission sphere.
  85542. */
  85543. radius?: number,
  85544. /**
  85545. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85546. */
  85547. radiusRange?: number,
  85548. /**
  85549. * How much to randomize the particle direction [0-1].
  85550. */
  85551. directionRandomizer?: number);
  85552. /**
  85553. * Called by the particle System when the direction is computed for the created particle.
  85554. * @param worldMatrix is the world matrix of the particle system
  85555. * @param directionToUpdate is the direction vector to update with the result
  85556. * @param particle is the particle we are computed the direction for
  85557. */
  85558. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85559. /**
  85560. * Called by the particle System when the position is computed for the created particle.
  85561. * @param worldMatrix is the world matrix of the particle system
  85562. * @param positionToUpdate is the position vector to update with the result
  85563. * @param particle is the particle we are computed the position for
  85564. */
  85565. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85566. /**
  85567. * Clones the current emitter and returns a copy of it
  85568. * @returns the new emitter
  85569. */
  85570. clone(): SphereParticleEmitter;
  85571. /**
  85572. * Called by the GPUParticleSystem to setup the update shader
  85573. * @param effect defines the update shader
  85574. */
  85575. applyToShader(effect: Effect): void;
  85576. /**
  85577. * Returns a string to use to update the GPU particles update shader
  85578. * @returns a string containng the defines string
  85579. */
  85580. getEffectDefines(): string;
  85581. /**
  85582. * Returns the string "SphereParticleEmitter"
  85583. * @returns a string containing the class name
  85584. */
  85585. getClassName(): string;
  85586. /**
  85587. * Serializes the particle system to a JSON object.
  85588. * @returns the JSON object
  85589. */
  85590. serialize(): any;
  85591. /**
  85592. * Parse properties from a JSON object
  85593. * @param serializationObject defines the JSON object
  85594. */
  85595. parse(serializationObject: any): void;
  85596. }
  85597. /**
  85598. * Particle emitter emitting particles from the inside of a sphere.
  85599. * It emits the particles randomly between two vectors.
  85600. */
  85601. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85602. /**
  85603. * The min limit of the emission direction.
  85604. */
  85605. direction1: Vector3;
  85606. /**
  85607. * The max limit of the emission direction.
  85608. */
  85609. direction2: Vector3;
  85610. /**
  85611. * Creates a new instance SphereDirectedParticleEmitter
  85612. * @param radius the radius of the emission sphere (1 by default)
  85613. * @param direction1 the min limit of the emission direction (up vector by default)
  85614. * @param direction2 the max limit of the emission direction (up vector by default)
  85615. */
  85616. constructor(radius?: number,
  85617. /**
  85618. * The min limit of the emission direction.
  85619. */
  85620. direction1?: Vector3,
  85621. /**
  85622. * The max limit of the emission direction.
  85623. */
  85624. direction2?: Vector3);
  85625. /**
  85626. * Called by the particle System when the direction is computed for the created particle.
  85627. * @param worldMatrix is the world matrix of the particle system
  85628. * @param directionToUpdate is the direction vector to update with the result
  85629. * @param particle is the particle we are computed the direction for
  85630. */
  85631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85632. /**
  85633. * Clones the current emitter and returns a copy of it
  85634. * @returns the new emitter
  85635. */
  85636. clone(): SphereDirectedParticleEmitter;
  85637. /**
  85638. * Called by the GPUParticleSystem to setup the update shader
  85639. * @param effect defines the update shader
  85640. */
  85641. applyToShader(effect: Effect): void;
  85642. /**
  85643. * Returns a string to use to update the GPU particles update shader
  85644. * @returns a string containng the defines string
  85645. */
  85646. getEffectDefines(): string;
  85647. /**
  85648. * Returns the string "SphereDirectedParticleEmitter"
  85649. * @returns a string containing the class name
  85650. */
  85651. getClassName(): string;
  85652. /**
  85653. * Serializes the particle system to a JSON object.
  85654. * @returns the JSON object
  85655. */
  85656. serialize(): any;
  85657. /**
  85658. * Parse properties from a JSON object
  85659. * @param serializationObject defines the JSON object
  85660. */
  85661. parse(serializationObject: any): void;
  85662. }
  85663. }
  85664. declare module BABYLON {
  85665. /**
  85666. * Interface representing a particle system in Babylon.js.
  85667. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85668. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85669. */
  85670. export interface IParticleSystem {
  85671. /**
  85672. * List of animations used by the particle system.
  85673. */
  85674. animations: Animation[];
  85675. /**
  85676. * The id of the Particle system.
  85677. */
  85678. id: string;
  85679. /**
  85680. * The name of the Particle system.
  85681. */
  85682. name: string;
  85683. /**
  85684. * The emitter represents the Mesh or position we are attaching the particle system to.
  85685. */
  85686. emitter: Nullable<AbstractMesh | Vector3>;
  85687. /**
  85688. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85689. */
  85690. isBillboardBased: boolean;
  85691. /**
  85692. * The rendering group used by the Particle system to chose when to render.
  85693. */
  85694. renderingGroupId: number;
  85695. /**
  85696. * The layer mask we are rendering the particles through.
  85697. */
  85698. layerMask: number;
  85699. /**
  85700. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85701. */
  85702. updateSpeed: number;
  85703. /**
  85704. * The amount of time the particle system is running (depends of the overall update speed).
  85705. */
  85706. targetStopDuration: number;
  85707. /**
  85708. * The texture used to render each particle. (this can be a spritesheet)
  85709. */
  85710. particleTexture: Nullable<Texture>;
  85711. /**
  85712. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85713. */
  85714. blendMode: number;
  85715. /**
  85716. * Minimum life time of emitting particles.
  85717. */
  85718. minLifeTime: number;
  85719. /**
  85720. * Maximum life time of emitting particles.
  85721. */
  85722. maxLifeTime: number;
  85723. /**
  85724. * Minimum Size of emitting particles.
  85725. */
  85726. minSize: number;
  85727. /**
  85728. * Maximum Size of emitting particles.
  85729. */
  85730. maxSize: number;
  85731. /**
  85732. * Minimum scale of emitting particles on X axis.
  85733. */
  85734. minScaleX: number;
  85735. /**
  85736. * Maximum scale of emitting particles on X axis.
  85737. */
  85738. maxScaleX: number;
  85739. /**
  85740. * Minimum scale of emitting particles on Y axis.
  85741. */
  85742. minScaleY: number;
  85743. /**
  85744. * Maximum scale of emitting particles on Y axis.
  85745. */
  85746. maxScaleY: number;
  85747. /**
  85748. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85749. */
  85750. color1: Color4;
  85751. /**
  85752. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85753. */
  85754. color2: Color4;
  85755. /**
  85756. * Color the particle will have at the end of its lifetime.
  85757. */
  85758. colorDead: Color4;
  85759. /**
  85760. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85761. */
  85762. emitRate: number;
  85763. /**
  85764. * You can use gravity if you want to give an orientation to your particles.
  85765. */
  85766. gravity: Vector3;
  85767. /**
  85768. * Minimum power of emitting particles.
  85769. */
  85770. minEmitPower: number;
  85771. /**
  85772. * Maximum power of emitting particles.
  85773. */
  85774. maxEmitPower: number;
  85775. /**
  85776. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85777. */
  85778. minAngularSpeed: number;
  85779. /**
  85780. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85781. */
  85782. maxAngularSpeed: number;
  85783. /**
  85784. * Gets or sets the minimal initial rotation in radians.
  85785. */
  85786. minInitialRotation: number;
  85787. /**
  85788. * Gets or sets the maximal initial rotation in radians.
  85789. */
  85790. maxInitialRotation: number;
  85791. /**
  85792. * The particle emitter type defines the emitter used by the particle system.
  85793. * It can be for example box, sphere, or cone...
  85794. */
  85795. particleEmitterType: Nullable<IParticleEmitterType>;
  85796. /**
  85797. * Defines the delay in milliseconds before starting the system (0 by default)
  85798. */
  85799. startDelay: number;
  85800. /**
  85801. * 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
  85802. */
  85803. preWarmCycles: number;
  85804. /**
  85805. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85806. */
  85807. preWarmStepOffset: number;
  85808. /**
  85809. * 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)
  85810. */
  85811. spriteCellChangeSpeed: number;
  85812. /**
  85813. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85814. */
  85815. startSpriteCellID: number;
  85816. /**
  85817. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85818. */
  85819. endSpriteCellID: number;
  85820. /**
  85821. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85822. */
  85823. spriteCellWidth: number;
  85824. /**
  85825. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85826. */
  85827. spriteCellHeight: number;
  85828. /**
  85829. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85830. */
  85831. spriteRandomStartCell: boolean;
  85832. /**
  85833. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85834. */
  85835. isAnimationSheetEnabled: boolean;
  85836. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85837. translationPivot: Vector2;
  85838. /**
  85839. * Gets or sets a texture used to add random noise to particle positions
  85840. */
  85841. noiseTexture: Nullable<BaseTexture>;
  85842. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85843. noiseStrength: Vector3;
  85844. /**
  85845. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85846. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85847. */
  85848. billboardMode: number;
  85849. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85850. limitVelocityDamping: number;
  85851. /**
  85852. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85853. */
  85854. beginAnimationOnStart: boolean;
  85855. /**
  85856. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85857. */
  85858. beginAnimationFrom: number;
  85859. /**
  85860. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85861. */
  85862. beginAnimationTo: number;
  85863. /**
  85864. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85865. */
  85866. beginAnimationLoop: boolean;
  85867. /**
  85868. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85869. */
  85870. disposeOnStop: boolean;
  85871. /**
  85872. * Gets the maximum number of particles active at the same time.
  85873. * @returns The max number of active particles.
  85874. */
  85875. getCapacity(): number;
  85876. /**
  85877. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85878. * @returns True if it has been started, otherwise false.
  85879. */
  85880. isStarted(): boolean;
  85881. /**
  85882. * Animates the particle system for this frame.
  85883. */
  85884. animate(): void;
  85885. /**
  85886. * Renders the particle system in its current state.
  85887. * @returns the current number of particles
  85888. */
  85889. render(): number;
  85890. /**
  85891. * Dispose the particle system and frees its associated resources.
  85892. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85893. */
  85894. dispose(disposeTexture?: boolean): void;
  85895. /**
  85896. * Clones the particle system.
  85897. * @param name The name of the cloned object
  85898. * @param newEmitter The new emitter to use
  85899. * @returns the cloned particle system
  85900. */
  85901. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85902. /**
  85903. * Serializes the particle system to a JSON object.
  85904. * @returns the JSON object
  85905. */
  85906. serialize(): any;
  85907. /**
  85908. * Rebuild the particle system
  85909. */
  85910. rebuild(): void;
  85911. /**
  85912. * Starts the particle system and begins to emit
  85913. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85914. */
  85915. start(delay?: number): void;
  85916. /**
  85917. * Stops the particle system.
  85918. */
  85919. stop(): void;
  85920. /**
  85921. * Remove all active particles
  85922. */
  85923. reset(): void;
  85924. /**
  85925. * Is this system ready to be used/rendered
  85926. * @return true if the system is ready
  85927. */
  85928. isReady(): boolean;
  85929. /**
  85930. * Adds a new color gradient
  85931. * @param gradient defines the gradient to use (between 0 and 1)
  85932. * @param color1 defines the color to affect to the specified gradient
  85933. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85934. * @returns the current particle system
  85935. */
  85936. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85937. /**
  85938. * Remove a specific color gradient
  85939. * @param gradient defines the gradient to remove
  85940. * @returns the current particle system
  85941. */
  85942. removeColorGradient(gradient: number): IParticleSystem;
  85943. /**
  85944. * Adds a new size gradient
  85945. * @param gradient defines the gradient to use (between 0 and 1)
  85946. * @param factor defines the size factor to affect to the specified gradient
  85947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85948. * @returns the current particle system
  85949. */
  85950. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85951. /**
  85952. * Remove a specific size gradient
  85953. * @param gradient defines the gradient to remove
  85954. * @returns the current particle system
  85955. */
  85956. removeSizeGradient(gradient: number): IParticleSystem;
  85957. /**
  85958. * Gets the current list of color gradients.
  85959. * You must use addColorGradient and removeColorGradient to udpate this list
  85960. * @returns the list of color gradients
  85961. */
  85962. getColorGradients(): Nullable<Array<ColorGradient>>;
  85963. /**
  85964. * Gets the current list of size gradients.
  85965. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85966. * @returns the list of size gradients
  85967. */
  85968. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85969. /**
  85970. * Gets the current list of angular speed gradients.
  85971. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85972. * @returns the list of angular speed gradients
  85973. */
  85974. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85975. /**
  85976. * Adds a new angular speed gradient
  85977. * @param gradient defines the gradient to use (between 0 and 1)
  85978. * @param factor defines the angular speed to affect to the specified gradient
  85979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85980. * @returns the current particle system
  85981. */
  85982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85983. /**
  85984. * Remove a specific angular speed gradient
  85985. * @param gradient defines the gradient to remove
  85986. * @returns the current particle system
  85987. */
  85988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85989. /**
  85990. * Gets the current list of velocity gradients.
  85991. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85992. * @returns the list of velocity gradients
  85993. */
  85994. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85995. /**
  85996. * Adds a new velocity gradient
  85997. * @param gradient defines the gradient to use (between 0 and 1)
  85998. * @param factor defines the velocity to affect to the specified gradient
  85999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86000. * @returns the current particle system
  86001. */
  86002. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86003. /**
  86004. * Remove a specific velocity gradient
  86005. * @param gradient defines the gradient to remove
  86006. * @returns the current particle system
  86007. */
  86008. removeVelocityGradient(gradient: number): IParticleSystem;
  86009. /**
  86010. * Gets the current list of limit velocity gradients.
  86011. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86012. * @returns the list of limit velocity gradients
  86013. */
  86014. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86015. /**
  86016. * Adds a new limit velocity gradient
  86017. * @param gradient defines the gradient to use (between 0 and 1)
  86018. * @param factor defines the limit velocity to affect to the specified gradient
  86019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86020. * @returns the current particle system
  86021. */
  86022. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86023. /**
  86024. * Remove a specific limit velocity gradient
  86025. * @param gradient defines the gradient to remove
  86026. * @returns the current particle system
  86027. */
  86028. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86029. /**
  86030. * Adds a new drag gradient
  86031. * @param gradient defines the gradient to use (between 0 and 1)
  86032. * @param factor defines the drag to affect to the specified gradient
  86033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86034. * @returns the current particle system
  86035. */
  86036. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86037. /**
  86038. * Remove a specific drag gradient
  86039. * @param gradient defines the gradient to remove
  86040. * @returns the current particle system
  86041. */
  86042. removeDragGradient(gradient: number): IParticleSystem;
  86043. /**
  86044. * Gets the current list of drag gradients.
  86045. * You must use addDragGradient and removeDragGradient to udpate this list
  86046. * @returns the list of drag gradients
  86047. */
  86048. getDragGradients(): Nullable<Array<FactorGradient>>;
  86049. /**
  86050. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86051. * @param gradient defines the gradient to use (between 0 and 1)
  86052. * @param factor defines the emit rate to affect to the specified gradient
  86053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86054. * @returns the current particle system
  86055. */
  86056. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86057. /**
  86058. * Remove a specific emit rate gradient
  86059. * @param gradient defines the gradient to remove
  86060. * @returns the current particle system
  86061. */
  86062. removeEmitRateGradient(gradient: number): IParticleSystem;
  86063. /**
  86064. * Gets the current list of emit rate gradients.
  86065. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86066. * @returns the list of emit rate gradients
  86067. */
  86068. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86069. /**
  86070. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86071. * @param gradient defines the gradient to use (between 0 and 1)
  86072. * @param factor defines the start size to affect to the specified gradient
  86073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86074. * @returns the current particle system
  86075. */
  86076. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86077. /**
  86078. * Remove a specific start size gradient
  86079. * @param gradient defines the gradient to remove
  86080. * @returns the current particle system
  86081. */
  86082. removeStartSizeGradient(gradient: number): IParticleSystem;
  86083. /**
  86084. * Gets the current list of start size gradients.
  86085. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86086. * @returns the list of start size gradients
  86087. */
  86088. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86089. /**
  86090. * Adds a new life time gradient
  86091. * @param gradient defines the gradient to use (between 0 and 1)
  86092. * @param factor defines the life time factor to affect to the specified gradient
  86093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86094. * @returns the current particle system
  86095. */
  86096. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86097. /**
  86098. * Remove a specific life time gradient
  86099. * @param gradient defines the gradient to remove
  86100. * @returns the current particle system
  86101. */
  86102. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86103. /**
  86104. * Gets the current list of life time gradients.
  86105. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86106. * @returns the list of life time gradients
  86107. */
  86108. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86109. /**
  86110. * Gets the current list of color gradients.
  86111. * You must use addColorGradient and removeColorGradient to udpate this list
  86112. * @returns the list of color gradients
  86113. */
  86114. getColorGradients(): Nullable<Array<ColorGradient>>;
  86115. /**
  86116. * Adds a new ramp gradient used to remap particle colors
  86117. * @param gradient defines the gradient to use (between 0 and 1)
  86118. * @param color defines the color to affect to the specified gradient
  86119. * @returns the current particle system
  86120. */
  86121. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86122. /**
  86123. * Gets the current list of ramp gradients.
  86124. * You must use addRampGradient and removeRampGradient to udpate this list
  86125. * @returns the list of ramp gradients
  86126. */
  86127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86128. /** Gets or sets a boolean indicating that ramp gradients must be used
  86129. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86130. */
  86131. useRampGradients: boolean;
  86132. /**
  86133. * Adds a new color remap gradient
  86134. * @param gradient defines the gradient to use (between 0 and 1)
  86135. * @param min defines the color remap minimal range
  86136. * @param max defines the color remap maximal range
  86137. * @returns the current particle system
  86138. */
  86139. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86140. /**
  86141. * Gets the current list of color remap gradients.
  86142. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86143. * @returns the list of color remap gradients
  86144. */
  86145. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86146. /**
  86147. * Adds a new alpha remap gradient
  86148. * @param gradient defines the gradient to use (between 0 and 1)
  86149. * @param min defines the alpha remap minimal range
  86150. * @param max defines the alpha remap maximal range
  86151. * @returns the current particle system
  86152. */
  86153. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86154. /**
  86155. * Gets the current list of alpha remap gradients.
  86156. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86157. * @returns the list of alpha remap gradients
  86158. */
  86159. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86160. /**
  86161. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86162. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86163. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86164. * @returns the emitter
  86165. */
  86166. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86167. /**
  86168. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86169. * @param radius The radius of the hemisphere to emit from
  86170. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86171. * @returns the emitter
  86172. */
  86173. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86174. /**
  86175. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86176. * @param radius The radius of the sphere to emit from
  86177. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86178. * @returns the emitter
  86179. */
  86180. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86181. /**
  86182. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86183. * @param radius The radius of the sphere to emit from
  86184. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86185. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86186. * @returns the emitter
  86187. */
  86188. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86189. /**
  86190. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86191. * @param radius The radius of the emission cylinder
  86192. * @param height The height of the emission cylinder
  86193. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86194. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86195. * @returns the emitter
  86196. */
  86197. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86198. /**
  86199. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86200. * @param radius The radius of the cylinder to emit from
  86201. * @param height The height of the emission cylinder
  86202. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86203. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86204. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86205. * @returns the emitter
  86206. */
  86207. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86208. /**
  86209. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86210. * @param radius The radius of the cone to emit from
  86211. * @param angle The base angle of the cone
  86212. * @returns the emitter
  86213. */
  86214. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86215. /**
  86216. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86217. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86218. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86219. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86220. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86221. * @returns the emitter
  86222. */
  86223. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86224. /**
  86225. * Get hosting scene
  86226. * @returns the scene
  86227. */
  86228. getScene(): Scene;
  86229. }
  86230. }
  86231. declare module BABYLON {
  86232. /**
  86233. * Creates an instance based on a source mesh.
  86234. */
  86235. export class InstancedMesh extends AbstractMesh {
  86236. private _sourceMesh;
  86237. private _currentLOD;
  86238. /** @hidden */
  86239. _indexInSourceMeshInstanceArray: number;
  86240. constructor(name: string, source: Mesh);
  86241. /**
  86242. * Returns the string "InstancedMesh".
  86243. */
  86244. getClassName(): string;
  86245. /** Gets the list of lights affecting that mesh */
  86246. readonly lightSources: Light[];
  86247. _resyncLightSources(): void;
  86248. _resyncLighSource(light: Light): void;
  86249. _removeLightSource(light: Light, dispose: boolean): void;
  86250. /**
  86251. * If the source mesh receives shadows
  86252. */
  86253. readonly receiveShadows: boolean;
  86254. /**
  86255. * The material of the source mesh
  86256. */
  86257. readonly material: Nullable<Material>;
  86258. /**
  86259. * Visibility of the source mesh
  86260. */
  86261. readonly visibility: number;
  86262. /**
  86263. * Skeleton of the source mesh
  86264. */
  86265. readonly skeleton: Nullable<Skeleton>;
  86266. /**
  86267. * Rendering ground id of the source mesh
  86268. */
  86269. renderingGroupId: number;
  86270. /**
  86271. * Returns the total number of vertices (integer).
  86272. */
  86273. getTotalVertices(): number;
  86274. /**
  86275. * Returns a positive integer : the total number of indices in this mesh geometry.
  86276. * @returns the numner of indices or zero if the mesh has no geometry.
  86277. */
  86278. getTotalIndices(): number;
  86279. /**
  86280. * The source mesh of the instance
  86281. */
  86282. readonly sourceMesh: Mesh;
  86283. /**
  86284. * Is this node ready to be used/rendered
  86285. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86286. * @return {boolean} is it ready
  86287. */
  86288. isReady(completeCheck?: boolean): boolean;
  86289. /**
  86290. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86291. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86292. * @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.
  86293. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86294. */
  86295. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86296. /**
  86297. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86298. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86299. * The `data` are either a numeric array either a Float32Array.
  86300. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86301. * 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).
  86302. * Note that a new underlying VertexBuffer object is created each call.
  86303. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86304. *
  86305. * Possible `kind` values :
  86306. * - VertexBuffer.PositionKind
  86307. * - VertexBuffer.UVKind
  86308. * - VertexBuffer.UV2Kind
  86309. * - VertexBuffer.UV3Kind
  86310. * - VertexBuffer.UV4Kind
  86311. * - VertexBuffer.UV5Kind
  86312. * - VertexBuffer.UV6Kind
  86313. * - VertexBuffer.ColorKind
  86314. * - VertexBuffer.MatricesIndicesKind
  86315. * - VertexBuffer.MatricesIndicesExtraKind
  86316. * - VertexBuffer.MatricesWeightsKind
  86317. * - VertexBuffer.MatricesWeightsExtraKind
  86318. *
  86319. * Returns the Mesh.
  86320. */
  86321. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86322. /**
  86323. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86324. * If the mesh has no geometry, it is simply returned as it is.
  86325. * The `data` are either a numeric array either a Float32Array.
  86326. * No new underlying VertexBuffer object is created.
  86327. * 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.
  86328. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86329. *
  86330. * Possible `kind` values :
  86331. * - VertexBuffer.PositionKind
  86332. * - VertexBuffer.UVKind
  86333. * - VertexBuffer.UV2Kind
  86334. * - VertexBuffer.UV3Kind
  86335. * - VertexBuffer.UV4Kind
  86336. * - VertexBuffer.UV5Kind
  86337. * - VertexBuffer.UV6Kind
  86338. * - VertexBuffer.ColorKind
  86339. * - VertexBuffer.MatricesIndicesKind
  86340. * - VertexBuffer.MatricesIndicesExtraKind
  86341. * - VertexBuffer.MatricesWeightsKind
  86342. * - VertexBuffer.MatricesWeightsExtraKind
  86343. *
  86344. * Returns the Mesh.
  86345. */
  86346. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86347. /**
  86348. * Sets the mesh indices.
  86349. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86350. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86351. * This method creates a new index buffer each call.
  86352. * Returns the Mesh.
  86353. */
  86354. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86355. /**
  86356. * Boolean : True if the mesh owns the requested kind of data.
  86357. */
  86358. isVerticesDataPresent(kind: string): boolean;
  86359. /**
  86360. * Returns an array of indices (IndicesArray).
  86361. */
  86362. getIndices(): Nullable<IndicesArray>;
  86363. readonly _positions: Nullable<Vector3[]>;
  86364. /**
  86365. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86366. * This means the mesh underlying bounding box and sphere are recomputed.
  86367. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86368. * @returns the current mesh
  86369. */
  86370. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86371. /** @hidden */
  86372. _preActivate(): InstancedMesh;
  86373. /** @hidden */
  86374. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86375. /** @hidden */
  86376. _postActivate(): void;
  86377. getWorldMatrix(): Matrix;
  86378. readonly isAnInstance: boolean;
  86379. /**
  86380. * Returns the current associated LOD AbstractMesh.
  86381. */
  86382. getLOD(camera: Camera): AbstractMesh;
  86383. /** @hidden */
  86384. _syncSubMeshes(): InstancedMesh;
  86385. /** @hidden */
  86386. _generatePointsArray(): boolean;
  86387. /**
  86388. * Creates a new InstancedMesh from the current mesh.
  86389. * - name (string) : the cloned mesh name
  86390. * - newParent (optional Node) : the optional Node to parent the clone to.
  86391. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86392. *
  86393. * Returns the clone.
  86394. */
  86395. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86396. /**
  86397. * Disposes the InstancedMesh.
  86398. * Returns nothing.
  86399. */
  86400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86401. }
  86402. interface Mesh {
  86403. /**
  86404. * Register a custom buffer that will be instanced
  86405. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86406. * @param kind defines the buffer kind
  86407. * @param stride defines the stride in floats
  86408. */
  86409. registerInstancedBuffer(kind: string, stride: number): void;
  86410. /** @hidden */
  86411. _userInstancedBuffersStorage: {
  86412. data: {
  86413. [key: string]: Float32Array;
  86414. };
  86415. sizes: {
  86416. [key: string]: number;
  86417. };
  86418. vertexBuffers: {
  86419. [key: string]: Nullable<VertexBuffer>;
  86420. };
  86421. strides: {
  86422. [key: string]: number;
  86423. };
  86424. };
  86425. }
  86426. interface AbstractMesh {
  86427. /**
  86428. * Object used to store instanced buffers defined by user
  86429. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86430. */
  86431. instancedBuffers: {
  86432. [key: string]: any;
  86433. };
  86434. }
  86435. }
  86436. declare module BABYLON {
  86437. /**
  86438. * Defines the options associated with the creation of a shader material.
  86439. */
  86440. export interface IShaderMaterialOptions {
  86441. /**
  86442. * Does the material work in alpha blend mode
  86443. */
  86444. needAlphaBlending: boolean;
  86445. /**
  86446. * Does the material work in alpha test mode
  86447. */
  86448. needAlphaTesting: boolean;
  86449. /**
  86450. * The list of attribute names used in the shader
  86451. */
  86452. attributes: string[];
  86453. /**
  86454. * The list of unifrom names used in the shader
  86455. */
  86456. uniforms: string[];
  86457. /**
  86458. * The list of UBO names used in the shader
  86459. */
  86460. uniformBuffers: string[];
  86461. /**
  86462. * The list of sampler names used in the shader
  86463. */
  86464. samplers: string[];
  86465. /**
  86466. * The list of defines used in the shader
  86467. */
  86468. defines: string[];
  86469. }
  86470. /**
  86471. * 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.
  86472. *
  86473. * This returned material effects how the mesh will look based on the code in the shaders.
  86474. *
  86475. * @see http://doc.babylonjs.com/how_to/shader_material
  86476. */
  86477. export class ShaderMaterial extends Material {
  86478. private _shaderPath;
  86479. private _options;
  86480. private _textures;
  86481. private _textureArrays;
  86482. private _floats;
  86483. private _ints;
  86484. private _floatsArrays;
  86485. private _colors3;
  86486. private _colors3Arrays;
  86487. private _colors4;
  86488. private _colors4Arrays;
  86489. private _vectors2;
  86490. private _vectors3;
  86491. private _vectors4;
  86492. private _matrices;
  86493. private _matrices3x3;
  86494. private _matrices2x2;
  86495. private _vectors2Arrays;
  86496. private _vectors3Arrays;
  86497. private _vectors4Arrays;
  86498. private _cachedWorldViewMatrix;
  86499. private _cachedWorldViewProjectionMatrix;
  86500. private _renderId;
  86501. /**
  86502. * Instantiate a new shader material.
  86503. * 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.
  86504. * This returned material effects how the mesh will look based on the code in the shaders.
  86505. * @see http://doc.babylonjs.com/how_to/shader_material
  86506. * @param name Define the name of the material in the scene
  86507. * @param scene Define the scene the material belongs to
  86508. * @param shaderPath Defines the route to the shader code in one of three ways:
  86509. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86510. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86511. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86512. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86513. * @param options Define the options used to create the shader
  86514. */
  86515. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86516. /**
  86517. * Gets the options used to compile the shader.
  86518. * They can be modified to trigger a new compilation
  86519. */
  86520. readonly options: IShaderMaterialOptions;
  86521. /**
  86522. * Gets the current class name of the material e.g. "ShaderMaterial"
  86523. * Mainly use in serialization.
  86524. * @returns the class name
  86525. */
  86526. getClassName(): string;
  86527. /**
  86528. * Specifies if the material will require alpha blending
  86529. * @returns a boolean specifying if alpha blending is needed
  86530. */
  86531. needAlphaBlending(): boolean;
  86532. /**
  86533. * Specifies if this material should be rendered in alpha test mode
  86534. * @returns a boolean specifying if an alpha test is needed.
  86535. */
  86536. needAlphaTesting(): boolean;
  86537. private _checkUniform;
  86538. /**
  86539. * Set a texture in the shader.
  86540. * @param name Define the name of the uniform samplers as defined in the shader
  86541. * @param texture Define the texture to bind to this sampler
  86542. * @return the material itself allowing "fluent" like uniform updates
  86543. */
  86544. setTexture(name: string, texture: Texture): ShaderMaterial;
  86545. /**
  86546. * Set a texture array in the shader.
  86547. * @param name Define the name of the uniform sampler array as defined in the shader
  86548. * @param textures Define the list of textures to bind to this sampler
  86549. * @return the material itself allowing "fluent" like uniform updates
  86550. */
  86551. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86552. /**
  86553. * Set a float in the shader.
  86554. * @param name Define the name of the uniform as defined in the shader
  86555. * @param value Define the value to give to the uniform
  86556. * @return the material itself allowing "fluent" like uniform updates
  86557. */
  86558. setFloat(name: string, value: number): ShaderMaterial;
  86559. /**
  86560. * Set a int in the shader.
  86561. * @param name Define the name of the uniform as defined in the shader
  86562. * @param value Define the value to give to the uniform
  86563. * @return the material itself allowing "fluent" like uniform updates
  86564. */
  86565. setInt(name: string, value: number): ShaderMaterial;
  86566. /**
  86567. * Set an array of floats in the shader.
  86568. * @param name Define the name of the uniform as defined in the shader
  86569. * @param value Define the value to give to the uniform
  86570. * @return the material itself allowing "fluent" like uniform updates
  86571. */
  86572. setFloats(name: string, value: number[]): ShaderMaterial;
  86573. /**
  86574. * Set a vec3 in the shader from a Color3.
  86575. * @param name Define the name of the uniform as defined in the shader
  86576. * @param value Define the value to give to the uniform
  86577. * @return the material itself allowing "fluent" like uniform updates
  86578. */
  86579. setColor3(name: string, value: Color3): ShaderMaterial;
  86580. /**
  86581. * Set a vec3 array in the shader from a Color3 array.
  86582. * @param name Define the name of the uniform as defined in the shader
  86583. * @param value Define the value to give to the uniform
  86584. * @return the material itself allowing "fluent" like uniform updates
  86585. */
  86586. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86587. /**
  86588. * Set a vec4 in the shader from a Color4.
  86589. * @param name Define the name of the uniform as defined in the shader
  86590. * @param value Define the value to give to the uniform
  86591. * @return the material itself allowing "fluent" like uniform updates
  86592. */
  86593. setColor4(name: string, value: Color4): ShaderMaterial;
  86594. /**
  86595. * Set a vec4 array in the shader from a Color4 array.
  86596. * @param name Define the name of the uniform as defined in the shader
  86597. * @param value Define the value to give to the uniform
  86598. * @return the material itself allowing "fluent" like uniform updates
  86599. */
  86600. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86601. /**
  86602. * Set a vec2 in the shader from a Vector2.
  86603. * @param name Define the name of the uniform as defined in the shader
  86604. * @param value Define the value to give to the uniform
  86605. * @return the material itself allowing "fluent" like uniform updates
  86606. */
  86607. setVector2(name: string, value: Vector2): ShaderMaterial;
  86608. /**
  86609. * Set a vec3 in the shader from a Vector3.
  86610. * @param name Define the name of the uniform as defined in the shader
  86611. * @param value Define the value to give to the uniform
  86612. * @return the material itself allowing "fluent" like uniform updates
  86613. */
  86614. setVector3(name: string, value: Vector3): ShaderMaterial;
  86615. /**
  86616. * Set a vec4 in the shader from a Vector4.
  86617. * @param name Define the name of the uniform as defined in the shader
  86618. * @param value Define the value to give to the uniform
  86619. * @return the material itself allowing "fluent" like uniform updates
  86620. */
  86621. setVector4(name: string, value: Vector4): ShaderMaterial;
  86622. /**
  86623. * Set a mat4 in the shader from a Matrix.
  86624. * @param name Define the name of the uniform as defined in the shader
  86625. * @param value Define the value to give to the uniform
  86626. * @return the material itself allowing "fluent" like uniform updates
  86627. */
  86628. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86629. /**
  86630. * Set a mat3 in the shader from a Float32Array.
  86631. * @param name Define the name of the uniform as defined in the shader
  86632. * @param value Define the value to give to the uniform
  86633. * @return the material itself allowing "fluent" like uniform updates
  86634. */
  86635. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86636. /**
  86637. * Set a mat2 in the shader from a Float32Array.
  86638. * @param name Define the name of the uniform as defined in the shader
  86639. * @param value Define the value to give to the uniform
  86640. * @return the material itself allowing "fluent" like uniform updates
  86641. */
  86642. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86643. /**
  86644. * Set a vec2 array in the shader from a number array.
  86645. * @param name Define the name of the uniform as defined in the shader
  86646. * @param value Define the value to give to the uniform
  86647. * @return the material itself allowing "fluent" like uniform updates
  86648. */
  86649. setArray2(name: string, value: number[]): ShaderMaterial;
  86650. /**
  86651. * Set a vec3 array in the shader from a number array.
  86652. * @param name Define the name of the uniform as defined in the shader
  86653. * @param value Define the value to give to the uniform
  86654. * @return the material itself allowing "fluent" like uniform updates
  86655. */
  86656. setArray3(name: string, value: number[]): ShaderMaterial;
  86657. /**
  86658. * Set a vec4 array in the shader from a number array.
  86659. * @param name Define the name of the uniform as defined in the shader
  86660. * @param value Define the value to give to the uniform
  86661. * @return the material itself allowing "fluent" like uniform updates
  86662. */
  86663. setArray4(name: string, value: number[]): ShaderMaterial;
  86664. private _checkCache;
  86665. /**
  86666. * Specifies that the submesh is ready to be used
  86667. * @param mesh defines the mesh to check
  86668. * @param subMesh defines which submesh to check
  86669. * @param useInstances specifies that instances should be used
  86670. * @returns a boolean indicating that the submesh is ready or not
  86671. */
  86672. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86673. /**
  86674. * Checks if the material is ready to render the requested mesh
  86675. * @param mesh Define the mesh to render
  86676. * @param useInstances Define whether or not the material is used with instances
  86677. * @returns true if ready, otherwise false
  86678. */
  86679. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86680. /**
  86681. * Binds the world matrix to the material
  86682. * @param world defines the world transformation matrix
  86683. */
  86684. bindOnlyWorldMatrix(world: Matrix): void;
  86685. /**
  86686. * Binds the material to the mesh
  86687. * @param world defines the world transformation matrix
  86688. * @param mesh defines the mesh to bind the material to
  86689. */
  86690. bind(world: Matrix, mesh?: Mesh): void;
  86691. /**
  86692. * Gets the active textures from the material
  86693. * @returns an array of textures
  86694. */
  86695. getActiveTextures(): BaseTexture[];
  86696. /**
  86697. * Specifies if the material uses a texture
  86698. * @param texture defines the texture to check against the material
  86699. * @returns a boolean specifying if the material uses the texture
  86700. */
  86701. hasTexture(texture: BaseTexture): boolean;
  86702. /**
  86703. * Makes a duplicate of the material, and gives it a new name
  86704. * @param name defines the new name for the duplicated material
  86705. * @returns the cloned material
  86706. */
  86707. clone(name: string): ShaderMaterial;
  86708. /**
  86709. * Disposes the material
  86710. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86711. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86712. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86713. */
  86714. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86715. /**
  86716. * Serializes this material in a JSON representation
  86717. * @returns the serialized material object
  86718. */
  86719. serialize(): any;
  86720. /**
  86721. * Creates a shader material from parsed shader material data
  86722. * @param source defines the JSON represnetation of the material
  86723. * @param scene defines the hosting scene
  86724. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86725. * @returns a new material
  86726. */
  86727. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86728. }
  86729. }
  86730. declare module BABYLON {
  86731. /** @hidden */
  86732. export var colorPixelShader: {
  86733. name: string;
  86734. shader: string;
  86735. };
  86736. }
  86737. declare module BABYLON {
  86738. /** @hidden */
  86739. export var colorVertexShader: {
  86740. name: string;
  86741. shader: string;
  86742. };
  86743. }
  86744. declare module BABYLON {
  86745. /**
  86746. * Line mesh
  86747. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86748. */
  86749. export class LinesMesh extends Mesh {
  86750. /**
  86751. * If vertex color should be applied to the mesh
  86752. */
  86753. readonly useVertexColor?: boolean | undefined;
  86754. /**
  86755. * If vertex alpha should be applied to the mesh
  86756. */
  86757. readonly useVertexAlpha?: boolean | undefined;
  86758. /**
  86759. * Color of the line (Default: White)
  86760. */
  86761. color: Color3;
  86762. /**
  86763. * Alpha of the line (Default: 1)
  86764. */
  86765. alpha: number;
  86766. /**
  86767. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86768. * This margin is expressed in world space coordinates, so its value may vary.
  86769. * Default value is 0.1
  86770. */
  86771. intersectionThreshold: number;
  86772. private _colorShader;
  86773. private color4;
  86774. /**
  86775. * Creates a new LinesMesh
  86776. * @param name defines the name
  86777. * @param scene defines the hosting scene
  86778. * @param parent defines the parent mesh if any
  86779. * @param source defines the optional source LinesMesh used to clone data from
  86780. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86781. * When false, achieved by calling a clone(), also passing False.
  86782. * This will make creation of children, recursive.
  86783. * @param useVertexColor defines if this LinesMesh supports vertex color
  86784. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86785. */
  86786. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86787. /**
  86788. * If vertex color should be applied to the mesh
  86789. */
  86790. useVertexColor?: boolean | undefined,
  86791. /**
  86792. * If vertex alpha should be applied to the mesh
  86793. */
  86794. useVertexAlpha?: boolean | undefined);
  86795. private _addClipPlaneDefine;
  86796. private _removeClipPlaneDefine;
  86797. isReady(): boolean;
  86798. /**
  86799. * Returns the string "LineMesh"
  86800. */
  86801. getClassName(): string;
  86802. /**
  86803. * @hidden
  86804. */
  86805. /**
  86806. * @hidden
  86807. */
  86808. material: Material;
  86809. /**
  86810. * @hidden
  86811. */
  86812. readonly checkCollisions: boolean;
  86813. /** @hidden */
  86814. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86815. /** @hidden */
  86816. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86817. /**
  86818. * Disposes of the line mesh
  86819. * @param doNotRecurse If children should be disposed
  86820. */
  86821. dispose(doNotRecurse?: boolean): void;
  86822. /**
  86823. * Returns a new LineMesh object cloned from the current one.
  86824. */
  86825. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86826. /**
  86827. * Creates a new InstancedLinesMesh object from the mesh model.
  86828. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86829. * @param name defines the name of the new instance
  86830. * @returns a new InstancedLinesMesh
  86831. */
  86832. createInstance(name: string): InstancedLinesMesh;
  86833. }
  86834. /**
  86835. * Creates an instance based on a source LinesMesh
  86836. */
  86837. export class InstancedLinesMesh extends InstancedMesh {
  86838. /**
  86839. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86840. * This margin is expressed in world space coordinates, so its value may vary.
  86841. * Initilized with the intersectionThreshold value of the source LinesMesh
  86842. */
  86843. intersectionThreshold: number;
  86844. constructor(name: string, source: LinesMesh);
  86845. /**
  86846. * Returns the string "InstancedLinesMesh".
  86847. */
  86848. getClassName(): string;
  86849. }
  86850. }
  86851. declare module BABYLON {
  86852. /** @hidden */
  86853. export var linePixelShader: {
  86854. name: string;
  86855. shader: string;
  86856. };
  86857. }
  86858. declare module BABYLON {
  86859. /** @hidden */
  86860. export var lineVertexShader: {
  86861. name: string;
  86862. shader: string;
  86863. };
  86864. }
  86865. declare module BABYLON {
  86866. interface AbstractMesh {
  86867. /**
  86868. * Gets the edgesRenderer associated with the mesh
  86869. */
  86870. edgesRenderer: Nullable<EdgesRenderer>;
  86871. }
  86872. interface LinesMesh {
  86873. /**
  86874. * Enables the edge rendering mode on the mesh.
  86875. * This mode makes the mesh edges visible
  86876. * @param epsilon defines the maximal distance between two angles to detect a face
  86877. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86878. * @returns the currentAbstractMesh
  86879. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86880. */
  86881. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86882. }
  86883. interface InstancedLinesMesh {
  86884. /**
  86885. * Enables the edge rendering mode on the mesh.
  86886. * This mode makes the mesh edges visible
  86887. * @param epsilon defines the maximal distance between two angles to detect a face
  86888. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86889. * @returns the current InstancedLinesMesh
  86890. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86891. */
  86892. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86893. }
  86894. /**
  86895. * Defines the minimum contract an Edges renderer should follow.
  86896. */
  86897. export interface IEdgesRenderer extends IDisposable {
  86898. /**
  86899. * Gets or sets a boolean indicating if the edgesRenderer is active
  86900. */
  86901. isEnabled: boolean;
  86902. /**
  86903. * Renders the edges of the attached mesh,
  86904. */
  86905. render(): void;
  86906. /**
  86907. * Checks wether or not the edges renderer is ready to render.
  86908. * @return true if ready, otherwise false.
  86909. */
  86910. isReady(): boolean;
  86911. }
  86912. /**
  86913. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86914. */
  86915. export class EdgesRenderer implements IEdgesRenderer {
  86916. /**
  86917. * Define the size of the edges with an orthographic camera
  86918. */
  86919. edgesWidthScalerForOrthographic: number;
  86920. /**
  86921. * Define the size of the edges with a perspective camera
  86922. */
  86923. edgesWidthScalerForPerspective: number;
  86924. protected _source: AbstractMesh;
  86925. protected _linesPositions: number[];
  86926. protected _linesNormals: number[];
  86927. protected _linesIndices: number[];
  86928. protected _epsilon: number;
  86929. protected _indicesCount: number;
  86930. protected _lineShader: ShaderMaterial;
  86931. protected _ib: DataBuffer;
  86932. protected _buffers: {
  86933. [key: string]: Nullable<VertexBuffer>;
  86934. };
  86935. protected _checkVerticesInsteadOfIndices: boolean;
  86936. private _meshRebuildObserver;
  86937. private _meshDisposeObserver;
  86938. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86939. isEnabled: boolean;
  86940. /**
  86941. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86942. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86943. * @param source Mesh used to create edges
  86944. * @param epsilon sum of angles in adjacency to check for edge
  86945. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86946. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86947. */
  86948. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86949. protected _prepareRessources(): void;
  86950. /** @hidden */
  86951. _rebuild(): void;
  86952. /**
  86953. * Releases the required resources for the edges renderer
  86954. */
  86955. dispose(): void;
  86956. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86957. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86958. /**
  86959. * Checks if the pair of p0 and p1 is en edge
  86960. * @param faceIndex
  86961. * @param edge
  86962. * @param faceNormals
  86963. * @param p0
  86964. * @param p1
  86965. * @private
  86966. */
  86967. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86968. /**
  86969. * push line into the position, normal and index buffer
  86970. * @protected
  86971. */
  86972. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86973. /**
  86974. * Generates lines edges from adjacencjes
  86975. * @private
  86976. */
  86977. _generateEdgesLines(): void;
  86978. /**
  86979. * Checks wether or not the edges renderer is ready to render.
  86980. * @return true if ready, otherwise false.
  86981. */
  86982. isReady(): boolean;
  86983. /**
  86984. * Renders the edges of the attached mesh,
  86985. */
  86986. render(): void;
  86987. }
  86988. /**
  86989. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86990. */
  86991. export class LineEdgesRenderer extends EdgesRenderer {
  86992. /**
  86993. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86994. * @param source LineMesh used to generate edges
  86995. * @param epsilon not important (specified angle for edge detection)
  86996. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86997. */
  86998. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86999. /**
  87000. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87001. */
  87002. _generateEdgesLines(): void;
  87003. }
  87004. }
  87005. declare module BABYLON {
  87006. /**
  87007. * This represents the object necessary to create a rendering group.
  87008. * This is exclusively used and created by the rendering manager.
  87009. * To modify the behavior, you use the available helpers in your scene or meshes.
  87010. * @hidden
  87011. */
  87012. export class RenderingGroup {
  87013. index: number;
  87014. private static _zeroVector;
  87015. private _scene;
  87016. private _opaqueSubMeshes;
  87017. private _transparentSubMeshes;
  87018. private _alphaTestSubMeshes;
  87019. private _depthOnlySubMeshes;
  87020. private _particleSystems;
  87021. private _spriteManagers;
  87022. private _opaqueSortCompareFn;
  87023. private _alphaTestSortCompareFn;
  87024. private _transparentSortCompareFn;
  87025. private _renderOpaque;
  87026. private _renderAlphaTest;
  87027. private _renderTransparent;
  87028. /** @hidden */
  87029. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87030. onBeforeTransparentRendering: () => void;
  87031. /**
  87032. * Set the opaque sort comparison function.
  87033. * If null the sub meshes will be render in the order they were created
  87034. */
  87035. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87036. /**
  87037. * Set the alpha test sort comparison function.
  87038. * If null the sub meshes will be render in the order they were created
  87039. */
  87040. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87041. /**
  87042. * Set the transparent sort comparison function.
  87043. * If null the sub meshes will be render in the order they were created
  87044. */
  87045. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87046. /**
  87047. * Creates a new rendering group.
  87048. * @param index The rendering group index
  87049. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87050. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87051. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87052. */
  87053. 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>);
  87054. /**
  87055. * Render all the sub meshes contained in the group.
  87056. * @param customRenderFunction Used to override the default render behaviour of the group.
  87057. * @returns true if rendered some submeshes.
  87058. */
  87059. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87060. /**
  87061. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87062. * @param subMeshes The submeshes to render
  87063. */
  87064. private renderOpaqueSorted;
  87065. /**
  87066. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87067. * @param subMeshes The submeshes to render
  87068. */
  87069. private renderAlphaTestSorted;
  87070. /**
  87071. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87072. * @param subMeshes The submeshes to render
  87073. */
  87074. private renderTransparentSorted;
  87075. /**
  87076. * Renders the submeshes in a specified order.
  87077. * @param subMeshes The submeshes to sort before render
  87078. * @param sortCompareFn The comparison function use to sort
  87079. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87080. * @param transparent Specifies to activate blending if true
  87081. */
  87082. private static renderSorted;
  87083. /**
  87084. * Renders the submeshes in the order they were dispatched (no sort applied).
  87085. * @param subMeshes The submeshes to render
  87086. */
  87087. private static renderUnsorted;
  87088. /**
  87089. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87090. * are rendered back to front if in the same alpha index.
  87091. *
  87092. * @param a The first submesh
  87093. * @param b The second submesh
  87094. * @returns The result of the comparison
  87095. */
  87096. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87097. /**
  87098. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87099. * are rendered back to front.
  87100. *
  87101. * @param a The first submesh
  87102. * @param b The second submesh
  87103. * @returns The result of the comparison
  87104. */
  87105. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87106. /**
  87107. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87108. * are rendered front to back (prevent overdraw).
  87109. *
  87110. * @param a The first submesh
  87111. * @param b The second submesh
  87112. * @returns The result of the comparison
  87113. */
  87114. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87115. /**
  87116. * Resets the different lists of submeshes to prepare a new frame.
  87117. */
  87118. prepare(): void;
  87119. dispose(): void;
  87120. /**
  87121. * Inserts the submesh in its correct queue depending on its material.
  87122. * @param subMesh The submesh to dispatch
  87123. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87124. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87125. */
  87126. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87127. dispatchSprites(spriteManager: ISpriteManager): void;
  87128. dispatchParticles(particleSystem: IParticleSystem): void;
  87129. private _renderParticles;
  87130. private _renderSprites;
  87131. }
  87132. }
  87133. declare module BABYLON {
  87134. /**
  87135. * Interface describing the different options available in the rendering manager
  87136. * regarding Auto Clear between groups.
  87137. */
  87138. export interface IRenderingManagerAutoClearSetup {
  87139. /**
  87140. * Defines whether or not autoclear is enable.
  87141. */
  87142. autoClear: boolean;
  87143. /**
  87144. * Defines whether or not to autoclear the depth buffer.
  87145. */
  87146. depth: boolean;
  87147. /**
  87148. * Defines whether or not to autoclear the stencil buffer.
  87149. */
  87150. stencil: boolean;
  87151. }
  87152. /**
  87153. * This class is used by the onRenderingGroupObservable
  87154. */
  87155. export class RenderingGroupInfo {
  87156. /**
  87157. * The Scene that being rendered
  87158. */
  87159. scene: Scene;
  87160. /**
  87161. * The camera currently used for the rendering pass
  87162. */
  87163. camera: Nullable<Camera>;
  87164. /**
  87165. * The ID of the renderingGroup being processed
  87166. */
  87167. renderingGroupId: number;
  87168. }
  87169. /**
  87170. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87171. * It is enable to manage the different groups as well as the different necessary sort functions.
  87172. * This should not be used directly aside of the few static configurations
  87173. */
  87174. export class RenderingManager {
  87175. /**
  87176. * The max id used for rendering groups (not included)
  87177. */
  87178. static MAX_RENDERINGGROUPS: number;
  87179. /**
  87180. * The min id used for rendering groups (included)
  87181. */
  87182. static MIN_RENDERINGGROUPS: number;
  87183. /**
  87184. * Used to globally prevent autoclearing scenes.
  87185. */
  87186. static AUTOCLEAR: boolean;
  87187. /**
  87188. * @hidden
  87189. */
  87190. _useSceneAutoClearSetup: boolean;
  87191. private _scene;
  87192. private _renderingGroups;
  87193. private _depthStencilBufferAlreadyCleaned;
  87194. private _autoClearDepthStencil;
  87195. private _customOpaqueSortCompareFn;
  87196. private _customAlphaTestSortCompareFn;
  87197. private _customTransparentSortCompareFn;
  87198. private _renderingGroupInfo;
  87199. /**
  87200. * Instantiates a new rendering group for a particular scene
  87201. * @param scene Defines the scene the groups belongs to
  87202. */
  87203. constructor(scene: Scene);
  87204. private _clearDepthStencilBuffer;
  87205. /**
  87206. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87207. * @hidden
  87208. */
  87209. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87210. /**
  87211. * Resets the different information of the group to prepare a new frame
  87212. * @hidden
  87213. */
  87214. reset(): void;
  87215. /**
  87216. * Dispose and release the group and its associated resources.
  87217. * @hidden
  87218. */
  87219. dispose(): void;
  87220. /**
  87221. * Clear the info related to rendering groups preventing retention points during dispose.
  87222. */
  87223. freeRenderingGroups(): void;
  87224. private _prepareRenderingGroup;
  87225. /**
  87226. * Add a sprite manager to the rendering manager in order to render it this frame.
  87227. * @param spriteManager Define the sprite manager to render
  87228. */
  87229. dispatchSprites(spriteManager: ISpriteManager): void;
  87230. /**
  87231. * Add a particle system to the rendering manager in order to render it this frame.
  87232. * @param particleSystem Define the particle system to render
  87233. */
  87234. dispatchParticles(particleSystem: IParticleSystem): void;
  87235. /**
  87236. * Add a submesh to the manager in order to render it this frame
  87237. * @param subMesh The submesh to dispatch
  87238. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87239. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87240. */
  87241. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87242. /**
  87243. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87244. * This allowed control for front to back rendering or reversly depending of the special needs.
  87245. *
  87246. * @param renderingGroupId The rendering group id corresponding to its index
  87247. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87248. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87249. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87250. */
  87251. 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;
  87252. /**
  87253. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87254. *
  87255. * @param renderingGroupId The rendering group id corresponding to its index
  87256. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87257. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87258. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87259. */
  87260. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87261. /**
  87262. * Gets the current auto clear configuration for one rendering group of the rendering
  87263. * manager.
  87264. * @param index the rendering group index to get the information for
  87265. * @returns The auto clear setup for the requested rendering group
  87266. */
  87267. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87268. }
  87269. }
  87270. declare module BABYLON {
  87271. /**
  87272. * This Helps creating a texture that will be created from a camera in your scene.
  87273. * It is basically a dynamic texture that could be used to create special effects for instance.
  87274. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87275. */
  87276. export class RenderTargetTexture extends Texture {
  87277. isCube: boolean;
  87278. /**
  87279. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87280. */
  87281. static readonly REFRESHRATE_RENDER_ONCE: number;
  87282. /**
  87283. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87284. */
  87285. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87286. /**
  87287. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87288. * the central point of your effect and can save a lot of performances.
  87289. */
  87290. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87291. /**
  87292. * Use this predicate to dynamically define the list of mesh you want to render.
  87293. * If set, the renderList property will be overwritten.
  87294. */
  87295. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87296. private _renderList;
  87297. /**
  87298. * Use this list to define the list of mesh you want to render.
  87299. */
  87300. renderList: Nullable<Array<AbstractMesh>>;
  87301. private _hookArray;
  87302. /**
  87303. * Define if particles should be rendered in your texture.
  87304. */
  87305. renderParticles: boolean;
  87306. /**
  87307. * Define if sprites should be rendered in your texture.
  87308. */
  87309. renderSprites: boolean;
  87310. /**
  87311. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87312. */
  87313. coordinatesMode: number;
  87314. /**
  87315. * Define the camera used to render the texture.
  87316. */
  87317. activeCamera: Nullable<Camera>;
  87318. /**
  87319. * Override the render function of the texture with your own one.
  87320. */
  87321. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87322. /**
  87323. * Define if camera post processes should be use while rendering the texture.
  87324. */
  87325. useCameraPostProcesses: boolean;
  87326. /**
  87327. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87328. */
  87329. ignoreCameraViewport: boolean;
  87330. private _postProcessManager;
  87331. private _postProcesses;
  87332. private _resizeObserver;
  87333. /**
  87334. * An event triggered when the texture is unbind.
  87335. */
  87336. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87337. /**
  87338. * An event triggered when the texture is unbind.
  87339. */
  87340. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87341. private _onAfterUnbindObserver;
  87342. /**
  87343. * Set a after unbind callback in the texture.
  87344. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87345. */
  87346. onAfterUnbind: () => void;
  87347. /**
  87348. * An event triggered before rendering the texture
  87349. */
  87350. onBeforeRenderObservable: Observable<number>;
  87351. private _onBeforeRenderObserver;
  87352. /**
  87353. * Set a before render callback in the texture.
  87354. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87355. */
  87356. onBeforeRender: (faceIndex: number) => void;
  87357. /**
  87358. * An event triggered after rendering the texture
  87359. */
  87360. onAfterRenderObservable: Observable<number>;
  87361. private _onAfterRenderObserver;
  87362. /**
  87363. * Set a after render callback in the texture.
  87364. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87365. */
  87366. onAfterRender: (faceIndex: number) => void;
  87367. /**
  87368. * An event triggered after the texture clear
  87369. */
  87370. onClearObservable: Observable<Engine>;
  87371. private _onClearObserver;
  87372. /**
  87373. * Set a clear callback in the texture.
  87374. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87375. */
  87376. onClear: (Engine: Engine) => void;
  87377. /**
  87378. * An event triggered when the texture is resized.
  87379. */
  87380. onResizeObservable: Observable<RenderTargetTexture>;
  87381. /**
  87382. * Define the clear color of the Render Target if it should be different from the scene.
  87383. */
  87384. clearColor: Color4;
  87385. protected _size: number | {
  87386. width: number;
  87387. height: number;
  87388. };
  87389. protected _initialSizeParameter: number | {
  87390. width: number;
  87391. height: number;
  87392. } | {
  87393. ratio: number;
  87394. };
  87395. protected _sizeRatio: Nullable<number>;
  87396. /** @hidden */
  87397. _generateMipMaps: boolean;
  87398. protected _renderingManager: RenderingManager;
  87399. /** @hidden */
  87400. _waitingRenderList: string[];
  87401. protected _doNotChangeAspectRatio: boolean;
  87402. protected _currentRefreshId: number;
  87403. protected _refreshRate: number;
  87404. protected _textureMatrix: Matrix;
  87405. protected _samples: number;
  87406. protected _renderTargetOptions: RenderTargetCreationOptions;
  87407. /**
  87408. * Gets render target creation options that were used.
  87409. */
  87410. readonly renderTargetOptions: RenderTargetCreationOptions;
  87411. protected _engine: Engine;
  87412. protected _onRatioRescale(): void;
  87413. /**
  87414. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87415. * It must define where the camera used to render the texture is set
  87416. */
  87417. boundingBoxPosition: Vector3;
  87418. private _boundingBoxSize;
  87419. /**
  87420. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87421. * When defined, the cubemap will switch to local mode
  87422. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87423. * @example https://www.babylonjs-playground.com/#RNASML
  87424. */
  87425. boundingBoxSize: Vector3;
  87426. /**
  87427. * In case the RTT has been created with a depth texture, get the associated
  87428. * depth texture.
  87429. * Otherwise, return null.
  87430. */
  87431. depthStencilTexture: Nullable<InternalTexture>;
  87432. /**
  87433. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87434. * or used a shadow, depth texture...
  87435. * @param name The friendly name of the texture
  87436. * @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)
  87437. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87438. * @param generateMipMaps True if mip maps need to be generated after render.
  87439. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87440. * @param type The type of the buffer in the RTT (int, half float, float...)
  87441. * @param isCube True if a cube texture needs to be created
  87442. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87443. * @param generateDepthBuffer True to generate a depth buffer
  87444. * @param generateStencilBuffer True to generate a stencil buffer
  87445. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87446. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87447. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87448. */
  87449. constructor(name: string, size: number | {
  87450. width: number;
  87451. height: number;
  87452. } | {
  87453. ratio: number;
  87454. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87455. /**
  87456. * Creates a depth stencil texture.
  87457. * This is only available in WebGL 2 or with the depth texture extension available.
  87458. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87459. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87460. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87461. */
  87462. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87463. private _processSizeParameter;
  87464. /**
  87465. * Define the number of samples to use in case of MSAA.
  87466. * It defaults to one meaning no MSAA has been enabled.
  87467. */
  87468. samples: number;
  87469. /**
  87470. * Resets the refresh counter of the texture and start bak from scratch.
  87471. * Could be useful to regenerate the texture if it is setup to render only once.
  87472. */
  87473. resetRefreshCounter(): void;
  87474. /**
  87475. * Define the refresh rate of the texture or the rendering frequency.
  87476. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87477. */
  87478. refreshRate: number;
  87479. /**
  87480. * Adds a post process to the render target rendering passes.
  87481. * @param postProcess define the post process to add
  87482. */
  87483. addPostProcess(postProcess: PostProcess): void;
  87484. /**
  87485. * Clear all the post processes attached to the render target
  87486. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87487. */
  87488. clearPostProcesses(dispose?: boolean): void;
  87489. /**
  87490. * Remove one of the post process from the list of attached post processes to the texture
  87491. * @param postProcess define the post process to remove from the list
  87492. */
  87493. removePostProcess(postProcess: PostProcess): void;
  87494. /** @hidden */
  87495. _shouldRender(): boolean;
  87496. /**
  87497. * Gets the actual render size of the texture.
  87498. * @returns the width of the render size
  87499. */
  87500. getRenderSize(): number;
  87501. /**
  87502. * Gets the actual render width of the texture.
  87503. * @returns the width of the render size
  87504. */
  87505. getRenderWidth(): number;
  87506. /**
  87507. * Gets the actual render height of the texture.
  87508. * @returns the height of the render size
  87509. */
  87510. getRenderHeight(): number;
  87511. /**
  87512. * Get if the texture can be rescaled or not.
  87513. */
  87514. readonly canRescale: boolean;
  87515. /**
  87516. * Resize the texture using a ratio.
  87517. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87518. */
  87519. scale(ratio: number): void;
  87520. /**
  87521. * Get the texture reflection matrix used to rotate/transform the reflection.
  87522. * @returns the reflection matrix
  87523. */
  87524. getReflectionTextureMatrix(): Matrix;
  87525. /**
  87526. * Resize the texture to a new desired size.
  87527. * Be carrefull as it will recreate all the data in the new texture.
  87528. * @param size Define the new size. It can be:
  87529. * - a number for squared texture,
  87530. * - an object containing { width: number, height: number }
  87531. * - or an object containing a ratio { ratio: number }
  87532. */
  87533. resize(size: number | {
  87534. width: number;
  87535. height: number;
  87536. } | {
  87537. ratio: number;
  87538. }): void;
  87539. /**
  87540. * Renders all the objects from the render list into the texture.
  87541. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87542. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87543. */
  87544. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87545. private _bestReflectionRenderTargetDimension;
  87546. /**
  87547. * @hidden
  87548. * @param faceIndex face index to bind to if this is a cubetexture
  87549. */
  87550. _bindFrameBuffer(faceIndex?: number): void;
  87551. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87552. private renderToTarget;
  87553. /**
  87554. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87555. * This allowed control for front to back rendering or reversly depending of the special needs.
  87556. *
  87557. * @param renderingGroupId The rendering group id corresponding to its index
  87558. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87559. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87560. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87561. */
  87562. 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;
  87563. /**
  87564. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87565. *
  87566. * @param renderingGroupId The rendering group id corresponding to its index
  87567. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87568. */
  87569. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87570. /**
  87571. * Clones the texture.
  87572. * @returns the cloned texture
  87573. */
  87574. clone(): RenderTargetTexture;
  87575. /**
  87576. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87577. * @returns The JSON representation of the texture
  87578. */
  87579. serialize(): any;
  87580. /**
  87581. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87582. */
  87583. disposeFramebufferObjects(): void;
  87584. /**
  87585. * Dispose the texture and release its associated resources.
  87586. */
  87587. dispose(): void;
  87588. /** @hidden */
  87589. _rebuild(): void;
  87590. /**
  87591. * Clear the info related to rendering groups preventing retention point in material dispose.
  87592. */
  87593. freeRenderingGroups(): void;
  87594. /**
  87595. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87596. * @returns the view count
  87597. */
  87598. getViewCount(): number;
  87599. }
  87600. }
  87601. declare module BABYLON {
  87602. /**
  87603. * Base class for the main features of a material in Babylon.js
  87604. */
  87605. export class Material implements IAnimatable {
  87606. /**
  87607. * Returns the triangle fill mode
  87608. */
  87609. static readonly TriangleFillMode: number;
  87610. /**
  87611. * Returns the wireframe mode
  87612. */
  87613. static readonly WireFrameFillMode: number;
  87614. /**
  87615. * Returns the point fill mode
  87616. */
  87617. static readonly PointFillMode: number;
  87618. /**
  87619. * Returns the point list draw mode
  87620. */
  87621. static readonly PointListDrawMode: number;
  87622. /**
  87623. * Returns the line list draw mode
  87624. */
  87625. static readonly LineListDrawMode: number;
  87626. /**
  87627. * Returns the line loop draw mode
  87628. */
  87629. static readonly LineLoopDrawMode: number;
  87630. /**
  87631. * Returns the line strip draw mode
  87632. */
  87633. static readonly LineStripDrawMode: number;
  87634. /**
  87635. * Returns the triangle strip draw mode
  87636. */
  87637. static readonly TriangleStripDrawMode: number;
  87638. /**
  87639. * Returns the triangle fan draw mode
  87640. */
  87641. static readonly TriangleFanDrawMode: number;
  87642. /**
  87643. * Stores the clock-wise side orientation
  87644. */
  87645. static readonly ClockWiseSideOrientation: number;
  87646. /**
  87647. * Stores the counter clock-wise side orientation
  87648. */
  87649. static readonly CounterClockWiseSideOrientation: number;
  87650. /**
  87651. * The dirty texture flag value
  87652. */
  87653. static readonly TextureDirtyFlag: number;
  87654. /**
  87655. * The dirty light flag value
  87656. */
  87657. static readonly LightDirtyFlag: number;
  87658. /**
  87659. * The dirty fresnel flag value
  87660. */
  87661. static readonly FresnelDirtyFlag: number;
  87662. /**
  87663. * The dirty attribute flag value
  87664. */
  87665. static readonly AttributesDirtyFlag: number;
  87666. /**
  87667. * The dirty misc flag value
  87668. */
  87669. static readonly MiscDirtyFlag: number;
  87670. /**
  87671. * The all dirty flag value
  87672. */
  87673. static readonly AllDirtyFlag: number;
  87674. /**
  87675. * The ID of the material
  87676. */
  87677. id: string;
  87678. /**
  87679. * Gets or sets the unique id of the material
  87680. */
  87681. uniqueId: number;
  87682. /**
  87683. * The name of the material
  87684. */
  87685. name: string;
  87686. /**
  87687. * Gets or sets user defined metadata
  87688. */
  87689. metadata: any;
  87690. /**
  87691. * For internal use only. Please do not use.
  87692. */
  87693. reservedDataStore: any;
  87694. /**
  87695. * Specifies if the ready state should be checked on each call
  87696. */
  87697. checkReadyOnEveryCall: boolean;
  87698. /**
  87699. * Specifies if the ready state should be checked once
  87700. */
  87701. checkReadyOnlyOnce: boolean;
  87702. /**
  87703. * The state of the material
  87704. */
  87705. state: string;
  87706. /**
  87707. * The alpha value of the material
  87708. */
  87709. protected _alpha: number;
  87710. /**
  87711. * List of inspectable custom properties (used by the Inspector)
  87712. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87713. */
  87714. inspectableCustomProperties: IInspectable[];
  87715. /**
  87716. * Sets the alpha value of the material
  87717. */
  87718. /**
  87719. * Gets the alpha value of the material
  87720. */
  87721. alpha: number;
  87722. /**
  87723. * Specifies if back face culling is enabled
  87724. */
  87725. protected _backFaceCulling: boolean;
  87726. /**
  87727. * Sets the back-face culling state
  87728. */
  87729. /**
  87730. * Gets the back-face culling state
  87731. */
  87732. backFaceCulling: boolean;
  87733. /**
  87734. * Stores the value for side orientation
  87735. */
  87736. sideOrientation: number;
  87737. /**
  87738. * Callback triggered when the material is compiled
  87739. */
  87740. onCompiled: Nullable<(effect: Effect) => void>;
  87741. /**
  87742. * Callback triggered when an error occurs
  87743. */
  87744. onError: Nullable<(effect: Effect, errors: string) => void>;
  87745. /**
  87746. * Callback triggered to get the render target textures
  87747. */
  87748. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87749. /**
  87750. * Gets a boolean indicating that current material needs to register RTT
  87751. */
  87752. readonly hasRenderTargetTextures: boolean;
  87753. /**
  87754. * Specifies if the material should be serialized
  87755. */
  87756. doNotSerialize: boolean;
  87757. /**
  87758. * @hidden
  87759. */
  87760. _storeEffectOnSubMeshes: boolean;
  87761. /**
  87762. * Stores the animations for the material
  87763. */
  87764. animations: Nullable<Array<Animation>>;
  87765. /**
  87766. * An event triggered when the material is disposed
  87767. */
  87768. onDisposeObservable: Observable<Material>;
  87769. /**
  87770. * An observer which watches for dispose events
  87771. */
  87772. private _onDisposeObserver;
  87773. private _onUnBindObservable;
  87774. /**
  87775. * Called during a dispose event
  87776. */
  87777. onDispose: () => void;
  87778. private _onBindObservable;
  87779. /**
  87780. * An event triggered when the material is bound
  87781. */
  87782. readonly onBindObservable: Observable<AbstractMesh>;
  87783. /**
  87784. * An observer which watches for bind events
  87785. */
  87786. private _onBindObserver;
  87787. /**
  87788. * Called during a bind event
  87789. */
  87790. onBind: (Mesh: AbstractMesh) => void;
  87791. /**
  87792. * An event triggered when the material is unbound
  87793. */
  87794. readonly onUnBindObservable: Observable<Material>;
  87795. /**
  87796. * Stores the value of the alpha mode
  87797. */
  87798. private _alphaMode;
  87799. /**
  87800. * Sets the value of the alpha mode.
  87801. *
  87802. * | Value | Type | Description |
  87803. * | --- | --- | --- |
  87804. * | 0 | ALPHA_DISABLE | |
  87805. * | 1 | ALPHA_ADD | |
  87806. * | 2 | ALPHA_COMBINE | |
  87807. * | 3 | ALPHA_SUBTRACT | |
  87808. * | 4 | ALPHA_MULTIPLY | |
  87809. * | 5 | ALPHA_MAXIMIZED | |
  87810. * | 6 | ALPHA_ONEONE | |
  87811. * | 7 | ALPHA_PREMULTIPLIED | |
  87812. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87813. * | 9 | ALPHA_INTERPOLATE | |
  87814. * | 10 | ALPHA_SCREENMODE | |
  87815. *
  87816. */
  87817. /**
  87818. * Gets the value of the alpha mode
  87819. */
  87820. alphaMode: number;
  87821. /**
  87822. * Stores the state of the need depth pre-pass value
  87823. */
  87824. private _needDepthPrePass;
  87825. /**
  87826. * Sets the need depth pre-pass value
  87827. */
  87828. /**
  87829. * Gets the depth pre-pass value
  87830. */
  87831. needDepthPrePass: boolean;
  87832. /**
  87833. * Specifies if depth writing should be disabled
  87834. */
  87835. disableDepthWrite: boolean;
  87836. /**
  87837. * Specifies if depth writing should be forced
  87838. */
  87839. forceDepthWrite: boolean;
  87840. /**
  87841. * Specifies if there should be a separate pass for culling
  87842. */
  87843. separateCullingPass: boolean;
  87844. /**
  87845. * Stores the state specifing if fog should be enabled
  87846. */
  87847. private _fogEnabled;
  87848. /**
  87849. * Sets the state for enabling fog
  87850. */
  87851. /**
  87852. * Gets the value of the fog enabled state
  87853. */
  87854. fogEnabled: boolean;
  87855. /**
  87856. * Stores the size of points
  87857. */
  87858. pointSize: number;
  87859. /**
  87860. * Stores the z offset value
  87861. */
  87862. zOffset: number;
  87863. /**
  87864. * Gets a value specifying if wireframe mode is enabled
  87865. */
  87866. /**
  87867. * Sets the state of wireframe mode
  87868. */
  87869. wireframe: boolean;
  87870. /**
  87871. * Gets the value specifying if point clouds are enabled
  87872. */
  87873. /**
  87874. * Sets the state of point cloud mode
  87875. */
  87876. pointsCloud: boolean;
  87877. /**
  87878. * Gets the material fill mode
  87879. */
  87880. /**
  87881. * Sets the material fill mode
  87882. */
  87883. fillMode: number;
  87884. /**
  87885. * @hidden
  87886. * Stores the effects for the material
  87887. */
  87888. _effect: Nullable<Effect>;
  87889. /**
  87890. * @hidden
  87891. * Specifies if the material was previously ready
  87892. */
  87893. _wasPreviouslyReady: boolean;
  87894. /**
  87895. * Specifies if uniform buffers should be used
  87896. */
  87897. private _useUBO;
  87898. /**
  87899. * Stores a reference to the scene
  87900. */
  87901. private _scene;
  87902. /**
  87903. * Stores the fill mode state
  87904. */
  87905. private _fillMode;
  87906. /**
  87907. * Specifies if the depth write state should be cached
  87908. */
  87909. private _cachedDepthWriteState;
  87910. /**
  87911. * Stores the uniform buffer
  87912. */
  87913. protected _uniformBuffer: UniformBuffer;
  87914. /** @hidden */
  87915. _indexInSceneMaterialArray: number;
  87916. /** @hidden */
  87917. meshMap: Nullable<{
  87918. [id: string]: AbstractMesh | undefined;
  87919. }>;
  87920. /**
  87921. * Creates a material instance
  87922. * @param name defines the name of the material
  87923. * @param scene defines the scene to reference
  87924. * @param doNotAdd specifies if the material should be added to the scene
  87925. */
  87926. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87927. /**
  87928. * Returns a string representation of the current material
  87929. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87930. * @returns a string with material information
  87931. */
  87932. toString(fullDetails?: boolean): string;
  87933. /**
  87934. * Gets the class name of the material
  87935. * @returns a string with the class name of the material
  87936. */
  87937. getClassName(): string;
  87938. /**
  87939. * Specifies if updates for the material been locked
  87940. */
  87941. readonly isFrozen: boolean;
  87942. /**
  87943. * Locks updates for the material
  87944. */
  87945. freeze(): void;
  87946. /**
  87947. * Unlocks updates for the material
  87948. */
  87949. unfreeze(): void;
  87950. /**
  87951. * Specifies if the material is ready to be used
  87952. * @param mesh defines the mesh to check
  87953. * @param useInstances specifies if instances should be used
  87954. * @returns a boolean indicating if the material is ready to be used
  87955. */
  87956. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87957. /**
  87958. * Specifies that the submesh is ready to be used
  87959. * @param mesh defines the mesh to check
  87960. * @param subMesh defines which submesh to check
  87961. * @param useInstances specifies that instances should be used
  87962. * @returns a boolean indicating that the submesh is ready or not
  87963. */
  87964. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87965. /**
  87966. * Returns the material effect
  87967. * @returns the effect associated with the material
  87968. */
  87969. getEffect(): Nullable<Effect>;
  87970. /**
  87971. * Returns the current scene
  87972. * @returns a Scene
  87973. */
  87974. getScene(): Scene;
  87975. /**
  87976. * Specifies if the material will require alpha blending
  87977. * @returns a boolean specifying if alpha blending is needed
  87978. */
  87979. needAlphaBlending(): boolean;
  87980. /**
  87981. * Specifies if the mesh will require alpha blending
  87982. * @param mesh defines the mesh to check
  87983. * @returns a boolean specifying if alpha blending is needed for the mesh
  87984. */
  87985. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87986. /**
  87987. * Specifies if this material should be rendered in alpha test mode
  87988. * @returns a boolean specifying if an alpha test is needed.
  87989. */
  87990. needAlphaTesting(): boolean;
  87991. /**
  87992. * Gets the texture used for the alpha test
  87993. * @returns the texture to use for alpha testing
  87994. */
  87995. getAlphaTestTexture(): Nullable<BaseTexture>;
  87996. /**
  87997. * Marks the material to indicate that it needs to be re-calculated
  87998. */
  87999. markDirty(): void;
  88000. /** @hidden */
  88001. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88002. /**
  88003. * Binds the material to the mesh
  88004. * @param world defines the world transformation matrix
  88005. * @param mesh defines the mesh to bind the material to
  88006. */
  88007. bind(world: Matrix, mesh?: Mesh): void;
  88008. /**
  88009. * Binds the submesh to the material
  88010. * @param world defines the world transformation matrix
  88011. * @param mesh defines the mesh containing the submesh
  88012. * @param subMesh defines the submesh to bind the material to
  88013. */
  88014. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88015. /**
  88016. * Binds the world matrix to the material
  88017. * @param world defines the world transformation matrix
  88018. */
  88019. bindOnlyWorldMatrix(world: Matrix): void;
  88020. /**
  88021. * Binds the scene's uniform buffer to the effect.
  88022. * @param effect defines the effect to bind to the scene uniform buffer
  88023. * @param sceneUbo defines the uniform buffer storing scene data
  88024. */
  88025. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88026. /**
  88027. * Binds the view matrix to the effect
  88028. * @param effect defines the effect to bind the view matrix to
  88029. */
  88030. bindView(effect: Effect): void;
  88031. /**
  88032. * Binds the view projection matrix to the effect
  88033. * @param effect defines the effect to bind the view projection matrix to
  88034. */
  88035. bindViewProjection(effect: Effect): void;
  88036. /**
  88037. * Specifies if material alpha testing should be turned on for the mesh
  88038. * @param mesh defines the mesh to check
  88039. */
  88040. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88041. /**
  88042. * Processes to execute after binding the material to a mesh
  88043. * @param mesh defines the rendered mesh
  88044. */
  88045. protected _afterBind(mesh?: Mesh): void;
  88046. /**
  88047. * Unbinds the material from the mesh
  88048. */
  88049. unbind(): void;
  88050. /**
  88051. * Gets the active textures from the material
  88052. * @returns an array of textures
  88053. */
  88054. getActiveTextures(): BaseTexture[];
  88055. /**
  88056. * Specifies if the material uses a texture
  88057. * @param texture defines the texture to check against the material
  88058. * @returns a boolean specifying if the material uses the texture
  88059. */
  88060. hasTexture(texture: BaseTexture): boolean;
  88061. /**
  88062. * Makes a duplicate of the material, and gives it a new name
  88063. * @param name defines the new name for the duplicated material
  88064. * @returns the cloned material
  88065. */
  88066. clone(name: string): Nullable<Material>;
  88067. /**
  88068. * Gets the meshes bound to the material
  88069. * @returns an array of meshes bound to the material
  88070. */
  88071. getBindedMeshes(): AbstractMesh[];
  88072. /**
  88073. * Force shader compilation
  88074. * @param mesh defines the mesh associated with this material
  88075. * @param onCompiled defines a function to execute once the material is compiled
  88076. * @param options defines the options to configure the compilation
  88077. * @param onError defines a function to execute if the material fails compiling
  88078. */
  88079. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  88080. clipPlane: boolean;
  88081. }>, onError?: (reason: string) => void): void;
  88082. /**
  88083. * Force shader compilation
  88084. * @param mesh defines the mesh that will use this material
  88085. * @param options defines additional options for compiling the shaders
  88086. * @returns a promise that resolves when the compilation completes
  88087. */
  88088. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  88089. clipPlane: boolean;
  88090. }>): Promise<void>;
  88091. private static readonly _AllDirtyCallBack;
  88092. private static readonly _ImageProcessingDirtyCallBack;
  88093. private static readonly _TextureDirtyCallBack;
  88094. private static readonly _FresnelDirtyCallBack;
  88095. private static readonly _MiscDirtyCallBack;
  88096. private static readonly _LightsDirtyCallBack;
  88097. private static readonly _AttributeDirtyCallBack;
  88098. private static _FresnelAndMiscDirtyCallBack;
  88099. private static _TextureAndMiscDirtyCallBack;
  88100. private static readonly _DirtyCallbackArray;
  88101. private static readonly _RunDirtyCallBacks;
  88102. /**
  88103. * Marks a define in the material to indicate that it needs to be re-computed
  88104. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88105. */
  88106. markAsDirty(flag: number): void;
  88107. /**
  88108. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88109. * @param func defines a function which checks material defines against the submeshes
  88110. */
  88111. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88112. /**
  88113. * Indicates that we need to re-calculated for all submeshes
  88114. */
  88115. protected _markAllSubMeshesAsAllDirty(): void;
  88116. /**
  88117. * Indicates that image processing needs to be re-calculated for all submeshes
  88118. */
  88119. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88120. /**
  88121. * Indicates that textures need to be re-calculated for all submeshes
  88122. */
  88123. protected _markAllSubMeshesAsTexturesDirty(): void;
  88124. /**
  88125. * Indicates that fresnel needs to be re-calculated for all submeshes
  88126. */
  88127. protected _markAllSubMeshesAsFresnelDirty(): void;
  88128. /**
  88129. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88130. */
  88131. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88132. /**
  88133. * Indicates that lights need to be re-calculated for all submeshes
  88134. */
  88135. protected _markAllSubMeshesAsLightsDirty(): void;
  88136. /**
  88137. * Indicates that attributes need to be re-calculated for all submeshes
  88138. */
  88139. protected _markAllSubMeshesAsAttributesDirty(): void;
  88140. /**
  88141. * Indicates that misc needs to be re-calculated for all submeshes
  88142. */
  88143. protected _markAllSubMeshesAsMiscDirty(): void;
  88144. /**
  88145. * Indicates that textures and misc need to be re-calculated for all submeshes
  88146. */
  88147. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88148. /**
  88149. * Disposes the material
  88150. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88151. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88152. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88153. */
  88154. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88155. /** @hidden */
  88156. private releaseVertexArrayObject;
  88157. /**
  88158. * Serializes this material
  88159. * @returns the serialized material object
  88160. */
  88161. serialize(): any;
  88162. /**
  88163. * Creates a material from parsed material data
  88164. * @param parsedMaterial defines parsed material data
  88165. * @param scene defines the hosting scene
  88166. * @param rootUrl defines the root URL to use to load textures
  88167. * @returns a new material
  88168. */
  88169. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88170. }
  88171. }
  88172. declare module BABYLON {
  88173. /**
  88174. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88175. * separate meshes. This can be use to improve performances.
  88176. * @see http://doc.babylonjs.com/how_to/multi_materials
  88177. */
  88178. export class MultiMaterial extends Material {
  88179. private _subMaterials;
  88180. /**
  88181. * Gets or Sets the list of Materials used within the multi material.
  88182. * They need to be ordered according to the submeshes order in the associated mesh
  88183. */
  88184. subMaterials: Nullable<Material>[];
  88185. /**
  88186. * Function used to align with Node.getChildren()
  88187. * @returns the list of Materials used within the multi material
  88188. */
  88189. getChildren(): Nullable<Material>[];
  88190. /**
  88191. * Instantiates a new Multi Material
  88192. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88193. * separate meshes. This can be use to improve performances.
  88194. * @see http://doc.babylonjs.com/how_to/multi_materials
  88195. * @param name Define the name in the scene
  88196. * @param scene Define the scene the material belongs to
  88197. */
  88198. constructor(name: string, scene: Scene);
  88199. private _hookArray;
  88200. /**
  88201. * Get one of the submaterial by its index in the submaterials array
  88202. * @param index The index to look the sub material at
  88203. * @returns The Material if the index has been defined
  88204. */
  88205. getSubMaterial(index: number): Nullable<Material>;
  88206. /**
  88207. * Get the list of active textures for the whole sub materials list.
  88208. * @returns All the textures that will be used during the rendering
  88209. */
  88210. getActiveTextures(): BaseTexture[];
  88211. /**
  88212. * Gets the current class name of the material e.g. "MultiMaterial"
  88213. * Mainly use in serialization.
  88214. * @returns the class name
  88215. */
  88216. getClassName(): string;
  88217. /**
  88218. * Checks if the material is ready to render the requested sub mesh
  88219. * @param mesh Define the mesh the submesh belongs to
  88220. * @param subMesh Define the sub mesh to look readyness for
  88221. * @param useInstances Define whether or not the material is used with instances
  88222. * @returns true if ready, otherwise false
  88223. */
  88224. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88225. /**
  88226. * Clones the current material and its related sub materials
  88227. * @param name Define the name of the newly cloned material
  88228. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88229. * @returns the cloned material
  88230. */
  88231. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88232. /**
  88233. * Serializes the materials into a JSON representation.
  88234. * @returns the JSON representation
  88235. */
  88236. serialize(): any;
  88237. /**
  88238. * Dispose the material and release its associated resources
  88239. * @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)
  88240. * @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)
  88241. * @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)
  88242. */
  88243. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88244. /**
  88245. * Creates a MultiMaterial from parsed MultiMaterial data.
  88246. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88247. * @param scene defines the hosting scene
  88248. * @returns a new MultiMaterial
  88249. */
  88250. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88251. }
  88252. }
  88253. declare module BABYLON {
  88254. /**
  88255. * Base class for submeshes
  88256. */
  88257. export class BaseSubMesh {
  88258. /** @hidden */
  88259. _materialDefines: Nullable<MaterialDefines>;
  88260. /** @hidden */
  88261. _materialEffect: Nullable<Effect>;
  88262. /**
  88263. * Gets associated effect
  88264. */
  88265. readonly effect: Nullable<Effect>;
  88266. /**
  88267. * Sets associated effect (effect used to render this submesh)
  88268. * @param effect defines the effect to associate with
  88269. * @param defines defines the set of defines used to compile this effect
  88270. */
  88271. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88272. }
  88273. /**
  88274. * Defines a subdivision inside a mesh
  88275. */
  88276. export class SubMesh extends BaseSubMesh implements ICullable {
  88277. /** the material index to use */
  88278. materialIndex: number;
  88279. /** vertex index start */
  88280. verticesStart: number;
  88281. /** vertices count */
  88282. verticesCount: number;
  88283. /** index start */
  88284. indexStart: number;
  88285. /** indices count */
  88286. indexCount: number;
  88287. /** @hidden */
  88288. _linesIndexCount: number;
  88289. private _mesh;
  88290. private _renderingMesh;
  88291. private _boundingInfo;
  88292. private _linesIndexBuffer;
  88293. /** @hidden */
  88294. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88295. /** @hidden */
  88296. _trianglePlanes: Plane[];
  88297. /** @hidden */
  88298. _lastColliderTransformMatrix: Nullable<Matrix>;
  88299. /** @hidden */
  88300. _renderId: number;
  88301. /** @hidden */
  88302. _alphaIndex: number;
  88303. /** @hidden */
  88304. _distanceToCamera: number;
  88305. /** @hidden */
  88306. _id: number;
  88307. private _currentMaterial;
  88308. /**
  88309. * Add a new submesh to a mesh
  88310. * @param materialIndex defines the material index to use
  88311. * @param verticesStart defines vertex index start
  88312. * @param verticesCount defines vertices count
  88313. * @param indexStart defines index start
  88314. * @param indexCount defines indices count
  88315. * @param mesh defines the parent mesh
  88316. * @param renderingMesh defines an optional rendering mesh
  88317. * @param createBoundingBox defines if bounding box should be created for this submesh
  88318. * @returns the new submesh
  88319. */
  88320. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88321. /**
  88322. * Creates a new submesh
  88323. * @param materialIndex defines the material index to use
  88324. * @param verticesStart defines vertex index start
  88325. * @param verticesCount defines vertices count
  88326. * @param indexStart defines index start
  88327. * @param indexCount defines indices count
  88328. * @param mesh defines the parent mesh
  88329. * @param renderingMesh defines an optional rendering mesh
  88330. * @param createBoundingBox defines if bounding box should be created for this submesh
  88331. */
  88332. constructor(
  88333. /** the material index to use */
  88334. materialIndex: number,
  88335. /** vertex index start */
  88336. verticesStart: number,
  88337. /** vertices count */
  88338. verticesCount: number,
  88339. /** index start */
  88340. indexStart: number,
  88341. /** indices count */
  88342. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88343. /**
  88344. * Returns true if this submesh covers the entire parent mesh
  88345. * @ignorenaming
  88346. */
  88347. readonly IsGlobal: boolean;
  88348. /**
  88349. * Returns the submesh BoudingInfo object
  88350. * @returns current bounding info (or mesh's one if the submesh is global)
  88351. */
  88352. getBoundingInfo(): BoundingInfo;
  88353. /**
  88354. * Sets the submesh BoundingInfo
  88355. * @param boundingInfo defines the new bounding info to use
  88356. * @returns the SubMesh
  88357. */
  88358. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88359. /**
  88360. * Returns the mesh of the current submesh
  88361. * @return the parent mesh
  88362. */
  88363. getMesh(): AbstractMesh;
  88364. /**
  88365. * Returns the rendering mesh of the submesh
  88366. * @returns the rendering mesh (could be different from parent mesh)
  88367. */
  88368. getRenderingMesh(): Mesh;
  88369. /**
  88370. * Returns the submesh material
  88371. * @returns null or the current material
  88372. */
  88373. getMaterial(): Nullable<Material>;
  88374. /**
  88375. * Sets a new updated BoundingInfo object to the submesh
  88376. * @param data defines an optional position array to use to determine the bounding info
  88377. * @returns the SubMesh
  88378. */
  88379. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88380. /** @hidden */
  88381. _checkCollision(collider: Collider): boolean;
  88382. /**
  88383. * Updates the submesh BoundingInfo
  88384. * @param world defines the world matrix to use to update the bounding info
  88385. * @returns the submesh
  88386. */
  88387. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88388. /**
  88389. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88390. * @param frustumPlanes defines the frustum planes
  88391. * @returns true if the submesh is intersecting with the frustum
  88392. */
  88393. isInFrustum(frustumPlanes: Plane[]): boolean;
  88394. /**
  88395. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88396. * @param frustumPlanes defines the frustum planes
  88397. * @returns true if the submesh is inside the frustum
  88398. */
  88399. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88400. /**
  88401. * Renders the submesh
  88402. * @param enableAlphaMode defines if alpha needs to be used
  88403. * @returns the submesh
  88404. */
  88405. render(enableAlphaMode: boolean): SubMesh;
  88406. /**
  88407. * @hidden
  88408. */
  88409. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88410. /**
  88411. * Checks if the submesh intersects with a ray
  88412. * @param ray defines the ray to test
  88413. * @returns true is the passed ray intersects the submesh bounding box
  88414. */
  88415. canIntersects(ray: Ray): boolean;
  88416. /**
  88417. * Intersects current submesh with a ray
  88418. * @param ray defines the ray to test
  88419. * @param positions defines mesh's positions array
  88420. * @param indices defines mesh's indices array
  88421. * @param fastCheck defines if only bounding info should be used
  88422. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88423. * @returns intersection info or null if no intersection
  88424. */
  88425. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88426. /** @hidden */
  88427. private _intersectLines;
  88428. /** @hidden */
  88429. private _intersectUnIndexedLines;
  88430. /** @hidden */
  88431. private _intersectTriangles;
  88432. /** @hidden */
  88433. private _intersectUnIndexedTriangles;
  88434. /** @hidden */
  88435. _rebuild(): void;
  88436. /**
  88437. * Creates a new submesh from the passed mesh
  88438. * @param newMesh defines the new hosting mesh
  88439. * @param newRenderingMesh defines an optional rendering mesh
  88440. * @returns the new submesh
  88441. */
  88442. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88443. /**
  88444. * Release associated resources
  88445. */
  88446. dispose(): void;
  88447. /**
  88448. * Gets the class name
  88449. * @returns the string "SubMesh".
  88450. */
  88451. getClassName(): string;
  88452. /**
  88453. * Creates a new submesh from indices data
  88454. * @param materialIndex the index of the main mesh material
  88455. * @param startIndex the index where to start the copy in the mesh indices array
  88456. * @param indexCount the number of indices to copy then from the startIndex
  88457. * @param mesh the main mesh to create the submesh from
  88458. * @param renderingMesh the optional rendering mesh
  88459. * @returns a new submesh
  88460. */
  88461. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88462. }
  88463. }
  88464. declare module BABYLON {
  88465. /**
  88466. * Class used to represent data loading progression
  88467. */
  88468. export class SceneLoaderFlags {
  88469. private static _ForceFullSceneLoadingForIncremental;
  88470. private static _ShowLoadingScreen;
  88471. private static _CleanBoneMatrixWeights;
  88472. private static _loggingLevel;
  88473. /**
  88474. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88475. */
  88476. static ForceFullSceneLoadingForIncremental: boolean;
  88477. /**
  88478. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88479. */
  88480. static ShowLoadingScreen: boolean;
  88481. /**
  88482. * Defines the current logging level (while loading the scene)
  88483. * @ignorenaming
  88484. */
  88485. static loggingLevel: number;
  88486. /**
  88487. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88488. */
  88489. static CleanBoneMatrixWeights: boolean;
  88490. }
  88491. }
  88492. declare module BABYLON {
  88493. /**
  88494. * Class used to store geometry data (vertex buffers + index buffer)
  88495. */
  88496. export class Geometry implements IGetSetVerticesData {
  88497. /**
  88498. * Gets or sets the ID of the geometry
  88499. */
  88500. id: string;
  88501. /**
  88502. * Gets or sets the unique ID of the geometry
  88503. */
  88504. uniqueId: number;
  88505. /**
  88506. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88507. */
  88508. delayLoadState: number;
  88509. /**
  88510. * Gets the file containing the data to load when running in delay load state
  88511. */
  88512. delayLoadingFile: Nullable<string>;
  88513. /**
  88514. * Callback called when the geometry is updated
  88515. */
  88516. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88517. private _scene;
  88518. private _engine;
  88519. private _meshes;
  88520. private _totalVertices;
  88521. /** @hidden */
  88522. _indices: IndicesArray;
  88523. /** @hidden */
  88524. _vertexBuffers: {
  88525. [key: string]: VertexBuffer;
  88526. };
  88527. private _isDisposed;
  88528. private _extend;
  88529. private _boundingBias;
  88530. /** @hidden */
  88531. _delayInfo: Array<string>;
  88532. private _indexBuffer;
  88533. private _indexBufferIsUpdatable;
  88534. /** @hidden */
  88535. _boundingInfo: Nullable<BoundingInfo>;
  88536. /** @hidden */
  88537. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88538. /** @hidden */
  88539. _softwareSkinningFrameId: number;
  88540. private _vertexArrayObjects;
  88541. private _updatable;
  88542. /** @hidden */
  88543. _positions: Nullable<Vector3[]>;
  88544. /**
  88545. * 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
  88546. */
  88547. /**
  88548. * 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
  88549. */
  88550. boundingBias: Vector2;
  88551. /**
  88552. * Static function used to attach a new empty geometry to a mesh
  88553. * @param mesh defines the mesh to attach the geometry to
  88554. * @returns the new Geometry
  88555. */
  88556. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88557. /**
  88558. * Creates a new geometry
  88559. * @param id defines the unique ID
  88560. * @param scene defines the hosting scene
  88561. * @param vertexData defines the VertexData used to get geometry data
  88562. * @param updatable defines if geometry must be updatable (false by default)
  88563. * @param mesh defines the mesh that will be associated with the geometry
  88564. */
  88565. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88566. /**
  88567. * Gets the current extend of the geometry
  88568. */
  88569. readonly extend: {
  88570. minimum: Vector3;
  88571. maximum: Vector3;
  88572. };
  88573. /**
  88574. * Gets the hosting scene
  88575. * @returns the hosting Scene
  88576. */
  88577. getScene(): Scene;
  88578. /**
  88579. * Gets the hosting engine
  88580. * @returns the hosting Engine
  88581. */
  88582. getEngine(): Engine;
  88583. /**
  88584. * Defines if the geometry is ready to use
  88585. * @returns true if the geometry is ready to be used
  88586. */
  88587. isReady(): boolean;
  88588. /**
  88589. * Gets a value indicating that the geometry should not be serialized
  88590. */
  88591. readonly doNotSerialize: boolean;
  88592. /** @hidden */
  88593. _rebuild(): void;
  88594. /**
  88595. * Affects all geometry data in one call
  88596. * @param vertexData defines the geometry data
  88597. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88598. */
  88599. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88600. /**
  88601. * Set specific vertex data
  88602. * @param kind defines the data kind (Position, normal, etc...)
  88603. * @param data defines the vertex data to use
  88604. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88605. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88606. */
  88607. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88608. /**
  88609. * Removes a specific vertex data
  88610. * @param kind defines the data kind (Position, normal, etc...)
  88611. */
  88612. removeVerticesData(kind: string): void;
  88613. /**
  88614. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88615. * @param buffer defines the vertex buffer to use
  88616. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88617. */
  88618. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88619. /**
  88620. * Update a specific vertex buffer
  88621. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88622. * It will do nothing if the buffer is not updatable
  88623. * @param kind defines the data kind (Position, normal, etc...)
  88624. * @param data defines the data to use
  88625. * @param offset defines the offset in the target buffer where to store the data
  88626. * @param useBytes set to true if the offset is in bytes
  88627. */
  88628. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88629. /**
  88630. * Update a specific vertex buffer
  88631. * This function will create a new buffer if the current one is not updatable
  88632. * @param kind defines the data kind (Position, normal, etc...)
  88633. * @param data defines the data to use
  88634. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88635. */
  88636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88637. private _updateBoundingInfo;
  88638. /** @hidden */
  88639. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88640. /**
  88641. * Gets total number of vertices
  88642. * @returns the total number of vertices
  88643. */
  88644. getTotalVertices(): number;
  88645. /**
  88646. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88647. * @param kind defines the data kind (Position, normal, etc...)
  88648. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88650. * @returns a float array containing vertex data
  88651. */
  88652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88653. /**
  88654. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88655. * @param kind defines the data kind (Position, normal, etc...)
  88656. * @returns true if the vertex buffer with the specified kind is updatable
  88657. */
  88658. isVertexBufferUpdatable(kind: string): boolean;
  88659. /**
  88660. * Gets a specific vertex buffer
  88661. * @param kind defines the data kind (Position, normal, etc...)
  88662. * @returns a VertexBuffer
  88663. */
  88664. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88665. /**
  88666. * Returns all vertex buffers
  88667. * @return an object holding all vertex buffers indexed by kind
  88668. */
  88669. getVertexBuffers(): Nullable<{
  88670. [key: string]: VertexBuffer;
  88671. }>;
  88672. /**
  88673. * Gets a boolean indicating if specific vertex buffer is present
  88674. * @param kind defines the data kind (Position, normal, etc...)
  88675. * @returns true if data is present
  88676. */
  88677. isVerticesDataPresent(kind: string): boolean;
  88678. /**
  88679. * Gets a list of all attached data kinds (Position, normal, etc...)
  88680. * @returns a list of string containing all kinds
  88681. */
  88682. getVerticesDataKinds(): string[];
  88683. /**
  88684. * Update index buffer
  88685. * @param indices defines the indices to store in the index buffer
  88686. * @param offset defines the offset in the target buffer where to store the data
  88687. * @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)
  88688. */
  88689. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88690. /**
  88691. * Creates a new index buffer
  88692. * @param indices defines the indices to store in the index buffer
  88693. * @param totalVertices defines the total number of vertices (could be null)
  88694. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88695. */
  88696. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88697. /**
  88698. * Return the total number of indices
  88699. * @returns the total number of indices
  88700. */
  88701. getTotalIndices(): number;
  88702. /**
  88703. * Gets the index buffer array
  88704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88706. * @returns the index buffer array
  88707. */
  88708. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88709. /**
  88710. * Gets the index buffer
  88711. * @return the index buffer
  88712. */
  88713. getIndexBuffer(): Nullable<DataBuffer>;
  88714. /** @hidden */
  88715. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88716. /**
  88717. * Release the associated resources for a specific mesh
  88718. * @param mesh defines the source mesh
  88719. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88720. */
  88721. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88722. /**
  88723. * Apply current geometry to a given mesh
  88724. * @param mesh defines the mesh to apply geometry to
  88725. */
  88726. applyToMesh(mesh: Mesh): void;
  88727. private _updateExtend;
  88728. private _applyToMesh;
  88729. private notifyUpdate;
  88730. /**
  88731. * Load the geometry if it was flagged as delay loaded
  88732. * @param scene defines the hosting scene
  88733. * @param onLoaded defines a callback called when the geometry is loaded
  88734. */
  88735. load(scene: Scene, onLoaded?: () => void): void;
  88736. private _queueLoad;
  88737. /**
  88738. * Invert the geometry to move from a right handed system to a left handed one.
  88739. */
  88740. toLeftHanded(): void;
  88741. /** @hidden */
  88742. _resetPointsArrayCache(): void;
  88743. /** @hidden */
  88744. _generatePointsArray(): boolean;
  88745. /**
  88746. * Gets a value indicating if the geometry is disposed
  88747. * @returns true if the geometry was disposed
  88748. */
  88749. isDisposed(): boolean;
  88750. private _disposeVertexArrayObjects;
  88751. /**
  88752. * Free all associated resources
  88753. */
  88754. dispose(): void;
  88755. /**
  88756. * Clone the current geometry into a new geometry
  88757. * @param id defines the unique ID of the new geometry
  88758. * @returns a new geometry object
  88759. */
  88760. copy(id: string): Geometry;
  88761. /**
  88762. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88763. * @return a JSON representation of the current geometry data (without the vertices data)
  88764. */
  88765. serialize(): any;
  88766. private toNumberArray;
  88767. /**
  88768. * Serialize all vertices data into a JSON oject
  88769. * @returns a JSON representation of the current geometry data
  88770. */
  88771. serializeVerticeData(): any;
  88772. /**
  88773. * Extracts a clone of a mesh geometry
  88774. * @param mesh defines the source mesh
  88775. * @param id defines the unique ID of the new geometry object
  88776. * @returns the new geometry object
  88777. */
  88778. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88779. /**
  88780. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88781. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88782. * Be aware Math.random() could cause collisions, but:
  88783. * "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"
  88784. * @returns a string containing a new GUID
  88785. */
  88786. static RandomId(): string;
  88787. /** @hidden */
  88788. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88789. private static _CleanMatricesWeights;
  88790. /**
  88791. * Create a new geometry from persisted data (Using .babylon file format)
  88792. * @param parsedVertexData defines the persisted data
  88793. * @param scene defines the hosting scene
  88794. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88795. * @returns the new geometry object
  88796. */
  88797. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88798. }
  88799. }
  88800. declare module BABYLON {
  88801. /**
  88802. * Define an interface for all classes that will get and set the data on vertices
  88803. */
  88804. export interface IGetSetVerticesData {
  88805. /**
  88806. * Gets a boolean indicating if specific vertex data is present
  88807. * @param kind defines the vertex data kind to use
  88808. * @returns true is data kind is present
  88809. */
  88810. isVerticesDataPresent(kind: string): boolean;
  88811. /**
  88812. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88813. * @param kind defines the data kind (Position, normal, etc...)
  88814. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88815. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88816. * @returns a float array containing vertex data
  88817. */
  88818. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88819. /**
  88820. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88821. * @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.
  88822. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88823. * @returns the indices array or an empty array if the mesh has no geometry
  88824. */
  88825. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88826. /**
  88827. * Set specific vertex data
  88828. * @param kind defines the data kind (Position, normal, etc...)
  88829. * @param data defines the vertex data to use
  88830. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88831. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88832. */
  88833. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88834. /**
  88835. * Update a specific associated vertex buffer
  88836. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88837. * - VertexBuffer.PositionKind
  88838. * - VertexBuffer.UVKind
  88839. * - VertexBuffer.UV2Kind
  88840. * - VertexBuffer.UV3Kind
  88841. * - VertexBuffer.UV4Kind
  88842. * - VertexBuffer.UV5Kind
  88843. * - VertexBuffer.UV6Kind
  88844. * - VertexBuffer.ColorKind
  88845. * - VertexBuffer.MatricesIndicesKind
  88846. * - VertexBuffer.MatricesIndicesExtraKind
  88847. * - VertexBuffer.MatricesWeightsKind
  88848. * - VertexBuffer.MatricesWeightsExtraKind
  88849. * @param data defines the data source
  88850. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88851. * @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)
  88852. */
  88853. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88854. /**
  88855. * Creates a new index buffer
  88856. * @param indices defines the indices to store in the index buffer
  88857. * @param totalVertices defines the total number of vertices (could be null)
  88858. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88859. */
  88860. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88861. }
  88862. /**
  88863. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88864. */
  88865. export class VertexData {
  88866. /**
  88867. * Mesh side orientation : usually the external or front surface
  88868. */
  88869. static readonly FRONTSIDE: number;
  88870. /**
  88871. * Mesh side orientation : usually the internal or back surface
  88872. */
  88873. static readonly BACKSIDE: number;
  88874. /**
  88875. * Mesh side orientation : both internal and external or front and back surfaces
  88876. */
  88877. static readonly DOUBLESIDE: number;
  88878. /**
  88879. * Mesh side orientation : by default, `FRONTSIDE`
  88880. */
  88881. static readonly DEFAULTSIDE: number;
  88882. /**
  88883. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88884. */
  88885. positions: Nullable<FloatArray>;
  88886. /**
  88887. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88888. */
  88889. normals: Nullable<FloatArray>;
  88890. /**
  88891. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88892. */
  88893. tangents: Nullable<FloatArray>;
  88894. /**
  88895. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88896. */
  88897. uvs: Nullable<FloatArray>;
  88898. /**
  88899. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88900. */
  88901. uvs2: Nullable<FloatArray>;
  88902. /**
  88903. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88904. */
  88905. uvs3: Nullable<FloatArray>;
  88906. /**
  88907. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88908. */
  88909. uvs4: Nullable<FloatArray>;
  88910. /**
  88911. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88912. */
  88913. uvs5: Nullable<FloatArray>;
  88914. /**
  88915. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88916. */
  88917. uvs6: Nullable<FloatArray>;
  88918. /**
  88919. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88920. */
  88921. colors: Nullable<FloatArray>;
  88922. /**
  88923. * 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).
  88924. */
  88925. matricesIndices: Nullable<FloatArray>;
  88926. /**
  88927. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88928. */
  88929. matricesWeights: Nullable<FloatArray>;
  88930. /**
  88931. * An array extending the number of possible indices
  88932. */
  88933. matricesIndicesExtra: Nullable<FloatArray>;
  88934. /**
  88935. * An array extending the number of possible weights when the number of indices is extended
  88936. */
  88937. matricesWeightsExtra: Nullable<FloatArray>;
  88938. /**
  88939. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88940. */
  88941. indices: Nullable<IndicesArray>;
  88942. /**
  88943. * Uses the passed data array to set the set the values for the specified kind of data
  88944. * @param data a linear array of floating numbers
  88945. * @param kind the type of data that is being set, eg positions, colors etc
  88946. */
  88947. set(data: FloatArray, kind: string): void;
  88948. /**
  88949. * Associates the vertexData to the passed Mesh.
  88950. * Sets it as updatable or not (default `false`)
  88951. * @param mesh the mesh the vertexData is applied to
  88952. * @param updatable when used and having the value true allows new data to update the vertexData
  88953. * @returns the VertexData
  88954. */
  88955. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88956. /**
  88957. * Associates the vertexData to the passed Geometry.
  88958. * Sets it as updatable or not (default `false`)
  88959. * @param geometry the geometry the vertexData is applied to
  88960. * @param updatable when used and having the value true allows new data to update the vertexData
  88961. * @returns VertexData
  88962. */
  88963. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88964. /**
  88965. * Updates the associated mesh
  88966. * @param mesh the mesh to be updated
  88967. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88968. * @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
  88969. * @returns VertexData
  88970. */
  88971. updateMesh(mesh: Mesh): VertexData;
  88972. /**
  88973. * Updates the associated geometry
  88974. * @param geometry the geometry to be updated
  88975. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88976. * @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
  88977. * @returns VertexData.
  88978. */
  88979. updateGeometry(geometry: Geometry): VertexData;
  88980. private _applyTo;
  88981. private _update;
  88982. /**
  88983. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88984. * @param matrix the transforming matrix
  88985. * @returns the VertexData
  88986. */
  88987. transform(matrix: Matrix): VertexData;
  88988. /**
  88989. * Merges the passed VertexData into the current one
  88990. * @param other the VertexData to be merged into the current one
  88991. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88992. * @returns the modified VertexData
  88993. */
  88994. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88995. private _mergeElement;
  88996. private _validate;
  88997. /**
  88998. * Serializes the VertexData
  88999. * @returns a serialized object
  89000. */
  89001. serialize(): any;
  89002. /**
  89003. * Extracts the vertexData from a mesh
  89004. * @param mesh the mesh from which to extract the VertexData
  89005. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89006. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89007. * @returns the object VertexData associated to the passed mesh
  89008. */
  89009. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89010. /**
  89011. * Extracts the vertexData from the geometry
  89012. * @param geometry the geometry from which to extract the VertexData
  89013. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89014. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89015. * @returns the object VertexData associated to the passed mesh
  89016. */
  89017. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89018. private static _ExtractFrom;
  89019. /**
  89020. * Creates the VertexData for a Ribbon
  89021. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89022. * * pathArray array of paths, each of which an array of successive Vector3
  89023. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89024. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89025. * * 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
  89026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89027. * * 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)
  89028. * * 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)
  89029. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89030. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89031. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89032. * @returns the VertexData of the ribbon
  89033. */
  89034. static CreateRibbon(options: {
  89035. pathArray: Vector3[][];
  89036. closeArray?: boolean;
  89037. closePath?: boolean;
  89038. offset?: number;
  89039. sideOrientation?: number;
  89040. frontUVs?: Vector4;
  89041. backUVs?: Vector4;
  89042. invertUV?: boolean;
  89043. uvs?: Vector2[];
  89044. colors?: Color4[];
  89045. }): VertexData;
  89046. /**
  89047. * Creates the VertexData for a box
  89048. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89049. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89050. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89051. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89052. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89053. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89054. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89056. * * 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)
  89057. * * 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)
  89058. * @returns the VertexData of the box
  89059. */
  89060. static CreateBox(options: {
  89061. size?: number;
  89062. width?: number;
  89063. height?: number;
  89064. depth?: number;
  89065. faceUV?: Vector4[];
  89066. faceColors?: Color4[];
  89067. sideOrientation?: number;
  89068. frontUVs?: Vector4;
  89069. backUVs?: Vector4;
  89070. }): VertexData;
  89071. /**
  89072. * Creates the VertexData for a tiled box
  89073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89074. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89075. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89076. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89078. * @returns the VertexData of the box
  89079. */
  89080. static CreateTiledBox(options: {
  89081. pattern?: number;
  89082. width?: number;
  89083. height?: number;
  89084. depth?: number;
  89085. tileSize?: number;
  89086. tileWidth?: number;
  89087. tileHeight?: number;
  89088. alignHorizontal?: number;
  89089. alignVertical?: number;
  89090. faceUV?: Vector4[];
  89091. faceColors?: Color4[];
  89092. sideOrientation?: number;
  89093. }): VertexData;
  89094. /**
  89095. * Creates the VertexData for a tiled plane
  89096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89097. * * pattern a limited pattern arrangement depending on the number
  89098. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89099. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89100. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89102. * * 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)
  89103. * * 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)
  89104. * @returns the VertexData of the tiled plane
  89105. */
  89106. static CreateTiledPlane(options: {
  89107. pattern?: number;
  89108. tileSize?: number;
  89109. tileWidth?: number;
  89110. tileHeight?: number;
  89111. size?: number;
  89112. width?: number;
  89113. height?: number;
  89114. alignHorizontal?: number;
  89115. alignVertical?: number;
  89116. sideOrientation?: number;
  89117. frontUVs?: Vector4;
  89118. backUVs?: Vector4;
  89119. }): VertexData;
  89120. /**
  89121. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89122. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89123. * * segments sets the number of horizontal strips optional, default 32
  89124. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89125. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89126. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89127. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89128. * * 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
  89129. * * 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
  89130. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89131. * * 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)
  89132. * * 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)
  89133. * @returns the VertexData of the ellipsoid
  89134. */
  89135. static CreateSphere(options: {
  89136. segments?: number;
  89137. diameter?: number;
  89138. diameterX?: number;
  89139. diameterY?: number;
  89140. diameterZ?: number;
  89141. arc?: number;
  89142. slice?: number;
  89143. sideOrientation?: number;
  89144. frontUVs?: Vector4;
  89145. backUVs?: Vector4;
  89146. }): VertexData;
  89147. /**
  89148. * Creates the VertexData for a cylinder, cone or prism
  89149. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89150. * * height sets the height (y direction) of the cylinder, optional, default 2
  89151. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89152. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89153. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89154. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89155. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89156. * * 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
  89157. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89158. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89159. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89160. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89162. * * 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)
  89163. * * 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)
  89164. * @returns the VertexData of the cylinder, cone or prism
  89165. */
  89166. static CreateCylinder(options: {
  89167. height?: number;
  89168. diameterTop?: number;
  89169. diameterBottom?: number;
  89170. diameter?: number;
  89171. tessellation?: number;
  89172. subdivisions?: number;
  89173. arc?: number;
  89174. faceColors?: Color4[];
  89175. faceUV?: Vector4[];
  89176. hasRings?: boolean;
  89177. enclose?: boolean;
  89178. sideOrientation?: number;
  89179. frontUVs?: Vector4;
  89180. backUVs?: Vector4;
  89181. }): VertexData;
  89182. /**
  89183. * Creates the VertexData for a torus
  89184. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89185. * * diameter the diameter of the torus, optional default 1
  89186. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89187. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89189. * * 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)
  89190. * * 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)
  89191. * @returns the VertexData of the torus
  89192. */
  89193. static CreateTorus(options: {
  89194. diameter?: number;
  89195. thickness?: number;
  89196. tessellation?: number;
  89197. sideOrientation?: number;
  89198. frontUVs?: Vector4;
  89199. backUVs?: Vector4;
  89200. }): VertexData;
  89201. /**
  89202. * Creates the VertexData of the LineSystem
  89203. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89204. * - lines an array of lines, each line being an array of successive Vector3
  89205. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89206. * @returns the VertexData of the LineSystem
  89207. */
  89208. static CreateLineSystem(options: {
  89209. lines: Vector3[][];
  89210. colors?: Nullable<Color4[][]>;
  89211. }): VertexData;
  89212. /**
  89213. * Create the VertexData for a DashedLines
  89214. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89215. * - points an array successive Vector3
  89216. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89217. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89218. * - dashNb the intended total number of dashes, optional, default 200
  89219. * @returns the VertexData for the DashedLines
  89220. */
  89221. static CreateDashedLines(options: {
  89222. points: Vector3[];
  89223. dashSize?: number;
  89224. gapSize?: number;
  89225. dashNb?: number;
  89226. }): VertexData;
  89227. /**
  89228. * Creates the VertexData for a Ground
  89229. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89230. * - width the width (x direction) of the ground, optional, default 1
  89231. * - height the height (z direction) of the ground, optional, default 1
  89232. * - subdivisions the number of subdivisions per side, optional, default 1
  89233. * @returns the VertexData of the Ground
  89234. */
  89235. static CreateGround(options: {
  89236. width?: number;
  89237. height?: number;
  89238. subdivisions?: number;
  89239. subdivisionsX?: number;
  89240. subdivisionsY?: number;
  89241. }): VertexData;
  89242. /**
  89243. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89244. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89245. * * xmin the ground minimum X coordinate, optional, default -1
  89246. * * zmin the ground minimum Z coordinate, optional, default -1
  89247. * * xmax the ground maximum X coordinate, optional, default 1
  89248. * * zmax the ground maximum Z coordinate, optional, default 1
  89249. * * 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}
  89250. * * 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}
  89251. * @returns the VertexData of the TiledGround
  89252. */
  89253. static CreateTiledGround(options: {
  89254. xmin: number;
  89255. zmin: number;
  89256. xmax: number;
  89257. zmax: number;
  89258. subdivisions?: {
  89259. w: number;
  89260. h: number;
  89261. };
  89262. precision?: {
  89263. w: number;
  89264. h: number;
  89265. };
  89266. }): VertexData;
  89267. /**
  89268. * Creates the VertexData of the Ground designed from a heightmap
  89269. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89270. * * width the width (x direction) of the ground
  89271. * * height the height (z direction) of the ground
  89272. * * subdivisions the number of subdivisions per side
  89273. * * minHeight the minimum altitude on the ground, optional, default 0
  89274. * * maxHeight the maximum altitude on the ground, optional default 1
  89275. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89276. * * buffer the array holding the image color data
  89277. * * bufferWidth the width of image
  89278. * * bufferHeight the height of image
  89279. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89280. * @returns the VertexData of the Ground designed from a heightmap
  89281. */
  89282. static CreateGroundFromHeightMap(options: {
  89283. width: number;
  89284. height: number;
  89285. subdivisions: number;
  89286. minHeight: number;
  89287. maxHeight: number;
  89288. colorFilter: Color3;
  89289. buffer: Uint8Array;
  89290. bufferWidth: number;
  89291. bufferHeight: number;
  89292. alphaFilter: number;
  89293. }): VertexData;
  89294. /**
  89295. * Creates the VertexData for a Plane
  89296. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89297. * * size sets the width and height of the plane to the value of size, optional default 1
  89298. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89299. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89301. * * 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)
  89302. * * 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)
  89303. * @returns the VertexData of the box
  89304. */
  89305. static CreatePlane(options: {
  89306. size?: number;
  89307. width?: number;
  89308. height?: number;
  89309. sideOrientation?: number;
  89310. frontUVs?: Vector4;
  89311. backUVs?: Vector4;
  89312. }): VertexData;
  89313. /**
  89314. * Creates the VertexData of the Disc or regular Polygon
  89315. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89316. * * radius the radius of the disc, optional default 0.5
  89317. * * tessellation the number of polygon sides, optional, default 64
  89318. * * 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
  89319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89320. * * 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)
  89321. * * 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)
  89322. * @returns the VertexData of the box
  89323. */
  89324. static CreateDisc(options: {
  89325. radius?: number;
  89326. tessellation?: number;
  89327. arc?: number;
  89328. sideOrientation?: number;
  89329. frontUVs?: Vector4;
  89330. backUVs?: Vector4;
  89331. }): VertexData;
  89332. /**
  89333. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89334. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89335. * @param polygon a mesh built from polygonTriangulation.build()
  89336. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89337. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89338. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89339. * @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)
  89340. * @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)
  89341. * @returns the VertexData of the Polygon
  89342. */
  89343. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89344. /**
  89345. * Creates the VertexData of the IcoSphere
  89346. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89347. * * radius the radius of the IcoSphere, optional default 1
  89348. * * radiusX allows stretching in the x direction, optional, default radius
  89349. * * radiusY allows stretching in the y direction, optional, default radius
  89350. * * radiusZ allows stretching in the z direction, optional, default radius
  89351. * * flat when true creates a flat shaded mesh, optional, default true
  89352. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89354. * * 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)
  89355. * * 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)
  89356. * @returns the VertexData of the IcoSphere
  89357. */
  89358. static CreateIcoSphere(options: {
  89359. radius?: number;
  89360. radiusX?: number;
  89361. radiusY?: number;
  89362. radiusZ?: number;
  89363. flat?: boolean;
  89364. subdivisions?: number;
  89365. sideOrientation?: number;
  89366. frontUVs?: Vector4;
  89367. backUVs?: Vector4;
  89368. }): VertexData;
  89369. /**
  89370. * Creates the VertexData for a Polyhedron
  89371. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89372. * * type provided types are:
  89373. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89374. * * 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)
  89375. * * size the size of the IcoSphere, optional default 1
  89376. * * sizeX allows stretching in the x direction, optional, default size
  89377. * * sizeY allows stretching in the y direction, optional, default size
  89378. * * sizeZ allows stretching in the z direction, optional, default size
  89379. * * 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
  89380. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89381. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89382. * * flat when true creates a flat shaded mesh, optional, default true
  89383. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89385. * * 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)
  89386. * * 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)
  89387. * @returns the VertexData of the Polyhedron
  89388. */
  89389. static CreatePolyhedron(options: {
  89390. type?: number;
  89391. size?: number;
  89392. sizeX?: number;
  89393. sizeY?: number;
  89394. sizeZ?: number;
  89395. custom?: any;
  89396. faceUV?: Vector4[];
  89397. faceColors?: Color4[];
  89398. flat?: boolean;
  89399. sideOrientation?: number;
  89400. frontUVs?: Vector4;
  89401. backUVs?: Vector4;
  89402. }): VertexData;
  89403. /**
  89404. * Creates the VertexData for a TorusKnot
  89405. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89406. * * radius the radius of the torus knot, optional, default 2
  89407. * * tube the thickness of the tube, optional, default 0.5
  89408. * * radialSegments the number of sides on each tube segments, optional, default 32
  89409. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89410. * * p the number of windings around the z axis, optional, default 2
  89411. * * q the number of windings around the x axis, optional, default 3
  89412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89413. * * 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)
  89414. * * 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)
  89415. * @returns the VertexData of the Torus Knot
  89416. */
  89417. static CreateTorusKnot(options: {
  89418. radius?: number;
  89419. tube?: number;
  89420. radialSegments?: number;
  89421. tubularSegments?: number;
  89422. p?: number;
  89423. q?: number;
  89424. sideOrientation?: number;
  89425. frontUVs?: Vector4;
  89426. backUVs?: Vector4;
  89427. }): VertexData;
  89428. /**
  89429. * Compute normals for given positions and indices
  89430. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89431. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89432. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89433. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89434. * * facetNormals : optional array of facet normals (vector3)
  89435. * * facetPositions : optional array of facet positions (vector3)
  89436. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89437. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89438. * * bInfo : optional bounding info, required for facetPartitioning computation
  89439. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89440. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89441. * * useRightHandedSystem: optional boolean to for right handed system computation
  89442. * * depthSort : optional boolean to enable the facet depth sort computation
  89443. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89444. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89445. */
  89446. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89447. facetNormals?: any;
  89448. facetPositions?: any;
  89449. facetPartitioning?: any;
  89450. ratio?: number;
  89451. bInfo?: any;
  89452. bbSize?: Vector3;
  89453. subDiv?: any;
  89454. useRightHandedSystem?: boolean;
  89455. depthSort?: boolean;
  89456. distanceTo?: Vector3;
  89457. depthSortedFacets?: any;
  89458. }): void;
  89459. /** @hidden */
  89460. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89461. /**
  89462. * Applies VertexData created from the imported parameters to the geometry
  89463. * @param parsedVertexData the parsed data from an imported file
  89464. * @param geometry the geometry to apply the VertexData to
  89465. */
  89466. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89467. }
  89468. }
  89469. declare module BABYLON {
  89470. /**
  89471. * Defines a target to use with MorphTargetManager
  89472. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89473. */
  89474. export class MorphTarget implements IAnimatable {
  89475. /** defines the name of the target */
  89476. name: string;
  89477. /**
  89478. * Gets or sets the list of animations
  89479. */
  89480. animations: Animation[];
  89481. private _scene;
  89482. private _positions;
  89483. private _normals;
  89484. private _tangents;
  89485. private _uvs;
  89486. private _influence;
  89487. /**
  89488. * Observable raised when the influence changes
  89489. */
  89490. onInfluenceChanged: Observable<boolean>;
  89491. /** @hidden */
  89492. _onDataLayoutChanged: Observable<void>;
  89493. /**
  89494. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89495. */
  89496. influence: number;
  89497. /**
  89498. * Gets or sets the id of the morph Target
  89499. */
  89500. id: string;
  89501. private _animationPropertiesOverride;
  89502. /**
  89503. * Gets or sets the animation properties override
  89504. */
  89505. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89506. /**
  89507. * Creates a new MorphTarget
  89508. * @param name defines the name of the target
  89509. * @param influence defines the influence to use
  89510. * @param scene defines the scene the morphtarget belongs to
  89511. */
  89512. constructor(
  89513. /** defines the name of the target */
  89514. name: string, influence?: number, scene?: Nullable<Scene>);
  89515. /**
  89516. * Gets a boolean defining if the target contains position data
  89517. */
  89518. readonly hasPositions: boolean;
  89519. /**
  89520. * Gets a boolean defining if the target contains normal data
  89521. */
  89522. readonly hasNormals: boolean;
  89523. /**
  89524. * Gets a boolean defining if the target contains tangent data
  89525. */
  89526. readonly hasTangents: boolean;
  89527. /**
  89528. * Gets a boolean defining if the target contains texture coordinates data
  89529. */
  89530. readonly hasUVs: boolean;
  89531. /**
  89532. * Affects position data to this target
  89533. * @param data defines the position data to use
  89534. */
  89535. setPositions(data: Nullable<FloatArray>): void;
  89536. /**
  89537. * Gets the position data stored in this target
  89538. * @returns a FloatArray containing the position data (or null if not present)
  89539. */
  89540. getPositions(): Nullable<FloatArray>;
  89541. /**
  89542. * Affects normal data to this target
  89543. * @param data defines the normal data to use
  89544. */
  89545. setNormals(data: Nullable<FloatArray>): void;
  89546. /**
  89547. * Gets the normal data stored in this target
  89548. * @returns a FloatArray containing the normal data (or null if not present)
  89549. */
  89550. getNormals(): Nullable<FloatArray>;
  89551. /**
  89552. * Affects tangent data to this target
  89553. * @param data defines the tangent data to use
  89554. */
  89555. setTangents(data: Nullable<FloatArray>): void;
  89556. /**
  89557. * Gets the tangent data stored in this target
  89558. * @returns a FloatArray containing the tangent data (or null if not present)
  89559. */
  89560. getTangents(): Nullable<FloatArray>;
  89561. /**
  89562. * Affects texture coordinates data to this target
  89563. * @param data defines the texture coordinates data to use
  89564. */
  89565. setUVs(data: Nullable<FloatArray>): void;
  89566. /**
  89567. * Gets the texture coordinates data stored in this target
  89568. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89569. */
  89570. getUVs(): Nullable<FloatArray>;
  89571. /**
  89572. * Serializes the current target into a Serialization object
  89573. * @returns the serialized object
  89574. */
  89575. serialize(): any;
  89576. /**
  89577. * Returns the string "MorphTarget"
  89578. * @returns "MorphTarget"
  89579. */
  89580. getClassName(): string;
  89581. /**
  89582. * Creates a new target from serialized data
  89583. * @param serializationObject defines the serialized data to use
  89584. * @returns a new MorphTarget
  89585. */
  89586. static Parse(serializationObject: any): MorphTarget;
  89587. /**
  89588. * Creates a MorphTarget from mesh data
  89589. * @param mesh defines the source mesh
  89590. * @param name defines the name to use for the new target
  89591. * @param influence defines the influence to attach to the target
  89592. * @returns a new MorphTarget
  89593. */
  89594. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89595. }
  89596. }
  89597. declare module BABYLON {
  89598. /**
  89599. * This class is used to deform meshes using morphing between different targets
  89600. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89601. */
  89602. export class MorphTargetManager {
  89603. private _targets;
  89604. private _targetInfluenceChangedObservers;
  89605. private _targetDataLayoutChangedObservers;
  89606. private _activeTargets;
  89607. private _scene;
  89608. private _influences;
  89609. private _supportsNormals;
  89610. private _supportsTangents;
  89611. private _supportsUVs;
  89612. private _vertexCount;
  89613. private _uniqueId;
  89614. private _tempInfluences;
  89615. /**
  89616. * Gets or sets a boolean indicating if normals must be morphed
  89617. */
  89618. enableNormalMorphing: boolean;
  89619. /**
  89620. * Gets or sets a boolean indicating if tangents must be morphed
  89621. */
  89622. enableTangentMorphing: boolean;
  89623. /**
  89624. * Gets or sets a boolean indicating if UV must be morphed
  89625. */
  89626. enableUVMorphing: boolean;
  89627. /**
  89628. * Creates a new MorphTargetManager
  89629. * @param scene defines the current scene
  89630. */
  89631. constructor(scene?: Nullable<Scene>);
  89632. /**
  89633. * Gets the unique ID of this manager
  89634. */
  89635. readonly uniqueId: number;
  89636. /**
  89637. * Gets the number of vertices handled by this manager
  89638. */
  89639. readonly vertexCount: number;
  89640. /**
  89641. * Gets a boolean indicating if this manager supports morphing of normals
  89642. */
  89643. readonly supportsNormals: boolean;
  89644. /**
  89645. * Gets a boolean indicating if this manager supports morphing of tangents
  89646. */
  89647. readonly supportsTangents: boolean;
  89648. /**
  89649. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89650. */
  89651. readonly supportsUVs: boolean;
  89652. /**
  89653. * Gets the number of targets stored in this manager
  89654. */
  89655. readonly numTargets: number;
  89656. /**
  89657. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89658. */
  89659. readonly numInfluencers: number;
  89660. /**
  89661. * Gets the list of influences (one per target)
  89662. */
  89663. readonly influences: Float32Array;
  89664. /**
  89665. * Gets the active target at specified index. An active target is a target with an influence > 0
  89666. * @param index defines the index to check
  89667. * @returns the requested target
  89668. */
  89669. getActiveTarget(index: number): MorphTarget;
  89670. /**
  89671. * Gets the target at specified index
  89672. * @param index defines the index to check
  89673. * @returns the requested target
  89674. */
  89675. getTarget(index: number): MorphTarget;
  89676. /**
  89677. * Add a new target to this manager
  89678. * @param target defines the target to add
  89679. */
  89680. addTarget(target: MorphTarget): void;
  89681. /**
  89682. * Removes a target from the manager
  89683. * @param target defines the target to remove
  89684. */
  89685. removeTarget(target: MorphTarget): void;
  89686. /**
  89687. * Serializes the current manager into a Serialization object
  89688. * @returns the serialized object
  89689. */
  89690. serialize(): any;
  89691. private _syncActiveTargets;
  89692. /**
  89693. * Syncrhonize the targets with all the meshes using this morph target manager
  89694. */
  89695. synchronize(): void;
  89696. /**
  89697. * Creates a new MorphTargetManager from serialized data
  89698. * @param serializationObject defines the serialized data
  89699. * @param scene defines the hosting scene
  89700. * @returns the new MorphTargetManager
  89701. */
  89702. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89703. }
  89704. }
  89705. declare module BABYLON {
  89706. /**
  89707. * Class used to represent a specific level of detail of a mesh
  89708. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89709. */
  89710. export class MeshLODLevel {
  89711. /** Defines the distance where this level should start being displayed */
  89712. distance: number;
  89713. /** Defines the mesh to use to render this level */
  89714. mesh: Nullable<Mesh>;
  89715. /**
  89716. * Creates a new LOD level
  89717. * @param distance defines the distance where this level should star being displayed
  89718. * @param mesh defines the mesh to use to render this level
  89719. */
  89720. constructor(
  89721. /** Defines the distance where this level should start being displayed */
  89722. distance: number,
  89723. /** Defines the mesh to use to render this level */
  89724. mesh: Nullable<Mesh>);
  89725. }
  89726. }
  89727. declare module BABYLON {
  89728. /**
  89729. * Mesh representing the gorund
  89730. */
  89731. export class GroundMesh extends Mesh {
  89732. /** If octree should be generated */
  89733. generateOctree: boolean;
  89734. private _heightQuads;
  89735. /** @hidden */
  89736. _subdivisionsX: number;
  89737. /** @hidden */
  89738. _subdivisionsY: number;
  89739. /** @hidden */
  89740. _width: number;
  89741. /** @hidden */
  89742. _height: number;
  89743. /** @hidden */
  89744. _minX: number;
  89745. /** @hidden */
  89746. _maxX: number;
  89747. /** @hidden */
  89748. _minZ: number;
  89749. /** @hidden */
  89750. _maxZ: number;
  89751. constructor(name: string, scene: Scene);
  89752. /**
  89753. * "GroundMesh"
  89754. * @returns "GroundMesh"
  89755. */
  89756. getClassName(): string;
  89757. /**
  89758. * The minimum of x and y subdivisions
  89759. */
  89760. readonly subdivisions: number;
  89761. /**
  89762. * X subdivisions
  89763. */
  89764. readonly subdivisionsX: number;
  89765. /**
  89766. * Y subdivisions
  89767. */
  89768. readonly subdivisionsY: number;
  89769. /**
  89770. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89771. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89772. * @param chunksCount the number of subdivisions for x and y
  89773. * @param octreeBlocksSize (Default: 32)
  89774. */
  89775. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89776. /**
  89777. * Returns a height (y) value in the Worl system :
  89778. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89779. * @param x x coordinate
  89780. * @param z z coordinate
  89781. * @returns the ground y position if (x, z) are outside the ground surface.
  89782. */
  89783. getHeightAtCoordinates(x: number, z: number): number;
  89784. /**
  89785. * Returns a normalized vector (Vector3) orthogonal to the ground
  89786. * at the ground coordinates (x, z) expressed in the World system.
  89787. * @param x x coordinate
  89788. * @param z z coordinate
  89789. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89790. */
  89791. getNormalAtCoordinates(x: number, z: number): Vector3;
  89792. /**
  89793. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89794. * at the ground coordinates (x, z) expressed in the World system.
  89795. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89796. * @param x x coordinate
  89797. * @param z z coordinate
  89798. * @param ref vector to store the result
  89799. * @returns the GroundMesh.
  89800. */
  89801. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89802. /**
  89803. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89804. * if the ground has been updated.
  89805. * This can be used in the render loop.
  89806. * @returns the GroundMesh.
  89807. */
  89808. updateCoordinateHeights(): GroundMesh;
  89809. private _getFacetAt;
  89810. private _initHeightQuads;
  89811. private _computeHeightQuads;
  89812. /**
  89813. * Serializes this ground mesh
  89814. * @param serializationObject object to write serialization to
  89815. */
  89816. serialize(serializationObject: any): void;
  89817. /**
  89818. * Parses a serialized ground mesh
  89819. * @param parsedMesh the serialized mesh
  89820. * @param scene the scene to create the ground mesh in
  89821. * @returns the created ground mesh
  89822. */
  89823. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89824. }
  89825. }
  89826. declare module BABYLON {
  89827. /**
  89828. * Interface for Physics-Joint data
  89829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89830. */
  89831. export interface PhysicsJointData {
  89832. /**
  89833. * The main pivot of the joint
  89834. */
  89835. mainPivot?: Vector3;
  89836. /**
  89837. * The connected pivot of the joint
  89838. */
  89839. connectedPivot?: Vector3;
  89840. /**
  89841. * The main axis of the joint
  89842. */
  89843. mainAxis?: Vector3;
  89844. /**
  89845. * The connected axis of the joint
  89846. */
  89847. connectedAxis?: Vector3;
  89848. /**
  89849. * The collision of the joint
  89850. */
  89851. collision?: boolean;
  89852. /**
  89853. * Native Oimo/Cannon/Energy data
  89854. */
  89855. nativeParams?: any;
  89856. }
  89857. /**
  89858. * This is a holder class for the physics joint created by the physics plugin
  89859. * It holds a set of functions to control the underlying joint
  89860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89861. */
  89862. export class PhysicsJoint {
  89863. /**
  89864. * The type of the physics joint
  89865. */
  89866. type: number;
  89867. /**
  89868. * The data for the physics joint
  89869. */
  89870. jointData: PhysicsJointData;
  89871. private _physicsJoint;
  89872. protected _physicsPlugin: IPhysicsEnginePlugin;
  89873. /**
  89874. * Initializes the physics joint
  89875. * @param type The type of the physics joint
  89876. * @param jointData The data for the physics joint
  89877. */
  89878. constructor(
  89879. /**
  89880. * The type of the physics joint
  89881. */
  89882. type: number,
  89883. /**
  89884. * The data for the physics joint
  89885. */
  89886. jointData: PhysicsJointData);
  89887. /**
  89888. * Gets the physics joint
  89889. */
  89890. /**
  89891. * Sets the physics joint
  89892. */
  89893. physicsJoint: any;
  89894. /**
  89895. * Sets the physics plugin
  89896. */
  89897. physicsPlugin: IPhysicsEnginePlugin;
  89898. /**
  89899. * Execute a function that is physics-plugin specific.
  89900. * @param {Function} func the function that will be executed.
  89901. * It accepts two parameters: the physics world and the physics joint
  89902. */
  89903. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89904. /**
  89905. * Distance-Joint type
  89906. */
  89907. static DistanceJoint: number;
  89908. /**
  89909. * Hinge-Joint type
  89910. */
  89911. static HingeJoint: number;
  89912. /**
  89913. * Ball-and-Socket joint type
  89914. */
  89915. static BallAndSocketJoint: number;
  89916. /**
  89917. * Wheel-Joint type
  89918. */
  89919. static WheelJoint: number;
  89920. /**
  89921. * Slider-Joint type
  89922. */
  89923. static SliderJoint: number;
  89924. /**
  89925. * Prismatic-Joint type
  89926. */
  89927. static PrismaticJoint: number;
  89928. /**
  89929. * Universal-Joint type
  89930. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89931. */
  89932. static UniversalJoint: number;
  89933. /**
  89934. * Hinge-Joint 2 type
  89935. */
  89936. static Hinge2Joint: number;
  89937. /**
  89938. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89939. */
  89940. static PointToPointJoint: number;
  89941. /**
  89942. * Spring-Joint type
  89943. */
  89944. static SpringJoint: number;
  89945. /**
  89946. * Lock-Joint type
  89947. */
  89948. static LockJoint: number;
  89949. }
  89950. /**
  89951. * A class representing a physics distance joint
  89952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89953. */
  89954. export class DistanceJoint extends PhysicsJoint {
  89955. /**
  89956. *
  89957. * @param jointData The data for the Distance-Joint
  89958. */
  89959. constructor(jointData: DistanceJointData);
  89960. /**
  89961. * Update the predefined distance.
  89962. * @param maxDistance The maximum preferred distance
  89963. * @param minDistance The minimum preferred distance
  89964. */
  89965. updateDistance(maxDistance: number, minDistance?: number): void;
  89966. }
  89967. /**
  89968. * Represents a Motor-Enabled Joint
  89969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89970. */
  89971. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89972. /**
  89973. * Initializes the Motor-Enabled Joint
  89974. * @param type The type of the joint
  89975. * @param jointData The physica joint data for the joint
  89976. */
  89977. constructor(type: number, jointData: PhysicsJointData);
  89978. /**
  89979. * Set the motor values.
  89980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89981. * @param force the force to apply
  89982. * @param maxForce max force for this motor.
  89983. */
  89984. setMotor(force?: number, maxForce?: number): void;
  89985. /**
  89986. * Set the motor's limits.
  89987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89988. * @param upperLimit The upper limit of the motor
  89989. * @param lowerLimit The lower limit of the motor
  89990. */
  89991. setLimit(upperLimit: number, lowerLimit?: number): void;
  89992. }
  89993. /**
  89994. * This class represents a single physics Hinge-Joint
  89995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89996. */
  89997. export class HingeJoint extends MotorEnabledJoint {
  89998. /**
  89999. * Initializes the Hinge-Joint
  90000. * @param jointData The joint data for the Hinge-Joint
  90001. */
  90002. constructor(jointData: PhysicsJointData);
  90003. /**
  90004. * Set the motor values.
  90005. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90006. * @param {number} force the force to apply
  90007. * @param {number} maxForce max force for this motor.
  90008. */
  90009. setMotor(force?: number, maxForce?: number): void;
  90010. /**
  90011. * Set the motor's limits.
  90012. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90013. * @param upperLimit The upper limit of the motor
  90014. * @param lowerLimit The lower limit of the motor
  90015. */
  90016. setLimit(upperLimit: number, lowerLimit?: number): void;
  90017. }
  90018. /**
  90019. * This class represents a dual hinge physics joint (same as wheel joint)
  90020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90021. */
  90022. export class Hinge2Joint extends MotorEnabledJoint {
  90023. /**
  90024. * Initializes the Hinge2-Joint
  90025. * @param jointData The joint data for the Hinge2-Joint
  90026. */
  90027. constructor(jointData: PhysicsJointData);
  90028. /**
  90029. * Set the motor values.
  90030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90031. * @param {number} targetSpeed the speed the motor is to reach
  90032. * @param {number} maxForce max force for this motor.
  90033. * @param {motorIndex} the motor's index, 0 or 1.
  90034. */
  90035. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90036. /**
  90037. * Set the motor limits.
  90038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90039. * @param {number} upperLimit the upper limit
  90040. * @param {number} lowerLimit lower limit
  90041. * @param {motorIndex} the motor's index, 0 or 1.
  90042. */
  90043. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90044. }
  90045. /**
  90046. * Interface for a motor enabled joint
  90047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90048. */
  90049. export interface IMotorEnabledJoint {
  90050. /**
  90051. * Physics joint
  90052. */
  90053. physicsJoint: any;
  90054. /**
  90055. * Sets the motor of the motor-enabled joint
  90056. * @param force The force of the motor
  90057. * @param maxForce The maximum force of the motor
  90058. * @param motorIndex The index of the motor
  90059. */
  90060. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90061. /**
  90062. * Sets the limit of the motor
  90063. * @param upperLimit The upper limit of the motor
  90064. * @param lowerLimit The lower limit of the motor
  90065. * @param motorIndex The index of the motor
  90066. */
  90067. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90068. }
  90069. /**
  90070. * Joint data for a Distance-Joint
  90071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90072. */
  90073. export interface DistanceJointData extends PhysicsJointData {
  90074. /**
  90075. * Max distance the 2 joint objects can be apart
  90076. */
  90077. maxDistance: number;
  90078. }
  90079. /**
  90080. * Joint data from a spring joint
  90081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90082. */
  90083. export interface SpringJointData extends PhysicsJointData {
  90084. /**
  90085. * Length of the spring
  90086. */
  90087. length: number;
  90088. /**
  90089. * Stiffness of the spring
  90090. */
  90091. stiffness: number;
  90092. /**
  90093. * Damping of the spring
  90094. */
  90095. damping: number;
  90096. /** this callback will be called when applying the force to the impostors. */
  90097. forceApplicationCallback: () => void;
  90098. }
  90099. }
  90100. declare module BABYLON {
  90101. /**
  90102. * Holds the data for the raycast result
  90103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90104. */
  90105. export class PhysicsRaycastResult {
  90106. private _hasHit;
  90107. private _hitDistance;
  90108. private _hitNormalWorld;
  90109. private _hitPointWorld;
  90110. private _rayFromWorld;
  90111. private _rayToWorld;
  90112. /**
  90113. * Gets if there was a hit
  90114. */
  90115. readonly hasHit: boolean;
  90116. /**
  90117. * Gets the distance from the hit
  90118. */
  90119. readonly hitDistance: number;
  90120. /**
  90121. * Gets the hit normal/direction in the world
  90122. */
  90123. readonly hitNormalWorld: Vector3;
  90124. /**
  90125. * Gets the hit point in the world
  90126. */
  90127. readonly hitPointWorld: Vector3;
  90128. /**
  90129. * Gets the ray "start point" of the ray in the world
  90130. */
  90131. readonly rayFromWorld: Vector3;
  90132. /**
  90133. * Gets the ray "end point" of the ray in the world
  90134. */
  90135. readonly rayToWorld: Vector3;
  90136. /**
  90137. * Sets the hit data (normal & point in world space)
  90138. * @param hitNormalWorld defines the normal in world space
  90139. * @param hitPointWorld defines the point in world space
  90140. */
  90141. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90142. /**
  90143. * Sets the distance from the start point to the hit point
  90144. * @param distance
  90145. */
  90146. setHitDistance(distance: number): void;
  90147. /**
  90148. * Calculates the distance manually
  90149. */
  90150. calculateHitDistance(): void;
  90151. /**
  90152. * Resets all the values to default
  90153. * @param from The from point on world space
  90154. * @param to The to point on world space
  90155. */
  90156. reset(from?: Vector3, to?: Vector3): void;
  90157. }
  90158. /**
  90159. * Interface for the size containing width and height
  90160. */
  90161. interface IXYZ {
  90162. /**
  90163. * X
  90164. */
  90165. x: number;
  90166. /**
  90167. * Y
  90168. */
  90169. y: number;
  90170. /**
  90171. * Z
  90172. */
  90173. z: number;
  90174. }
  90175. }
  90176. declare module BABYLON {
  90177. /**
  90178. * Interface used to describe a physics joint
  90179. */
  90180. export interface PhysicsImpostorJoint {
  90181. /** Defines the main impostor to which the joint is linked */
  90182. mainImpostor: PhysicsImpostor;
  90183. /** Defines the impostor that is connected to the main impostor using this joint */
  90184. connectedImpostor: PhysicsImpostor;
  90185. /** Defines the joint itself */
  90186. joint: PhysicsJoint;
  90187. }
  90188. /** @hidden */
  90189. export interface IPhysicsEnginePlugin {
  90190. world: any;
  90191. name: string;
  90192. setGravity(gravity: Vector3): void;
  90193. setTimeStep(timeStep: number): void;
  90194. getTimeStep(): number;
  90195. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90197. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90199. removePhysicsBody(impostor: PhysicsImpostor): void;
  90200. generateJoint(joint: PhysicsImpostorJoint): void;
  90201. removeJoint(joint: PhysicsImpostorJoint): void;
  90202. isSupported(): boolean;
  90203. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90204. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90205. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90207. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90208. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90209. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90210. getBodyMass(impostor: PhysicsImpostor): number;
  90211. getBodyFriction(impostor: PhysicsImpostor): number;
  90212. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90213. getBodyRestitution(impostor: PhysicsImpostor): number;
  90214. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90215. getBodyPressure?(impostor: PhysicsImpostor): number;
  90216. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90217. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90218. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90219. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90220. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90221. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90222. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90223. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90224. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90225. sleepBody(impostor: PhysicsImpostor): void;
  90226. wakeUpBody(impostor: PhysicsImpostor): void;
  90227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90228. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90229. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90230. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90231. getRadius(impostor: PhysicsImpostor): number;
  90232. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90233. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90234. dispose(): void;
  90235. }
  90236. /**
  90237. * Interface used to define a physics engine
  90238. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90239. */
  90240. export interface IPhysicsEngine {
  90241. /**
  90242. * Gets the gravity vector used by the simulation
  90243. */
  90244. gravity: Vector3;
  90245. /**
  90246. * Sets the gravity vector used by the simulation
  90247. * @param gravity defines the gravity vector to use
  90248. */
  90249. setGravity(gravity: Vector3): void;
  90250. /**
  90251. * Set the time step of the physics engine.
  90252. * Default is 1/60.
  90253. * To slow it down, enter 1/600 for example.
  90254. * To speed it up, 1/30
  90255. * @param newTimeStep the new timestep to apply to this world.
  90256. */
  90257. setTimeStep(newTimeStep: number): void;
  90258. /**
  90259. * Get the time step of the physics engine.
  90260. * @returns the current time step
  90261. */
  90262. getTimeStep(): number;
  90263. /**
  90264. * Release all resources
  90265. */
  90266. dispose(): void;
  90267. /**
  90268. * Gets the name of the current physics plugin
  90269. * @returns the name of the plugin
  90270. */
  90271. getPhysicsPluginName(): string;
  90272. /**
  90273. * Adding a new impostor for the impostor tracking.
  90274. * This will be done by the impostor itself.
  90275. * @param impostor the impostor to add
  90276. */
  90277. addImpostor(impostor: PhysicsImpostor): void;
  90278. /**
  90279. * Remove an impostor from the engine.
  90280. * This impostor and its mesh will not longer be updated by the physics engine.
  90281. * @param impostor the impostor to remove
  90282. */
  90283. removeImpostor(impostor: PhysicsImpostor): void;
  90284. /**
  90285. * Add a joint to the physics engine
  90286. * @param mainImpostor defines the main impostor to which the joint is added.
  90287. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90288. * @param joint defines the joint that will connect both impostors.
  90289. */
  90290. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90291. /**
  90292. * Removes a joint from the simulation
  90293. * @param mainImpostor defines the impostor used with the joint
  90294. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90295. * @param joint defines the joint to remove
  90296. */
  90297. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90298. /**
  90299. * Gets the current plugin used to run the simulation
  90300. * @returns current plugin
  90301. */
  90302. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90303. /**
  90304. * Gets the list of physic impostors
  90305. * @returns an array of PhysicsImpostor
  90306. */
  90307. getImpostors(): Array<PhysicsImpostor>;
  90308. /**
  90309. * Gets the impostor for a physics enabled object
  90310. * @param object defines the object impersonated by the impostor
  90311. * @returns the PhysicsImpostor or null if not found
  90312. */
  90313. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90314. /**
  90315. * Gets the impostor for a physics body object
  90316. * @param body defines physics body used by the impostor
  90317. * @returns the PhysicsImpostor or null if not found
  90318. */
  90319. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90320. /**
  90321. * Does a raycast in the physics world
  90322. * @param from when should the ray start?
  90323. * @param to when should the ray end?
  90324. * @returns PhysicsRaycastResult
  90325. */
  90326. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90327. /**
  90328. * Called by the scene. No need to call it.
  90329. * @param delta defines the timespam between frames
  90330. */
  90331. _step(delta: number): void;
  90332. }
  90333. }
  90334. declare module BABYLON {
  90335. /**
  90336. * The interface for the physics imposter parameters
  90337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90338. */
  90339. export interface PhysicsImpostorParameters {
  90340. /**
  90341. * The mass of the physics imposter
  90342. */
  90343. mass: number;
  90344. /**
  90345. * The friction of the physics imposter
  90346. */
  90347. friction?: number;
  90348. /**
  90349. * The coefficient of restitution of the physics imposter
  90350. */
  90351. restitution?: number;
  90352. /**
  90353. * The native options of the physics imposter
  90354. */
  90355. nativeOptions?: any;
  90356. /**
  90357. * Specifies if the parent should be ignored
  90358. */
  90359. ignoreParent?: boolean;
  90360. /**
  90361. * Specifies if bi-directional transformations should be disabled
  90362. */
  90363. disableBidirectionalTransformation?: boolean;
  90364. /**
  90365. * The pressure inside the physics imposter, soft object only
  90366. */
  90367. pressure?: number;
  90368. /**
  90369. * The stiffness the physics imposter, soft object only
  90370. */
  90371. stiffness?: number;
  90372. /**
  90373. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90374. */
  90375. velocityIterations?: number;
  90376. /**
  90377. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90378. */
  90379. positionIterations?: number;
  90380. /**
  90381. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90382. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90383. * Add to fix multiple points
  90384. */
  90385. fixedPoints?: number;
  90386. /**
  90387. * The collision margin around a soft object
  90388. */
  90389. margin?: number;
  90390. /**
  90391. * The collision margin around a soft object
  90392. */
  90393. damping?: number;
  90394. /**
  90395. * The path for a rope based on an extrusion
  90396. */
  90397. path?: any;
  90398. /**
  90399. * The shape of an extrusion used for a rope based on an extrusion
  90400. */
  90401. shape?: any;
  90402. }
  90403. /**
  90404. * Interface for a physics-enabled object
  90405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90406. */
  90407. export interface IPhysicsEnabledObject {
  90408. /**
  90409. * The position of the physics-enabled object
  90410. */
  90411. position: Vector3;
  90412. /**
  90413. * The rotation of the physics-enabled object
  90414. */
  90415. rotationQuaternion: Nullable<Quaternion>;
  90416. /**
  90417. * The scale of the physics-enabled object
  90418. */
  90419. scaling: Vector3;
  90420. /**
  90421. * The rotation of the physics-enabled object
  90422. */
  90423. rotation?: Vector3;
  90424. /**
  90425. * The parent of the physics-enabled object
  90426. */
  90427. parent?: any;
  90428. /**
  90429. * The bounding info of the physics-enabled object
  90430. * @returns The bounding info of the physics-enabled object
  90431. */
  90432. getBoundingInfo(): BoundingInfo;
  90433. /**
  90434. * Computes the world matrix
  90435. * @param force Specifies if the world matrix should be computed by force
  90436. * @returns A world matrix
  90437. */
  90438. computeWorldMatrix(force: boolean): Matrix;
  90439. /**
  90440. * Gets the world matrix
  90441. * @returns A world matrix
  90442. */
  90443. getWorldMatrix?(): Matrix;
  90444. /**
  90445. * Gets the child meshes
  90446. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90447. * @returns An array of abstract meshes
  90448. */
  90449. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90450. /**
  90451. * Gets the vertex data
  90452. * @param kind The type of vertex data
  90453. * @returns A nullable array of numbers, or a float32 array
  90454. */
  90455. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90456. /**
  90457. * Gets the indices from the mesh
  90458. * @returns A nullable array of index arrays
  90459. */
  90460. getIndices?(): Nullable<IndicesArray>;
  90461. /**
  90462. * Gets the scene from the mesh
  90463. * @returns the indices array or null
  90464. */
  90465. getScene?(): Scene;
  90466. /**
  90467. * Gets the absolute position from the mesh
  90468. * @returns the absolute position
  90469. */
  90470. getAbsolutePosition(): Vector3;
  90471. /**
  90472. * Gets the absolute pivot point from the mesh
  90473. * @returns the absolute pivot point
  90474. */
  90475. getAbsolutePivotPoint(): Vector3;
  90476. /**
  90477. * Rotates the mesh
  90478. * @param axis The axis of rotation
  90479. * @param amount The amount of rotation
  90480. * @param space The space of the rotation
  90481. * @returns The rotation transform node
  90482. */
  90483. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90484. /**
  90485. * Translates the mesh
  90486. * @param axis The axis of translation
  90487. * @param distance The distance of translation
  90488. * @param space The space of the translation
  90489. * @returns The transform node
  90490. */
  90491. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90492. /**
  90493. * Sets the absolute position of the mesh
  90494. * @param absolutePosition The absolute position of the mesh
  90495. * @returns The transform node
  90496. */
  90497. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90498. /**
  90499. * Gets the class name of the mesh
  90500. * @returns The class name
  90501. */
  90502. getClassName(): string;
  90503. }
  90504. /**
  90505. * Represents a physics imposter
  90506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90507. */
  90508. export class PhysicsImpostor {
  90509. /**
  90510. * The physics-enabled object used as the physics imposter
  90511. */
  90512. object: IPhysicsEnabledObject;
  90513. /**
  90514. * The type of the physics imposter
  90515. */
  90516. type: number;
  90517. private _options;
  90518. private _scene?;
  90519. /**
  90520. * The default object size of the imposter
  90521. */
  90522. static DEFAULT_OBJECT_SIZE: Vector3;
  90523. /**
  90524. * The identity quaternion of the imposter
  90525. */
  90526. static IDENTITY_QUATERNION: Quaternion;
  90527. /** @hidden */
  90528. _pluginData: any;
  90529. private _physicsEngine;
  90530. private _physicsBody;
  90531. private _bodyUpdateRequired;
  90532. private _onBeforePhysicsStepCallbacks;
  90533. private _onAfterPhysicsStepCallbacks;
  90534. /** @hidden */
  90535. _onPhysicsCollideCallbacks: Array<{
  90536. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90537. otherImpostors: Array<PhysicsImpostor>;
  90538. }>;
  90539. private _deltaPosition;
  90540. private _deltaRotation;
  90541. private _deltaRotationConjugated;
  90542. /** @hidden */
  90543. _isFromLine: boolean;
  90544. private _parent;
  90545. private _isDisposed;
  90546. private static _tmpVecs;
  90547. private static _tmpQuat;
  90548. /**
  90549. * Specifies if the physics imposter is disposed
  90550. */
  90551. readonly isDisposed: boolean;
  90552. /**
  90553. * Gets the mass of the physics imposter
  90554. */
  90555. mass: number;
  90556. /**
  90557. * Gets the coefficient of friction
  90558. */
  90559. /**
  90560. * Sets the coefficient of friction
  90561. */
  90562. friction: number;
  90563. /**
  90564. * Gets the coefficient of restitution
  90565. */
  90566. /**
  90567. * Sets the coefficient of restitution
  90568. */
  90569. restitution: number;
  90570. /**
  90571. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90572. */
  90573. /**
  90574. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90575. */
  90576. pressure: number;
  90577. /**
  90578. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90579. */
  90580. /**
  90581. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90582. */
  90583. stiffness: number;
  90584. /**
  90585. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90586. */
  90587. /**
  90588. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90589. */
  90590. velocityIterations: number;
  90591. /**
  90592. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90593. */
  90594. /**
  90595. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90596. */
  90597. positionIterations: number;
  90598. /**
  90599. * The unique id of the physics imposter
  90600. * set by the physics engine when adding this impostor to the array
  90601. */
  90602. uniqueId: number;
  90603. /**
  90604. * @hidden
  90605. */
  90606. soft: boolean;
  90607. /**
  90608. * @hidden
  90609. */
  90610. segments: number;
  90611. private _joints;
  90612. /**
  90613. * Initializes the physics imposter
  90614. * @param object The physics-enabled object used as the physics imposter
  90615. * @param type The type of the physics imposter
  90616. * @param _options The options for the physics imposter
  90617. * @param _scene The Babylon scene
  90618. */
  90619. constructor(
  90620. /**
  90621. * The physics-enabled object used as the physics imposter
  90622. */
  90623. object: IPhysicsEnabledObject,
  90624. /**
  90625. * The type of the physics imposter
  90626. */
  90627. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90628. /**
  90629. * This function will completly initialize this impostor.
  90630. * It will create a new body - but only if this mesh has no parent.
  90631. * If it has, this impostor will not be used other than to define the impostor
  90632. * of the child mesh.
  90633. * @hidden
  90634. */
  90635. _init(): void;
  90636. private _getPhysicsParent;
  90637. /**
  90638. * Should a new body be generated.
  90639. * @returns boolean specifying if body initialization is required
  90640. */
  90641. isBodyInitRequired(): boolean;
  90642. /**
  90643. * Sets the updated scaling
  90644. * @param updated Specifies if the scaling is updated
  90645. */
  90646. setScalingUpdated(): void;
  90647. /**
  90648. * Force a regeneration of this or the parent's impostor's body.
  90649. * Use under cautious - This will remove all joints already implemented.
  90650. */
  90651. forceUpdate(): void;
  90652. /**
  90653. * Gets the body that holds this impostor. Either its own, or its parent.
  90654. */
  90655. /**
  90656. * Set the physics body. Used mainly by the physics engine/plugin
  90657. */
  90658. physicsBody: any;
  90659. /**
  90660. * Get the parent of the physics imposter
  90661. * @returns Physics imposter or null
  90662. */
  90663. /**
  90664. * Sets the parent of the physics imposter
  90665. */
  90666. parent: Nullable<PhysicsImpostor>;
  90667. /**
  90668. * Resets the update flags
  90669. */
  90670. resetUpdateFlags(): void;
  90671. /**
  90672. * Gets the object extend size
  90673. * @returns the object extend size
  90674. */
  90675. getObjectExtendSize(): Vector3;
  90676. /**
  90677. * Gets the object center
  90678. * @returns The object center
  90679. */
  90680. getObjectCenter(): Vector3;
  90681. /**
  90682. * Get a specific parametes from the options parameter
  90683. * @param paramName The object parameter name
  90684. * @returns The object parameter
  90685. */
  90686. getParam(paramName: string): any;
  90687. /**
  90688. * Sets a specific parameter in the options given to the physics plugin
  90689. * @param paramName The parameter name
  90690. * @param value The value of the parameter
  90691. */
  90692. setParam(paramName: string, value: number): void;
  90693. /**
  90694. * Specifically change the body's mass option. Won't recreate the physics body object
  90695. * @param mass The mass of the physics imposter
  90696. */
  90697. setMass(mass: number): void;
  90698. /**
  90699. * Gets the linear velocity
  90700. * @returns linear velocity or null
  90701. */
  90702. getLinearVelocity(): Nullable<Vector3>;
  90703. /**
  90704. * Sets the linear velocity
  90705. * @param velocity linear velocity or null
  90706. */
  90707. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90708. /**
  90709. * Gets the angular velocity
  90710. * @returns angular velocity or null
  90711. */
  90712. getAngularVelocity(): Nullable<Vector3>;
  90713. /**
  90714. * Sets the angular velocity
  90715. * @param velocity The velocity or null
  90716. */
  90717. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90718. /**
  90719. * Execute a function with the physics plugin native code
  90720. * Provide a function the will have two variables - the world object and the physics body object
  90721. * @param func The function to execute with the physics plugin native code
  90722. */
  90723. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90724. /**
  90725. * Register a function that will be executed before the physics world is stepping forward
  90726. * @param func The function to execute before the physics world is stepped forward
  90727. */
  90728. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90729. /**
  90730. * Unregister a function that will be executed before the physics world is stepping forward
  90731. * @param func The function to execute before the physics world is stepped forward
  90732. */
  90733. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90734. /**
  90735. * Register a function that will be executed after the physics step
  90736. * @param func The function to execute after physics step
  90737. */
  90738. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90739. /**
  90740. * Unregisters a function that will be executed after the physics step
  90741. * @param func The function to execute after physics step
  90742. */
  90743. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90744. /**
  90745. * register a function that will be executed when this impostor collides against a different body
  90746. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90747. * @param func Callback that is executed on collision
  90748. */
  90749. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90750. /**
  90751. * Unregisters the physics imposter on contact
  90752. * @param collideAgainst The physics object to collide against
  90753. * @param func Callback to execute on collision
  90754. */
  90755. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90756. private _tmpQuat;
  90757. private _tmpQuat2;
  90758. /**
  90759. * Get the parent rotation
  90760. * @returns The parent rotation
  90761. */
  90762. getParentsRotation(): Quaternion;
  90763. /**
  90764. * this function is executed by the physics engine.
  90765. */
  90766. beforeStep: () => void;
  90767. /**
  90768. * this function is executed by the physics engine
  90769. */
  90770. afterStep: () => void;
  90771. /**
  90772. * Legacy collision detection event support
  90773. */
  90774. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90775. /**
  90776. * event and body object due to cannon's event-based architecture.
  90777. */
  90778. onCollide: (e: {
  90779. body: any;
  90780. }) => void;
  90781. /**
  90782. * Apply a force
  90783. * @param force The force to apply
  90784. * @param contactPoint The contact point for the force
  90785. * @returns The physics imposter
  90786. */
  90787. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90788. /**
  90789. * Apply an impulse
  90790. * @param force The impulse force
  90791. * @param contactPoint The contact point for the impulse force
  90792. * @returns The physics imposter
  90793. */
  90794. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90795. /**
  90796. * A help function to create a joint
  90797. * @param otherImpostor A physics imposter used to create a joint
  90798. * @param jointType The type of joint
  90799. * @param jointData The data for the joint
  90800. * @returns The physics imposter
  90801. */
  90802. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90803. /**
  90804. * Add a joint to this impostor with a different impostor
  90805. * @param otherImpostor A physics imposter used to add a joint
  90806. * @param joint The joint to add
  90807. * @returns The physics imposter
  90808. */
  90809. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90810. /**
  90811. * Add an anchor to a cloth impostor
  90812. * @param otherImpostor rigid impostor to anchor to
  90813. * @param width ratio across width from 0 to 1
  90814. * @param height ratio up height from 0 to 1
  90815. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90816. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90817. * @returns impostor the soft imposter
  90818. */
  90819. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90820. /**
  90821. * Add a hook to a rope impostor
  90822. * @param otherImpostor rigid impostor to anchor to
  90823. * @param length ratio across rope from 0 to 1
  90824. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90825. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90826. * @returns impostor the rope imposter
  90827. */
  90828. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90829. /**
  90830. * Will keep this body still, in a sleep mode.
  90831. * @returns the physics imposter
  90832. */
  90833. sleep(): PhysicsImpostor;
  90834. /**
  90835. * Wake the body up.
  90836. * @returns The physics imposter
  90837. */
  90838. wakeUp(): PhysicsImpostor;
  90839. /**
  90840. * Clones the physics imposter
  90841. * @param newObject The physics imposter clones to this physics-enabled object
  90842. * @returns A nullable physics imposter
  90843. */
  90844. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90845. /**
  90846. * Disposes the physics imposter
  90847. */
  90848. dispose(): void;
  90849. /**
  90850. * Sets the delta position
  90851. * @param position The delta position amount
  90852. */
  90853. setDeltaPosition(position: Vector3): void;
  90854. /**
  90855. * Sets the delta rotation
  90856. * @param rotation The delta rotation amount
  90857. */
  90858. setDeltaRotation(rotation: Quaternion): void;
  90859. /**
  90860. * Gets the box size of the physics imposter and stores the result in the input parameter
  90861. * @param result Stores the box size
  90862. * @returns The physics imposter
  90863. */
  90864. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90865. /**
  90866. * Gets the radius of the physics imposter
  90867. * @returns Radius of the physics imposter
  90868. */
  90869. getRadius(): number;
  90870. /**
  90871. * Sync a bone with this impostor
  90872. * @param bone The bone to sync to the impostor.
  90873. * @param boneMesh The mesh that the bone is influencing.
  90874. * @param jointPivot The pivot of the joint / bone in local space.
  90875. * @param distToJoint Optional distance from the impostor to the joint.
  90876. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90877. */
  90878. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90879. /**
  90880. * Sync impostor to a bone
  90881. * @param bone The bone that the impostor will be synced to.
  90882. * @param boneMesh The mesh that the bone is influencing.
  90883. * @param jointPivot The pivot of the joint / bone in local space.
  90884. * @param distToJoint Optional distance from the impostor to the joint.
  90885. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90886. * @param boneAxis Optional vector3 axis the bone is aligned with
  90887. */
  90888. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90889. /**
  90890. * No-Imposter type
  90891. */
  90892. static NoImpostor: number;
  90893. /**
  90894. * Sphere-Imposter type
  90895. */
  90896. static SphereImpostor: number;
  90897. /**
  90898. * Box-Imposter type
  90899. */
  90900. static BoxImpostor: number;
  90901. /**
  90902. * Plane-Imposter type
  90903. */
  90904. static PlaneImpostor: number;
  90905. /**
  90906. * Mesh-imposter type
  90907. */
  90908. static MeshImpostor: number;
  90909. /**
  90910. * Capsule-Impostor type (Ammo.js plugin only)
  90911. */
  90912. static CapsuleImpostor: number;
  90913. /**
  90914. * Cylinder-Imposter type
  90915. */
  90916. static CylinderImpostor: number;
  90917. /**
  90918. * Particle-Imposter type
  90919. */
  90920. static ParticleImpostor: number;
  90921. /**
  90922. * Heightmap-Imposter type
  90923. */
  90924. static HeightmapImpostor: number;
  90925. /**
  90926. * ConvexHull-Impostor type (Ammo.js plugin only)
  90927. */
  90928. static ConvexHullImpostor: number;
  90929. /**
  90930. * Rope-Imposter type
  90931. */
  90932. static RopeImpostor: number;
  90933. /**
  90934. * Cloth-Imposter type
  90935. */
  90936. static ClothImpostor: number;
  90937. /**
  90938. * Softbody-Imposter type
  90939. */
  90940. static SoftbodyImpostor: number;
  90941. }
  90942. }
  90943. declare module BABYLON {
  90944. /**
  90945. * @hidden
  90946. **/
  90947. export class _CreationDataStorage {
  90948. closePath?: boolean;
  90949. closeArray?: boolean;
  90950. idx: number[];
  90951. dashSize: number;
  90952. gapSize: number;
  90953. path3D: Path3D;
  90954. pathArray: Vector3[][];
  90955. arc: number;
  90956. radius: number;
  90957. cap: number;
  90958. tessellation: number;
  90959. }
  90960. /**
  90961. * @hidden
  90962. **/
  90963. class _InstanceDataStorage {
  90964. visibleInstances: any;
  90965. batchCache: _InstancesBatch;
  90966. instancesBufferSize: number;
  90967. instancesBuffer: Nullable<Buffer>;
  90968. instancesData: Float32Array;
  90969. overridenInstanceCount: number;
  90970. isFrozen: boolean;
  90971. previousBatch: Nullable<_InstancesBatch>;
  90972. hardwareInstancedRendering: boolean;
  90973. sideOrientation: number;
  90974. }
  90975. /**
  90976. * @hidden
  90977. **/
  90978. export class _InstancesBatch {
  90979. mustReturn: boolean;
  90980. visibleInstances: Nullable<InstancedMesh[]>[];
  90981. renderSelf: boolean[];
  90982. hardwareInstancedRendering: boolean[];
  90983. }
  90984. /**
  90985. * Class used to represent renderable models
  90986. */
  90987. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90988. /**
  90989. * Mesh side orientation : usually the external or front surface
  90990. */
  90991. static readonly FRONTSIDE: number;
  90992. /**
  90993. * Mesh side orientation : usually the internal or back surface
  90994. */
  90995. static readonly BACKSIDE: number;
  90996. /**
  90997. * Mesh side orientation : both internal and external or front and back surfaces
  90998. */
  90999. static readonly DOUBLESIDE: number;
  91000. /**
  91001. * Mesh side orientation : by default, `FRONTSIDE`
  91002. */
  91003. static readonly DEFAULTSIDE: number;
  91004. /**
  91005. * Mesh cap setting : no cap
  91006. */
  91007. static readonly NO_CAP: number;
  91008. /**
  91009. * Mesh cap setting : one cap at the beginning of the mesh
  91010. */
  91011. static readonly CAP_START: number;
  91012. /**
  91013. * Mesh cap setting : one cap at the end of the mesh
  91014. */
  91015. static readonly CAP_END: number;
  91016. /**
  91017. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91018. */
  91019. static readonly CAP_ALL: number;
  91020. /**
  91021. * Mesh pattern setting : no flip or rotate
  91022. */
  91023. static readonly NO_FLIP: number;
  91024. /**
  91025. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91026. */
  91027. static readonly FLIP_TILE: number;
  91028. /**
  91029. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91030. */
  91031. static readonly ROTATE_TILE: number;
  91032. /**
  91033. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91034. */
  91035. static readonly FLIP_ROW: number;
  91036. /**
  91037. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91038. */
  91039. static readonly ROTATE_ROW: number;
  91040. /**
  91041. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91042. */
  91043. static readonly FLIP_N_ROTATE_TILE: number;
  91044. /**
  91045. * Mesh pattern setting : rotate pattern and rotate
  91046. */
  91047. static readonly FLIP_N_ROTATE_ROW: number;
  91048. /**
  91049. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91050. */
  91051. static readonly CENTER: number;
  91052. /**
  91053. * Mesh tile positioning : part tiles on left
  91054. */
  91055. static readonly LEFT: number;
  91056. /**
  91057. * Mesh tile positioning : part tiles on right
  91058. */
  91059. static readonly RIGHT: number;
  91060. /**
  91061. * Mesh tile positioning : part tiles on top
  91062. */
  91063. static readonly TOP: number;
  91064. /**
  91065. * Mesh tile positioning : part tiles on bottom
  91066. */
  91067. static readonly BOTTOM: number;
  91068. /**
  91069. * Gets the default side orientation.
  91070. * @param orientation the orientation to value to attempt to get
  91071. * @returns the default orientation
  91072. * @hidden
  91073. */
  91074. static _GetDefaultSideOrientation(orientation?: number): number;
  91075. private _internalMeshDataInfo;
  91076. /**
  91077. * An event triggered before rendering the mesh
  91078. */
  91079. readonly onBeforeRenderObservable: Observable<Mesh>;
  91080. /**
  91081. * An event triggered before binding the mesh
  91082. */
  91083. readonly onBeforeBindObservable: Observable<Mesh>;
  91084. /**
  91085. * An event triggered after rendering the mesh
  91086. */
  91087. readonly onAfterRenderObservable: Observable<Mesh>;
  91088. /**
  91089. * An event triggered before drawing the mesh
  91090. */
  91091. readonly onBeforeDrawObservable: Observable<Mesh>;
  91092. private _onBeforeDrawObserver;
  91093. /**
  91094. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91095. */
  91096. onBeforeDraw: () => void;
  91097. readonly hasInstances: boolean;
  91098. /**
  91099. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91100. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91101. */
  91102. delayLoadState: number;
  91103. /**
  91104. * Gets the list of instances created from this mesh
  91105. * it is not supposed to be modified manually.
  91106. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91107. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91108. */
  91109. instances: InstancedMesh[];
  91110. /**
  91111. * Gets the file containing delay loading data for this mesh
  91112. */
  91113. delayLoadingFile: string;
  91114. /** @hidden */
  91115. _binaryInfo: any;
  91116. /**
  91117. * User defined function used to change how LOD level selection is done
  91118. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91119. */
  91120. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91121. /**
  91122. * Gets or sets the morph target manager
  91123. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91124. */
  91125. morphTargetManager: Nullable<MorphTargetManager>;
  91126. /** @hidden */
  91127. _creationDataStorage: Nullable<_CreationDataStorage>;
  91128. /** @hidden */
  91129. _geometry: Nullable<Geometry>;
  91130. /** @hidden */
  91131. _delayInfo: Array<string>;
  91132. /** @hidden */
  91133. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91134. /** @hidden */
  91135. _instanceDataStorage: _InstanceDataStorage;
  91136. private _effectiveMaterial;
  91137. /** @hidden */
  91138. _shouldGenerateFlatShading: boolean;
  91139. /** @hidden */
  91140. _originalBuilderSideOrientation: number;
  91141. /**
  91142. * Use this property to change the original side orientation defined at construction time
  91143. */
  91144. overrideMaterialSideOrientation: Nullable<number>;
  91145. /**
  91146. * Gets the source mesh (the one used to clone this one from)
  91147. */
  91148. readonly source: Nullable<Mesh>;
  91149. /**
  91150. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91151. */
  91152. isUnIndexed: boolean;
  91153. /**
  91154. * @constructor
  91155. * @param name The value used by scene.getMeshByName() to do a lookup.
  91156. * @param scene The scene to add this mesh to.
  91157. * @param parent The parent of this mesh, if it has one
  91158. * @param source An optional Mesh from which geometry is shared, cloned.
  91159. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91160. * When false, achieved by calling a clone(), also passing False.
  91161. * This will make creation of children, recursive.
  91162. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91163. */
  91164. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91165. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  91166. /**
  91167. * Gets the class name
  91168. * @returns the string "Mesh".
  91169. */
  91170. getClassName(): string;
  91171. /** @hidden */
  91172. readonly _isMesh: boolean;
  91173. /**
  91174. * Returns a description of this mesh
  91175. * @param fullDetails define if full details about this mesh must be used
  91176. * @returns a descriptive string representing this mesh
  91177. */
  91178. toString(fullDetails?: boolean): string;
  91179. /** @hidden */
  91180. _unBindEffect(): void;
  91181. /**
  91182. * Gets a boolean indicating if this mesh has LOD
  91183. */
  91184. readonly hasLODLevels: boolean;
  91185. /**
  91186. * Gets the list of MeshLODLevel associated with the current mesh
  91187. * @returns an array of MeshLODLevel
  91188. */
  91189. getLODLevels(): MeshLODLevel[];
  91190. private _sortLODLevels;
  91191. /**
  91192. * Add a mesh as LOD level triggered at the given distance.
  91193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91194. * @param distance The distance from the center of the object to show this level
  91195. * @param mesh The mesh to be added as LOD level (can be null)
  91196. * @return This mesh (for chaining)
  91197. */
  91198. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91199. /**
  91200. * Returns the LOD level mesh at the passed distance or null if not found.
  91201. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91202. * @param distance The distance from the center of the object to show this level
  91203. * @returns a Mesh or `null`
  91204. */
  91205. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91206. /**
  91207. * Remove a mesh from the LOD array
  91208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91209. * @param mesh defines the mesh to be removed
  91210. * @return This mesh (for chaining)
  91211. */
  91212. removeLODLevel(mesh: Mesh): Mesh;
  91213. /**
  91214. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91215. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91216. * @param camera defines the camera to use to compute distance
  91217. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91218. * @return This mesh (for chaining)
  91219. */
  91220. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91221. /**
  91222. * Gets the mesh internal Geometry object
  91223. */
  91224. readonly geometry: Nullable<Geometry>;
  91225. /**
  91226. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91227. * @returns the total number of vertices
  91228. */
  91229. getTotalVertices(): number;
  91230. /**
  91231. * Returns the content of an associated vertex buffer
  91232. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91233. * - VertexBuffer.PositionKind
  91234. * - VertexBuffer.UVKind
  91235. * - VertexBuffer.UV2Kind
  91236. * - VertexBuffer.UV3Kind
  91237. * - VertexBuffer.UV4Kind
  91238. * - VertexBuffer.UV5Kind
  91239. * - VertexBuffer.UV6Kind
  91240. * - VertexBuffer.ColorKind
  91241. * - VertexBuffer.MatricesIndicesKind
  91242. * - VertexBuffer.MatricesIndicesExtraKind
  91243. * - VertexBuffer.MatricesWeightsKind
  91244. * - VertexBuffer.MatricesWeightsExtraKind
  91245. * @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
  91246. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91247. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91248. */
  91249. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91250. /**
  91251. * Returns the mesh VertexBuffer object from the requested `kind`
  91252. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91253. * - VertexBuffer.PositionKind
  91254. * - VertexBuffer.NormalKind
  91255. * - VertexBuffer.UVKind
  91256. * - VertexBuffer.UV2Kind
  91257. * - VertexBuffer.UV3Kind
  91258. * - VertexBuffer.UV4Kind
  91259. * - VertexBuffer.UV5Kind
  91260. * - VertexBuffer.UV6Kind
  91261. * - VertexBuffer.ColorKind
  91262. * - VertexBuffer.MatricesIndicesKind
  91263. * - VertexBuffer.MatricesIndicesExtraKind
  91264. * - VertexBuffer.MatricesWeightsKind
  91265. * - VertexBuffer.MatricesWeightsExtraKind
  91266. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91267. */
  91268. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91269. /**
  91270. * Tests if a specific vertex buffer is associated with this mesh
  91271. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91272. * - VertexBuffer.PositionKind
  91273. * - VertexBuffer.NormalKind
  91274. * - VertexBuffer.UVKind
  91275. * - VertexBuffer.UV2Kind
  91276. * - VertexBuffer.UV3Kind
  91277. * - VertexBuffer.UV4Kind
  91278. * - VertexBuffer.UV5Kind
  91279. * - VertexBuffer.UV6Kind
  91280. * - VertexBuffer.ColorKind
  91281. * - VertexBuffer.MatricesIndicesKind
  91282. * - VertexBuffer.MatricesIndicesExtraKind
  91283. * - VertexBuffer.MatricesWeightsKind
  91284. * - VertexBuffer.MatricesWeightsExtraKind
  91285. * @returns a boolean
  91286. */
  91287. isVerticesDataPresent(kind: string): boolean;
  91288. /**
  91289. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91290. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91291. * - VertexBuffer.PositionKind
  91292. * - VertexBuffer.UVKind
  91293. * - VertexBuffer.UV2Kind
  91294. * - VertexBuffer.UV3Kind
  91295. * - VertexBuffer.UV4Kind
  91296. * - VertexBuffer.UV5Kind
  91297. * - VertexBuffer.UV6Kind
  91298. * - VertexBuffer.ColorKind
  91299. * - VertexBuffer.MatricesIndicesKind
  91300. * - VertexBuffer.MatricesIndicesExtraKind
  91301. * - VertexBuffer.MatricesWeightsKind
  91302. * - VertexBuffer.MatricesWeightsExtraKind
  91303. * @returns a boolean
  91304. */
  91305. isVertexBufferUpdatable(kind: string): boolean;
  91306. /**
  91307. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91308. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91309. * - VertexBuffer.PositionKind
  91310. * - VertexBuffer.NormalKind
  91311. * - VertexBuffer.UVKind
  91312. * - VertexBuffer.UV2Kind
  91313. * - VertexBuffer.UV3Kind
  91314. * - VertexBuffer.UV4Kind
  91315. * - VertexBuffer.UV5Kind
  91316. * - VertexBuffer.UV6Kind
  91317. * - VertexBuffer.ColorKind
  91318. * - VertexBuffer.MatricesIndicesKind
  91319. * - VertexBuffer.MatricesIndicesExtraKind
  91320. * - VertexBuffer.MatricesWeightsKind
  91321. * - VertexBuffer.MatricesWeightsExtraKind
  91322. * @returns an array of strings
  91323. */
  91324. getVerticesDataKinds(): string[];
  91325. /**
  91326. * Returns a positive integer : the total number of indices in this mesh geometry.
  91327. * @returns the numner of indices or zero if the mesh has no geometry.
  91328. */
  91329. getTotalIndices(): number;
  91330. /**
  91331. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91332. * @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.
  91333. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91334. * @returns the indices array or an empty array if the mesh has no geometry
  91335. */
  91336. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91337. readonly isBlocked: boolean;
  91338. /**
  91339. * Determine if the current mesh is ready to be rendered
  91340. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91341. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91342. * @returns true if all associated assets are ready (material, textures, shaders)
  91343. */
  91344. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91345. /**
  91346. * 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.
  91347. */
  91348. readonly areNormalsFrozen: boolean;
  91349. /**
  91350. * 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.
  91351. * @returns the current mesh
  91352. */
  91353. freezeNormals(): Mesh;
  91354. /**
  91355. * 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
  91356. * @returns the current mesh
  91357. */
  91358. unfreezeNormals(): Mesh;
  91359. /**
  91360. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91361. */
  91362. overridenInstanceCount: number;
  91363. /** @hidden */
  91364. _preActivate(): Mesh;
  91365. /** @hidden */
  91366. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91367. /** @hidden */
  91368. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91369. /**
  91370. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91371. * This means the mesh underlying bounding box and sphere are recomputed.
  91372. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91373. * @returns the current mesh
  91374. */
  91375. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91376. /** @hidden */
  91377. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91378. /**
  91379. * This function will subdivide the mesh into multiple submeshes
  91380. * @param count defines the expected number of submeshes
  91381. */
  91382. subdivide(count: number): void;
  91383. /**
  91384. * Copy a FloatArray into a specific associated vertex buffer
  91385. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91386. * - VertexBuffer.PositionKind
  91387. * - VertexBuffer.UVKind
  91388. * - VertexBuffer.UV2Kind
  91389. * - VertexBuffer.UV3Kind
  91390. * - VertexBuffer.UV4Kind
  91391. * - VertexBuffer.UV5Kind
  91392. * - VertexBuffer.UV6Kind
  91393. * - VertexBuffer.ColorKind
  91394. * - VertexBuffer.MatricesIndicesKind
  91395. * - VertexBuffer.MatricesIndicesExtraKind
  91396. * - VertexBuffer.MatricesWeightsKind
  91397. * - VertexBuffer.MatricesWeightsExtraKind
  91398. * @param data defines the data source
  91399. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91400. * @param stride defines the data stride size (can be null)
  91401. * @returns the current mesh
  91402. */
  91403. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91404. /**
  91405. * Delete a vertex buffer associated with this mesh
  91406. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91407. * - VertexBuffer.PositionKind
  91408. * - VertexBuffer.UVKind
  91409. * - VertexBuffer.UV2Kind
  91410. * - VertexBuffer.UV3Kind
  91411. * - VertexBuffer.UV4Kind
  91412. * - VertexBuffer.UV5Kind
  91413. * - VertexBuffer.UV6Kind
  91414. * - VertexBuffer.ColorKind
  91415. * - VertexBuffer.MatricesIndicesKind
  91416. * - VertexBuffer.MatricesIndicesExtraKind
  91417. * - VertexBuffer.MatricesWeightsKind
  91418. * - VertexBuffer.MatricesWeightsExtraKind
  91419. */
  91420. removeVerticesData(kind: string): void;
  91421. /**
  91422. * Flags an associated vertex buffer as updatable
  91423. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91424. * - VertexBuffer.PositionKind
  91425. * - VertexBuffer.UVKind
  91426. * - VertexBuffer.UV2Kind
  91427. * - VertexBuffer.UV3Kind
  91428. * - VertexBuffer.UV4Kind
  91429. * - VertexBuffer.UV5Kind
  91430. * - VertexBuffer.UV6Kind
  91431. * - VertexBuffer.ColorKind
  91432. * - VertexBuffer.MatricesIndicesKind
  91433. * - VertexBuffer.MatricesIndicesExtraKind
  91434. * - VertexBuffer.MatricesWeightsKind
  91435. * - VertexBuffer.MatricesWeightsExtraKind
  91436. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91437. */
  91438. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91439. /**
  91440. * Sets the mesh global Vertex Buffer
  91441. * @param buffer defines the buffer to use
  91442. * @returns the current mesh
  91443. */
  91444. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91445. /**
  91446. * Update a specific associated vertex buffer
  91447. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91448. * - VertexBuffer.PositionKind
  91449. * - VertexBuffer.UVKind
  91450. * - VertexBuffer.UV2Kind
  91451. * - VertexBuffer.UV3Kind
  91452. * - VertexBuffer.UV4Kind
  91453. * - VertexBuffer.UV5Kind
  91454. * - VertexBuffer.UV6Kind
  91455. * - VertexBuffer.ColorKind
  91456. * - VertexBuffer.MatricesIndicesKind
  91457. * - VertexBuffer.MatricesIndicesExtraKind
  91458. * - VertexBuffer.MatricesWeightsKind
  91459. * - VertexBuffer.MatricesWeightsExtraKind
  91460. * @param data defines the data source
  91461. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91462. * @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)
  91463. * @returns the current mesh
  91464. */
  91465. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91466. /**
  91467. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91468. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91469. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91470. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91471. * @returns the current mesh
  91472. */
  91473. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91474. /**
  91475. * Creates a un-shared specific occurence of the geometry for the mesh.
  91476. * @returns the current mesh
  91477. */
  91478. makeGeometryUnique(): Mesh;
  91479. /**
  91480. * Set the index buffer of this mesh
  91481. * @param indices defines the source data
  91482. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91483. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91484. * @returns the current mesh
  91485. */
  91486. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91487. /**
  91488. * Update the current index buffer
  91489. * @param indices defines the source data
  91490. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91491. * @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)
  91492. * @returns the current mesh
  91493. */
  91494. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91495. /**
  91496. * Invert the geometry to move from a right handed system to a left handed one.
  91497. * @returns the current mesh
  91498. */
  91499. toLeftHanded(): Mesh;
  91500. /** @hidden */
  91501. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91502. /** @hidden */
  91503. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91504. /**
  91505. * Registers for this mesh a javascript function called just before the rendering process
  91506. * @param func defines the function to call before rendering this mesh
  91507. * @returns the current mesh
  91508. */
  91509. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91510. /**
  91511. * Disposes a previously registered javascript function called before the rendering
  91512. * @param func defines the function to remove
  91513. * @returns the current mesh
  91514. */
  91515. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91516. /**
  91517. * Registers for this mesh a javascript function called just after the rendering is complete
  91518. * @param func defines the function to call after rendering this mesh
  91519. * @returns the current mesh
  91520. */
  91521. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91522. /**
  91523. * Disposes a previously registered javascript function called after the rendering.
  91524. * @param func defines the function to remove
  91525. * @returns the current mesh
  91526. */
  91527. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91528. /** @hidden */
  91529. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91530. /** @hidden */
  91531. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91532. /** @hidden */
  91533. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91534. /** @hidden */
  91535. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91536. /** @hidden */
  91537. _rebuild(): void;
  91538. /** @hidden */
  91539. _freeze(): void;
  91540. /** @hidden */
  91541. _unFreeze(): void;
  91542. /**
  91543. * 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
  91544. * @param subMesh defines the subMesh to render
  91545. * @param enableAlphaMode defines if alpha mode can be changed
  91546. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91547. * @returns the current mesh
  91548. */
  91549. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91550. private _onBeforeDraw;
  91551. /**
  91552. * Renormalize the mesh and patch it up if there are no weights
  91553. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91554. * However in the case of zero weights then we set just a single influence to 1.
  91555. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91556. */
  91557. cleanMatrixWeights(): void;
  91558. private normalizeSkinFourWeights;
  91559. private normalizeSkinWeightsAndExtra;
  91560. /**
  91561. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91562. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91563. * the user know there was an issue with importing the mesh
  91564. * @returns a validation object with skinned, valid and report string
  91565. */
  91566. validateSkinning(): {
  91567. skinned: boolean;
  91568. valid: boolean;
  91569. report: string;
  91570. };
  91571. /** @hidden */
  91572. _checkDelayState(): Mesh;
  91573. private _queueLoad;
  91574. /**
  91575. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91576. * A mesh is in the frustum if its bounding box intersects the frustum
  91577. * @param frustumPlanes defines the frustum to test
  91578. * @returns true if the mesh is in the frustum planes
  91579. */
  91580. isInFrustum(frustumPlanes: Plane[]): boolean;
  91581. /**
  91582. * Sets the mesh material by the material or multiMaterial `id` property
  91583. * @param id is a string identifying the material or the multiMaterial
  91584. * @returns the current mesh
  91585. */
  91586. setMaterialByID(id: string): Mesh;
  91587. /**
  91588. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91589. * @returns an array of IAnimatable
  91590. */
  91591. getAnimatables(): IAnimatable[];
  91592. /**
  91593. * Modifies the mesh geometry according to the passed transformation matrix.
  91594. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91595. * The mesh normals are modified using the same transformation.
  91596. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91597. * @param transform defines the transform matrix to use
  91598. * @see http://doc.babylonjs.com/resources/baking_transformations
  91599. * @returns the current mesh
  91600. */
  91601. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91602. /**
  91603. * Modifies the mesh geometry according to its own current World Matrix.
  91604. * The mesh World Matrix is then reset.
  91605. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91606. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91607. * @see http://doc.babylonjs.com/resources/baking_transformations
  91608. * @returns the current mesh
  91609. */
  91610. bakeCurrentTransformIntoVertices(): Mesh;
  91611. /** @hidden */
  91612. readonly _positions: Nullable<Vector3[]>;
  91613. /** @hidden */
  91614. _resetPointsArrayCache(): Mesh;
  91615. /** @hidden */
  91616. _generatePointsArray(): boolean;
  91617. /**
  91618. * Returns a new Mesh object generated from the current mesh properties.
  91619. * This method must not get confused with createInstance()
  91620. * @param name is a string, the name given to the new mesh
  91621. * @param newParent can be any Node object (default `null`)
  91622. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91623. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91624. * @returns a new mesh
  91625. */
  91626. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91627. /**
  91628. * Releases resources associated with this mesh.
  91629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91631. */
  91632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91633. /** @hidden */
  91634. _disposeInstanceSpecificData(): void;
  91635. /**
  91636. * Modifies the mesh geometry according to a displacement map.
  91637. * 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.
  91638. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91639. * @param url is a string, the URL from the image file is to be downloaded.
  91640. * @param minHeight is the lower limit of the displacement.
  91641. * @param maxHeight is the upper limit of the displacement.
  91642. * @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.
  91643. * @param uvOffset is an optional vector2 used to offset UV.
  91644. * @param uvScale is an optional vector2 used to scale UV.
  91645. * @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.
  91646. * @returns the Mesh.
  91647. */
  91648. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91649. /**
  91650. * Modifies the mesh geometry according to a displacementMap buffer.
  91651. * 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.
  91652. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91653. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91654. * @param heightMapWidth is the width of the buffer image.
  91655. * @param heightMapHeight is the height of the buffer image.
  91656. * @param minHeight is the lower limit of the displacement.
  91657. * @param maxHeight is the upper limit of the displacement.
  91658. * @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.
  91659. * @param uvOffset is an optional vector2 used to offset UV.
  91660. * @param uvScale is an optional vector2 used to scale UV.
  91661. * @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.
  91662. * @returns the Mesh.
  91663. */
  91664. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91665. /**
  91666. * Modify the mesh to get a flat shading rendering.
  91667. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91668. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91669. * @returns current mesh
  91670. */
  91671. convertToFlatShadedMesh(): Mesh;
  91672. /**
  91673. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91674. * In other words, more vertices, no more indices and a single bigger VBO.
  91675. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91676. * @returns current mesh
  91677. */
  91678. convertToUnIndexedMesh(): Mesh;
  91679. /**
  91680. * Inverses facet orientations.
  91681. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91682. * @param flipNormals will also inverts the normals
  91683. * @returns current mesh
  91684. */
  91685. flipFaces(flipNormals?: boolean): Mesh;
  91686. /**
  91687. * Increase the number of facets and hence vertices in a mesh
  91688. * Vertex normals are interpolated from existing vertex normals
  91689. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91690. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91691. */
  91692. increaseVertices(numberPerEdge: number): void;
  91693. /**
  91694. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91695. * This will undo any application of covertToFlatShadedMesh
  91696. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91697. */
  91698. forceSharedVertices(): void;
  91699. /** @hidden */
  91700. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91701. /** @hidden */
  91702. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91703. /**
  91704. * Creates a new InstancedMesh object from the mesh model.
  91705. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91706. * @param name defines the name of the new instance
  91707. * @returns a new InstancedMesh
  91708. */
  91709. createInstance(name: string): InstancedMesh;
  91710. /**
  91711. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91712. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91713. * @returns the current mesh
  91714. */
  91715. synchronizeInstances(): Mesh;
  91716. /**
  91717. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91718. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91719. * This should be used together with the simplification to avoid disappearing triangles.
  91720. * @param successCallback an optional success callback to be called after the optimization finished.
  91721. * @returns the current mesh
  91722. */
  91723. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91724. /**
  91725. * Serialize current mesh
  91726. * @param serializationObject defines the object which will receive the serialization data
  91727. */
  91728. serialize(serializationObject: any): void;
  91729. /** @hidden */
  91730. _syncGeometryWithMorphTargetManager(): void;
  91731. /** @hidden */
  91732. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91733. /**
  91734. * Returns a new Mesh object parsed from the source provided.
  91735. * @param parsedMesh is the source
  91736. * @param scene defines the hosting scene
  91737. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91738. * @returns a new Mesh
  91739. */
  91740. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91741. /**
  91742. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91744. * @param name defines the name of the mesh to create
  91745. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91746. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91747. * @param closePath creates a seam between the first and the last points of each path of the path array
  91748. * @param offset is taken in account only if the `pathArray` is containing a single path
  91749. * @param scene defines the hosting scene
  91750. * @param updatable defines if the mesh must be flagged as updatable
  91751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91752. * @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)
  91753. * @returns a new Mesh
  91754. */
  91755. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91756. /**
  91757. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91758. * @param name defines the name of the mesh to create
  91759. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91760. * @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
  91761. * @param scene defines the hosting scene
  91762. * @param updatable defines if the mesh must be flagged as updatable
  91763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91764. * @returns a new Mesh
  91765. */
  91766. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91767. /**
  91768. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91769. * @param name defines the name of the mesh to create
  91770. * @param size sets the size (float) of each box side (default 1)
  91771. * @param scene defines the hosting scene
  91772. * @param updatable defines if the mesh must be flagged as updatable
  91773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91774. * @returns a new Mesh
  91775. */
  91776. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91777. /**
  91778. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91779. * @param name defines the name of the mesh to create
  91780. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91781. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91782. * @param scene defines the hosting scene
  91783. * @param updatable defines if the mesh must be flagged as updatable
  91784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91785. * @returns a new Mesh
  91786. */
  91787. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91788. /**
  91789. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91790. * @param name defines the name of the mesh to create
  91791. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91792. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91793. * @param scene defines the hosting scene
  91794. * @returns a new Mesh
  91795. */
  91796. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91797. /**
  91798. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91799. * @param name defines the name of the mesh to create
  91800. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91801. * @param diameterTop set the top cap diameter (floats, default 1)
  91802. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91803. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91804. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91805. * @param scene defines the hosting scene
  91806. * @param updatable defines if the mesh must be flagged as updatable
  91807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91808. * @returns a new Mesh
  91809. */
  91810. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91811. /**
  91812. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91813. * @param name defines the name of the mesh to create
  91814. * @param diameter sets the diameter size (float) of the torus (default 1)
  91815. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91816. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91817. * @param scene defines the hosting scene
  91818. * @param updatable defines if the mesh must be flagged as updatable
  91819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91820. * @returns a new Mesh
  91821. */
  91822. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91823. /**
  91824. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91825. * @param name defines the name of the mesh to create
  91826. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91827. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91828. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91829. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91830. * @param p the number of windings on X axis (positive integers, default 2)
  91831. * @param q the number of windings on Y axis (positive integers, default 3)
  91832. * @param scene defines the hosting scene
  91833. * @param updatable defines if the mesh must be flagged as updatable
  91834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91835. * @returns a new Mesh
  91836. */
  91837. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91838. /**
  91839. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91840. * @param name defines the name of the mesh to create
  91841. * @param points is an array successive Vector3
  91842. * @param scene defines the hosting scene
  91843. * @param updatable defines if the mesh must be flagged as updatable
  91844. * @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).
  91845. * @returns a new Mesh
  91846. */
  91847. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91848. /**
  91849. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91850. * @param name defines the name of the mesh to create
  91851. * @param points is an array successive Vector3
  91852. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91853. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91854. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91855. * @param scene defines the hosting scene
  91856. * @param updatable defines if the mesh must be flagged as updatable
  91857. * @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)
  91858. * @returns a new Mesh
  91859. */
  91860. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91861. /**
  91862. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91863. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91864. * 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.
  91865. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91866. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91867. * Remember you can only change the shape positions, not their number when updating a polygon.
  91868. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91869. * @param name defines the name of the mesh to create
  91870. * @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
  91871. * @param scene defines the hosting scene
  91872. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91873. * @param updatable defines if the mesh must be flagged as updatable
  91874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91875. * @param earcutInjection can be used to inject your own earcut reference
  91876. * @returns a new Mesh
  91877. */
  91878. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91879. /**
  91880. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91881. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91882. * @param name defines the name of the mesh to create
  91883. * @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
  91884. * @param depth defines the height of extrusion
  91885. * @param scene defines the hosting scene
  91886. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91887. * @param updatable defines if the mesh must be flagged as updatable
  91888. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91889. * @param earcutInjection can be used to inject your own earcut reference
  91890. * @returns a new Mesh
  91891. */
  91892. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91893. /**
  91894. * Creates an extruded shape mesh.
  91895. * 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
  91896. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91897. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91898. * @param name defines the name of the mesh to create
  91899. * @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
  91900. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91901. * @param scale is the value to scale the shape
  91902. * @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
  91903. * @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
  91904. * @param scene defines the hosting scene
  91905. * @param updatable defines if the mesh must be flagged as updatable
  91906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91907. * @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)
  91908. * @returns a new Mesh
  91909. */
  91910. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91911. /**
  91912. * Creates an custom extruded shape mesh.
  91913. * The custom extrusion is a parametric shape.
  91914. * It has no predefined shape. Its final shape will depend on the input parameters.
  91915. * Please consider using the same method from the MeshBuilder class instead
  91916. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91917. * @param name defines the name of the mesh to create
  91918. * @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
  91919. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91920. * @param scaleFunction is a custom Javascript function called on each path point
  91921. * @param rotationFunction is a custom Javascript function called on each path point
  91922. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91923. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91924. * @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
  91925. * @param scene defines the hosting scene
  91926. * @param updatable defines if the mesh must be flagged as updatable
  91927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91928. * @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)
  91929. * @returns a new Mesh
  91930. */
  91931. 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;
  91932. /**
  91933. * Creates lathe mesh.
  91934. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91935. * Please consider using the same method from the MeshBuilder class instead
  91936. * @param name defines the name of the mesh to create
  91937. * @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
  91938. * @param radius is the radius value of the lathe
  91939. * @param tessellation is the side number of the lathe.
  91940. * @param scene defines the hosting scene
  91941. * @param updatable defines if the mesh must be flagged as updatable
  91942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91943. * @returns a new Mesh
  91944. */
  91945. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91946. /**
  91947. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91948. * @param name defines the name of the mesh to create
  91949. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91950. * @param scene defines the hosting scene
  91951. * @param updatable defines if the mesh must be flagged as updatable
  91952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91953. * @returns a new Mesh
  91954. */
  91955. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91956. /**
  91957. * Creates a ground mesh.
  91958. * Please consider using the same method from the MeshBuilder class instead
  91959. * @param name defines the name of the mesh to create
  91960. * @param width set the width of the ground
  91961. * @param height set the height of the ground
  91962. * @param subdivisions sets the number of subdivisions per side
  91963. * @param scene defines the hosting scene
  91964. * @param updatable defines if the mesh must be flagged as updatable
  91965. * @returns a new Mesh
  91966. */
  91967. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91968. /**
  91969. * Creates a tiled ground mesh.
  91970. * Please consider using the same method from the MeshBuilder class instead
  91971. * @param name defines the name of the mesh to create
  91972. * @param xmin set the ground minimum X coordinate
  91973. * @param zmin set the ground minimum Y coordinate
  91974. * @param xmax set the ground maximum X coordinate
  91975. * @param zmax set the ground maximum Z coordinate
  91976. * @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
  91977. * @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
  91978. * @param scene defines the hosting scene
  91979. * @param updatable defines if the mesh must be flagged as updatable
  91980. * @returns a new Mesh
  91981. */
  91982. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91983. w: number;
  91984. h: number;
  91985. }, precision: {
  91986. w: number;
  91987. h: number;
  91988. }, scene: Scene, updatable?: boolean): Mesh;
  91989. /**
  91990. * Creates a ground mesh from a height map.
  91991. * Please consider using the same method from the MeshBuilder class instead
  91992. * @see http://doc.babylonjs.com/babylon101/height_map
  91993. * @param name defines the name of the mesh to create
  91994. * @param url sets the URL of the height map image resource
  91995. * @param width set the ground width size
  91996. * @param height set the ground height size
  91997. * @param subdivisions sets the number of subdivision per side
  91998. * @param minHeight is the minimum altitude on the ground
  91999. * @param maxHeight is the maximum altitude on the ground
  92000. * @param scene defines the hosting scene
  92001. * @param updatable defines if the mesh must be flagged as updatable
  92002. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92003. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92004. * @returns a new Mesh
  92005. */
  92006. 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;
  92007. /**
  92008. * Creates a tube mesh.
  92009. * The tube is a parametric shape.
  92010. * It has no predefined shape. Its final shape will depend on the input parameters.
  92011. * Please consider using the same method from the MeshBuilder class instead
  92012. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92013. * @param name defines the name of the mesh to create
  92014. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92015. * @param radius sets the tube radius size
  92016. * @param tessellation is the number of sides on the tubular surface
  92017. * @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
  92018. * @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
  92019. * @param scene defines the hosting scene
  92020. * @param updatable defines if the mesh must be flagged as updatable
  92021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92022. * @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)
  92023. * @returns a new Mesh
  92024. */
  92025. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92026. (i: number, distance: number): number;
  92027. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92028. /**
  92029. * Creates a polyhedron mesh.
  92030. * Please consider using the same method from the MeshBuilder class instead.
  92031. * * 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
  92032. * * The parameter `size` (positive float, default 1) sets the polygon size
  92033. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92034. * * 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`
  92035. * * 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
  92036. * * 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)`)
  92037. * * 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
  92038. * * 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
  92039. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92040. * * If you create a double-sided mesh, you can choose what parts of 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
  92041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92042. * @param name defines the name of the mesh to create
  92043. * @param options defines the options used to create the mesh
  92044. * @param scene defines the hosting scene
  92045. * @returns a new Mesh
  92046. */
  92047. static CreatePolyhedron(name: string, options: {
  92048. type?: number;
  92049. size?: number;
  92050. sizeX?: number;
  92051. sizeY?: number;
  92052. sizeZ?: number;
  92053. custom?: any;
  92054. faceUV?: Vector4[];
  92055. faceColors?: Color4[];
  92056. updatable?: boolean;
  92057. sideOrientation?: number;
  92058. }, scene: Scene): Mesh;
  92059. /**
  92060. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92061. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92062. * * 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`)
  92063. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92064. * * 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
  92065. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92066. * * If you create a double-sided mesh, you can choose what parts of 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
  92067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92068. * @param name defines the name of the mesh
  92069. * @param options defines the options used to create the mesh
  92070. * @param scene defines the hosting scene
  92071. * @returns a new Mesh
  92072. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92073. */
  92074. static CreateIcoSphere(name: string, options: {
  92075. radius?: number;
  92076. flat?: boolean;
  92077. subdivisions?: number;
  92078. sideOrientation?: number;
  92079. updatable?: boolean;
  92080. }, scene: Scene): Mesh;
  92081. /**
  92082. * Creates a decal mesh.
  92083. * Please consider using the same method from the MeshBuilder class instead.
  92084. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92085. * @param name defines the name of the mesh
  92086. * @param sourceMesh defines the mesh receiving the decal
  92087. * @param position sets the position of the decal in world coordinates
  92088. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92089. * @param size sets the decal scaling
  92090. * @param angle sets the angle to rotate the decal
  92091. * @returns a new Mesh
  92092. */
  92093. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92094. /**
  92095. * Prepare internal position array for software CPU skinning
  92096. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92097. */
  92098. setPositionsForCPUSkinning(): Float32Array;
  92099. /**
  92100. * Prepare internal normal array for software CPU skinning
  92101. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92102. */
  92103. setNormalsForCPUSkinning(): Float32Array;
  92104. /**
  92105. * Updates the vertex buffer by applying transformation from the bones
  92106. * @param skeleton defines the skeleton to apply to current mesh
  92107. * @returns the current mesh
  92108. */
  92109. applySkeleton(skeleton: Skeleton): Mesh;
  92110. /**
  92111. * 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
  92112. * @param meshes defines the list of meshes to scan
  92113. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92114. */
  92115. static MinMax(meshes: AbstractMesh[]): {
  92116. min: Vector3;
  92117. max: Vector3;
  92118. };
  92119. /**
  92120. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92121. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92122. * @returns a vector3
  92123. */
  92124. static Center(meshesOrMinMaxVector: {
  92125. min: Vector3;
  92126. max: Vector3;
  92127. } | AbstractMesh[]): Vector3;
  92128. /**
  92129. * Merge the array of meshes into a single mesh for performance reasons.
  92130. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92131. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92132. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92133. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92134. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92135. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92136. * @returns a new mesh
  92137. */
  92138. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92139. /** @hidden */
  92140. addInstance(instance: InstancedMesh): void;
  92141. /** @hidden */
  92142. removeInstance(instance: InstancedMesh): void;
  92143. }
  92144. }
  92145. declare module BABYLON {
  92146. /**
  92147. * This is the base class of all the camera used in the application.
  92148. * @see http://doc.babylonjs.com/features/cameras
  92149. */
  92150. export class Camera extends Node {
  92151. /** @hidden */
  92152. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92153. /**
  92154. * This is the default projection mode used by the cameras.
  92155. * It helps recreating a feeling of perspective and better appreciate depth.
  92156. * This is the best way to simulate real life cameras.
  92157. */
  92158. static readonly PERSPECTIVE_CAMERA: number;
  92159. /**
  92160. * This helps creating camera with an orthographic mode.
  92161. * 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.
  92162. */
  92163. static readonly ORTHOGRAPHIC_CAMERA: number;
  92164. /**
  92165. * This is the default FOV mode for perspective cameras.
  92166. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92167. */
  92168. static readonly FOVMODE_VERTICAL_FIXED: number;
  92169. /**
  92170. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92171. */
  92172. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92173. /**
  92174. * This specifies ther is no need for a camera rig.
  92175. * Basically only one eye is rendered corresponding to the camera.
  92176. */
  92177. static readonly RIG_MODE_NONE: number;
  92178. /**
  92179. * Simulates a camera Rig with one blue eye and one red eye.
  92180. * This can be use with 3d blue and red glasses.
  92181. */
  92182. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92183. /**
  92184. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92185. */
  92186. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92187. /**
  92188. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92189. */
  92190. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92191. /**
  92192. * Defines that both eyes of the camera will be rendered over under each other.
  92193. */
  92194. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92195. /**
  92196. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92197. */
  92198. static readonly RIG_MODE_VR: number;
  92199. /**
  92200. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92201. */
  92202. static readonly RIG_MODE_WEBVR: number;
  92203. /**
  92204. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92205. */
  92206. static readonly RIG_MODE_CUSTOM: number;
  92207. /**
  92208. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92209. */
  92210. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92211. /**
  92212. * Define the input manager associated with the camera.
  92213. */
  92214. inputs: CameraInputsManager<Camera>;
  92215. /** @hidden */
  92216. _position: Vector3;
  92217. /**
  92218. * Define the current local position of the camera in the scene
  92219. */
  92220. position: Vector3;
  92221. /**
  92222. * The vector the camera should consider as up.
  92223. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92224. */
  92225. upVector: Vector3;
  92226. /**
  92227. * Define the current limit on the left side for an orthographic camera
  92228. * In scene unit
  92229. */
  92230. orthoLeft: Nullable<number>;
  92231. /**
  92232. * Define the current limit on the right side for an orthographic camera
  92233. * In scene unit
  92234. */
  92235. orthoRight: Nullable<number>;
  92236. /**
  92237. * Define the current limit on the bottom side for an orthographic camera
  92238. * In scene unit
  92239. */
  92240. orthoBottom: Nullable<number>;
  92241. /**
  92242. * Define the current limit on the top side for an orthographic camera
  92243. * In scene unit
  92244. */
  92245. orthoTop: Nullable<number>;
  92246. /**
  92247. * Field Of View is set in Radians. (default is 0.8)
  92248. */
  92249. fov: number;
  92250. /**
  92251. * Define the minimum distance the camera can see from.
  92252. * This is important to note that the depth buffer are not infinite and the closer it starts
  92253. * the more your scene might encounter depth fighting issue.
  92254. */
  92255. minZ: number;
  92256. /**
  92257. * Define the maximum distance the camera can see to.
  92258. * This is important to note that the depth buffer are not infinite and the further it end
  92259. * the more your scene might encounter depth fighting issue.
  92260. */
  92261. maxZ: number;
  92262. /**
  92263. * Define the default inertia of the camera.
  92264. * This helps giving a smooth feeling to the camera movement.
  92265. */
  92266. inertia: number;
  92267. /**
  92268. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92269. */
  92270. mode: number;
  92271. /**
  92272. * Define wether the camera is intermediate.
  92273. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92274. */
  92275. isIntermediate: boolean;
  92276. /**
  92277. * Define the viewport of the camera.
  92278. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92279. */
  92280. viewport: Viewport;
  92281. /**
  92282. * Restricts the camera to viewing objects with the same layerMask.
  92283. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92284. */
  92285. layerMask: number;
  92286. /**
  92287. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92288. */
  92289. fovMode: number;
  92290. /**
  92291. * Rig mode of the camera.
  92292. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92293. * This is normally controlled byt the camera themselves as internal use.
  92294. */
  92295. cameraRigMode: number;
  92296. /**
  92297. * Defines the distance between both "eyes" in case of a RIG
  92298. */
  92299. interaxialDistance: number;
  92300. /**
  92301. * Defines if stereoscopic rendering is done side by side or over under.
  92302. */
  92303. isStereoscopicSideBySide: boolean;
  92304. /**
  92305. * 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
  92306. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92307. * else in the scene. (Eg. security camera)
  92308. *
  92309. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  92310. */
  92311. customRenderTargets: RenderTargetTexture[];
  92312. /**
  92313. * When set, the camera will render to this render target instead of the default canvas
  92314. *
  92315. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92316. */
  92317. outputRenderTarget: Nullable<RenderTargetTexture>;
  92318. /**
  92319. * Observable triggered when the camera view matrix has changed.
  92320. */
  92321. onViewMatrixChangedObservable: Observable<Camera>;
  92322. /**
  92323. * Observable triggered when the camera Projection matrix has changed.
  92324. */
  92325. onProjectionMatrixChangedObservable: Observable<Camera>;
  92326. /**
  92327. * Observable triggered when the inputs have been processed.
  92328. */
  92329. onAfterCheckInputsObservable: Observable<Camera>;
  92330. /**
  92331. * Observable triggered when reset has been called and applied to the camera.
  92332. */
  92333. onRestoreStateObservable: Observable<Camera>;
  92334. /** @hidden */
  92335. _cameraRigParams: any;
  92336. /** @hidden */
  92337. _rigCameras: Camera[];
  92338. /** @hidden */
  92339. _rigPostProcess: Nullable<PostProcess>;
  92340. protected _webvrViewMatrix: Matrix;
  92341. /** @hidden */
  92342. _skipRendering: boolean;
  92343. /** @hidden */
  92344. _projectionMatrix: Matrix;
  92345. /** @hidden */
  92346. _postProcesses: Nullable<PostProcess>[];
  92347. /** @hidden */
  92348. _activeMeshes: SmartArray<AbstractMesh>;
  92349. protected _globalPosition: Vector3;
  92350. /** @hidden */
  92351. _computedViewMatrix: Matrix;
  92352. private _doNotComputeProjectionMatrix;
  92353. private _transformMatrix;
  92354. private _frustumPlanes;
  92355. private _refreshFrustumPlanes;
  92356. private _storedFov;
  92357. private _stateStored;
  92358. /**
  92359. * Instantiates a new camera object.
  92360. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92361. * @see http://doc.babylonjs.com/features/cameras
  92362. * @param name Defines the name of the camera in the scene
  92363. * @param position Defines the position of the camera
  92364. * @param scene Defines the scene the camera belongs too
  92365. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92366. */
  92367. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92368. /**
  92369. * Store current camera state (fov, position, etc..)
  92370. * @returns the camera
  92371. */
  92372. storeState(): Camera;
  92373. /**
  92374. * Restores the camera state values if it has been stored. You must call storeState() first
  92375. */
  92376. protected _restoreStateValues(): boolean;
  92377. /**
  92378. * Restored camera state. You must call storeState() first.
  92379. * @returns true if restored and false otherwise
  92380. */
  92381. restoreState(): boolean;
  92382. /**
  92383. * Gets the class name of the camera.
  92384. * @returns the class name
  92385. */
  92386. getClassName(): string;
  92387. /** @hidden */
  92388. readonly _isCamera: boolean;
  92389. /**
  92390. * Gets a string representation of the camera useful for debug purpose.
  92391. * @param fullDetails Defines that a more verboe level of logging is required
  92392. * @returns the string representation
  92393. */
  92394. toString(fullDetails?: boolean): string;
  92395. /**
  92396. * Gets the current world space position of the camera.
  92397. */
  92398. readonly globalPosition: Vector3;
  92399. /**
  92400. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92401. * @returns the active meshe list
  92402. */
  92403. getActiveMeshes(): SmartArray<AbstractMesh>;
  92404. /**
  92405. * Check wether a mesh is part of the current active mesh list of the camera
  92406. * @param mesh Defines the mesh to check
  92407. * @returns true if active, false otherwise
  92408. */
  92409. isActiveMesh(mesh: Mesh): boolean;
  92410. /**
  92411. * Is this camera ready to be used/rendered
  92412. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92413. * @return true if the camera is ready
  92414. */
  92415. isReady(completeCheck?: boolean): boolean;
  92416. /** @hidden */
  92417. _initCache(): void;
  92418. /** @hidden */
  92419. _updateCache(ignoreParentClass?: boolean): void;
  92420. /** @hidden */
  92421. _isSynchronized(): boolean;
  92422. /** @hidden */
  92423. _isSynchronizedViewMatrix(): boolean;
  92424. /** @hidden */
  92425. _isSynchronizedProjectionMatrix(): boolean;
  92426. /**
  92427. * Attach the input controls to a specific dom element to get the input from.
  92428. * @param element Defines the element the controls should be listened from
  92429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92430. */
  92431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92432. /**
  92433. * Detach the current controls from the specified dom element.
  92434. * @param element Defines the element to stop listening the inputs from
  92435. */
  92436. detachControl(element: HTMLElement): void;
  92437. /**
  92438. * Update the camera state according to the different inputs gathered during the frame.
  92439. */
  92440. update(): void;
  92441. /** @hidden */
  92442. _checkInputs(): void;
  92443. /** @hidden */
  92444. readonly rigCameras: Camera[];
  92445. /**
  92446. * Gets the post process used by the rig cameras
  92447. */
  92448. readonly rigPostProcess: Nullable<PostProcess>;
  92449. /**
  92450. * Internal, gets the first post proces.
  92451. * @returns the first post process to be run on this camera.
  92452. */
  92453. _getFirstPostProcess(): Nullable<PostProcess>;
  92454. private _cascadePostProcessesToRigCams;
  92455. /**
  92456. * Attach a post process to the camera.
  92457. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92458. * @param postProcess The post process to attach to the camera
  92459. * @param insertAt The position of the post process in case several of them are in use in the scene
  92460. * @returns the position the post process has been inserted at
  92461. */
  92462. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92463. /**
  92464. * Detach a post process to the camera.
  92465. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92466. * @param postProcess The post process to detach from the camera
  92467. */
  92468. detachPostProcess(postProcess: PostProcess): void;
  92469. /**
  92470. * Gets the current world matrix of the camera
  92471. */
  92472. getWorldMatrix(): Matrix;
  92473. /** @hidden */
  92474. _getViewMatrix(): Matrix;
  92475. /**
  92476. * Gets the current view matrix of the camera.
  92477. * @param force forces the camera to recompute the matrix without looking at the cached state
  92478. * @returns the view matrix
  92479. */
  92480. getViewMatrix(force?: boolean): Matrix;
  92481. /**
  92482. * Freeze the projection matrix.
  92483. * It will prevent the cache check of the camera projection compute and can speed up perf
  92484. * if no parameter of the camera are meant to change
  92485. * @param projection Defines manually a projection if necessary
  92486. */
  92487. freezeProjectionMatrix(projection?: Matrix): void;
  92488. /**
  92489. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92490. */
  92491. unfreezeProjectionMatrix(): void;
  92492. /**
  92493. * Gets the current projection matrix of the camera.
  92494. * @param force forces the camera to recompute the matrix without looking at the cached state
  92495. * @returns the projection matrix
  92496. */
  92497. getProjectionMatrix(force?: boolean): Matrix;
  92498. /**
  92499. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92500. * @returns a Matrix
  92501. */
  92502. getTransformationMatrix(): Matrix;
  92503. private _updateFrustumPlanes;
  92504. /**
  92505. * Checks if a cullable object (mesh...) is in the camera frustum
  92506. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92507. * @param target The object to check
  92508. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92509. * @returns true if the object is in frustum otherwise false
  92510. */
  92511. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92512. /**
  92513. * Checks if a cullable object (mesh...) is in the camera frustum
  92514. * Unlike isInFrustum this cheks the full bounding box
  92515. * @param target The object to check
  92516. * @returns true if the object is in frustum otherwise false
  92517. */
  92518. isCompletelyInFrustum(target: ICullable): boolean;
  92519. /**
  92520. * Gets a ray in the forward direction from the camera.
  92521. * @param length Defines the length of the ray to create
  92522. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92523. * @param origin Defines the start point of the ray which defaults to the camera position
  92524. * @returns the forward ray
  92525. */
  92526. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92527. /**
  92528. * Releases resources associated with this node.
  92529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92531. */
  92532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92533. /** @hidden */
  92534. _isLeftCamera: boolean;
  92535. /**
  92536. * Gets the left camera of a rig setup in case of Rigged Camera
  92537. */
  92538. readonly isLeftCamera: boolean;
  92539. /** @hidden */
  92540. _isRightCamera: boolean;
  92541. /**
  92542. * Gets the right camera of a rig setup in case of Rigged Camera
  92543. */
  92544. readonly isRightCamera: boolean;
  92545. /**
  92546. * Gets the left camera of a rig setup in case of Rigged Camera
  92547. */
  92548. readonly leftCamera: Nullable<FreeCamera>;
  92549. /**
  92550. * Gets the right camera of a rig setup in case of Rigged Camera
  92551. */
  92552. readonly rightCamera: Nullable<FreeCamera>;
  92553. /**
  92554. * Gets the left camera target of a rig setup in case of Rigged Camera
  92555. * @returns the target position
  92556. */
  92557. getLeftTarget(): Nullable<Vector3>;
  92558. /**
  92559. * Gets the right camera target of a rig setup in case of Rigged Camera
  92560. * @returns the target position
  92561. */
  92562. getRightTarget(): Nullable<Vector3>;
  92563. /**
  92564. * @hidden
  92565. */
  92566. setCameraRigMode(mode: number, rigParams: any): void;
  92567. /** @hidden */
  92568. static _setStereoscopicRigMode(camera: Camera): void;
  92569. /** @hidden */
  92570. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92571. /** @hidden */
  92572. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92573. /** @hidden */
  92574. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92575. /** @hidden */
  92576. _getVRProjectionMatrix(): Matrix;
  92577. protected _updateCameraRotationMatrix(): void;
  92578. protected _updateWebVRCameraRotationMatrix(): void;
  92579. /**
  92580. * This function MUST be overwritten by the different WebVR cameras available.
  92581. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92582. * @hidden
  92583. */
  92584. _getWebVRProjectionMatrix(): Matrix;
  92585. /**
  92586. * This function MUST be overwritten by the different WebVR cameras available.
  92587. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92588. * @hidden
  92589. */
  92590. _getWebVRViewMatrix(): Matrix;
  92591. /** @hidden */
  92592. setCameraRigParameter(name: string, value: any): void;
  92593. /**
  92594. * needs to be overridden by children so sub has required properties to be copied
  92595. * @hidden
  92596. */
  92597. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92598. /**
  92599. * May need to be overridden by children
  92600. * @hidden
  92601. */
  92602. _updateRigCameras(): void;
  92603. /** @hidden */
  92604. _setupInputs(): void;
  92605. /**
  92606. * Serialiaze the camera setup to a json represention
  92607. * @returns the JSON representation
  92608. */
  92609. serialize(): any;
  92610. /**
  92611. * Clones the current camera.
  92612. * @param name The cloned camera name
  92613. * @returns the cloned camera
  92614. */
  92615. clone(name: string): Camera;
  92616. /**
  92617. * Gets the direction of the camera relative to a given local axis.
  92618. * @param localAxis Defines the reference axis to provide a relative direction.
  92619. * @return the direction
  92620. */
  92621. getDirection(localAxis: Vector3): Vector3;
  92622. /**
  92623. * Returns the current camera absolute rotation
  92624. */
  92625. readonly absoluteRotation: Quaternion;
  92626. /**
  92627. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92628. * @param localAxis Defines the reference axis to provide a relative direction.
  92629. * @param result Defines the vector to store the result in
  92630. */
  92631. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92632. /**
  92633. * Gets a camera constructor for a given camera type
  92634. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92635. * @param name The name of the camera the result will be able to instantiate
  92636. * @param scene The scene the result will construct the camera in
  92637. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92638. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92639. * @returns a factory method to construc the camera
  92640. */
  92641. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92642. /**
  92643. * Compute the world matrix of the camera.
  92644. * @returns the camera workd matrix
  92645. */
  92646. computeWorldMatrix(): Matrix;
  92647. /**
  92648. * Parse a JSON and creates the camera from the parsed information
  92649. * @param parsedCamera The JSON to parse
  92650. * @param scene The scene to instantiate the camera in
  92651. * @returns the newly constructed camera
  92652. */
  92653. static Parse(parsedCamera: any, scene: Scene): Camera;
  92654. }
  92655. }
  92656. declare module BABYLON {
  92657. /**
  92658. * Class containing static functions to help procedurally build meshes
  92659. */
  92660. export class DiscBuilder {
  92661. /**
  92662. * Creates a plane polygonal mesh. By default, this is a disc
  92663. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92664. * * 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
  92665. * * 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
  92666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92669. * @param name defines the name of the mesh
  92670. * @param options defines the options used to create the mesh
  92671. * @param scene defines the hosting scene
  92672. * @returns the plane polygonal mesh
  92673. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92674. */
  92675. static CreateDisc(name: string, options: {
  92676. radius?: number;
  92677. tessellation?: number;
  92678. arc?: number;
  92679. updatable?: boolean;
  92680. sideOrientation?: number;
  92681. frontUVs?: Vector4;
  92682. backUVs?: Vector4;
  92683. }, scene?: Nullable<Scene>): Mesh;
  92684. }
  92685. }
  92686. declare module BABYLON {
  92687. /**
  92688. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92689. *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.
  92690. * The SPS is also a particle system. It provides some methods to manage the particles.
  92691. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92692. *
  92693. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92694. */
  92695. export class SolidParticleSystem implements IDisposable {
  92696. /**
  92697. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92698. * Example : var p = SPS.particles[i];
  92699. */
  92700. particles: SolidParticle[];
  92701. /**
  92702. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92703. */
  92704. nbParticles: number;
  92705. /**
  92706. * If the particles must ever face the camera (default false). Useful for planar particles.
  92707. */
  92708. billboard: boolean;
  92709. /**
  92710. * Recompute normals when adding a shape
  92711. */
  92712. recomputeNormals: boolean;
  92713. /**
  92714. * This a counter ofr your own usage. It's not set by any SPS functions.
  92715. */
  92716. counter: number;
  92717. /**
  92718. * The SPS name. This name is also given to the underlying mesh.
  92719. */
  92720. name: string;
  92721. /**
  92722. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92723. */
  92724. mesh: Mesh;
  92725. /**
  92726. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92727. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92728. */
  92729. vars: any;
  92730. /**
  92731. * This array is populated when the SPS is set as 'pickable'.
  92732. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92733. * Each element of this array is an object `{idx: int, faceId: int}`.
  92734. * `idx` is the picked particle index in the `SPS.particles` array
  92735. * `faceId` is the picked face index counted within this particle.
  92736. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92737. */
  92738. pickedParticles: {
  92739. idx: number;
  92740. faceId: number;
  92741. }[];
  92742. /**
  92743. * This array is populated when `enableDepthSort` is set to true.
  92744. * Each element of this array is an instance of the class DepthSortedParticle.
  92745. */
  92746. depthSortedParticles: DepthSortedParticle[];
  92747. /**
  92748. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92749. * @hidden
  92750. */
  92751. _bSphereOnly: boolean;
  92752. /**
  92753. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92754. * @hidden
  92755. */
  92756. _bSphereRadiusFactor: number;
  92757. private _scene;
  92758. private _positions;
  92759. private _indices;
  92760. private _normals;
  92761. private _colors;
  92762. private _uvs;
  92763. private _indices32;
  92764. private _positions32;
  92765. private _normals32;
  92766. private _fixedNormal32;
  92767. private _colors32;
  92768. private _uvs32;
  92769. private _index;
  92770. private _updatable;
  92771. private _pickable;
  92772. private _isVisibilityBoxLocked;
  92773. private _alwaysVisible;
  92774. private _depthSort;
  92775. private _expandable;
  92776. private _shapeCounter;
  92777. private _copy;
  92778. private _color;
  92779. private _computeParticleColor;
  92780. private _computeParticleTexture;
  92781. private _computeParticleRotation;
  92782. private _computeParticleVertex;
  92783. private _computeBoundingBox;
  92784. private _depthSortParticles;
  92785. private _camera;
  92786. private _mustUnrotateFixedNormals;
  92787. private _particlesIntersect;
  92788. private _needs32Bits;
  92789. private _isNotBuilt;
  92790. /**
  92791. * Creates a SPS (Solid Particle System) object.
  92792. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92793. * @param scene (Scene) is the scene in which the SPS is added.
  92794. * @param options defines the options of the sps e.g.
  92795. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92796. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92797. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92798. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92799. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92800. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92801. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92802. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92803. */
  92804. constructor(name: string, scene: Scene, options?: {
  92805. updatable?: boolean;
  92806. isPickable?: boolean;
  92807. enableDepthSort?: boolean;
  92808. particleIntersection?: boolean;
  92809. boundingSphereOnly?: boolean;
  92810. bSphereRadiusFactor?: number;
  92811. expandable?: boolean;
  92812. });
  92813. /**
  92814. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92815. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92816. * @returns the created mesh
  92817. */
  92818. buildMesh(): Mesh;
  92819. /**
  92820. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92821. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92822. * Thus the particles generated from `digest()` have their property `position` set yet.
  92823. * @param mesh ( Mesh ) is the mesh to be digested
  92824. * @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
  92825. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92826. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92827. * @returns the current SPS
  92828. */
  92829. digest(mesh: Mesh, options?: {
  92830. facetNb?: number;
  92831. number?: number;
  92832. delta?: number;
  92833. }): SolidParticleSystem;
  92834. private _unrotateFixedNormals;
  92835. private _resetCopy;
  92836. private _meshBuilder;
  92837. private _posToShape;
  92838. private _uvsToShapeUV;
  92839. private _addParticle;
  92840. /**
  92841. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92842. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92843. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92844. * @param nb (positive integer) the number of particles to be created from this model
  92845. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92846. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92847. * @returns the number of shapes in the system
  92848. */
  92849. addShape(mesh: Mesh, nb: number, options?: {
  92850. positionFunction?: any;
  92851. vertexFunction?: any;
  92852. }): number;
  92853. private _rebuildParticle;
  92854. /**
  92855. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92856. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  92857. * @returns the SPS.
  92858. */
  92859. rebuildMesh(reset?: boolean): SolidParticleSystem;
  92860. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  92861. * Returns an array with the removed particles.
  92862. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  92863. * The SPS can't be empty so at least one particle needs to remain in place.
  92864. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  92865. * @param start index of the first particle to remove
  92866. * @param end index of the last particle to remove (included)
  92867. * @returns an array populated with the removed particles
  92868. */
  92869. removeParticles(start: number, end: number): SolidParticle[];
  92870. /**
  92871. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92872. * This method calls `updateParticle()` for each particle of the SPS.
  92873. * For an animated SPS, it is usually called within the render loop.
  92874. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  92875. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92876. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92877. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92878. * @returns the SPS.
  92879. */
  92880. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92881. /**
  92882. * Disposes the SPS.
  92883. */
  92884. dispose(): void;
  92885. /**
  92886. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92888. * @returns the SPS.
  92889. */
  92890. refreshVisibleSize(): SolidParticleSystem;
  92891. /**
  92892. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92893. * @param size the size (float) of the visibility box
  92894. * note : this doesn't lock the SPS mesh bounding box.
  92895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92896. */
  92897. setVisibilityBox(size: number): void;
  92898. /**
  92899. * Gets whether the SPS as always visible or not
  92900. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92901. */
  92902. /**
  92903. * Sets the SPS as always visible or not
  92904. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92905. */
  92906. isAlwaysVisible: boolean;
  92907. /**
  92908. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92909. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92910. */
  92911. /**
  92912. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92913. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92914. */
  92915. isVisibilityBoxLocked: boolean;
  92916. /**
  92917. * Tells to `setParticles()` to compute the particle rotations or not.
  92918. * Default value : true. The SPS is faster when it's set to false.
  92919. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92920. */
  92921. /**
  92922. * Gets if `setParticles()` computes the particle rotations or not.
  92923. * Default value : true. The SPS is faster when it's set to false.
  92924. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92925. */
  92926. computeParticleRotation: boolean;
  92927. /**
  92928. * Tells to `setParticles()` to compute the particle colors or not.
  92929. * Default value : true. The SPS is faster when it's set to false.
  92930. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92931. */
  92932. /**
  92933. * Gets if `setParticles()` computes the particle colors or not.
  92934. * Default value : true. The SPS is faster when it's set to false.
  92935. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92936. */
  92937. computeParticleColor: boolean;
  92938. /**
  92939. * Gets if `setParticles()` computes the particle textures or not.
  92940. * Default value : true. The SPS is faster when it's set to false.
  92941. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92942. */
  92943. computeParticleTexture: boolean;
  92944. /**
  92945. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92946. * Default value : false. The SPS is faster when it's set to false.
  92947. * Note : the particle custom vertex positions aren't stored values.
  92948. */
  92949. /**
  92950. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92951. * Default value : false. The SPS is faster when it's set to false.
  92952. * Note : the particle custom vertex positions aren't stored values.
  92953. */
  92954. computeParticleVertex: boolean;
  92955. /**
  92956. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92957. */
  92958. /**
  92959. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92960. */
  92961. computeBoundingBox: boolean;
  92962. /**
  92963. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92964. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92965. * Default : `true`
  92966. */
  92967. /**
  92968. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92969. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92970. * Default : `true`
  92971. */
  92972. depthSortParticles: boolean;
  92973. /**
  92974. * Gets if the SPS is created as expandable at construction time.
  92975. * Default : `false`
  92976. */
  92977. readonly expandable: boolean;
  92978. /**
  92979. * This function does nothing. It may be overwritten to set all the particle first values.
  92980. * The SPS doesn't call this function, you may have to call it by your own.
  92981. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92982. */
  92983. initParticles(): void;
  92984. /**
  92985. * This function does nothing. It may be overwritten to recycle a particle.
  92986. * The SPS doesn't call this function, you may have to call it by your own.
  92987. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92988. * @param particle The particle to recycle
  92989. * @returns the recycled particle
  92990. */
  92991. recycleParticle(particle: SolidParticle): SolidParticle;
  92992. /**
  92993. * Updates a particle : this function should be overwritten by the user.
  92994. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92996. * @example : just set a particle position or velocity and recycle conditions
  92997. * @param particle The particle to update
  92998. * @returns the updated particle
  92999. */
  93000. updateParticle(particle: SolidParticle): SolidParticle;
  93001. /**
  93002. * Updates a vertex of a particle : it can be overwritten by the user.
  93003. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93004. * @param particle the current particle
  93005. * @param vertex the current index of the current particle
  93006. * @param pt the index of the current vertex in the particle shape
  93007. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93008. * @example : just set a vertex particle position
  93009. * @returns the updated vertex
  93010. */
  93011. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93012. /**
  93013. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93014. * This does nothing and may be overwritten by the user.
  93015. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93016. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93017. * @param update the boolean update value actually passed to setParticles()
  93018. */
  93019. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93020. /**
  93021. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93022. * This will be passed three parameters.
  93023. * This does nothing and may be overwritten by the user.
  93024. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93025. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93026. * @param update the boolean update value actually passed to setParticles()
  93027. */
  93028. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93029. }
  93030. }
  93031. declare module BABYLON {
  93032. /**
  93033. * Represents one particle of a solid particle system.
  93034. */
  93035. export class SolidParticle {
  93036. /**
  93037. * particle global index
  93038. */
  93039. idx: number;
  93040. /**
  93041. * The color of the particle
  93042. */
  93043. color: Nullable<Color4>;
  93044. /**
  93045. * The world space position of the particle.
  93046. */
  93047. position: Vector3;
  93048. /**
  93049. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93050. */
  93051. rotation: Vector3;
  93052. /**
  93053. * The world space rotation quaternion of the particle.
  93054. */
  93055. rotationQuaternion: Nullable<Quaternion>;
  93056. /**
  93057. * The scaling of the particle.
  93058. */
  93059. scaling: Vector3;
  93060. /**
  93061. * The uvs of the particle.
  93062. */
  93063. uvs: Vector4;
  93064. /**
  93065. * The current speed of the particle.
  93066. */
  93067. velocity: Vector3;
  93068. /**
  93069. * The pivot point in the particle local space.
  93070. */
  93071. pivot: Vector3;
  93072. /**
  93073. * Must the particle be translated from its pivot point in its local space ?
  93074. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93075. * Default : false
  93076. */
  93077. translateFromPivot: boolean;
  93078. /**
  93079. * Is the particle active or not ?
  93080. */
  93081. alive: boolean;
  93082. /**
  93083. * Is the particle visible or not ?
  93084. */
  93085. isVisible: boolean;
  93086. /**
  93087. * Index of this particle in the global "positions" array (Internal use)
  93088. * @hidden
  93089. */
  93090. _pos: number;
  93091. /**
  93092. * @hidden Index of this particle in the global "indices" array (Internal use)
  93093. */
  93094. _ind: number;
  93095. /**
  93096. * @hidden ModelShape of this particle (Internal use)
  93097. */
  93098. _model: ModelShape;
  93099. /**
  93100. * ModelShape id of this particle
  93101. */
  93102. shapeId: number;
  93103. /**
  93104. * Index of the particle in its shape id
  93105. */
  93106. idxInShape: number;
  93107. /**
  93108. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93109. */
  93110. _modelBoundingInfo: BoundingInfo;
  93111. /**
  93112. * @hidden Particle BoundingInfo object (Internal use)
  93113. */
  93114. _boundingInfo: BoundingInfo;
  93115. /**
  93116. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93117. */
  93118. _sps: SolidParticleSystem;
  93119. /**
  93120. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93121. */
  93122. _stillInvisible: boolean;
  93123. /**
  93124. * @hidden Last computed particle rotation matrix
  93125. */
  93126. _rotationMatrix: number[];
  93127. /**
  93128. * Parent particle Id, if any.
  93129. * Default null.
  93130. */
  93131. parentId: Nullable<number>;
  93132. /**
  93133. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93134. * The possible values are :
  93135. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93136. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93137. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93139. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93140. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93141. * */
  93142. cullingStrategy: number;
  93143. /**
  93144. * @hidden Internal global position in the SPS.
  93145. */
  93146. _globalPosition: Vector3;
  93147. /**
  93148. * Creates a Solid Particle object.
  93149. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93150. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93151. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93152. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93153. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93154. * @param shapeId (integer) is the model shape identifier in the SPS.
  93155. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93156. * @param sps defines the sps it is associated to
  93157. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93158. */
  93159. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93160. /**
  93161. * Legacy support, changed scale to scaling
  93162. */
  93163. /**
  93164. * Legacy support, changed scale to scaling
  93165. */
  93166. scale: Vector3;
  93167. /**
  93168. * Legacy support, changed quaternion to rotationQuaternion
  93169. */
  93170. /**
  93171. * Legacy support, changed quaternion to rotationQuaternion
  93172. */
  93173. quaternion: Nullable<Quaternion>;
  93174. /**
  93175. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93176. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93177. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93178. * @returns true if it intersects
  93179. */
  93180. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93181. /**
  93182. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93183. * A particle is in the frustum if its bounding box intersects the frustum
  93184. * @param frustumPlanes defines the frustum to test
  93185. * @returns true if the particle is in the frustum planes
  93186. */
  93187. isInFrustum(frustumPlanes: Plane[]): boolean;
  93188. /**
  93189. * get the rotation matrix of the particle
  93190. * @hidden
  93191. */
  93192. getRotationMatrix(m: Matrix): void;
  93193. }
  93194. /**
  93195. * Represents the shape of the model used by one particle of a solid particle system.
  93196. * SPS internal tool, don't use it manually.
  93197. */
  93198. export class ModelShape {
  93199. /**
  93200. * The shape id
  93201. * @hidden
  93202. */
  93203. shapeID: number;
  93204. /**
  93205. * flat array of model positions (internal use)
  93206. * @hidden
  93207. */
  93208. _shape: Vector3[];
  93209. /**
  93210. * flat array of model UVs (internal use)
  93211. * @hidden
  93212. */
  93213. _shapeUV: number[];
  93214. /**
  93215. * color array of the model
  93216. * @hidden
  93217. */
  93218. _shapeColors: number[];
  93219. /**
  93220. * indices array of the model
  93221. * @hidden
  93222. */
  93223. _indices: number[];
  93224. /**
  93225. * normals array of the model
  93226. * @hidden
  93227. */
  93228. _normals: number[];
  93229. /**
  93230. * length of the shape in the model indices array (internal use)
  93231. * @hidden
  93232. */
  93233. _indicesLength: number;
  93234. /**
  93235. * Custom position function (internal use)
  93236. * @hidden
  93237. */
  93238. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93239. /**
  93240. * Custom vertex function (internal use)
  93241. * @hidden
  93242. */
  93243. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93244. /**
  93245. * 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.
  93246. * SPS internal tool, don't use it manually.
  93247. * @hidden
  93248. */
  93249. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  93250. }
  93251. /**
  93252. * Represents a Depth Sorted Particle in the solid particle system.
  93253. */
  93254. export class DepthSortedParticle {
  93255. /**
  93256. * Index of the particle in the "indices" array
  93257. */
  93258. ind: number;
  93259. /**
  93260. * Length of the particle shape in the "indices" array
  93261. */
  93262. indicesLength: number;
  93263. /**
  93264. * Squared distance from the particle to the camera
  93265. */
  93266. sqDistance: number;
  93267. }
  93268. }
  93269. declare module BABYLON {
  93270. /**
  93271. * @hidden
  93272. */
  93273. export class _MeshCollisionData {
  93274. _checkCollisions: boolean;
  93275. _collisionMask: number;
  93276. _collisionGroup: number;
  93277. _collider: Nullable<Collider>;
  93278. _oldPositionForCollisions: Vector3;
  93279. _diffPositionForCollisions: Vector3;
  93280. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93281. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93282. }
  93283. }
  93284. declare module BABYLON {
  93285. /** @hidden */
  93286. class _FacetDataStorage {
  93287. facetPositions: Vector3[];
  93288. facetNormals: Vector3[];
  93289. facetPartitioning: number[][];
  93290. facetNb: number;
  93291. partitioningSubdivisions: number;
  93292. partitioningBBoxRatio: number;
  93293. facetDataEnabled: boolean;
  93294. facetParameters: any;
  93295. bbSize: Vector3;
  93296. subDiv: {
  93297. max: number;
  93298. X: number;
  93299. Y: number;
  93300. Z: number;
  93301. };
  93302. facetDepthSort: boolean;
  93303. facetDepthSortEnabled: boolean;
  93304. depthSortedIndices: IndicesArray;
  93305. depthSortedFacets: {
  93306. ind: number;
  93307. sqDistance: number;
  93308. }[];
  93309. facetDepthSortFunction: (f1: {
  93310. ind: number;
  93311. sqDistance: number;
  93312. }, f2: {
  93313. ind: number;
  93314. sqDistance: number;
  93315. }) => number;
  93316. facetDepthSortFrom: Vector3;
  93317. facetDepthSortOrigin: Vector3;
  93318. invertedMatrix: Matrix;
  93319. }
  93320. /**
  93321. * @hidden
  93322. **/
  93323. class _InternalAbstractMeshDataInfo {
  93324. _hasVertexAlpha: boolean;
  93325. _useVertexColors: boolean;
  93326. _numBoneInfluencers: number;
  93327. _applyFog: boolean;
  93328. _receiveShadows: boolean;
  93329. _facetData: _FacetDataStorage;
  93330. _visibility: number;
  93331. _skeleton: Nullable<Skeleton>;
  93332. _layerMask: number;
  93333. _computeBonesUsingShaders: boolean;
  93334. _isActive: boolean;
  93335. _onlyForInstances: boolean;
  93336. _isActiveIntermediate: boolean;
  93337. _onlyForInstancesIntermediate: boolean;
  93338. _actAsRegularMesh: boolean;
  93339. }
  93340. /**
  93341. * Class used to store all common mesh properties
  93342. */
  93343. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93344. /** No occlusion */
  93345. static OCCLUSION_TYPE_NONE: number;
  93346. /** Occlusion set to optimisitic */
  93347. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93348. /** Occlusion set to strict */
  93349. static OCCLUSION_TYPE_STRICT: number;
  93350. /** Use an accurante occlusion algorithm */
  93351. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93352. /** Use a conservative occlusion algorithm */
  93353. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93354. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93355. * Test order :
  93356. * Is the bounding sphere outside the frustum ?
  93357. * If not, are the bounding box vertices outside the frustum ?
  93358. * It not, then the cullable object is in the frustum.
  93359. */
  93360. static readonly CULLINGSTRATEGY_STANDARD: number;
  93361. /** Culling strategy : Bounding Sphere Only.
  93362. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93363. * It's also less accurate than the standard because some not visible objects can still be selected.
  93364. * Test : is the bounding sphere outside the frustum ?
  93365. * If not, then the cullable object is in the frustum.
  93366. */
  93367. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93368. /** Culling strategy : Optimistic Inclusion.
  93369. * This in an inclusion test first, then the standard exclusion test.
  93370. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93371. * 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.
  93372. * Anyway, it's as accurate as the standard strategy.
  93373. * Test :
  93374. * Is the cullable object bounding sphere center in the frustum ?
  93375. * If not, apply the default culling strategy.
  93376. */
  93377. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93378. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93379. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93380. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93381. * 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.
  93382. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93383. * Test :
  93384. * Is the cullable object bounding sphere center in the frustum ?
  93385. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93386. */
  93387. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93388. /**
  93389. * No billboard
  93390. */
  93391. static readonly BILLBOARDMODE_NONE: number;
  93392. /** Billboard on X axis */
  93393. static readonly BILLBOARDMODE_X: number;
  93394. /** Billboard on Y axis */
  93395. static readonly BILLBOARDMODE_Y: number;
  93396. /** Billboard on Z axis */
  93397. static readonly BILLBOARDMODE_Z: number;
  93398. /** Billboard on all axes */
  93399. static readonly BILLBOARDMODE_ALL: number;
  93400. /** Billboard on using position instead of orientation */
  93401. static readonly BILLBOARDMODE_USE_POSITION: number;
  93402. /** @hidden */
  93403. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93404. /**
  93405. * The culling strategy to use to check whether the mesh must be rendered or not.
  93406. * This value can be changed at any time and will be used on the next render mesh selection.
  93407. * The possible values are :
  93408. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93409. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93410. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93411. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93412. * Please read each static variable documentation to get details about the culling process.
  93413. * */
  93414. cullingStrategy: number;
  93415. /**
  93416. * Gets the number of facets in the mesh
  93417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93418. */
  93419. readonly facetNb: number;
  93420. /**
  93421. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93422. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93423. */
  93424. partitioningSubdivisions: number;
  93425. /**
  93426. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93427. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93429. */
  93430. partitioningBBoxRatio: number;
  93431. /**
  93432. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93433. * Works only for updatable meshes.
  93434. * Doesn't work with multi-materials
  93435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93436. */
  93437. mustDepthSortFacets: boolean;
  93438. /**
  93439. * The location (Vector3) where the facet depth sort must be computed from.
  93440. * By default, the active camera position.
  93441. * Used only when facet depth sort is enabled
  93442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93443. */
  93444. facetDepthSortFrom: Vector3;
  93445. /**
  93446. * gets a boolean indicating if facetData is enabled
  93447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93448. */
  93449. readonly isFacetDataEnabled: boolean;
  93450. /** @hidden */
  93451. _updateNonUniformScalingState(value: boolean): boolean;
  93452. /**
  93453. * An event triggered when this mesh collides with another one
  93454. */
  93455. onCollideObservable: Observable<AbstractMesh>;
  93456. /** Set a function to call when this mesh collides with another one */
  93457. onCollide: () => void;
  93458. /**
  93459. * An event triggered when the collision's position changes
  93460. */
  93461. onCollisionPositionChangeObservable: Observable<Vector3>;
  93462. /** Set a function to call when the collision's position changes */
  93463. onCollisionPositionChange: () => void;
  93464. /**
  93465. * An event triggered when material is changed
  93466. */
  93467. onMaterialChangedObservable: Observable<AbstractMesh>;
  93468. /**
  93469. * Gets or sets the orientation for POV movement & rotation
  93470. */
  93471. definedFacingForward: boolean;
  93472. /** @hidden */
  93473. _occlusionQuery: Nullable<WebGLQuery>;
  93474. /** @hidden */
  93475. _renderingGroup: Nullable<RenderingGroup>;
  93476. /**
  93477. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93478. */
  93479. /**
  93480. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93481. */
  93482. visibility: number;
  93483. /** Gets or sets the alpha index used to sort transparent meshes
  93484. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93485. */
  93486. alphaIndex: number;
  93487. /**
  93488. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93489. */
  93490. isVisible: boolean;
  93491. /**
  93492. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93493. */
  93494. isPickable: boolean;
  93495. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93496. showSubMeshesBoundingBox: boolean;
  93497. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93498. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93499. */
  93500. isBlocker: boolean;
  93501. /**
  93502. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93503. */
  93504. enablePointerMoveEvents: boolean;
  93505. /**
  93506. * Specifies the rendering group id for this mesh (0 by default)
  93507. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93508. */
  93509. renderingGroupId: number;
  93510. private _material;
  93511. /** Gets or sets current material */
  93512. material: Nullable<Material>;
  93513. /**
  93514. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93515. * @see http://doc.babylonjs.com/babylon101/shadows
  93516. */
  93517. receiveShadows: boolean;
  93518. /** Defines color to use when rendering outline */
  93519. outlineColor: Color3;
  93520. /** Define width to use when rendering outline */
  93521. outlineWidth: number;
  93522. /** Defines color to use when rendering overlay */
  93523. overlayColor: Color3;
  93524. /** Defines alpha to use when rendering overlay */
  93525. overlayAlpha: number;
  93526. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93527. hasVertexAlpha: boolean;
  93528. /** 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) */
  93529. useVertexColors: boolean;
  93530. /**
  93531. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93532. */
  93533. computeBonesUsingShaders: boolean;
  93534. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93535. numBoneInfluencers: number;
  93536. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93537. applyFog: boolean;
  93538. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93539. useOctreeForRenderingSelection: boolean;
  93540. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93541. useOctreeForPicking: boolean;
  93542. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93543. useOctreeForCollisions: boolean;
  93544. /**
  93545. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93546. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93547. */
  93548. layerMask: number;
  93549. /**
  93550. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93551. */
  93552. alwaysSelectAsActiveMesh: boolean;
  93553. /**
  93554. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93555. */
  93556. doNotSyncBoundingInfo: boolean;
  93557. /**
  93558. * Gets or sets the current action manager
  93559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93560. */
  93561. actionManager: Nullable<AbstractActionManager>;
  93562. private _meshCollisionData;
  93563. /**
  93564. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93566. */
  93567. ellipsoid: Vector3;
  93568. /**
  93569. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93571. */
  93572. ellipsoidOffset: Vector3;
  93573. /**
  93574. * Gets or sets a collision mask used to mask collisions (default is -1).
  93575. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93576. */
  93577. collisionMask: number;
  93578. /**
  93579. * Gets or sets the current collision group mask (-1 by default).
  93580. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93581. */
  93582. collisionGroup: number;
  93583. /**
  93584. * Defines edge width used when edgesRenderer is enabled
  93585. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93586. */
  93587. edgesWidth: number;
  93588. /**
  93589. * Defines edge color used when edgesRenderer is enabled
  93590. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93591. */
  93592. edgesColor: Color4;
  93593. /** @hidden */
  93594. _edgesRenderer: Nullable<IEdgesRenderer>;
  93595. /** @hidden */
  93596. _masterMesh: Nullable<AbstractMesh>;
  93597. /** @hidden */
  93598. _boundingInfo: Nullable<BoundingInfo>;
  93599. /** @hidden */
  93600. _renderId: number;
  93601. /**
  93602. * Gets or sets the list of subMeshes
  93603. * @see http://doc.babylonjs.com/how_to/multi_materials
  93604. */
  93605. subMeshes: SubMesh[];
  93606. /** @hidden */
  93607. _intersectionsInProgress: AbstractMesh[];
  93608. /** @hidden */
  93609. _unIndexed: boolean;
  93610. /** @hidden */
  93611. _lightSources: Light[];
  93612. /** Gets the list of lights affecting that mesh */
  93613. readonly lightSources: Light[];
  93614. /** @hidden */
  93615. readonly _positions: Nullable<Vector3[]>;
  93616. /** @hidden */
  93617. _waitingData: {
  93618. lods: Nullable<any>;
  93619. actions: Nullable<any>;
  93620. freezeWorldMatrix: Nullable<boolean>;
  93621. };
  93622. /** @hidden */
  93623. _bonesTransformMatrices: Nullable<Float32Array>;
  93624. /** @hidden */
  93625. _transformMatrixTexture: Nullable<RawTexture>;
  93626. /**
  93627. * Gets or sets a skeleton to apply skining transformations
  93628. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93629. */
  93630. skeleton: Nullable<Skeleton>;
  93631. /**
  93632. * An event triggered when the mesh is rebuilt.
  93633. */
  93634. onRebuildObservable: Observable<AbstractMesh>;
  93635. /**
  93636. * Creates a new AbstractMesh
  93637. * @param name defines the name of the mesh
  93638. * @param scene defines the hosting scene
  93639. */
  93640. constructor(name: string, scene?: Nullable<Scene>);
  93641. /**
  93642. * Returns the string "AbstractMesh"
  93643. * @returns "AbstractMesh"
  93644. */
  93645. getClassName(): string;
  93646. /**
  93647. * Gets a string representation of the current mesh
  93648. * @param fullDetails defines a boolean indicating if full details must be included
  93649. * @returns a string representation of the current mesh
  93650. */
  93651. toString(fullDetails?: boolean): string;
  93652. /**
  93653. * @hidden
  93654. */
  93655. protected _getEffectiveParent(): Nullable<Node>;
  93656. /** @hidden */
  93657. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93658. /** @hidden */
  93659. _rebuild(): void;
  93660. /** @hidden */
  93661. _resyncLightSources(): void;
  93662. /** @hidden */
  93663. _resyncLighSource(light: Light): void;
  93664. /** @hidden */
  93665. _unBindEffect(): void;
  93666. /** @hidden */
  93667. _removeLightSource(light: Light, dispose: boolean): void;
  93668. private _markSubMeshesAsDirty;
  93669. /** @hidden */
  93670. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93671. /** @hidden */
  93672. _markSubMeshesAsAttributesDirty(): void;
  93673. /** @hidden */
  93674. _markSubMeshesAsMiscDirty(): void;
  93675. /**
  93676. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93677. */
  93678. scaling: Vector3;
  93679. /**
  93680. * Returns true if the mesh is blocked. Implemented by child classes
  93681. */
  93682. readonly isBlocked: boolean;
  93683. /**
  93684. * Returns the mesh itself by default. Implemented by child classes
  93685. * @param camera defines the camera to use to pick the right LOD level
  93686. * @returns the currentAbstractMesh
  93687. */
  93688. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93689. /**
  93690. * Returns 0 by default. Implemented by child classes
  93691. * @returns an integer
  93692. */
  93693. getTotalVertices(): number;
  93694. /**
  93695. * Returns a positive integer : the total number of indices in this mesh geometry.
  93696. * @returns the numner of indices or zero if the mesh has no geometry.
  93697. */
  93698. getTotalIndices(): number;
  93699. /**
  93700. * Returns null by default. Implemented by child classes
  93701. * @returns null
  93702. */
  93703. getIndices(): Nullable<IndicesArray>;
  93704. /**
  93705. * Returns the array of the requested vertex data kind. Implemented by child classes
  93706. * @param kind defines the vertex data kind to use
  93707. * @returns null
  93708. */
  93709. getVerticesData(kind: string): Nullable<FloatArray>;
  93710. /**
  93711. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93712. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93713. * Note that a new underlying VertexBuffer object is created each call.
  93714. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93715. * @param kind defines vertex data kind:
  93716. * * VertexBuffer.PositionKind
  93717. * * VertexBuffer.UVKind
  93718. * * VertexBuffer.UV2Kind
  93719. * * VertexBuffer.UV3Kind
  93720. * * VertexBuffer.UV4Kind
  93721. * * VertexBuffer.UV5Kind
  93722. * * VertexBuffer.UV6Kind
  93723. * * VertexBuffer.ColorKind
  93724. * * VertexBuffer.MatricesIndicesKind
  93725. * * VertexBuffer.MatricesIndicesExtraKind
  93726. * * VertexBuffer.MatricesWeightsKind
  93727. * * VertexBuffer.MatricesWeightsExtraKind
  93728. * @param data defines the data source
  93729. * @param updatable defines if the data must be flagged as updatable (or static)
  93730. * @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
  93731. * @returns the current mesh
  93732. */
  93733. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93734. /**
  93735. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93736. * If the mesh has no geometry, it is simply returned as it is.
  93737. * @param kind defines vertex data kind:
  93738. * * VertexBuffer.PositionKind
  93739. * * VertexBuffer.UVKind
  93740. * * VertexBuffer.UV2Kind
  93741. * * VertexBuffer.UV3Kind
  93742. * * VertexBuffer.UV4Kind
  93743. * * VertexBuffer.UV5Kind
  93744. * * VertexBuffer.UV6Kind
  93745. * * VertexBuffer.ColorKind
  93746. * * VertexBuffer.MatricesIndicesKind
  93747. * * VertexBuffer.MatricesIndicesExtraKind
  93748. * * VertexBuffer.MatricesWeightsKind
  93749. * * VertexBuffer.MatricesWeightsExtraKind
  93750. * @param data defines the data source
  93751. * @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
  93752. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93753. * @returns the current mesh
  93754. */
  93755. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93756. /**
  93757. * Sets the mesh indices,
  93758. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93759. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93760. * @param totalVertices Defines the total number of vertices
  93761. * @returns the current mesh
  93762. */
  93763. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93764. /**
  93765. * Gets a boolean indicating if specific vertex data is present
  93766. * @param kind defines the vertex data kind to use
  93767. * @returns true is data kind is present
  93768. */
  93769. isVerticesDataPresent(kind: string): boolean;
  93770. /**
  93771. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93772. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93773. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93774. * @returns a BoundingInfo
  93775. */
  93776. getBoundingInfo(): BoundingInfo;
  93777. /**
  93778. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93779. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93780. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93781. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93782. * @returns the current mesh
  93783. */
  93784. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93785. /**
  93786. * Overwrite the current bounding info
  93787. * @param boundingInfo defines the new bounding info
  93788. * @returns the current mesh
  93789. */
  93790. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93791. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93792. readonly useBones: boolean;
  93793. /** @hidden */
  93794. _preActivate(): void;
  93795. /** @hidden */
  93796. _preActivateForIntermediateRendering(renderId: number): void;
  93797. /** @hidden */
  93798. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93799. /** @hidden */
  93800. _postActivate(): void;
  93801. /** @hidden */
  93802. _freeze(): void;
  93803. /** @hidden */
  93804. _unFreeze(): void;
  93805. /**
  93806. * Gets the current world matrix
  93807. * @returns a Matrix
  93808. */
  93809. getWorldMatrix(): Matrix;
  93810. /** @hidden */
  93811. _getWorldMatrixDeterminant(): number;
  93812. /**
  93813. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93814. */
  93815. readonly isAnInstance: boolean;
  93816. /**
  93817. * Gets a boolean indicating if this mesh has instances
  93818. */
  93819. readonly hasInstances: boolean;
  93820. /**
  93821. * Perform relative position change from the point of view of behind the front of the mesh.
  93822. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93823. * Supports definition of mesh facing forward or backward
  93824. * @param amountRight defines the distance on the right axis
  93825. * @param amountUp defines the distance on the up axis
  93826. * @param amountForward defines the distance on the forward axis
  93827. * @returns the current mesh
  93828. */
  93829. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93830. /**
  93831. * Calculate relative position change from the point of view of behind the front of the mesh.
  93832. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93833. * Supports definition of mesh facing forward or backward
  93834. * @param amountRight defines the distance on the right axis
  93835. * @param amountUp defines the distance on the up axis
  93836. * @param amountForward defines the distance on the forward axis
  93837. * @returns the new displacement vector
  93838. */
  93839. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93840. /**
  93841. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93842. * Supports definition of mesh facing forward or backward
  93843. * @param flipBack defines the flip
  93844. * @param twirlClockwise defines the twirl
  93845. * @param tiltRight defines the tilt
  93846. * @returns the current mesh
  93847. */
  93848. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93849. /**
  93850. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93851. * Supports definition of mesh facing forward or backward.
  93852. * @param flipBack defines the flip
  93853. * @param twirlClockwise defines the twirl
  93854. * @param tiltRight defines the tilt
  93855. * @returns the new rotation vector
  93856. */
  93857. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93858. /**
  93859. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93860. * This means the mesh underlying bounding box and sphere are recomputed.
  93861. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93862. * @returns the current mesh
  93863. */
  93864. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93865. /** @hidden */
  93866. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93867. /** @hidden */
  93868. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93869. /** @hidden */
  93870. _updateBoundingInfo(): AbstractMesh;
  93871. /** @hidden */
  93872. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93873. /** @hidden */
  93874. protected _afterComputeWorldMatrix(): void;
  93875. /** @hidden */
  93876. readonly _effectiveMesh: AbstractMesh;
  93877. /**
  93878. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93879. * A mesh is in the frustum if its bounding box intersects the frustum
  93880. * @param frustumPlanes defines the frustum to test
  93881. * @returns true if the mesh is in the frustum planes
  93882. */
  93883. isInFrustum(frustumPlanes: Plane[]): boolean;
  93884. /**
  93885. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93886. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93887. * @param frustumPlanes defines the frustum to test
  93888. * @returns true if the mesh is completely in the frustum planes
  93889. */
  93890. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93891. /**
  93892. * True if the mesh intersects another mesh or a SolidParticle object
  93893. * @param mesh defines a target mesh or SolidParticle to test
  93894. * @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)
  93895. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93896. * @returns true if there is an intersection
  93897. */
  93898. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93899. /**
  93900. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93901. * @param point defines the point to test
  93902. * @returns true if there is an intersection
  93903. */
  93904. intersectsPoint(point: Vector3): boolean;
  93905. /**
  93906. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93907. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93908. */
  93909. checkCollisions: boolean;
  93910. /**
  93911. * Gets Collider object used to compute collisions (not physics)
  93912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93913. */
  93914. readonly collider: Nullable<Collider>;
  93915. /**
  93916. * Move the mesh using collision engine
  93917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93918. * @param displacement defines the requested displacement vector
  93919. * @returns the current mesh
  93920. */
  93921. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93922. private _onCollisionPositionChange;
  93923. /** @hidden */
  93924. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93925. /** @hidden */
  93926. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93927. /** @hidden */
  93928. _checkCollision(collider: Collider): AbstractMesh;
  93929. /** @hidden */
  93930. _generatePointsArray(): boolean;
  93931. /**
  93932. * Checks if the passed Ray intersects with the mesh
  93933. * @param ray defines the ray to use
  93934. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93935. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93936. * @returns the picking info
  93937. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93938. */
  93939. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93940. /**
  93941. * Clones the current mesh
  93942. * @param name defines the mesh name
  93943. * @param newParent defines the new mesh parent
  93944. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93945. * @returns the new mesh
  93946. */
  93947. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93948. /**
  93949. * Disposes all the submeshes of the current meshnp
  93950. * @returns the current mesh
  93951. */
  93952. releaseSubMeshes(): AbstractMesh;
  93953. /**
  93954. * Releases resources associated with this abstract mesh.
  93955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93957. */
  93958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93959. /**
  93960. * Adds the passed mesh as a child to the current mesh
  93961. * @param mesh defines the child mesh
  93962. * @returns the current mesh
  93963. */
  93964. addChild(mesh: AbstractMesh): AbstractMesh;
  93965. /**
  93966. * Removes the passed mesh from the current mesh children list
  93967. * @param mesh defines the child mesh
  93968. * @returns the current mesh
  93969. */
  93970. removeChild(mesh: AbstractMesh): AbstractMesh;
  93971. /** @hidden */
  93972. private _initFacetData;
  93973. /**
  93974. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93975. * This method can be called within the render loop.
  93976. * 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
  93977. * @returns the current mesh
  93978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93979. */
  93980. updateFacetData(): AbstractMesh;
  93981. /**
  93982. * Returns the facetLocalNormals array.
  93983. * The normals are expressed in the mesh local spac
  93984. * @returns an array of Vector3
  93985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93986. */
  93987. getFacetLocalNormals(): Vector3[];
  93988. /**
  93989. * Returns the facetLocalPositions array.
  93990. * The facet positions are expressed in the mesh local space
  93991. * @returns an array of Vector3
  93992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93993. */
  93994. getFacetLocalPositions(): Vector3[];
  93995. /**
  93996. * Returns the facetLocalPartioning array
  93997. * @returns an array of array of numbers
  93998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93999. */
  94000. getFacetLocalPartitioning(): number[][];
  94001. /**
  94002. * Returns the i-th facet position in the world system.
  94003. * This method allocates a new Vector3 per call
  94004. * @param i defines the facet index
  94005. * @returns a new Vector3
  94006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94007. */
  94008. getFacetPosition(i: number): Vector3;
  94009. /**
  94010. * Sets the reference Vector3 with the i-th facet position in the world system
  94011. * @param i defines the facet index
  94012. * @param ref defines the target vector
  94013. * @returns the current mesh
  94014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94015. */
  94016. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94017. /**
  94018. * Returns the i-th facet normal in the world system.
  94019. * This method allocates a new Vector3 per call
  94020. * @param i defines the facet index
  94021. * @returns a new Vector3
  94022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94023. */
  94024. getFacetNormal(i: number): Vector3;
  94025. /**
  94026. * Sets the reference Vector3 with the i-th facet normal in the world system
  94027. * @param i defines the facet index
  94028. * @param ref defines the target vector
  94029. * @returns the current mesh
  94030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94031. */
  94032. getFacetNormalToRef(i: number, ref: Vector3): this;
  94033. /**
  94034. * 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)
  94035. * @param x defines x coordinate
  94036. * @param y defines y coordinate
  94037. * @param z defines z coordinate
  94038. * @returns the array of facet indexes
  94039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94040. */
  94041. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94042. /**
  94043. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94044. * @param projected sets as the (x,y,z) world projection on the facet
  94045. * @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
  94046. * @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
  94047. * @param x defines x coordinate
  94048. * @param y defines y coordinate
  94049. * @param z defines z coordinate
  94050. * @returns the face index if found (or null instead)
  94051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94052. */
  94053. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94054. /**
  94055. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94056. * @param projected sets as the (x,y,z) local projection on the facet
  94057. * @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
  94058. * @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
  94059. * @param x defines x coordinate
  94060. * @param y defines y coordinate
  94061. * @param z defines z coordinate
  94062. * @returns the face index if found (or null instead)
  94063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94064. */
  94065. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94066. /**
  94067. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94068. * @returns the parameters
  94069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94070. */
  94071. getFacetDataParameters(): any;
  94072. /**
  94073. * Disables the feature FacetData and frees the related memory
  94074. * @returns the current mesh
  94075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94076. */
  94077. disableFacetData(): AbstractMesh;
  94078. /**
  94079. * Updates the AbstractMesh indices array
  94080. * @param indices defines the data source
  94081. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94082. * @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)
  94083. * @returns the current mesh
  94084. */
  94085. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94086. /**
  94087. * Creates new normals data for the mesh
  94088. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94089. * @returns the current mesh
  94090. */
  94091. createNormals(updatable: boolean): AbstractMesh;
  94092. /**
  94093. * Align the mesh with a normal
  94094. * @param normal defines the normal to use
  94095. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94096. * @returns the current mesh
  94097. */
  94098. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94099. /** @hidden */
  94100. _checkOcclusionQuery(): boolean;
  94101. /**
  94102. * Disables the mesh edge rendering mode
  94103. * @returns the currentAbstractMesh
  94104. */
  94105. disableEdgesRendering(): AbstractMesh;
  94106. /**
  94107. * Enables the edge rendering mode on the mesh.
  94108. * This mode makes the mesh edges visible
  94109. * @param epsilon defines the maximal distance between two angles to detect a face
  94110. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94111. * @returns the currentAbstractMesh
  94112. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94113. */
  94114. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94115. }
  94116. }
  94117. declare module BABYLON {
  94118. /**
  94119. * Interface used to define ActionEvent
  94120. */
  94121. export interface IActionEvent {
  94122. /** The mesh or sprite that triggered the action */
  94123. source: any;
  94124. /** The X mouse cursor position at the time of the event */
  94125. pointerX: number;
  94126. /** The Y mouse cursor position at the time of the event */
  94127. pointerY: number;
  94128. /** The mesh that is currently pointed at (can be null) */
  94129. meshUnderPointer: Nullable<AbstractMesh>;
  94130. /** the original (browser) event that triggered the ActionEvent */
  94131. sourceEvent?: any;
  94132. /** additional data for the event */
  94133. additionalData?: any;
  94134. }
  94135. /**
  94136. * ActionEvent is the event being sent when an action is triggered.
  94137. */
  94138. export class ActionEvent implements IActionEvent {
  94139. /** The mesh or sprite that triggered the action */
  94140. source: any;
  94141. /** The X mouse cursor position at the time of the event */
  94142. pointerX: number;
  94143. /** The Y mouse cursor position at the time of the event */
  94144. pointerY: number;
  94145. /** The mesh that is currently pointed at (can be null) */
  94146. meshUnderPointer: Nullable<AbstractMesh>;
  94147. /** the original (browser) event that triggered the ActionEvent */
  94148. sourceEvent?: any;
  94149. /** additional data for the event */
  94150. additionalData?: any;
  94151. /**
  94152. * Creates a new ActionEvent
  94153. * @param source The mesh or sprite that triggered the action
  94154. * @param pointerX The X mouse cursor position at the time of the event
  94155. * @param pointerY The Y mouse cursor position at the time of the event
  94156. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94157. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94158. * @param additionalData additional data for the event
  94159. */
  94160. constructor(
  94161. /** The mesh or sprite that triggered the action */
  94162. source: any,
  94163. /** The X mouse cursor position at the time of the event */
  94164. pointerX: number,
  94165. /** The Y mouse cursor position at the time of the event */
  94166. pointerY: number,
  94167. /** The mesh that is currently pointed at (can be null) */
  94168. meshUnderPointer: Nullable<AbstractMesh>,
  94169. /** the original (browser) event that triggered the ActionEvent */
  94170. sourceEvent?: any,
  94171. /** additional data for the event */
  94172. additionalData?: any);
  94173. /**
  94174. * Helper function to auto-create an ActionEvent from a source mesh.
  94175. * @param source The source mesh that triggered the event
  94176. * @param evt The original (browser) event
  94177. * @param additionalData additional data for the event
  94178. * @returns the new ActionEvent
  94179. */
  94180. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94181. /**
  94182. * Helper function to auto-create an ActionEvent from a source sprite
  94183. * @param source The source sprite that triggered the event
  94184. * @param scene Scene associated with the sprite
  94185. * @param evt The original (browser) event
  94186. * @param additionalData additional data for the event
  94187. * @returns the new ActionEvent
  94188. */
  94189. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94190. /**
  94191. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94192. * @param scene the scene where the event occurred
  94193. * @param evt The original (browser) event
  94194. * @returns the new ActionEvent
  94195. */
  94196. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94197. /**
  94198. * Helper function to auto-create an ActionEvent from a primitive
  94199. * @param prim defines the target primitive
  94200. * @param pointerPos defines the pointer position
  94201. * @param evt The original (browser) event
  94202. * @param additionalData additional data for the event
  94203. * @returns the new ActionEvent
  94204. */
  94205. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94206. }
  94207. }
  94208. declare module BABYLON {
  94209. /**
  94210. * Abstract class used to decouple action Manager from scene and meshes.
  94211. * Do not instantiate.
  94212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94213. */
  94214. export abstract class AbstractActionManager implements IDisposable {
  94215. /** Gets the list of active triggers */
  94216. static Triggers: {
  94217. [key: string]: number;
  94218. };
  94219. /** Gets the cursor to use when hovering items */
  94220. hoverCursor: string;
  94221. /** Gets the list of actions */
  94222. actions: IAction[];
  94223. /**
  94224. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94225. */
  94226. isRecursive: boolean;
  94227. /**
  94228. * Releases all associated resources
  94229. */
  94230. abstract dispose(): void;
  94231. /**
  94232. * Does this action manager has pointer triggers
  94233. */
  94234. abstract readonly hasPointerTriggers: boolean;
  94235. /**
  94236. * Does this action manager has pick triggers
  94237. */
  94238. abstract readonly hasPickTriggers: boolean;
  94239. /**
  94240. * Process a specific trigger
  94241. * @param trigger defines the trigger to process
  94242. * @param evt defines the event details to be processed
  94243. */
  94244. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94245. /**
  94246. * Does this action manager handles actions of any of the given triggers
  94247. * @param triggers defines the triggers to be tested
  94248. * @return a boolean indicating whether one (or more) of the triggers is handled
  94249. */
  94250. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94251. /**
  94252. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94253. * speed.
  94254. * @param triggerA defines the trigger to be tested
  94255. * @param triggerB defines the trigger to be tested
  94256. * @return a boolean indicating whether one (or more) of the triggers is handled
  94257. */
  94258. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94259. /**
  94260. * Does this action manager handles actions of a given trigger
  94261. * @param trigger defines the trigger to be tested
  94262. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94263. * @return whether the trigger is handled
  94264. */
  94265. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94266. /**
  94267. * Serialize this manager to a JSON object
  94268. * @param name defines the property name to store this manager
  94269. * @returns a JSON representation of this manager
  94270. */
  94271. abstract serialize(name: string): any;
  94272. /**
  94273. * Registers an action to this action manager
  94274. * @param action defines the action to be registered
  94275. * @return the action amended (prepared) after registration
  94276. */
  94277. abstract registerAction(action: IAction): Nullable<IAction>;
  94278. /**
  94279. * Unregisters an action to this action manager
  94280. * @param action defines the action to be unregistered
  94281. * @return a boolean indicating whether the action has been unregistered
  94282. */
  94283. abstract unregisterAction(action: IAction): Boolean;
  94284. /**
  94285. * Does exist one action manager with at least one trigger
  94286. **/
  94287. static readonly HasTriggers: boolean;
  94288. /**
  94289. * Does exist one action manager with at least one pick trigger
  94290. **/
  94291. static readonly HasPickTriggers: boolean;
  94292. /**
  94293. * Does exist one action manager that handles actions of a given trigger
  94294. * @param trigger defines the trigger to be tested
  94295. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94296. **/
  94297. static HasSpecificTrigger(trigger: number): boolean;
  94298. }
  94299. }
  94300. declare module BABYLON {
  94301. /**
  94302. * Defines how a node can be built from a string name.
  94303. */
  94304. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94305. /**
  94306. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94307. */
  94308. export class Node implements IBehaviorAware<Node> {
  94309. /** @hidden */
  94310. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94311. private static _NodeConstructors;
  94312. /**
  94313. * Add a new node constructor
  94314. * @param type defines the type name of the node to construct
  94315. * @param constructorFunc defines the constructor function
  94316. */
  94317. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94318. /**
  94319. * Returns a node constructor based on type name
  94320. * @param type defines the type name
  94321. * @param name defines the new node name
  94322. * @param scene defines the hosting scene
  94323. * @param options defines optional options to transmit to constructors
  94324. * @returns the new constructor or null
  94325. */
  94326. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94327. /**
  94328. * Gets or sets the name of the node
  94329. */
  94330. name: string;
  94331. /**
  94332. * Gets or sets the id of the node
  94333. */
  94334. id: string;
  94335. /**
  94336. * Gets or sets the unique id of the node
  94337. */
  94338. uniqueId: number;
  94339. /**
  94340. * Gets or sets a string used to store user defined state for the node
  94341. */
  94342. state: string;
  94343. /**
  94344. * Gets or sets an object used to store user defined information for the node
  94345. */
  94346. metadata: any;
  94347. /**
  94348. * For internal use only. Please do not use.
  94349. */
  94350. reservedDataStore: any;
  94351. /**
  94352. * List of inspectable custom properties (used by the Inspector)
  94353. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94354. */
  94355. inspectableCustomProperties: IInspectable[];
  94356. private _doNotSerialize;
  94357. /**
  94358. * Gets or sets a boolean used to define if the node must be serialized
  94359. */
  94360. doNotSerialize: boolean;
  94361. /** @hidden */
  94362. _isDisposed: boolean;
  94363. /**
  94364. * Gets a list of Animations associated with the node
  94365. */
  94366. animations: Animation[];
  94367. protected _ranges: {
  94368. [name: string]: Nullable<AnimationRange>;
  94369. };
  94370. /**
  94371. * Callback raised when the node is ready to be used
  94372. */
  94373. onReady: Nullable<(node: Node) => void>;
  94374. private _isEnabled;
  94375. private _isParentEnabled;
  94376. private _isReady;
  94377. /** @hidden */
  94378. _currentRenderId: number;
  94379. private _parentUpdateId;
  94380. /** @hidden */
  94381. _childUpdateId: number;
  94382. /** @hidden */
  94383. _waitingParentId: Nullable<string>;
  94384. /** @hidden */
  94385. _scene: Scene;
  94386. /** @hidden */
  94387. _cache: any;
  94388. private _parentNode;
  94389. private _children;
  94390. /** @hidden */
  94391. _worldMatrix: Matrix;
  94392. /** @hidden */
  94393. _worldMatrixDeterminant: number;
  94394. /** @hidden */
  94395. _worldMatrixDeterminantIsDirty: boolean;
  94396. /** @hidden */
  94397. private _sceneRootNodesIndex;
  94398. /**
  94399. * Gets a boolean indicating if the node has been disposed
  94400. * @returns true if the node was disposed
  94401. */
  94402. isDisposed(): boolean;
  94403. /**
  94404. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94405. * @see https://doc.babylonjs.com/how_to/parenting
  94406. */
  94407. parent: Nullable<Node>;
  94408. private addToSceneRootNodes;
  94409. private removeFromSceneRootNodes;
  94410. private _animationPropertiesOverride;
  94411. /**
  94412. * Gets or sets the animation properties override
  94413. */
  94414. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94415. /**
  94416. * Gets a string idenfifying the name of the class
  94417. * @returns "Node" string
  94418. */
  94419. getClassName(): string;
  94420. /** @hidden */
  94421. readonly _isNode: boolean;
  94422. /**
  94423. * An event triggered when the mesh is disposed
  94424. */
  94425. onDisposeObservable: Observable<Node>;
  94426. private _onDisposeObserver;
  94427. /**
  94428. * Sets a callback that will be raised when the node will be disposed
  94429. */
  94430. onDispose: () => void;
  94431. /**
  94432. * Creates a new Node
  94433. * @param name the name and id to be given to this node
  94434. * @param scene the scene this node will be added to
  94435. * @param addToRootNodes the node will be added to scene.rootNodes
  94436. */
  94437. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94438. /**
  94439. * Gets the scene of the node
  94440. * @returns a scene
  94441. */
  94442. getScene(): Scene;
  94443. /**
  94444. * Gets the engine of the node
  94445. * @returns a Engine
  94446. */
  94447. getEngine(): Engine;
  94448. private _behaviors;
  94449. /**
  94450. * Attach a behavior to the node
  94451. * @see http://doc.babylonjs.com/features/behaviour
  94452. * @param behavior defines the behavior to attach
  94453. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94454. * @returns the current Node
  94455. */
  94456. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94457. /**
  94458. * Remove an attached behavior
  94459. * @see http://doc.babylonjs.com/features/behaviour
  94460. * @param behavior defines the behavior to attach
  94461. * @returns the current Node
  94462. */
  94463. removeBehavior(behavior: Behavior<Node>): Node;
  94464. /**
  94465. * Gets the list of attached behaviors
  94466. * @see http://doc.babylonjs.com/features/behaviour
  94467. */
  94468. readonly behaviors: Behavior<Node>[];
  94469. /**
  94470. * Gets an attached behavior by name
  94471. * @param name defines the name of the behavior to look for
  94472. * @see http://doc.babylonjs.com/features/behaviour
  94473. * @returns null if behavior was not found else the requested behavior
  94474. */
  94475. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94476. /**
  94477. * Returns the latest update of the World matrix
  94478. * @returns a Matrix
  94479. */
  94480. getWorldMatrix(): Matrix;
  94481. /** @hidden */
  94482. _getWorldMatrixDeterminant(): number;
  94483. /**
  94484. * Returns directly the latest state of the mesh World matrix.
  94485. * A Matrix is returned.
  94486. */
  94487. readonly worldMatrixFromCache: Matrix;
  94488. /** @hidden */
  94489. _initCache(): void;
  94490. /** @hidden */
  94491. updateCache(force?: boolean): void;
  94492. /** @hidden */
  94493. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94494. /** @hidden */
  94495. _updateCache(ignoreParentClass?: boolean): void;
  94496. /** @hidden */
  94497. _isSynchronized(): boolean;
  94498. /** @hidden */
  94499. _markSyncedWithParent(): void;
  94500. /** @hidden */
  94501. isSynchronizedWithParent(): boolean;
  94502. /** @hidden */
  94503. isSynchronized(): boolean;
  94504. /**
  94505. * Is this node ready to be used/rendered
  94506. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94507. * @return true if the node is ready
  94508. */
  94509. isReady(completeCheck?: boolean): boolean;
  94510. /**
  94511. * Is this node enabled?
  94512. * 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
  94513. * @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
  94514. * @return whether this node (and its parent) is enabled
  94515. */
  94516. isEnabled(checkAncestors?: boolean): boolean;
  94517. /** @hidden */
  94518. protected _syncParentEnabledState(): void;
  94519. /**
  94520. * Set the enabled state of this node
  94521. * @param value defines the new enabled state
  94522. */
  94523. setEnabled(value: boolean): void;
  94524. /**
  94525. * Is this node a descendant of the given node?
  94526. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94527. * @param ancestor defines the parent node to inspect
  94528. * @returns a boolean indicating if this node is a descendant of the given node
  94529. */
  94530. isDescendantOf(ancestor: Node): boolean;
  94531. /** @hidden */
  94532. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94533. /**
  94534. * Will return all nodes that have this node as ascendant
  94535. * @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
  94536. * @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
  94537. * @return all children nodes of all types
  94538. */
  94539. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94540. /**
  94541. * Get all child-meshes of this node
  94542. * @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)
  94543. * @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
  94544. * @returns an array of AbstractMesh
  94545. */
  94546. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94547. /**
  94548. * Get all direct children of this node
  94549. * @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
  94550. * @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)
  94551. * @returns an array of Node
  94552. */
  94553. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94554. /** @hidden */
  94555. _setReady(state: boolean): void;
  94556. /**
  94557. * Get an animation by name
  94558. * @param name defines the name of the animation to look for
  94559. * @returns null if not found else the requested animation
  94560. */
  94561. getAnimationByName(name: string): Nullable<Animation>;
  94562. /**
  94563. * Creates an animation range for this node
  94564. * @param name defines the name of the range
  94565. * @param from defines the starting key
  94566. * @param to defines the end key
  94567. */
  94568. createAnimationRange(name: string, from: number, to: number): void;
  94569. /**
  94570. * Delete a specific animation range
  94571. * @param name defines the name of the range to delete
  94572. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94573. */
  94574. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94575. /**
  94576. * Get an animation range by name
  94577. * @param name defines the name of the animation range to look for
  94578. * @returns null if not found else the requested animation range
  94579. */
  94580. getAnimationRange(name: string): Nullable<AnimationRange>;
  94581. /**
  94582. * Gets the list of all animation ranges defined on this node
  94583. * @returns an array
  94584. */
  94585. getAnimationRanges(): Nullable<AnimationRange>[];
  94586. /**
  94587. * Will start the animation sequence
  94588. * @param name defines the range frames for animation sequence
  94589. * @param loop defines if the animation should loop (false by default)
  94590. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94591. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94592. * @returns the object created for this animation. If range does not exist, it will return null
  94593. */
  94594. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94595. /**
  94596. * Serialize animation ranges into a JSON compatible object
  94597. * @returns serialization object
  94598. */
  94599. serializeAnimationRanges(): any;
  94600. /**
  94601. * Computes the world matrix of the node
  94602. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94603. * @returns the world matrix
  94604. */
  94605. computeWorldMatrix(force?: boolean): Matrix;
  94606. /**
  94607. * Releases resources associated with this node.
  94608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94610. */
  94611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94612. /**
  94613. * Parse animation range data from a serialization object and store them into a given node
  94614. * @param node defines where to store the animation ranges
  94615. * @param parsedNode defines the serialization object to read data from
  94616. * @param scene defines the hosting scene
  94617. */
  94618. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94619. /**
  94620. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94621. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94622. * @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
  94623. * @returns the new bounding vectors
  94624. */
  94625. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94626. min: Vector3;
  94627. max: Vector3;
  94628. };
  94629. }
  94630. }
  94631. declare module BABYLON {
  94632. /**
  94633. * @hidden
  94634. */
  94635. export class _IAnimationState {
  94636. key: number;
  94637. repeatCount: number;
  94638. workValue?: any;
  94639. loopMode?: number;
  94640. offsetValue?: any;
  94641. highLimitValue?: any;
  94642. }
  94643. /**
  94644. * Class used to store any kind of animation
  94645. */
  94646. export class Animation {
  94647. /**Name of the animation */
  94648. name: string;
  94649. /**Property to animate */
  94650. targetProperty: string;
  94651. /**The frames per second of the animation */
  94652. framePerSecond: number;
  94653. /**The data type of the animation */
  94654. dataType: number;
  94655. /**The loop mode of the animation */
  94656. loopMode?: number | undefined;
  94657. /**Specifies if blending should be enabled */
  94658. enableBlending?: boolean | undefined;
  94659. /**
  94660. * Use matrix interpolation instead of using direct key value when animating matrices
  94661. */
  94662. static AllowMatricesInterpolation: boolean;
  94663. /**
  94664. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94665. */
  94666. static AllowMatrixDecomposeForInterpolation: boolean;
  94667. /**
  94668. * Stores the key frames of the animation
  94669. */
  94670. private _keys;
  94671. /**
  94672. * Stores the easing function of the animation
  94673. */
  94674. private _easingFunction;
  94675. /**
  94676. * @hidden Internal use only
  94677. */
  94678. _runtimeAnimations: RuntimeAnimation[];
  94679. /**
  94680. * The set of event that will be linked to this animation
  94681. */
  94682. private _events;
  94683. /**
  94684. * Stores an array of target property paths
  94685. */
  94686. targetPropertyPath: string[];
  94687. /**
  94688. * Stores the blending speed of the animation
  94689. */
  94690. blendingSpeed: number;
  94691. /**
  94692. * Stores the animation ranges for the animation
  94693. */
  94694. private _ranges;
  94695. /**
  94696. * @hidden Internal use
  94697. */
  94698. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94699. /**
  94700. * Sets up an animation
  94701. * @param property The property to animate
  94702. * @param animationType The animation type to apply
  94703. * @param framePerSecond The frames per second of the animation
  94704. * @param easingFunction The easing function used in the animation
  94705. * @returns The created animation
  94706. */
  94707. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94708. /**
  94709. * Create and start an animation on a node
  94710. * @param name defines the name of the global animation that will be run on all nodes
  94711. * @param node defines the root node where the animation will take place
  94712. * @param targetProperty defines property to animate
  94713. * @param framePerSecond defines the number of frame per second yo use
  94714. * @param totalFrame defines the number of frames in total
  94715. * @param from defines the initial value
  94716. * @param to defines the final value
  94717. * @param loopMode defines which loop mode you want to use (off by default)
  94718. * @param easingFunction defines the easing function to use (linear by default)
  94719. * @param onAnimationEnd defines the callback to call when animation end
  94720. * @returns the animatable created for this animation
  94721. */
  94722. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94723. /**
  94724. * Create and start an animation on a node and its descendants
  94725. * @param name defines the name of the global animation that will be run on all nodes
  94726. * @param node defines the root node where the animation will take place
  94727. * @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
  94728. * @param targetProperty defines property to animate
  94729. * @param framePerSecond defines the number of frame per second to use
  94730. * @param totalFrame defines the number of frames in total
  94731. * @param from defines the initial value
  94732. * @param to defines the final value
  94733. * @param loopMode defines which loop mode you want to use (off by default)
  94734. * @param easingFunction defines the easing function to use (linear by default)
  94735. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94736. * @returns the list of animatables created for all nodes
  94737. * @example https://www.babylonjs-playground.com/#MH0VLI
  94738. */
  94739. 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[]>;
  94740. /**
  94741. * Creates a new animation, merges it with the existing animations and starts it
  94742. * @param name Name of the animation
  94743. * @param node Node which contains the scene that begins the animations
  94744. * @param targetProperty Specifies which property to animate
  94745. * @param framePerSecond The frames per second of the animation
  94746. * @param totalFrame The total number of frames
  94747. * @param from The frame at the beginning of the animation
  94748. * @param to The frame at the end of the animation
  94749. * @param loopMode Specifies the loop mode of the animation
  94750. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94751. * @param onAnimationEnd Callback to run once the animation is complete
  94752. * @returns Nullable animation
  94753. */
  94754. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94755. /**
  94756. * Transition property of an host to the target Value
  94757. * @param property The property to transition
  94758. * @param targetValue The target Value of the property
  94759. * @param host The object where the property to animate belongs
  94760. * @param scene Scene used to run the animation
  94761. * @param frameRate Framerate (in frame/s) to use
  94762. * @param transition The transition type we want to use
  94763. * @param duration The duration of the animation, in milliseconds
  94764. * @param onAnimationEnd Callback trigger at the end of the animation
  94765. * @returns Nullable animation
  94766. */
  94767. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94768. /**
  94769. * Return the array of runtime animations currently using this animation
  94770. */
  94771. readonly runtimeAnimations: RuntimeAnimation[];
  94772. /**
  94773. * Specifies if any of the runtime animations are currently running
  94774. */
  94775. readonly hasRunningRuntimeAnimations: boolean;
  94776. /**
  94777. * Initializes the animation
  94778. * @param name Name of the animation
  94779. * @param targetProperty Property to animate
  94780. * @param framePerSecond The frames per second of the animation
  94781. * @param dataType The data type of the animation
  94782. * @param loopMode The loop mode of the animation
  94783. * @param enableBlending Specifies if blending should be enabled
  94784. */
  94785. constructor(
  94786. /**Name of the animation */
  94787. name: string,
  94788. /**Property to animate */
  94789. targetProperty: string,
  94790. /**The frames per second of the animation */
  94791. framePerSecond: number,
  94792. /**The data type of the animation */
  94793. dataType: number,
  94794. /**The loop mode of the animation */
  94795. loopMode?: number | undefined,
  94796. /**Specifies if blending should be enabled */
  94797. enableBlending?: boolean | undefined);
  94798. /**
  94799. * Converts the animation to a string
  94800. * @param fullDetails support for multiple levels of logging within scene loading
  94801. * @returns String form of the animation
  94802. */
  94803. toString(fullDetails?: boolean): string;
  94804. /**
  94805. * Add an event to this animation
  94806. * @param event Event to add
  94807. */
  94808. addEvent(event: AnimationEvent): void;
  94809. /**
  94810. * Remove all events found at the given frame
  94811. * @param frame The frame to remove events from
  94812. */
  94813. removeEvents(frame: number): void;
  94814. /**
  94815. * Retrieves all the events from the animation
  94816. * @returns Events from the animation
  94817. */
  94818. getEvents(): AnimationEvent[];
  94819. /**
  94820. * Creates an animation range
  94821. * @param name Name of the animation range
  94822. * @param from Starting frame of the animation range
  94823. * @param to Ending frame of the animation
  94824. */
  94825. createRange(name: string, from: number, to: number): void;
  94826. /**
  94827. * Deletes an animation range by name
  94828. * @param name Name of the animation range to delete
  94829. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94830. */
  94831. deleteRange(name: string, deleteFrames?: boolean): void;
  94832. /**
  94833. * Gets the animation range by name, or null if not defined
  94834. * @param name Name of the animation range
  94835. * @returns Nullable animation range
  94836. */
  94837. getRange(name: string): Nullable<AnimationRange>;
  94838. /**
  94839. * Gets the key frames from the animation
  94840. * @returns The key frames of the animation
  94841. */
  94842. getKeys(): Array<IAnimationKey>;
  94843. /**
  94844. * Gets the highest frame rate of the animation
  94845. * @returns Highest frame rate of the animation
  94846. */
  94847. getHighestFrame(): number;
  94848. /**
  94849. * Gets the easing function of the animation
  94850. * @returns Easing function of the animation
  94851. */
  94852. getEasingFunction(): IEasingFunction;
  94853. /**
  94854. * Sets the easing function of the animation
  94855. * @param easingFunction A custom mathematical formula for animation
  94856. */
  94857. setEasingFunction(easingFunction: EasingFunction): void;
  94858. /**
  94859. * Interpolates a scalar linearly
  94860. * @param startValue Start value of the animation curve
  94861. * @param endValue End value of the animation curve
  94862. * @param gradient Scalar amount to interpolate
  94863. * @returns Interpolated scalar value
  94864. */
  94865. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94866. /**
  94867. * Interpolates a scalar cubically
  94868. * @param startValue Start value of the animation curve
  94869. * @param outTangent End tangent of the animation
  94870. * @param endValue End value of the animation curve
  94871. * @param inTangent Start tangent of the animation curve
  94872. * @param gradient Scalar amount to interpolate
  94873. * @returns Interpolated scalar value
  94874. */
  94875. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94876. /**
  94877. * Interpolates a quaternion using a spherical linear interpolation
  94878. * @param startValue Start value of the animation curve
  94879. * @param endValue End value of the animation curve
  94880. * @param gradient Scalar amount to interpolate
  94881. * @returns Interpolated quaternion value
  94882. */
  94883. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94884. /**
  94885. * Interpolates a quaternion cubically
  94886. * @param startValue Start value of the animation curve
  94887. * @param outTangent End tangent of the animation curve
  94888. * @param endValue End value of the animation curve
  94889. * @param inTangent Start tangent of the animation curve
  94890. * @param gradient Scalar amount to interpolate
  94891. * @returns Interpolated quaternion value
  94892. */
  94893. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94894. /**
  94895. * Interpolates a Vector3 linearl
  94896. * @param startValue Start value of the animation curve
  94897. * @param endValue End value of the animation curve
  94898. * @param gradient Scalar amount to interpolate
  94899. * @returns Interpolated scalar value
  94900. */
  94901. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94902. /**
  94903. * Interpolates a Vector3 cubically
  94904. * @param startValue Start value of the animation curve
  94905. * @param outTangent End tangent of the animation
  94906. * @param endValue End value of the animation curve
  94907. * @param inTangent Start tangent of the animation curve
  94908. * @param gradient Scalar amount to interpolate
  94909. * @returns InterpolatedVector3 value
  94910. */
  94911. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94912. /**
  94913. * Interpolates a Vector2 linearly
  94914. * @param startValue Start value of the animation curve
  94915. * @param endValue End value of the animation curve
  94916. * @param gradient Scalar amount to interpolate
  94917. * @returns Interpolated Vector2 value
  94918. */
  94919. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94920. /**
  94921. * Interpolates a Vector2 cubically
  94922. * @param startValue Start value of the animation curve
  94923. * @param outTangent End tangent of the animation
  94924. * @param endValue End value of the animation curve
  94925. * @param inTangent Start tangent of the animation curve
  94926. * @param gradient Scalar amount to interpolate
  94927. * @returns Interpolated Vector2 value
  94928. */
  94929. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94930. /**
  94931. * Interpolates a size linearly
  94932. * @param startValue Start value of the animation curve
  94933. * @param endValue End value of the animation curve
  94934. * @param gradient Scalar amount to interpolate
  94935. * @returns Interpolated Size value
  94936. */
  94937. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94938. /**
  94939. * Interpolates a Color3 linearly
  94940. * @param startValue Start value of the animation curve
  94941. * @param endValue End value of the animation curve
  94942. * @param gradient Scalar amount to interpolate
  94943. * @returns Interpolated Color3 value
  94944. */
  94945. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94946. /**
  94947. * @hidden Internal use only
  94948. */
  94949. _getKeyValue(value: any): any;
  94950. /**
  94951. * @hidden Internal use only
  94952. */
  94953. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94954. /**
  94955. * Defines the function to use to interpolate matrices
  94956. * @param startValue defines the start matrix
  94957. * @param endValue defines the end matrix
  94958. * @param gradient defines the gradient between both matrices
  94959. * @param result defines an optional target matrix where to store the interpolation
  94960. * @returns the interpolated matrix
  94961. */
  94962. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94963. /**
  94964. * Makes a copy of the animation
  94965. * @returns Cloned animation
  94966. */
  94967. clone(): Animation;
  94968. /**
  94969. * Sets the key frames of the animation
  94970. * @param values The animation key frames to set
  94971. */
  94972. setKeys(values: Array<IAnimationKey>): void;
  94973. /**
  94974. * Serializes the animation to an object
  94975. * @returns Serialized object
  94976. */
  94977. serialize(): any;
  94978. /**
  94979. * Float animation type
  94980. */
  94981. private static _ANIMATIONTYPE_FLOAT;
  94982. /**
  94983. * Vector3 animation type
  94984. */
  94985. private static _ANIMATIONTYPE_VECTOR3;
  94986. /**
  94987. * Quaternion animation type
  94988. */
  94989. private static _ANIMATIONTYPE_QUATERNION;
  94990. /**
  94991. * Matrix animation type
  94992. */
  94993. private static _ANIMATIONTYPE_MATRIX;
  94994. /**
  94995. * Color3 animation type
  94996. */
  94997. private static _ANIMATIONTYPE_COLOR3;
  94998. /**
  94999. * Vector2 animation type
  95000. */
  95001. private static _ANIMATIONTYPE_VECTOR2;
  95002. /**
  95003. * Size animation type
  95004. */
  95005. private static _ANIMATIONTYPE_SIZE;
  95006. /**
  95007. * Relative Loop Mode
  95008. */
  95009. private static _ANIMATIONLOOPMODE_RELATIVE;
  95010. /**
  95011. * Cycle Loop Mode
  95012. */
  95013. private static _ANIMATIONLOOPMODE_CYCLE;
  95014. /**
  95015. * Constant Loop Mode
  95016. */
  95017. private static _ANIMATIONLOOPMODE_CONSTANT;
  95018. /**
  95019. * Get the float animation type
  95020. */
  95021. static readonly ANIMATIONTYPE_FLOAT: number;
  95022. /**
  95023. * Get the Vector3 animation type
  95024. */
  95025. static readonly ANIMATIONTYPE_VECTOR3: number;
  95026. /**
  95027. * Get the Vector2 animation type
  95028. */
  95029. static readonly ANIMATIONTYPE_VECTOR2: number;
  95030. /**
  95031. * Get the Size animation type
  95032. */
  95033. static readonly ANIMATIONTYPE_SIZE: number;
  95034. /**
  95035. * Get the Quaternion animation type
  95036. */
  95037. static readonly ANIMATIONTYPE_QUATERNION: number;
  95038. /**
  95039. * Get the Matrix animation type
  95040. */
  95041. static readonly ANIMATIONTYPE_MATRIX: number;
  95042. /**
  95043. * Get the Color3 animation type
  95044. */
  95045. static readonly ANIMATIONTYPE_COLOR3: number;
  95046. /**
  95047. * Get the Relative Loop Mode
  95048. */
  95049. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95050. /**
  95051. * Get the Cycle Loop Mode
  95052. */
  95053. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95054. /**
  95055. * Get the Constant Loop Mode
  95056. */
  95057. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95058. /** @hidden */
  95059. static _UniversalLerp(left: any, right: any, amount: number): any;
  95060. /**
  95061. * Parses an animation object and creates an animation
  95062. * @param parsedAnimation Parsed animation object
  95063. * @returns Animation object
  95064. */
  95065. static Parse(parsedAnimation: any): Animation;
  95066. /**
  95067. * Appends the serialized animations from the source animations
  95068. * @param source Source containing the animations
  95069. * @param destination Target to store the animations
  95070. */
  95071. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95072. }
  95073. }
  95074. declare module BABYLON {
  95075. /**
  95076. * Interface containing an array of animations
  95077. */
  95078. export interface IAnimatable {
  95079. /**
  95080. * Array of animations
  95081. */
  95082. animations: Nullable<Array<Animation>>;
  95083. }
  95084. }
  95085. declare module BABYLON {
  95086. /**
  95087. * This represents all the required information to add a fresnel effect on a material:
  95088. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95089. */
  95090. export class FresnelParameters {
  95091. private _isEnabled;
  95092. /**
  95093. * Define if the fresnel effect is enable or not.
  95094. */
  95095. isEnabled: boolean;
  95096. /**
  95097. * Define the color used on edges (grazing angle)
  95098. */
  95099. leftColor: Color3;
  95100. /**
  95101. * Define the color used on center
  95102. */
  95103. rightColor: Color3;
  95104. /**
  95105. * Define bias applied to computed fresnel term
  95106. */
  95107. bias: number;
  95108. /**
  95109. * Defined the power exponent applied to fresnel term
  95110. */
  95111. power: number;
  95112. /**
  95113. * Clones the current fresnel and its valuues
  95114. * @returns a clone fresnel configuration
  95115. */
  95116. clone(): FresnelParameters;
  95117. /**
  95118. * Serializes the current fresnel parameters to a JSON representation.
  95119. * @return the JSON serialization
  95120. */
  95121. serialize(): any;
  95122. /**
  95123. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95124. * @param parsedFresnelParameters Define the JSON representation
  95125. * @returns the parsed parameters
  95126. */
  95127. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95128. }
  95129. }
  95130. declare module BABYLON {
  95131. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95132. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95133. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95134. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95135. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95136. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95137. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95138. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95139. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95140. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95141. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95142. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95143. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95144. /**
  95145. * Decorator used to define property that can be serialized as reference to a camera
  95146. * @param sourceName defines the name of the property to decorate
  95147. */
  95148. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95149. /**
  95150. * Class used to help serialization objects
  95151. */
  95152. export class SerializationHelper {
  95153. /** @hidden */
  95154. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95155. /** @hidden */
  95156. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95157. /** @hidden */
  95158. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95159. /** @hidden */
  95160. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95161. /**
  95162. * Appends the serialized animations from the source animations
  95163. * @param source Source containing the animations
  95164. * @param destination Target to store the animations
  95165. */
  95166. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95167. /**
  95168. * Static function used to serialized a specific entity
  95169. * @param entity defines the entity to serialize
  95170. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95171. * @returns a JSON compatible object representing the serialization of the entity
  95172. */
  95173. static Serialize<T>(entity: T, serializationObject?: any): any;
  95174. /**
  95175. * Creates a new entity from a serialization data object
  95176. * @param creationFunction defines a function used to instanciated the new entity
  95177. * @param source defines the source serialization data
  95178. * @param scene defines the hosting scene
  95179. * @param rootUrl defines the root url for resources
  95180. * @returns a new entity
  95181. */
  95182. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95183. /**
  95184. * Clones an object
  95185. * @param creationFunction defines the function used to instanciate the new object
  95186. * @param source defines the source object
  95187. * @returns the cloned object
  95188. */
  95189. static Clone<T>(creationFunction: () => T, source: T): T;
  95190. /**
  95191. * Instanciates a new object based on a source one (some data will be shared between both object)
  95192. * @param creationFunction defines the function used to instanciate the new object
  95193. * @param source defines the source object
  95194. * @returns the new object
  95195. */
  95196. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95197. }
  95198. }
  95199. declare module BABYLON {
  95200. /**
  95201. * Class used to manipulate GUIDs
  95202. */
  95203. export class GUID {
  95204. /**
  95205. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95206. * Be aware Math.random() could cause collisions, but:
  95207. * "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"
  95208. * @returns a pseudo random id
  95209. */
  95210. static RandomId(): string;
  95211. }
  95212. }
  95213. declare module BABYLON {
  95214. /**
  95215. * Base class of all the textures in babylon.
  95216. * It groups all the common properties the materials, post process, lights... might need
  95217. * in order to make a correct use of the texture.
  95218. */
  95219. export class BaseTexture implements IAnimatable {
  95220. /**
  95221. * Default anisotropic filtering level for the application.
  95222. * It is set to 4 as a good tradeoff between perf and quality.
  95223. */
  95224. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95225. /**
  95226. * Gets or sets the unique id of the texture
  95227. */
  95228. uniqueId: number;
  95229. /**
  95230. * Define the name of the texture.
  95231. */
  95232. name: string;
  95233. /**
  95234. * Gets or sets an object used to store user defined information.
  95235. */
  95236. metadata: any;
  95237. /**
  95238. * For internal use only. Please do not use.
  95239. */
  95240. reservedDataStore: any;
  95241. private _hasAlpha;
  95242. /**
  95243. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95244. */
  95245. hasAlpha: boolean;
  95246. /**
  95247. * Defines if the alpha value should be determined via the rgb values.
  95248. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95249. */
  95250. getAlphaFromRGB: boolean;
  95251. /**
  95252. * Intensity or strength of the texture.
  95253. * It is commonly used by materials to fine tune the intensity of the texture
  95254. */
  95255. level: number;
  95256. /**
  95257. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95258. * This is part of the texture as textures usually maps to one uv set.
  95259. */
  95260. coordinatesIndex: number;
  95261. private _coordinatesMode;
  95262. /**
  95263. * How a texture is mapped.
  95264. *
  95265. * | Value | Type | Description |
  95266. * | ----- | ----------------------------------- | ----------- |
  95267. * | 0 | EXPLICIT_MODE | |
  95268. * | 1 | SPHERICAL_MODE | |
  95269. * | 2 | PLANAR_MODE | |
  95270. * | 3 | CUBIC_MODE | |
  95271. * | 4 | PROJECTION_MODE | |
  95272. * | 5 | SKYBOX_MODE | |
  95273. * | 6 | INVCUBIC_MODE | |
  95274. * | 7 | EQUIRECTANGULAR_MODE | |
  95275. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95276. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95277. */
  95278. coordinatesMode: number;
  95279. /**
  95280. * | Value | Type | Description |
  95281. * | ----- | ------------------ | ----------- |
  95282. * | 0 | CLAMP_ADDRESSMODE | |
  95283. * | 1 | WRAP_ADDRESSMODE | |
  95284. * | 2 | MIRROR_ADDRESSMODE | |
  95285. */
  95286. wrapU: number;
  95287. /**
  95288. * | Value | Type | Description |
  95289. * | ----- | ------------------ | ----------- |
  95290. * | 0 | CLAMP_ADDRESSMODE | |
  95291. * | 1 | WRAP_ADDRESSMODE | |
  95292. * | 2 | MIRROR_ADDRESSMODE | |
  95293. */
  95294. wrapV: number;
  95295. /**
  95296. * | Value | Type | Description |
  95297. * | ----- | ------------------ | ----------- |
  95298. * | 0 | CLAMP_ADDRESSMODE | |
  95299. * | 1 | WRAP_ADDRESSMODE | |
  95300. * | 2 | MIRROR_ADDRESSMODE | |
  95301. */
  95302. wrapR: number;
  95303. /**
  95304. * With compliant hardware and browser (supporting anisotropic filtering)
  95305. * this defines the level of anisotropic filtering in the texture.
  95306. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95307. */
  95308. anisotropicFilteringLevel: number;
  95309. /**
  95310. * Define if the texture is a cube texture or if false a 2d texture.
  95311. */
  95312. isCube: boolean;
  95313. /**
  95314. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95315. */
  95316. is3D: boolean;
  95317. /**
  95318. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95319. * HDR texture are usually stored in linear space.
  95320. * This only impacts the PBR and Background materials
  95321. */
  95322. gammaSpace: boolean;
  95323. /**
  95324. * Gets or sets whether or not the texture contains RGBD data.
  95325. */
  95326. isRGBD: boolean;
  95327. /**
  95328. * Is Z inverted in the texture (useful in a cube texture).
  95329. */
  95330. invertZ: boolean;
  95331. /**
  95332. * Are mip maps generated for this texture or not.
  95333. */
  95334. readonly noMipmap: boolean;
  95335. /**
  95336. * @hidden
  95337. */
  95338. lodLevelInAlpha: boolean;
  95339. /**
  95340. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95341. */
  95342. lodGenerationOffset: number;
  95343. /**
  95344. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95345. */
  95346. lodGenerationScale: number;
  95347. /**
  95348. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95349. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95350. * average roughness values.
  95351. */
  95352. linearSpecularLOD: boolean;
  95353. /**
  95354. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95355. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95356. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95357. */
  95358. irradianceTexture: Nullable<BaseTexture>;
  95359. /**
  95360. * Define if the texture is a render target.
  95361. */
  95362. isRenderTarget: boolean;
  95363. /**
  95364. * Define the unique id of the texture in the scene.
  95365. */
  95366. readonly uid: string;
  95367. /**
  95368. * Return a string representation of the texture.
  95369. * @returns the texture as a string
  95370. */
  95371. toString(): string;
  95372. /**
  95373. * Get the class name of the texture.
  95374. * @returns "BaseTexture"
  95375. */
  95376. getClassName(): string;
  95377. /**
  95378. * Define the list of animation attached to the texture.
  95379. */
  95380. animations: Animation[];
  95381. /**
  95382. * An event triggered when the texture is disposed.
  95383. */
  95384. onDisposeObservable: Observable<BaseTexture>;
  95385. private _onDisposeObserver;
  95386. /**
  95387. * Callback triggered when the texture has been disposed.
  95388. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95389. */
  95390. onDispose: () => void;
  95391. /**
  95392. * Define the current state of the loading sequence when in delayed load mode.
  95393. */
  95394. delayLoadState: number;
  95395. private _scene;
  95396. /** @hidden */
  95397. _texture: Nullable<InternalTexture>;
  95398. private _uid;
  95399. /**
  95400. * Define if the texture is preventinga material to render or not.
  95401. * If not and the texture is not ready, the engine will use a default black texture instead.
  95402. */
  95403. readonly isBlocking: boolean;
  95404. /**
  95405. * Instantiates a new BaseTexture.
  95406. * Base class of all the textures in babylon.
  95407. * It groups all the common properties the materials, post process, lights... might need
  95408. * in order to make a correct use of the texture.
  95409. * @param scene Define the scene the texture blongs to
  95410. */
  95411. constructor(scene: Nullable<Scene>);
  95412. /**
  95413. * Get the scene the texture belongs to.
  95414. * @returns the scene or null if undefined
  95415. */
  95416. getScene(): Nullable<Scene>;
  95417. /**
  95418. * Get the texture transform matrix used to offset tile the texture for istance.
  95419. * @returns the transformation matrix
  95420. */
  95421. getTextureMatrix(): Matrix;
  95422. /**
  95423. * Get the texture reflection matrix used to rotate/transform the reflection.
  95424. * @returns the reflection matrix
  95425. */
  95426. getReflectionTextureMatrix(): Matrix;
  95427. /**
  95428. * Get the underlying lower level texture from Babylon.
  95429. * @returns the insternal texture
  95430. */
  95431. getInternalTexture(): Nullable<InternalTexture>;
  95432. /**
  95433. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95434. * @returns true if ready or not blocking
  95435. */
  95436. isReadyOrNotBlocking(): boolean;
  95437. /**
  95438. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95439. * @returns true if fully ready
  95440. */
  95441. isReady(): boolean;
  95442. private _cachedSize;
  95443. /**
  95444. * Get the size of the texture.
  95445. * @returns the texture size.
  95446. */
  95447. getSize(): ISize;
  95448. /**
  95449. * Get the base size of the texture.
  95450. * It can be different from the size if the texture has been resized for POT for instance
  95451. * @returns the base size
  95452. */
  95453. getBaseSize(): ISize;
  95454. /**
  95455. * Update the sampling mode of the texture.
  95456. * Default is Trilinear mode.
  95457. *
  95458. * | Value | Type | Description |
  95459. * | ----- | ------------------ | ----------- |
  95460. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95461. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95462. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95463. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95464. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95465. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95466. * | 7 | NEAREST_LINEAR | |
  95467. * | 8 | NEAREST_NEAREST | |
  95468. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95469. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95470. * | 11 | LINEAR_LINEAR | |
  95471. * | 12 | LINEAR_NEAREST | |
  95472. *
  95473. * > _mag_: magnification filter (close to the viewer)
  95474. * > _min_: minification filter (far from the viewer)
  95475. * > _mip_: filter used between mip map levels
  95476. *@param samplingMode Define the new sampling mode of the texture
  95477. */
  95478. updateSamplingMode(samplingMode: number): void;
  95479. /**
  95480. * Scales the texture if is `canRescale()`
  95481. * @param ratio the resize factor we want to use to rescale
  95482. */
  95483. scale(ratio: number): void;
  95484. /**
  95485. * Get if the texture can rescale.
  95486. */
  95487. readonly canRescale: boolean;
  95488. /** @hidden */
  95489. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95490. /** @hidden */
  95491. _rebuild(): void;
  95492. /**
  95493. * Triggers the load sequence in delayed load mode.
  95494. */
  95495. delayLoad(): void;
  95496. /**
  95497. * Clones the texture.
  95498. * @returns the cloned texture
  95499. */
  95500. clone(): Nullable<BaseTexture>;
  95501. /**
  95502. * Get the texture underlying type (INT, FLOAT...)
  95503. */
  95504. readonly textureType: number;
  95505. /**
  95506. * Get the texture underlying format (RGB, RGBA...)
  95507. */
  95508. readonly textureFormat: number;
  95509. /**
  95510. * Indicates that textures need to be re-calculated for all materials
  95511. */
  95512. protected _markAllSubMeshesAsTexturesDirty(): void;
  95513. /**
  95514. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95515. * This will returns an RGBA array buffer containing either in values (0-255) or
  95516. * float values (0-1) depending of the underlying buffer type.
  95517. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95518. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95519. * @param buffer defines a user defined buffer to fill with data (can be null)
  95520. * @returns The Array buffer containing the pixels data.
  95521. */
  95522. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95523. /**
  95524. * Release and destroy the underlying lower level texture aka internalTexture.
  95525. */
  95526. releaseInternalTexture(): void;
  95527. /** @hidden */
  95528. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95529. /** @hidden */
  95530. readonly _lodTextureMid: Nullable<BaseTexture>;
  95531. /** @hidden */
  95532. readonly _lodTextureLow: Nullable<BaseTexture>;
  95533. /**
  95534. * Dispose the texture and release its associated resources.
  95535. */
  95536. dispose(): void;
  95537. /**
  95538. * Serialize the texture into a JSON representation that can be parsed later on.
  95539. * @returns the JSON representation of the texture
  95540. */
  95541. serialize(): any;
  95542. /**
  95543. * Helper function to be called back once a list of texture contains only ready textures.
  95544. * @param textures Define the list of textures to wait for
  95545. * @param callback Define the callback triggered once the entire list will be ready
  95546. */
  95547. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95548. }
  95549. }
  95550. declare module BABYLON {
  95551. /**
  95552. * Options to be used when creating an effect.
  95553. */
  95554. export interface IEffectCreationOptions {
  95555. /**
  95556. * Atrributes that will be used in the shader.
  95557. */
  95558. attributes: string[];
  95559. /**
  95560. * Uniform varible names that will be set in the shader.
  95561. */
  95562. uniformsNames: string[];
  95563. /**
  95564. * Uniform buffer varible names that will be set in the shader.
  95565. */
  95566. uniformBuffersNames: string[];
  95567. /**
  95568. * Sampler texture variable names that will be set in the shader.
  95569. */
  95570. samplers: string[];
  95571. /**
  95572. * Define statements that will be set in the shader.
  95573. */
  95574. defines: any;
  95575. /**
  95576. * Possible fallbacks for this effect to improve performance when needed.
  95577. */
  95578. fallbacks: Nullable<IEffectFallbacks>;
  95579. /**
  95580. * Callback that will be called when the shader is compiled.
  95581. */
  95582. onCompiled: Nullable<(effect: Effect) => void>;
  95583. /**
  95584. * Callback that will be called if an error occurs during shader compilation.
  95585. */
  95586. onError: Nullable<(effect: Effect, errors: string) => void>;
  95587. /**
  95588. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95589. */
  95590. indexParameters?: any;
  95591. /**
  95592. * Max number of lights that can be used in the shader.
  95593. */
  95594. maxSimultaneousLights?: number;
  95595. /**
  95596. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95597. */
  95598. transformFeedbackVaryings?: Nullable<string[]>;
  95599. }
  95600. /**
  95601. * Effect containing vertex and fragment shader that can be executed on an object.
  95602. */
  95603. export class Effect implements IDisposable {
  95604. /**
  95605. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95606. */
  95607. static ShadersRepository: string;
  95608. /**
  95609. * Name of the effect.
  95610. */
  95611. name: any;
  95612. /**
  95613. * String container all the define statements that should be set on the shader.
  95614. */
  95615. defines: string;
  95616. /**
  95617. * Callback that will be called when the shader is compiled.
  95618. */
  95619. onCompiled: Nullable<(effect: Effect) => void>;
  95620. /**
  95621. * Callback that will be called if an error occurs during shader compilation.
  95622. */
  95623. onError: Nullable<(effect: Effect, errors: string) => void>;
  95624. /**
  95625. * Callback that will be called when effect is bound.
  95626. */
  95627. onBind: Nullable<(effect: Effect) => void>;
  95628. /**
  95629. * Unique ID of the effect.
  95630. */
  95631. uniqueId: number;
  95632. /**
  95633. * Observable that will be called when the shader is compiled.
  95634. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95635. */
  95636. onCompileObservable: Observable<Effect>;
  95637. /**
  95638. * Observable that will be called if an error occurs during shader compilation.
  95639. */
  95640. onErrorObservable: Observable<Effect>;
  95641. /** @hidden */
  95642. _onBindObservable: Nullable<Observable<Effect>>;
  95643. /**
  95644. * Observable that will be called when effect is bound.
  95645. */
  95646. readonly onBindObservable: Observable<Effect>;
  95647. /** @hidden */
  95648. _bonesComputationForcedToCPU: boolean;
  95649. private static _uniqueIdSeed;
  95650. private _engine;
  95651. private _uniformBuffersNames;
  95652. private _uniformsNames;
  95653. private _samplerList;
  95654. private _samplers;
  95655. private _isReady;
  95656. private _compilationError;
  95657. private _allFallbacksProcessed;
  95658. private _attributesNames;
  95659. private _attributes;
  95660. private _uniforms;
  95661. /**
  95662. * Key for the effect.
  95663. * @hidden
  95664. */
  95665. _key: string;
  95666. private _indexParameters;
  95667. private _fallbacks;
  95668. private _vertexSourceCode;
  95669. private _fragmentSourceCode;
  95670. private _vertexSourceCodeOverride;
  95671. private _fragmentSourceCodeOverride;
  95672. private _transformFeedbackVaryings;
  95673. /**
  95674. * Compiled shader to webGL program.
  95675. * @hidden
  95676. */
  95677. _pipelineContext: Nullable<IPipelineContext>;
  95678. private _valueCache;
  95679. private static _baseCache;
  95680. /**
  95681. * Instantiates an effect.
  95682. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95683. * @param baseName Name of the effect.
  95684. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95685. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95686. * @param samplers List of sampler variables that will be passed to the shader.
  95687. * @param engine Engine to be used to render the effect
  95688. * @param defines Define statements to be added to the shader.
  95689. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95690. * @param onCompiled Callback that will be called when the shader is compiled.
  95691. * @param onError Callback that will be called if an error occurs during shader compilation.
  95692. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95693. */
  95694. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  95695. private _useFinalCode;
  95696. /**
  95697. * Unique key for this effect
  95698. */
  95699. readonly key: string;
  95700. /**
  95701. * If the effect has been compiled and prepared.
  95702. * @returns if the effect is compiled and prepared.
  95703. */
  95704. isReady(): boolean;
  95705. private _isReadyInternal;
  95706. /**
  95707. * The engine the effect was initialized with.
  95708. * @returns the engine.
  95709. */
  95710. getEngine(): Engine;
  95711. /**
  95712. * The pipeline context for this effect
  95713. * @returns the associated pipeline context
  95714. */
  95715. getPipelineContext(): Nullable<IPipelineContext>;
  95716. /**
  95717. * The set of names of attribute variables for the shader.
  95718. * @returns An array of attribute names.
  95719. */
  95720. getAttributesNames(): string[];
  95721. /**
  95722. * Returns the attribute at the given index.
  95723. * @param index The index of the attribute.
  95724. * @returns The location of the attribute.
  95725. */
  95726. getAttributeLocation(index: number): number;
  95727. /**
  95728. * Returns the attribute based on the name of the variable.
  95729. * @param name of the attribute to look up.
  95730. * @returns the attribute location.
  95731. */
  95732. getAttributeLocationByName(name: string): number;
  95733. /**
  95734. * The number of attributes.
  95735. * @returns the numnber of attributes.
  95736. */
  95737. getAttributesCount(): number;
  95738. /**
  95739. * Gets the index of a uniform variable.
  95740. * @param uniformName of the uniform to look up.
  95741. * @returns the index.
  95742. */
  95743. getUniformIndex(uniformName: string): number;
  95744. /**
  95745. * Returns the attribute based on the name of the variable.
  95746. * @param uniformName of the uniform to look up.
  95747. * @returns the location of the uniform.
  95748. */
  95749. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95750. /**
  95751. * Returns an array of sampler variable names
  95752. * @returns The array of sampler variable neames.
  95753. */
  95754. getSamplers(): string[];
  95755. /**
  95756. * The error from the last compilation.
  95757. * @returns the error string.
  95758. */
  95759. getCompilationError(): string;
  95760. /**
  95761. * Gets a boolean indicating that all fallbacks were used during compilation
  95762. * @returns true if all fallbacks were used
  95763. */
  95764. allFallbacksProcessed(): boolean;
  95765. /**
  95766. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95767. * @param func The callback to be used.
  95768. */
  95769. executeWhenCompiled(func: (effect: Effect) => void): void;
  95770. private _checkIsReady;
  95771. private _loadShader;
  95772. /**
  95773. * Recompiles the webGL program
  95774. * @param vertexSourceCode The source code for the vertex shader.
  95775. * @param fragmentSourceCode The source code for the fragment shader.
  95776. * @param onCompiled Callback called when completed.
  95777. * @param onError Callback called on error.
  95778. * @hidden
  95779. */
  95780. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95781. /**
  95782. * Prepares the effect
  95783. * @hidden
  95784. */
  95785. _prepareEffect(): void;
  95786. private _processCompilationErrors;
  95787. /**
  95788. * Checks if the effect is supported. (Must be called after compilation)
  95789. */
  95790. readonly isSupported: boolean;
  95791. /**
  95792. * Binds a texture to the engine to be used as output of the shader.
  95793. * @param channel Name of the output variable.
  95794. * @param texture Texture to bind.
  95795. * @hidden
  95796. */
  95797. _bindTexture(channel: string, texture: InternalTexture): void;
  95798. /**
  95799. * Sets a texture on the engine to be used in the shader.
  95800. * @param channel Name of the sampler variable.
  95801. * @param texture Texture to set.
  95802. */
  95803. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95804. /**
  95805. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95806. * @param channel Name of the sampler variable.
  95807. * @param texture Texture to set.
  95808. */
  95809. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95810. /**
  95811. * Sets an array of textures on the engine to be used in the shader.
  95812. * @param channel Name of the variable.
  95813. * @param textures Textures to set.
  95814. */
  95815. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95816. /**
  95817. * 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)
  95818. * @param channel Name of the sampler variable.
  95819. * @param postProcess Post process to get the input texture from.
  95820. */
  95821. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95822. /**
  95823. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95824. * 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)
  95825. * @param channel Name of the sampler variable.
  95826. * @param postProcess Post process to get the output texture from.
  95827. */
  95828. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95829. /** @hidden */
  95830. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95831. /** @hidden */
  95832. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95833. /** @hidden */
  95834. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95835. /** @hidden */
  95836. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95837. /**
  95838. * Binds a buffer to a uniform.
  95839. * @param buffer Buffer to bind.
  95840. * @param name Name of the uniform variable to bind to.
  95841. */
  95842. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95843. /**
  95844. * Binds block to a uniform.
  95845. * @param blockName Name of the block to bind.
  95846. * @param index Index to bind.
  95847. */
  95848. bindUniformBlock(blockName: string, index: number): void;
  95849. /**
  95850. * Sets an interger value on a uniform variable.
  95851. * @param uniformName Name of the variable.
  95852. * @param value Value to be set.
  95853. * @returns this effect.
  95854. */
  95855. setInt(uniformName: string, value: number): Effect;
  95856. /**
  95857. * Sets an int array on a uniform variable.
  95858. * @param uniformName Name of the variable.
  95859. * @param array array to be set.
  95860. * @returns this effect.
  95861. */
  95862. setIntArray(uniformName: string, array: Int32Array): Effect;
  95863. /**
  95864. * 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)
  95865. * @param uniformName Name of the variable.
  95866. * @param array array to be set.
  95867. * @returns this effect.
  95868. */
  95869. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95870. /**
  95871. * 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)
  95872. * @param uniformName Name of the variable.
  95873. * @param array array to be set.
  95874. * @returns this effect.
  95875. */
  95876. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95877. /**
  95878. * 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)
  95879. * @param uniformName Name of the variable.
  95880. * @param array array to be set.
  95881. * @returns this effect.
  95882. */
  95883. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95884. /**
  95885. * Sets an float array on a uniform variable.
  95886. * @param uniformName Name of the variable.
  95887. * @param array array to be set.
  95888. * @returns this effect.
  95889. */
  95890. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95891. /**
  95892. * 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)
  95893. * @param uniformName Name of the variable.
  95894. * @param array array to be set.
  95895. * @returns this effect.
  95896. */
  95897. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95898. /**
  95899. * 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)
  95900. * @param uniformName Name of the variable.
  95901. * @param array array to be set.
  95902. * @returns this effect.
  95903. */
  95904. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95905. /**
  95906. * 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)
  95907. * @param uniformName Name of the variable.
  95908. * @param array array to be set.
  95909. * @returns this effect.
  95910. */
  95911. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95912. /**
  95913. * Sets an array on a uniform variable.
  95914. * @param uniformName Name of the variable.
  95915. * @param array array to be set.
  95916. * @returns this effect.
  95917. */
  95918. setArray(uniformName: string, array: number[]): Effect;
  95919. /**
  95920. * 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)
  95921. * @param uniformName Name of the variable.
  95922. * @param array array to be set.
  95923. * @returns this effect.
  95924. */
  95925. setArray2(uniformName: string, array: number[]): Effect;
  95926. /**
  95927. * 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)
  95928. * @param uniformName Name of the variable.
  95929. * @param array array to be set.
  95930. * @returns this effect.
  95931. */
  95932. setArray3(uniformName: string, array: number[]): Effect;
  95933. /**
  95934. * 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)
  95935. * @param uniformName Name of the variable.
  95936. * @param array array to be set.
  95937. * @returns this effect.
  95938. */
  95939. setArray4(uniformName: string, array: number[]): Effect;
  95940. /**
  95941. * Sets matrices on a uniform variable.
  95942. * @param uniformName Name of the variable.
  95943. * @param matrices matrices to be set.
  95944. * @returns this effect.
  95945. */
  95946. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95947. /**
  95948. * Sets matrix on a uniform variable.
  95949. * @param uniformName Name of the variable.
  95950. * @param matrix matrix to be set.
  95951. * @returns this effect.
  95952. */
  95953. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95954. /**
  95955. * 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)
  95956. * @param uniformName Name of the variable.
  95957. * @param matrix matrix to be set.
  95958. * @returns this effect.
  95959. */
  95960. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95961. /**
  95962. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95963. * @param uniformName Name of the variable.
  95964. * @param matrix matrix to be set.
  95965. * @returns this effect.
  95966. */
  95967. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95968. /**
  95969. * Sets a float on a uniform variable.
  95970. * @param uniformName Name of the variable.
  95971. * @param value value to be set.
  95972. * @returns this effect.
  95973. */
  95974. setFloat(uniformName: string, value: number): Effect;
  95975. /**
  95976. * Sets a boolean on a uniform variable.
  95977. * @param uniformName Name of the variable.
  95978. * @param bool value to be set.
  95979. * @returns this effect.
  95980. */
  95981. setBool(uniformName: string, bool: boolean): Effect;
  95982. /**
  95983. * Sets a Vector2 on a uniform variable.
  95984. * @param uniformName Name of the variable.
  95985. * @param vector2 vector2 to be set.
  95986. * @returns this effect.
  95987. */
  95988. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95989. /**
  95990. * Sets a float2 on a uniform variable.
  95991. * @param uniformName Name of the variable.
  95992. * @param x First float in float2.
  95993. * @param y Second float in float2.
  95994. * @returns this effect.
  95995. */
  95996. setFloat2(uniformName: string, x: number, y: number): Effect;
  95997. /**
  95998. * Sets a Vector3 on a uniform variable.
  95999. * @param uniformName Name of the variable.
  96000. * @param vector3 Value to be set.
  96001. * @returns this effect.
  96002. */
  96003. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96004. /**
  96005. * Sets a float3 on a uniform variable.
  96006. * @param uniformName Name of the variable.
  96007. * @param x First float in float3.
  96008. * @param y Second float in float3.
  96009. * @param z Third float in float3.
  96010. * @returns this effect.
  96011. */
  96012. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96013. /**
  96014. * Sets a Vector4 on a uniform variable.
  96015. * @param uniformName Name of the variable.
  96016. * @param vector4 Value to be set.
  96017. * @returns this effect.
  96018. */
  96019. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96020. /**
  96021. * Sets a float4 on a uniform variable.
  96022. * @param uniformName Name of the variable.
  96023. * @param x First float in float4.
  96024. * @param y Second float in float4.
  96025. * @param z Third float in float4.
  96026. * @param w Fourth float in float4.
  96027. * @returns this effect.
  96028. */
  96029. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96030. /**
  96031. * Sets a Color3 on a uniform variable.
  96032. * @param uniformName Name of the variable.
  96033. * @param color3 Value to be set.
  96034. * @returns this effect.
  96035. */
  96036. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96037. /**
  96038. * Sets a Color4 on a uniform variable.
  96039. * @param uniformName Name of the variable.
  96040. * @param color3 Value to be set.
  96041. * @param alpha Alpha value to be set.
  96042. * @returns this effect.
  96043. */
  96044. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96045. /**
  96046. * Sets a Color4 on a uniform variable
  96047. * @param uniformName defines the name of the variable
  96048. * @param color4 defines the value to be set
  96049. * @returns this effect.
  96050. */
  96051. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96052. /** Release all associated resources */
  96053. dispose(): void;
  96054. /**
  96055. * This function will add a new shader to the shader store
  96056. * @param name the name of the shader
  96057. * @param pixelShader optional pixel shader content
  96058. * @param vertexShader optional vertex shader content
  96059. */
  96060. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96061. /**
  96062. * Store of each shader (The can be looked up using effect.key)
  96063. */
  96064. static ShadersStore: {
  96065. [key: string]: string;
  96066. };
  96067. /**
  96068. * Store of each included file for a shader (The can be looked up using effect.key)
  96069. */
  96070. static IncludesShadersStore: {
  96071. [key: string]: string;
  96072. };
  96073. /**
  96074. * Resets the cache of effects.
  96075. */
  96076. static ResetCache(): void;
  96077. }
  96078. }
  96079. declare module BABYLON {
  96080. /**
  96081. * Class used to describe the capabilities of the engine relatively to the current browser
  96082. */
  96083. export class EngineCapabilities {
  96084. /** Maximum textures units per fragment shader */
  96085. maxTexturesImageUnits: number;
  96086. /** Maximum texture units per vertex shader */
  96087. maxVertexTextureImageUnits: number;
  96088. /** Maximum textures units in the entire pipeline */
  96089. maxCombinedTexturesImageUnits: number;
  96090. /** Maximum texture size */
  96091. maxTextureSize: number;
  96092. /** Maximum cube texture size */
  96093. maxCubemapTextureSize: number;
  96094. /** Maximum render texture size */
  96095. maxRenderTextureSize: number;
  96096. /** Maximum number of vertex attributes */
  96097. maxVertexAttribs: number;
  96098. /** Maximum number of varyings */
  96099. maxVaryingVectors: number;
  96100. /** Maximum number of uniforms per vertex shader */
  96101. maxVertexUniformVectors: number;
  96102. /** Maximum number of uniforms per fragment shader */
  96103. maxFragmentUniformVectors: number;
  96104. /** Defines if standard derivates (dx/dy) are supported */
  96105. standardDerivatives: boolean;
  96106. /** Defines if s3tc texture compression is supported */
  96107. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  96108. /** Defines if pvrtc texture compression is supported */
  96109. pvrtc: any;
  96110. /** Defines if etc1 texture compression is supported */
  96111. etc1: any;
  96112. /** Defines if etc2 texture compression is supported */
  96113. etc2: any;
  96114. /** Defines if astc texture compression is supported */
  96115. astc: any;
  96116. /** Defines if float textures are supported */
  96117. textureFloat: boolean;
  96118. /** Defines if vertex array objects are supported */
  96119. vertexArrayObject: boolean;
  96120. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96121. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  96122. /** Gets the maximum level of anisotropy supported */
  96123. maxAnisotropy: number;
  96124. /** Defines if instancing is supported */
  96125. instancedArrays: boolean;
  96126. /** Defines if 32 bits indices are supported */
  96127. uintIndices: boolean;
  96128. /** Defines if high precision shaders are supported */
  96129. highPrecisionShaderSupported: boolean;
  96130. /** Defines if depth reading in the fragment shader is supported */
  96131. fragmentDepthSupported: boolean;
  96132. /** Defines if float texture linear filtering is supported*/
  96133. textureFloatLinearFiltering: boolean;
  96134. /** Defines if rendering to float textures is supported */
  96135. textureFloatRender: boolean;
  96136. /** Defines if half float textures are supported*/
  96137. textureHalfFloat: boolean;
  96138. /** Defines if half float texture linear filtering is supported*/
  96139. textureHalfFloatLinearFiltering: boolean;
  96140. /** Defines if rendering to half float textures is supported */
  96141. textureHalfFloatRender: boolean;
  96142. /** Defines if textureLOD shader command is supported */
  96143. textureLOD: boolean;
  96144. /** Defines if draw buffers extension is supported */
  96145. drawBuffersExtension: boolean;
  96146. /** Defines if depth textures are supported */
  96147. depthTextureExtension: boolean;
  96148. /** Defines if float color buffer are supported */
  96149. colorBufferFloat: boolean;
  96150. /** Gets disjoint timer query extension (null if not supported) */
  96151. timerQuery: EXT_disjoint_timer_query;
  96152. /** Defines if timestamp can be used with timer query */
  96153. canUseTimestampForTimerQuery: boolean;
  96154. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96155. multiview: any;
  96156. /** Function used to let the system compiles shaders in background */
  96157. parallelShaderCompile: {
  96158. COMPLETION_STATUS_KHR: number;
  96159. };
  96160. /** Max number of texture samples for MSAA */
  96161. maxMSAASamples: number;
  96162. /** Defines if the blend min max extension is supported */
  96163. blendMinMax: boolean;
  96164. }
  96165. }
  96166. declare module BABYLON {
  96167. /**
  96168. * @hidden
  96169. **/
  96170. export class DepthCullingState {
  96171. private _isDepthTestDirty;
  96172. private _isDepthMaskDirty;
  96173. private _isDepthFuncDirty;
  96174. private _isCullFaceDirty;
  96175. private _isCullDirty;
  96176. private _isZOffsetDirty;
  96177. private _isFrontFaceDirty;
  96178. private _depthTest;
  96179. private _depthMask;
  96180. private _depthFunc;
  96181. private _cull;
  96182. private _cullFace;
  96183. private _zOffset;
  96184. private _frontFace;
  96185. /**
  96186. * Initializes the state.
  96187. */
  96188. constructor();
  96189. readonly isDirty: boolean;
  96190. zOffset: number;
  96191. cullFace: Nullable<number>;
  96192. cull: Nullable<boolean>;
  96193. depthFunc: Nullable<number>;
  96194. depthMask: boolean;
  96195. depthTest: boolean;
  96196. frontFace: Nullable<number>;
  96197. reset(): void;
  96198. apply(gl: WebGLRenderingContext): void;
  96199. }
  96200. }
  96201. declare module BABYLON {
  96202. /**
  96203. * @hidden
  96204. **/
  96205. export class StencilState {
  96206. /** 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 */
  96207. static readonly ALWAYS: number;
  96208. /** Passed to stencilOperation to specify that stencil value must be kept */
  96209. static readonly KEEP: number;
  96210. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96211. static readonly REPLACE: number;
  96212. private _isStencilTestDirty;
  96213. private _isStencilMaskDirty;
  96214. private _isStencilFuncDirty;
  96215. private _isStencilOpDirty;
  96216. private _stencilTest;
  96217. private _stencilMask;
  96218. private _stencilFunc;
  96219. private _stencilFuncRef;
  96220. private _stencilFuncMask;
  96221. private _stencilOpStencilFail;
  96222. private _stencilOpDepthFail;
  96223. private _stencilOpStencilDepthPass;
  96224. readonly isDirty: boolean;
  96225. stencilFunc: number;
  96226. stencilFuncRef: number;
  96227. stencilFuncMask: number;
  96228. stencilOpStencilFail: number;
  96229. stencilOpDepthFail: number;
  96230. stencilOpStencilDepthPass: number;
  96231. stencilMask: number;
  96232. stencilTest: boolean;
  96233. constructor();
  96234. reset(): void;
  96235. apply(gl: WebGLRenderingContext): void;
  96236. }
  96237. }
  96238. declare module BABYLON {
  96239. /**
  96240. * @hidden
  96241. **/
  96242. export class AlphaState {
  96243. private _isAlphaBlendDirty;
  96244. private _isBlendFunctionParametersDirty;
  96245. private _isBlendEquationParametersDirty;
  96246. private _isBlendConstantsDirty;
  96247. private _alphaBlend;
  96248. private _blendFunctionParameters;
  96249. private _blendEquationParameters;
  96250. private _blendConstants;
  96251. /**
  96252. * Initializes the state.
  96253. */
  96254. constructor();
  96255. readonly isDirty: boolean;
  96256. alphaBlend: boolean;
  96257. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96258. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96259. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96260. reset(): void;
  96261. apply(gl: WebGLRenderingContext): void;
  96262. }
  96263. }
  96264. declare module BABYLON {
  96265. /** @hidden */
  96266. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96267. attributeProcessor(attribute: string): string;
  96268. varyingProcessor(varying: string, isFragment: boolean): string;
  96269. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96270. }
  96271. }
  96272. declare module BABYLON {
  96273. /**
  96274. * Interface for attribute information associated with buffer instanciation
  96275. */
  96276. export class InstancingAttributeInfo {
  96277. /**
  96278. * Index/offset of the attribute in the vertex shader
  96279. */
  96280. index: number;
  96281. /**
  96282. * size of the attribute, 1, 2, 3 or 4
  96283. */
  96284. attributeSize: number;
  96285. /**
  96286. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96287. * default is FLOAT
  96288. */
  96289. attribyteType: number;
  96290. /**
  96291. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96292. */
  96293. normalized: boolean;
  96294. /**
  96295. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96296. */
  96297. offset: number;
  96298. /**
  96299. * Name of the GLSL attribute, for debugging purpose only
  96300. */
  96301. attributeName: string;
  96302. }
  96303. }
  96304. declare module BABYLON {
  96305. interface ThinEngine {
  96306. /**
  96307. * Update a video texture
  96308. * @param texture defines the texture to update
  96309. * @param video defines the video element to use
  96310. * @param invertY defines if data must be stored with Y axis inverted
  96311. */
  96312. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96313. }
  96314. }
  96315. declare module BABYLON {
  96316. /**
  96317. * Settings for finer control over video usage
  96318. */
  96319. export interface VideoTextureSettings {
  96320. /**
  96321. * Applies `autoplay` to video, if specified
  96322. */
  96323. autoPlay?: boolean;
  96324. /**
  96325. * Applies `loop` to video, if specified
  96326. */
  96327. loop?: boolean;
  96328. /**
  96329. * Automatically updates internal texture from video at every frame in the render loop
  96330. */
  96331. autoUpdateTexture: boolean;
  96332. /**
  96333. * Image src displayed during the video loading or until the user interacts with the video.
  96334. */
  96335. poster?: string;
  96336. }
  96337. /**
  96338. * If you want to display a video in your scene, this is the special texture for that.
  96339. * This special texture works similar to other textures, with the exception of a few parameters.
  96340. * @see https://doc.babylonjs.com/how_to/video_texture
  96341. */
  96342. export class VideoTexture extends Texture {
  96343. /**
  96344. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96345. */
  96346. readonly autoUpdateTexture: boolean;
  96347. /**
  96348. * The video instance used by the texture internally
  96349. */
  96350. readonly video: HTMLVideoElement;
  96351. private _onUserActionRequestedObservable;
  96352. /**
  96353. * Event triggerd when a dom action is required by the user to play the video.
  96354. * This happens due to recent changes in browser policies preventing video to auto start.
  96355. */
  96356. readonly onUserActionRequestedObservable: Observable<Texture>;
  96357. private _generateMipMaps;
  96358. private _engine;
  96359. private _stillImageCaptured;
  96360. private _displayingPosterTexture;
  96361. private _settings;
  96362. private _createInternalTextureOnEvent;
  96363. private _frameId;
  96364. /**
  96365. * Creates a video texture.
  96366. * If you want to display a video in your scene, this is the special texture for that.
  96367. * This special texture works similar to other textures, with the exception of a few parameters.
  96368. * @see https://doc.babylonjs.com/how_to/video_texture
  96369. * @param name optional name, will detect from video source, if not defined
  96370. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96371. * @param scene is obviously the current scene.
  96372. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96373. * @param invertY is false by default but can be used to invert video on Y axis
  96374. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96375. * @param settings allows finer control over video usage
  96376. */
  96377. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96378. private _getName;
  96379. private _getVideo;
  96380. private _createInternalTexture;
  96381. private reset;
  96382. /**
  96383. * @hidden Internal method to initiate `update`.
  96384. */
  96385. _rebuild(): void;
  96386. /**
  96387. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96388. */
  96389. update(): void;
  96390. /**
  96391. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96392. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96393. */
  96394. updateTexture(isVisible: boolean): void;
  96395. protected _updateInternalTexture: () => void;
  96396. /**
  96397. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96398. * @param url New url.
  96399. */
  96400. updateURL(url: string): void;
  96401. /**
  96402. * Dispose the texture and release its associated resources.
  96403. */
  96404. dispose(): void;
  96405. /**
  96406. * Creates a video texture straight from a stream.
  96407. * @param scene Define the scene the texture should be created in
  96408. * @param stream Define the stream the texture should be created from
  96409. * @returns The created video texture as a promise
  96410. */
  96411. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96412. /**
  96413. * Creates a video texture straight from your WebCam video feed.
  96414. * @param scene Define the scene the texture should be created in
  96415. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96416. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96417. * @returns The created video texture as a promise
  96418. */
  96419. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96420. minWidth: number;
  96421. maxWidth: number;
  96422. minHeight: number;
  96423. maxHeight: number;
  96424. deviceId: string;
  96425. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96426. /**
  96427. * Creates a video texture straight from your WebCam video feed.
  96428. * @param scene Define the scene the texture should be created in
  96429. * @param onReady Define a callback to triggered once the texture will be ready
  96430. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96431. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96432. */
  96433. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96434. minWidth: number;
  96435. maxWidth: number;
  96436. minHeight: number;
  96437. maxHeight: number;
  96438. deviceId: string;
  96439. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96440. }
  96441. }
  96442. declare module BABYLON {
  96443. /**
  96444. * Defines the interface used by objects working like Scene
  96445. * @hidden
  96446. */
  96447. interface ISceneLike {
  96448. _addPendingData(data: any): void;
  96449. _removePendingData(data: any): void;
  96450. offlineProvider: IOfflineProvider;
  96451. }
  96452. /** Interface defining initialization parameters for Engine class */
  96453. export interface EngineOptions extends WebGLContextAttributes {
  96454. /**
  96455. * Defines if the engine should no exceed a specified device ratio
  96456. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96457. */
  96458. limitDeviceRatio?: number;
  96459. /**
  96460. * Defines if webvr should be enabled automatically
  96461. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96462. */
  96463. autoEnableWebVR?: boolean;
  96464. /**
  96465. * Defines if webgl2 should be turned off even if supported
  96466. * @see http://doc.babylonjs.com/features/webgl2
  96467. */
  96468. disableWebGL2Support?: boolean;
  96469. /**
  96470. * Defines if webaudio should be initialized as well
  96471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96472. */
  96473. audioEngine?: boolean;
  96474. /**
  96475. * Defines if animations should run using a deterministic lock step
  96476. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96477. */
  96478. deterministicLockstep?: boolean;
  96479. /** Defines the maximum steps to use with deterministic lock step mode */
  96480. lockstepMaxSteps?: number;
  96481. /**
  96482. * Defines that engine should ignore context lost events
  96483. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96484. */
  96485. doNotHandleContextLost?: boolean;
  96486. /**
  96487. * Defines that engine should ignore modifying touch action attribute and style
  96488. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96489. */
  96490. doNotHandleTouchAction?: boolean;
  96491. /**
  96492. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96493. */
  96494. useHighPrecisionFloats?: boolean;
  96495. }
  96496. /**
  96497. * The base engine class (root of all engines)
  96498. */
  96499. export class ThinEngine {
  96500. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96501. static ExceptionList: ({
  96502. key: string;
  96503. capture: string;
  96504. captureConstraint: number;
  96505. targets: string[];
  96506. } | {
  96507. key: string;
  96508. capture: null;
  96509. captureConstraint: null;
  96510. targets: string[];
  96511. })[];
  96512. /** @hidden */
  96513. static _TextureLoaders: IInternalTextureLoader[];
  96514. /**
  96515. * Returns the current npm package of the sdk
  96516. */
  96517. static readonly NpmPackage: string;
  96518. /**
  96519. * Returns the current version of the framework
  96520. */
  96521. static readonly Version: string;
  96522. /**
  96523. * Returns a string describing the current engine
  96524. */
  96525. readonly description: string;
  96526. /**
  96527. * Gets or sets the epsilon value used by collision engine
  96528. */
  96529. static CollisionsEpsilon: number;
  96530. /**
  96531. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96532. */
  96533. static ShadersRepository: string;
  96534. /** @hidden */
  96535. _shaderProcessor: IShaderProcessor;
  96536. /**
  96537. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96538. */
  96539. forcePOTTextures: boolean;
  96540. /**
  96541. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96542. */
  96543. isFullscreen: boolean;
  96544. /**
  96545. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96546. */
  96547. cullBackFaces: boolean;
  96548. /**
  96549. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96550. */
  96551. renderEvenInBackground: boolean;
  96552. /**
  96553. * Gets or sets a boolean indicating that cache can be kept between frames
  96554. */
  96555. preventCacheWipeBetweenFrames: boolean;
  96556. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96557. validateShaderPrograms: boolean;
  96558. /**
  96559. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96560. */
  96561. disableUniformBuffers: boolean;
  96562. /** @hidden */
  96563. _uniformBuffers: UniformBuffer[];
  96564. /**
  96565. * Gets a boolean indicating that the engine supports uniform buffers
  96566. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96567. */
  96568. readonly supportsUniformBuffers: boolean;
  96569. /** @hidden */
  96570. _gl: WebGLRenderingContext;
  96571. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96572. protected _windowIsBackground: boolean;
  96573. protected _webGLVersion: number;
  96574. protected _highPrecisionShadersAllowed: boolean;
  96575. /** @hidden */
  96576. readonly _shouldUseHighPrecisionShader: boolean;
  96577. /**
  96578. * Gets a boolean indicating that only power of 2 textures are supported
  96579. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96580. */
  96581. readonly needPOTTextures: boolean;
  96582. /** @hidden */
  96583. _badOS: boolean;
  96584. /** @hidden */
  96585. _badDesktopOS: boolean;
  96586. private _hardwareScalingLevel;
  96587. /** @hidden */
  96588. _caps: EngineCapabilities;
  96589. private _isStencilEnable;
  96590. protected _colorWrite: boolean;
  96591. private _glVersion;
  96592. private _glRenderer;
  96593. private _glVendor;
  96594. /** @hidden */
  96595. _videoTextureSupported: boolean;
  96596. protected _renderingQueueLaunched: boolean;
  96597. protected _activeRenderLoops: (() => void)[];
  96598. /**
  96599. * Observable signaled when a context lost event is raised
  96600. */
  96601. onContextLostObservable: Observable<ThinEngine>;
  96602. /**
  96603. * Observable signaled when a context restored event is raised
  96604. */
  96605. onContextRestoredObservable: Observable<ThinEngine>;
  96606. private _onContextLost;
  96607. private _onContextRestored;
  96608. protected _contextWasLost: boolean;
  96609. /** @hidden */
  96610. _doNotHandleContextLost: boolean;
  96611. /**
  96612. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96614. */
  96615. doNotHandleContextLost: boolean;
  96616. /**
  96617. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96618. */
  96619. disableVertexArrayObjects: boolean;
  96620. /** @hidden */
  96621. protected _depthCullingState: DepthCullingState;
  96622. /** @hidden */
  96623. protected _stencilState: StencilState;
  96624. /** @hidden */
  96625. protected _alphaState: AlphaState;
  96626. /** @hidden */
  96627. _internalTexturesCache: InternalTexture[];
  96628. /** @hidden */
  96629. protected _activeChannel: number;
  96630. private _currentTextureChannel;
  96631. /** @hidden */
  96632. protected _boundTexturesCache: {
  96633. [key: string]: Nullable<InternalTexture>;
  96634. };
  96635. /** @hidden */
  96636. protected _currentEffect: Nullable<Effect>;
  96637. /** @hidden */
  96638. protected _currentProgram: Nullable<WebGLProgram>;
  96639. private _compiledEffects;
  96640. private _vertexAttribArraysEnabled;
  96641. /** @hidden */
  96642. protected _cachedViewport: Nullable<IViewportLike>;
  96643. private _cachedVertexArrayObject;
  96644. /** @hidden */
  96645. protected _cachedVertexBuffers: any;
  96646. /** @hidden */
  96647. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96648. /** @hidden */
  96649. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96650. /** @hidden */
  96651. _currentRenderTarget: Nullable<InternalTexture>;
  96652. private _uintIndicesCurrentlySet;
  96653. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96654. /** @hidden */
  96655. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96656. private _currentBufferPointers;
  96657. private _currentInstanceLocations;
  96658. private _currentInstanceBuffers;
  96659. private _textureUnits;
  96660. /** @hidden */
  96661. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96662. /** @hidden */
  96663. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96664. /** @hidden */
  96665. _bindedRenderFunction: any;
  96666. private _vaoRecordInProgress;
  96667. private _mustWipeVertexAttributes;
  96668. private _emptyTexture;
  96669. private _emptyCubeTexture;
  96670. private _emptyTexture3D;
  96671. /** @hidden */
  96672. _frameHandler: number;
  96673. private _nextFreeTextureSlots;
  96674. private _maxSimultaneousTextures;
  96675. private _activeRequests;
  96676. protected _texturesSupported: string[];
  96677. /** @hidden */
  96678. _textureFormatInUse: Nullable<string>;
  96679. protected readonly _supportsHardwareTextureRescaling: boolean;
  96680. /**
  96681. * Gets the list of texture formats supported
  96682. */
  96683. readonly texturesSupported: Array<string>;
  96684. /**
  96685. * Gets the list of texture formats in use
  96686. */
  96687. readonly textureFormatInUse: Nullable<string>;
  96688. /**
  96689. * Gets the current viewport
  96690. */
  96691. readonly currentViewport: Nullable<IViewportLike>;
  96692. /**
  96693. * Gets the default empty texture
  96694. */
  96695. readonly emptyTexture: InternalTexture;
  96696. /**
  96697. * Gets the default empty 3D texture
  96698. */
  96699. readonly emptyTexture3D: InternalTexture;
  96700. /**
  96701. * Gets the default empty cube texture
  96702. */
  96703. readonly emptyCubeTexture: InternalTexture;
  96704. /**
  96705. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96706. */
  96707. readonly premultipliedAlpha: boolean;
  96708. /**
  96709. * Observable event triggered before each texture is initialized
  96710. */
  96711. onBeforeTextureInitObservable: Observable<Texture>;
  96712. /**
  96713. * Creates a new engine
  96714. * @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
  96715. * @param antialias defines enable antialiasing (default: false)
  96716. * @param options defines further options to be sent to the getContext() function
  96717. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96718. */
  96719. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96720. private _rebuildInternalTextures;
  96721. private _rebuildEffects;
  96722. /**
  96723. * Gets a boolean indicating if all created effects are ready
  96724. * @returns true if all effects are ready
  96725. */
  96726. areAllEffectsReady(): boolean;
  96727. protected _rebuildBuffers(): void;
  96728. private _initGLContext;
  96729. /**
  96730. * Gets version of the current webGL context
  96731. */
  96732. readonly webGLVersion: number;
  96733. /**
  96734. * Gets a string idenfifying the name of the class
  96735. * @returns "Engine" string
  96736. */
  96737. getClassName(): string;
  96738. /**
  96739. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96740. */
  96741. readonly isStencilEnable: boolean;
  96742. /** @hidden */
  96743. _prepareWorkingCanvas(): void;
  96744. /**
  96745. * Reset the texture cache to empty state
  96746. */
  96747. resetTextureCache(): void;
  96748. /**
  96749. * Gets an object containing information about the current webGL context
  96750. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96751. */
  96752. getGlInfo(): {
  96753. vendor: string;
  96754. renderer: string;
  96755. version: string;
  96756. };
  96757. /**
  96758. * Defines the hardware scaling level.
  96759. * By default the hardware scaling level is computed from the window device ratio.
  96760. * 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.
  96761. * @param level defines the level to use
  96762. */
  96763. setHardwareScalingLevel(level: number): void;
  96764. /**
  96765. * Gets the current hardware scaling level.
  96766. * By default the hardware scaling level is computed from the window device ratio.
  96767. * 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.
  96768. * @returns a number indicating the current hardware scaling level
  96769. */
  96770. getHardwareScalingLevel(): number;
  96771. /**
  96772. * Gets the list of loaded textures
  96773. * @returns an array containing all loaded textures
  96774. */
  96775. getLoadedTexturesCache(): InternalTexture[];
  96776. /**
  96777. * Gets the object containing all engine capabilities
  96778. * @returns the EngineCapabilities object
  96779. */
  96780. getCaps(): EngineCapabilities;
  96781. /**
  96782. * stop executing a render loop function and remove it from the execution array
  96783. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96784. */
  96785. stopRenderLoop(renderFunction?: () => void): void;
  96786. /** @hidden */
  96787. _renderLoop(): void;
  96788. /**
  96789. * Gets the HTML canvas attached with the current webGL context
  96790. * @returns a HTML canvas
  96791. */
  96792. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96793. /**
  96794. * Gets host window
  96795. * @returns the host window object
  96796. */
  96797. getHostWindow(): Nullable<Window>;
  96798. /**
  96799. * Gets the current render width
  96800. * @param useScreen defines if screen size must be used (or the current render target if any)
  96801. * @returns a number defining the current render width
  96802. */
  96803. getRenderWidth(useScreen?: boolean): number;
  96804. /**
  96805. * Gets the current render height
  96806. * @param useScreen defines if screen size must be used (or the current render target if any)
  96807. * @returns a number defining the current render height
  96808. */
  96809. getRenderHeight(useScreen?: boolean): number;
  96810. /**
  96811. * Can be used to override the current requestAnimationFrame requester.
  96812. * @hidden
  96813. */
  96814. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96815. /**
  96816. * Register and execute a render loop. The engine can have more than one render function
  96817. * @param renderFunction defines the function to continuously execute
  96818. */
  96819. runRenderLoop(renderFunction: () => void): void;
  96820. /**
  96821. * Clear the current render buffer or the current render target (if any is set up)
  96822. * @param color defines the color to use
  96823. * @param backBuffer defines if the back buffer must be cleared
  96824. * @param depth defines if the depth buffer must be cleared
  96825. * @param stencil defines if the stencil buffer must be cleared
  96826. */
  96827. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96828. private _viewportCached;
  96829. /** @hidden */
  96830. _viewport(x: number, y: number, width: number, height: number): void;
  96831. /**
  96832. * Set the WebGL's viewport
  96833. * @param viewport defines the viewport element to be used
  96834. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96835. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96836. */
  96837. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96838. /**
  96839. * Begin a new frame
  96840. */
  96841. beginFrame(): void;
  96842. /**
  96843. * Enf the current frame
  96844. */
  96845. endFrame(): void;
  96846. /**
  96847. * Resize the view according to the canvas' size
  96848. */
  96849. resize(): void;
  96850. /**
  96851. * Force a specific size of the canvas
  96852. * @param width defines the new canvas' width
  96853. * @param height defines the new canvas' height
  96854. */
  96855. setSize(width: number, height: number): void;
  96856. /**
  96857. * Binds the frame buffer to the specified texture.
  96858. * @param texture The texture to render to or null for the default canvas
  96859. * @param faceIndex The face of the texture to render to in case of cube texture
  96860. * @param requiredWidth The width of the target to render to
  96861. * @param requiredHeight The height of the target to render to
  96862. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96863. * @param depthStencilTexture The depth stencil texture to use to render
  96864. * @param lodLevel defines le lod level to bind to the frame buffer
  96865. */
  96866. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96867. /** @hidden */
  96868. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96869. /**
  96870. * Unbind the current render target texture from the webGL context
  96871. * @param texture defines the render target texture to unbind
  96872. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96873. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96874. */
  96875. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96876. /**
  96877. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96878. */
  96879. flushFramebuffer(): void;
  96880. /**
  96881. * Unbind the current render target and bind the default framebuffer
  96882. */
  96883. restoreDefaultFramebuffer(): void;
  96884. private _resetVertexBufferBinding;
  96885. /**
  96886. * Creates a vertex buffer
  96887. * @param data the data for the vertex buffer
  96888. * @returns the new WebGL static buffer
  96889. */
  96890. createVertexBuffer(data: DataArray): DataBuffer;
  96891. private _createVertexBuffer;
  96892. /**
  96893. * Creates a dynamic vertex buffer
  96894. * @param data the data for the dynamic vertex buffer
  96895. * @returns the new WebGL dynamic buffer
  96896. */
  96897. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96898. /**
  96899. * Updates a dynamic vertex buffer.
  96900. * @param vertexBuffer the vertex buffer to update
  96901. * @param data the data used to update the vertex buffer
  96902. * @param byteOffset the byte offset of the data
  96903. * @param byteLength the byte length of the data
  96904. */
  96905. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96906. protected _resetIndexBufferBinding(): void;
  96907. /**
  96908. * Creates a new index buffer
  96909. * @param indices defines the content of the index buffer
  96910. * @param updatable defines if the index buffer must be updatable
  96911. * @returns a new webGL buffer
  96912. */
  96913. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96914. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96915. /**
  96916. * Bind a webGL buffer to the webGL context
  96917. * @param buffer defines the buffer to bind
  96918. */
  96919. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96920. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96921. private bindBuffer;
  96922. /**
  96923. * update the bound buffer with the given data
  96924. * @param data defines the data to update
  96925. */
  96926. updateArrayBuffer(data: Float32Array): void;
  96927. private _vertexAttribPointer;
  96928. private _bindIndexBufferWithCache;
  96929. private _bindVertexBuffersAttributes;
  96930. /**
  96931. * Records a vertex array object
  96932. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96933. * @param vertexBuffers defines the list of vertex buffers to store
  96934. * @param indexBuffer defines the index buffer to store
  96935. * @param effect defines the effect to store
  96936. * @returns the new vertex array object
  96937. */
  96938. recordVertexArrayObject(vertexBuffers: {
  96939. [key: string]: VertexBuffer;
  96940. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96941. /**
  96942. * Bind a specific vertex array object
  96943. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96944. * @param vertexArrayObject defines the vertex array object to bind
  96945. * @param indexBuffer defines the index buffer to bind
  96946. */
  96947. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96948. /**
  96949. * Bind webGl buffers directly to the webGL context
  96950. * @param vertexBuffer defines the vertex buffer to bind
  96951. * @param indexBuffer defines the index buffer to bind
  96952. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96953. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96954. * @param effect defines the effect associated with the vertex buffer
  96955. */
  96956. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96957. private _unbindVertexArrayObject;
  96958. /**
  96959. * Bind a list of vertex buffers to the webGL context
  96960. * @param vertexBuffers defines the list of vertex buffers to bind
  96961. * @param indexBuffer defines the index buffer to bind
  96962. * @param effect defines the effect associated with the vertex buffers
  96963. */
  96964. bindBuffers(vertexBuffers: {
  96965. [key: string]: Nullable<VertexBuffer>;
  96966. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96967. /**
  96968. * Unbind all instance attributes
  96969. */
  96970. unbindInstanceAttributes(): void;
  96971. /**
  96972. * Release and free the memory of a vertex array object
  96973. * @param vao defines the vertex array object to delete
  96974. */
  96975. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96976. /** @hidden */
  96977. _releaseBuffer(buffer: DataBuffer): boolean;
  96978. protected _deleteBuffer(buffer: DataBuffer): void;
  96979. /**
  96980. * Creates a webGL buffer to use with instanciation
  96981. * @param capacity defines the size of the buffer
  96982. * @returns the webGL buffer
  96983. */
  96984. createInstancesBuffer(capacity: number): DataBuffer;
  96985. /**
  96986. * Delete a webGL buffer used with instanciation
  96987. * @param buffer defines the webGL buffer to delete
  96988. */
  96989. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96990. /**
  96991. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96992. * @param instancesBuffer defines the webGL buffer to update and bind
  96993. * @param data defines the data to store in the buffer
  96994. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96995. */
  96996. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96997. /**
  96998. * Apply all cached states (depth, culling, stencil and alpha)
  96999. */
  97000. applyStates(): void;
  97001. /**
  97002. * Send a draw order
  97003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97004. * @param indexStart defines the starting index
  97005. * @param indexCount defines the number of index to draw
  97006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97007. */
  97008. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97009. /**
  97010. * Draw a list of points
  97011. * @param verticesStart defines the index of first vertex to draw
  97012. * @param verticesCount defines the count of vertices to draw
  97013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97014. */
  97015. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97016. /**
  97017. * Draw a list of unindexed primitives
  97018. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97019. * @param verticesStart defines the index of first vertex to draw
  97020. * @param verticesCount defines the count of vertices to draw
  97021. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97022. */
  97023. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97024. /**
  97025. * Draw a list of indexed primitives
  97026. * @param fillMode defines the primitive to use
  97027. * @param indexStart defines the starting index
  97028. * @param indexCount defines the number of index to draw
  97029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97030. */
  97031. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97032. /**
  97033. * Draw a list of unindexed primitives
  97034. * @param fillMode defines the primitive to use
  97035. * @param verticesStart defines the index of first vertex to draw
  97036. * @param verticesCount defines the count of vertices to draw
  97037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97038. */
  97039. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97040. private _drawMode;
  97041. /** @hidden */
  97042. protected _reportDrawCall(): void;
  97043. /** @hidden */
  97044. _releaseEffect(effect: Effect): void;
  97045. /** @hidden */
  97046. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97047. /**
  97048. * Create a new effect (used to store vertex/fragment shaders)
  97049. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97050. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97051. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97052. * @param samplers defines an array of string used to represent textures
  97053. * @param defines defines the string containing the defines to use to compile the shaders
  97054. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97055. * @param onCompiled defines a function to call when the effect creation is successful
  97056. * @param onError defines a function to call when the effect creation has failed
  97057. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97058. * @returns the new Effect
  97059. */
  97060. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  97061. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97062. private _compileShader;
  97063. private _compileRawShader;
  97064. /**
  97065. * Directly creates a webGL program
  97066. * @param pipelineContext defines the pipeline context to attach to
  97067. * @param vertexCode defines the vertex shader code to use
  97068. * @param fragmentCode defines the fragment shader code to use
  97069. * @param context defines the webGL context to use (if not set, the current one will be used)
  97070. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97071. * @returns the new webGL program
  97072. */
  97073. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97074. /**
  97075. * Creates a webGL program
  97076. * @param pipelineContext defines the pipeline context to attach to
  97077. * @param vertexCode defines the vertex shader code to use
  97078. * @param fragmentCode defines the fragment shader code to use
  97079. * @param defines defines the string containing the defines to use to compile the shaders
  97080. * @param context defines the webGL context to use (if not set, the current one will be used)
  97081. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97082. * @returns the new webGL program
  97083. */
  97084. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97085. /**
  97086. * Creates a new pipeline context
  97087. * @returns the new pipeline
  97088. */
  97089. createPipelineContext(): IPipelineContext;
  97090. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97091. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97092. /** @hidden */
  97093. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97094. /** @hidden */
  97095. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97096. /** @hidden */
  97097. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97098. /**
  97099. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97100. * @param pipelineContext defines the pipeline context to use
  97101. * @param uniformsNames defines the list of uniform names
  97102. * @returns an array of webGL uniform locations
  97103. */
  97104. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97105. /**
  97106. * Gets the lsit of active attributes for a given webGL program
  97107. * @param pipelineContext defines the pipeline context to use
  97108. * @param attributesNames defines the list of attribute names to get
  97109. * @returns an array of indices indicating the offset of each attribute
  97110. */
  97111. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97112. /**
  97113. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97114. * @param effect defines the effect to activate
  97115. */
  97116. enableEffect(effect: Nullable<Effect>): void;
  97117. /**
  97118. * Set the value of an uniform to an array of int32
  97119. * @param uniform defines the webGL uniform location where to store the value
  97120. * @param array defines the array of int32 to store
  97121. */
  97122. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97123. /**
  97124. * Set the value of an uniform to an array of int32 (stored as vec2)
  97125. * @param uniform defines the webGL uniform location where to store the value
  97126. * @param array defines the array of int32 to store
  97127. */
  97128. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97129. /**
  97130. * Set the value of an uniform to an array of int32 (stored as vec3)
  97131. * @param uniform defines the webGL uniform location where to store the value
  97132. * @param array defines the array of int32 to store
  97133. */
  97134. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97135. /**
  97136. * Set the value of an uniform to an array of int32 (stored as vec4)
  97137. * @param uniform defines the webGL uniform location where to store the value
  97138. * @param array defines the array of int32 to store
  97139. */
  97140. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97141. /**
  97142. * Set the value of an uniform to an array of float32
  97143. * @param uniform defines the webGL uniform location where to store the value
  97144. * @param array defines the array of float32 to store
  97145. */
  97146. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97147. /**
  97148. * Set the value of an uniform to an array of float32 (stored as vec2)
  97149. * @param uniform defines the webGL uniform location where to store the value
  97150. * @param array defines the array of float32 to store
  97151. */
  97152. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97153. /**
  97154. * Set the value of an uniform to an array of float32 (stored as vec3)
  97155. * @param uniform defines the webGL uniform location where to store the value
  97156. * @param array defines the array of float32 to store
  97157. */
  97158. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97159. /**
  97160. * Set the value of an uniform to an array of float32 (stored as vec4)
  97161. * @param uniform defines the webGL uniform location where to store the value
  97162. * @param array defines the array of float32 to store
  97163. */
  97164. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97165. /**
  97166. * Set the value of an uniform to an array of number
  97167. * @param uniform defines the webGL uniform location where to store the value
  97168. * @param array defines the array of number to store
  97169. */
  97170. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97171. /**
  97172. * Set the value of an uniform to an array of number (stored as vec2)
  97173. * @param uniform defines the webGL uniform location where to store the value
  97174. * @param array defines the array of number to store
  97175. */
  97176. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97177. /**
  97178. * Set the value of an uniform to an array of number (stored as vec3)
  97179. * @param uniform defines the webGL uniform location where to store the value
  97180. * @param array defines the array of number to store
  97181. */
  97182. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97183. /**
  97184. * Set the value of an uniform to an array of number (stored as vec4)
  97185. * @param uniform defines the webGL uniform location where to store the value
  97186. * @param array defines the array of number to store
  97187. */
  97188. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97189. /**
  97190. * Set the value of an uniform to an array of float32 (stored as matrices)
  97191. * @param uniform defines the webGL uniform location where to store the value
  97192. * @param matrices defines the array of float32 to store
  97193. */
  97194. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97195. /**
  97196. * Set the value of an uniform to a matrix (3x3)
  97197. * @param uniform defines the webGL uniform location where to store the value
  97198. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97199. */
  97200. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97201. /**
  97202. * Set the value of an uniform to a matrix (2x2)
  97203. * @param uniform defines the webGL uniform location where to store the value
  97204. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97205. */
  97206. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97207. /**
  97208. * Set the value of an uniform to a number (int)
  97209. * @param uniform defines the webGL uniform location where to store the value
  97210. * @param value defines the int number to store
  97211. */
  97212. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97213. /**
  97214. * Set the value of an uniform to a number (float)
  97215. * @param uniform defines the webGL uniform location where to store the value
  97216. * @param value defines the float number to store
  97217. */
  97218. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97219. /**
  97220. * Set the value of an uniform to a vec2
  97221. * @param uniform defines the webGL uniform location where to store the value
  97222. * @param x defines the 1st component of the value
  97223. * @param y defines the 2nd component of the value
  97224. */
  97225. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97226. /**
  97227. * Set the value of an uniform to a vec3
  97228. * @param uniform defines the webGL uniform location where to store the value
  97229. * @param x defines the 1st component of the value
  97230. * @param y defines the 2nd component of the value
  97231. * @param z defines the 3rd component of the value
  97232. */
  97233. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97234. /**
  97235. * Set the value of an uniform to a boolean
  97236. * @param uniform defines the webGL uniform location where to store the value
  97237. * @param bool defines the boolean to store
  97238. */
  97239. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97240. /**
  97241. * Set the value of an uniform to a vec4
  97242. * @param uniform defines the webGL uniform location where to store the value
  97243. * @param x defines the 1st component of the value
  97244. * @param y defines the 2nd component of the value
  97245. * @param z defines the 3rd component of the value
  97246. * @param w defines the 4th component of the value
  97247. */
  97248. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97249. /**
  97250. * Sets a Color4 on a uniform variable
  97251. * @param uniform defines the uniform location
  97252. * @param color4 defines the value to be set
  97253. */
  97254. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97255. /**
  97256. * Gets the depth culling state manager
  97257. */
  97258. readonly depthCullingState: DepthCullingState;
  97259. /**
  97260. * Gets the alpha state manager
  97261. */
  97262. readonly alphaState: AlphaState;
  97263. /**
  97264. * Gets the stencil state manager
  97265. */
  97266. readonly stencilState: StencilState;
  97267. /**
  97268. * Clears the list of texture accessible through engine.
  97269. * This can help preventing texture load conflict due to name collision.
  97270. */
  97271. clearInternalTexturesCache(): void;
  97272. /**
  97273. * Force the entire cache to be cleared
  97274. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97275. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97276. */
  97277. wipeCaches(bruteForce?: boolean): void;
  97278. /** @hidden */
  97279. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97280. min: number;
  97281. mag: number;
  97282. };
  97283. /** @hidden */
  97284. _createTexture(): WebGLTexture;
  97285. /**
  97286. * Usually called from Texture.ts.
  97287. * Passed information to create a WebGLTexture
  97288. * @param urlArg defines a value which contains one of the following:
  97289. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97290. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97291. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97292. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97293. * @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)
  97294. * @param scene needed for loading to the correct scene
  97295. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97296. * @param onLoad optional callback to be called upon successful completion
  97297. * @param onError optional callback to be called upon failure
  97298. * @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
  97299. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97300. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97301. * @param forcedExtension defines the extension to use to pick the right loader
  97302. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97303. * @param mimeType defines an optional mime type
  97304. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97305. */
  97306. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  97307. /**
  97308. * @hidden
  97309. */
  97310. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97311. /**
  97312. * Creates a raw texture
  97313. * @param data defines the data to store in the texture
  97314. * @param width defines the width of the texture
  97315. * @param height defines the height of the texture
  97316. * @param format defines the format of the data
  97317. * @param generateMipMaps defines if the engine should generate the mip levels
  97318. * @param invertY defines if data must be stored with Y axis inverted
  97319. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97320. * @param compression defines the compression used (null by default)
  97321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97322. * @returns the raw texture inside an InternalTexture
  97323. */
  97324. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97325. /**
  97326. * Creates a new raw cube texture
  97327. * @param data defines the array of data to use to create each face
  97328. * @param size defines the size of the textures
  97329. * @param format defines the format of the data
  97330. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97331. * @param generateMipMaps defines if the engine should generate the mip levels
  97332. * @param invertY defines if data must be stored with Y axis inverted
  97333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97334. * @param compression defines the compression used (null by default)
  97335. * @returns the cube texture as an InternalTexture
  97336. */
  97337. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97338. /**
  97339. * Creates a new raw 3D texture
  97340. * @param data defines the data used to create the texture
  97341. * @param width defines the width of the texture
  97342. * @param height defines the height of the texture
  97343. * @param depth defines the depth of the texture
  97344. * @param format defines the format of the texture
  97345. * @param generateMipMaps defines if the engine must generate mip levels
  97346. * @param invertY defines if data must be stored with Y axis inverted
  97347. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97348. * @param compression defines the compressed used (can be null)
  97349. * @param textureType defines the compressed used (can be null)
  97350. * @returns a new raw 3D texture (stored in an InternalTexture)
  97351. */
  97352. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97353. private _unpackFlipYCached;
  97354. /**
  97355. * In case you are sharing the context with other applications, it might
  97356. * be interested to not cache the unpack flip y state to ensure a consistent
  97357. * value would be set.
  97358. */
  97359. enableUnpackFlipYCached: boolean;
  97360. /** @hidden */
  97361. _unpackFlipY(value: boolean): void;
  97362. /** @hidden */
  97363. _getUnpackAlignement(): number;
  97364. /**
  97365. * Update the sampling mode of a given texture
  97366. * @param samplingMode defines the required sampling mode
  97367. * @param texture defines the texture to update
  97368. */
  97369. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97370. /**
  97371. * Updates a depth texture Comparison Mode and Function.
  97372. * If the comparison Function is equal to 0, the mode will be set to none.
  97373. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97374. * @param texture The texture to set the comparison function for
  97375. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97376. */
  97377. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97378. /** @hidden */
  97379. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97380. width: number;
  97381. height: number;
  97382. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97383. /**
  97384. * Creates a depth stencil texture.
  97385. * This is only available in WebGL 2 or with the depth texture extension available.
  97386. * @param size The size of face edge in the texture.
  97387. * @param options The options defining the texture.
  97388. * @returns The texture
  97389. */
  97390. createDepthStencilTexture(size: number | {
  97391. width: number;
  97392. height: number;
  97393. }, options: DepthTextureCreationOptions): InternalTexture;
  97394. /**
  97395. * Creates a depth stencil texture.
  97396. * This is only available in WebGL 2 or with the depth texture extension available.
  97397. * @param size The size of face edge in the texture.
  97398. * @param options The options defining the texture.
  97399. * @returns The texture
  97400. */
  97401. private _createDepthStencilTexture;
  97402. /** @hidden */
  97403. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97404. /** @hidden */
  97405. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97406. /** @hidden */
  97407. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97408. /** @hidden */
  97409. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  97410. /**
  97411. * @hidden
  97412. */
  97413. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97414. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97415. private _prepareWebGLTexture;
  97416. /** @hidden */
  97417. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97418. /** @hidden */
  97419. _releaseFramebufferObjects(texture: InternalTexture): void;
  97420. /** @hidden */
  97421. _releaseTexture(texture: InternalTexture): void;
  97422. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97423. protected _setProgram(program: WebGLProgram): void;
  97424. protected _boundUniforms: {
  97425. [key: number]: WebGLUniformLocation;
  97426. };
  97427. /**
  97428. * Binds an effect to the webGL context
  97429. * @param effect defines the effect to bind
  97430. */
  97431. bindSamplers(effect: Effect): void;
  97432. private _activateCurrentTexture;
  97433. /** @hidden */
  97434. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97435. /** @hidden */
  97436. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97437. /**
  97438. * Unbind all textures from the webGL context
  97439. */
  97440. unbindAllTextures(): void;
  97441. /**
  97442. * Sets a texture to the according uniform.
  97443. * @param channel The texture channel
  97444. * @param uniform The uniform to set
  97445. * @param texture The texture to apply
  97446. */
  97447. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97448. private _bindSamplerUniformToChannel;
  97449. private _getTextureWrapMode;
  97450. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97451. /**
  97452. * Sets an array of texture to the webGL context
  97453. * @param channel defines the channel where the texture array must be set
  97454. * @param uniform defines the associated uniform location
  97455. * @param textures defines the array of textures to bind
  97456. */
  97457. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97458. /** @hidden */
  97459. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97460. private _setTextureParameterFloat;
  97461. private _setTextureParameterInteger;
  97462. /**
  97463. * Unbind all vertex attributes from the webGL context
  97464. */
  97465. unbindAllAttributes(): void;
  97466. /**
  97467. * 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
  97468. */
  97469. releaseEffects(): void;
  97470. /**
  97471. * Dispose and release all associated resources
  97472. */
  97473. dispose(): void;
  97474. /**
  97475. * Attach a new callback raised when context lost event is fired
  97476. * @param callback defines the callback to call
  97477. */
  97478. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97479. /**
  97480. * Attach a new callback raised when context restored event is fired
  97481. * @param callback defines the callback to call
  97482. */
  97483. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97484. /**
  97485. * Get the current error code of the webGL context
  97486. * @returns the error code
  97487. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97488. */
  97489. getError(): number;
  97490. private _canRenderToFloatFramebuffer;
  97491. private _canRenderToHalfFloatFramebuffer;
  97492. private _canRenderToFramebuffer;
  97493. /** @hidden */
  97494. _getWebGLTextureType(type: number): number;
  97495. /** @hidden */
  97496. _getInternalFormat(format: number): number;
  97497. /** @hidden */
  97498. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97499. /** @hidden */
  97500. _getRGBAMultiSampleBufferFormat(type: number): number;
  97501. /** @hidden */
  97502. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  97503. /**
  97504. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97505. * @returns true if the engine can be created
  97506. * @ignorenaming
  97507. */
  97508. static isSupported(): boolean;
  97509. /**
  97510. * Find the next highest power of two.
  97511. * @param x Number to start search from.
  97512. * @return Next highest power of two.
  97513. */
  97514. static CeilingPOT(x: number): number;
  97515. /**
  97516. * Find the next lowest power of two.
  97517. * @param x Number to start search from.
  97518. * @return Next lowest power of two.
  97519. */
  97520. static FloorPOT(x: number): number;
  97521. /**
  97522. * Find the nearest power of two.
  97523. * @param x Number to start search from.
  97524. * @return Next nearest power of two.
  97525. */
  97526. static NearestPOT(x: number): number;
  97527. /**
  97528. * Get the closest exponent of two
  97529. * @param value defines the value to approximate
  97530. * @param max defines the maximum value to return
  97531. * @param mode defines how to define the closest value
  97532. * @returns closest exponent of two of the given value
  97533. */
  97534. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97535. /**
  97536. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97537. * @param func - the function to be called
  97538. * @param requester - the object that will request the next frame. Falls back to window.
  97539. * @returns frame number
  97540. */
  97541. static QueueNewFrame(func: () => void, requester?: any): number;
  97542. }
  97543. }
  97544. declare module BABYLON {
  97545. /**
  97546. * Class representing spherical harmonics coefficients to the 3rd degree
  97547. */
  97548. export class SphericalHarmonics {
  97549. /**
  97550. * Defines whether or not the harmonics have been prescaled for rendering.
  97551. */
  97552. preScaled: boolean;
  97553. /**
  97554. * The l0,0 coefficients of the spherical harmonics
  97555. */
  97556. l00: Vector3;
  97557. /**
  97558. * The l1,-1 coefficients of the spherical harmonics
  97559. */
  97560. l1_1: Vector3;
  97561. /**
  97562. * The l1,0 coefficients of the spherical harmonics
  97563. */
  97564. l10: Vector3;
  97565. /**
  97566. * The l1,1 coefficients of the spherical harmonics
  97567. */
  97568. l11: Vector3;
  97569. /**
  97570. * The l2,-2 coefficients of the spherical harmonics
  97571. */
  97572. l2_2: Vector3;
  97573. /**
  97574. * The l2,-1 coefficients of the spherical harmonics
  97575. */
  97576. l2_1: Vector3;
  97577. /**
  97578. * The l2,0 coefficients of the spherical harmonics
  97579. */
  97580. l20: Vector3;
  97581. /**
  97582. * The l2,1 coefficients of the spherical harmonics
  97583. */
  97584. l21: Vector3;
  97585. /**
  97586. * The l2,2 coefficients of the spherical harmonics
  97587. */
  97588. l22: Vector3;
  97589. /**
  97590. * Adds a light to the spherical harmonics
  97591. * @param direction the direction of the light
  97592. * @param color the color of the light
  97593. * @param deltaSolidAngle the delta solid angle of the light
  97594. */
  97595. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97596. /**
  97597. * Scales the spherical harmonics by the given amount
  97598. * @param scale the amount to scale
  97599. */
  97600. scaleInPlace(scale: number): void;
  97601. /**
  97602. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97603. *
  97604. * ```
  97605. * E_lm = A_l * L_lm
  97606. * ```
  97607. *
  97608. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97609. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97610. * the scaling factors are given in equation 9.
  97611. */
  97612. convertIncidentRadianceToIrradiance(): void;
  97613. /**
  97614. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97615. *
  97616. * ```
  97617. * L = (1/pi) * E * rho
  97618. * ```
  97619. *
  97620. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97621. */
  97622. convertIrradianceToLambertianRadiance(): void;
  97623. /**
  97624. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97625. * required operations at run time.
  97626. *
  97627. * This is simply done by scaling back the SH with Ylm constants parameter.
  97628. * The trigonometric part being applied by the shader at run time.
  97629. */
  97630. preScaleForRendering(): void;
  97631. /**
  97632. * Constructs a spherical harmonics from an array.
  97633. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97634. * @returns the spherical harmonics
  97635. */
  97636. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97637. /**
  97638. * Gets the spherical harmonics from polynomial
  97639. * @param polynomial the spherical polynomial
  97640. * @returns the spherical harmonics
  97641. */
  97642. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97643. }
  97644. /**
  97645. * Class representing spherical polynomial coefficients to the 3rd degree
  97646. */
  97647. export class SphericalPolynomial {
  97648. private _harmonics;
  97649. /**
  97650. * The spherical harmonics used to create the polynomials.
  97651. */
  97652. readonly preScaledHarmonics: SphericalHarmonics;
  97653. /**
  97654. * The x coefficients of the spherical polynomial
  97655. */
  97656. x: Vector3;
  97657. /**
  97658. * The y coefficients of the spherical polynomial
  97659. */
  97660. y: Vector3;
  97661. /**
  97662. * The z coefficients of the spherical polynomial
  97663. */
  97664. z: Vector3;
  97665. /**
  97666. * The xx coefficients of the spherical polynomial
  97667. */
  97668. xx: Vector3;
  97669. /**
  97670. * The yy coefficients of the spherical polynomial
  97671. */
  97672. yy: Vector3;
  97673. /**
  97674. * The zz coefficients of the spherical polynomial
  97675. */
  97676. zz: Vector3;
  97677. /**
  97678. * The xy coefficients of the spherical polynomial
  97679. */
  97680. xy: Vector3;
  97681. /**
  97682. * The yz coefficients of the spherical polynomial
  97683. */
  97684. yz: Vector3;
  97685. /**
  97686. * The zx coefficients of the spherical polynomial
  97687. */
  97688. zx: Vector3;
  97689. /**
  97690. * Adds an ambient color to the spherical polynomial
  97691. * @param color the color to add
  97692. */
  97693. addAmbient(color: Color3): void;
  97694. /**
  97695. * Scales the spherical polynomial by the given amount
  97696. * @param scale the amount to scale
  97697. */
  97698. scaleInPlace(scale: number): void;
  97699. /**
  97700. * Gets the spherical polynomial from harmonics
  97701. * @param harmonics the spherical harmonics
  97702. * @returns the spherical polynomial
  97703. */
  97704. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97705. /**
  97706. * Constructs a spherical polynomial from an array.
  97707. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97708. * @returns the spherical polynomial
  97709. */
  97710. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97711. }
  97712. }
  97713. declare module BABYLON {
  97714. /**
  97715. * Defines the source of the internal texture
  97716. */
  97717. export enum InternalTextureSource {
  97718. /**
  97719. * The source of the texture data is unknown
  97720. */
  97721. Unknown = 0,
  97722. /**
  97723. * Texture data comes from an URL
  97724. */
  97725. Url = 1,
  97726. /**
  97727. * Texture data is only used for temporary storage
  97728. */
  97729. Temp = 2,
  97730. /**
  97731. * Texture data comes from raw data (ArrayBuffer)
  97732. */
  97733. Raw = 3,
  97734. /**
  97735. * Texture content is dynamic (video or dynamic texture)
  97736. */
  97737. Dynamic = 4,
  97738. /**
  97739. * Texture content is generated by rendering to it
  97740. */
  97741. RenderTarget = 5,
  97742. /**
  97743. * Texture content is part of a multi render target process
  97744. */
  97745. MultiRenderTarget = 6,
  97746. /**
  97747. * Texture data comes from a cube data file
  97748. */
  97749. Cube = 7,
  97750. /**
  97751. * Texture data comes from a raw cube data
  97752. */
  97753. CubeRaw = 8,
  97754. /**
  97755. * Texture data come from a prefiltered cube data file
  97756. */
  97757. CubePrefiltered = 9,
  97758. /**
  97759. * Texture content is raw 3D data
  97760. */
  97761. Raw3D = 10,
  97762. /**
  97763. * Texture content is a depth texture
  97764. */
  97765. Depth = 11,
  97766. /**
  97767. * Texture data comes from a raw cube data encoded with RGBD
  97768. */
  97769. CubeRawRGBD = 12
  97770. }
  97771. /**
  97772. * Class used to store data associated with WebGL texture data for the engine
  97773. * This class should not be used directly
  97774. */
  97775. export class InternalTexture {
  97776. /** @hidden */
  97777. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97778. /**
  97779. * Defines if the texture is ready
  97780. */
  97781. isReady: boolean;
  97782. /**
  97783. * Defines if the texture is a cube texture
  97784. */
  97785. isCube: boolean;
  97786. /**
  97787. * Defines if the texture contains 3D data
  97788. */
  97789. is3D: boolean;
  97790. /**
  97791. * Defines if the texture contains multiview data
  97792. */
  97793. isMultiview: boolean;
  97794. /**
  97795. * Gets the URL used to load this texture
  97796. */
  97797. url: string;
  97798. /**
  97799. * Gets the sampling mode of the texture
  97800. */
  97801. samplingMode: number;
  97802. /**
  97803. * Gets a boolean indicating if the texture needs mipmaps generation
  97804. */
  97805. generateMipMaps: boolean;
  97806. /**
  97807. * Gets the number of samples used by the texture (WebGL2+ only)
  97808. */
  97809. samples: number;
  97810. /**
  97811. * Gets the type of the texture (int, float...)
  97812. */
  97813. type: number;
  97814. /**
  97815. * Gets the format of the texture (RGB, RGBA...)
  97816. */
  97817. format: number;
  97818. /**
  97819. * Observable called when the texture is loaded
  97820. */
  97821. onLoadedObservable: Observable<InternalTexture>;
  97822. /**
  97823. * Gets the width of the texture
  97824. */
  97825. width: number;
  97826. /**
  97827. * Gets the height of the texture
  97828. */
  97829. height: number;
  97830. /**
  97831. * Gets the depth of the texture
  97832. */
  97833. depth: number;
  97834. /**
  97835. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97836. */
  97837. baseWidth: number;
  97838. /**
  97839. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97840. */
  97841. baseHeight: number;
  97842. /**
  97843. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97844. */
  97845. baseDepth: number;
  97846. /**
  97847. * Gets a boolean indicating if the texture is inverted on Y axis
  97848. */
  97849. invertY: boolean;
  97850. /** @hidden */
  97851. _invertVScale: boolean;
  97852. /** @hidden */
  97853. _associatedChannel: number;
  97854. /** @hidden */
  97855. _source: InternalTextureSource;
  97856. /** @hidden */
  97857. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  97858. /** @hidden */
  97859. _bufferView: Nullable<ArrayBufferView>;
  97860. /** @hidden */
  97861. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97862. /** @hidden */
  97863. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97864. /** @hidden */
  97865. _size: number;
  97866. /** @hidden */
  97867. _extension: string;
  97868. /** @hidden */
  97869. _files: Nullable<string[]>;
  97870. /** @hidden */
  97871. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97872. /** @hidden */
  97873. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97874. /** @hidden */
  97875. _framebuffer: Nullable<WebGLFramebuffer>;
  97876. /** @hidden */
  97877. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97878. /** @hidden */
  97879. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97880. /** @hidden */
  97881. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97882. /** @hidden */
  97883. _attachments: Nullable<number[]>;
  97884. /** @hidden */
  97885. _cachedCoordinatesMode: Nullable<number>;
  97886. /** @hidden */
  97887. _cachedWrapU: Nullable<number>;
  97888. /** @hidden */
  97889. _cachedWrapV: Nullable<number>;
  97890. /** @hidden */
  97891. _cachedWrapR: Nullable<number>;
  97892. /** @hidden */
  97893. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97894. /** @hidden */
  97895. _isDisabled: boolean;
  97896. /** @hidden */
  97897. _compression: Nullable<string>;
  97898. /** @hidden */
  97899. _generateStencilBuffer: boolean;
  97900. /** @hidden */
  97901. _generateDepthBuffer: boolean;
  97902. /** @hidden */
  97903. _comparisonFunction: number;
  97904. /** @hidden */
  97905. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97906. /** @hidden */
  97907. _lodGenerationScale: number;
  97908. /** @hidden */
  97909. _lodGenerationOffset: number;
  97910. /** @hidden */
  97911. _colorTextureArray: Nullable<WebGLTexture>;
  97912. /** @hidden */
  97913. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97914. /** @hidden */
  97915. _lodTextureHigh: Nullable<BaseTexture>;
  97916. /** @hidden */
  97917. _lodTextureMid: Nullable<BaseTexture>;
  97918. /** @hidden */
  97919. _lodTextureLow: Nullable<BaseTexture>;
  97920. /** @hidden */
  97921. _isRGBD: boolean;
  97922. /** @hidden */
  97923. _linearSpecularLOD: boolean;
  97924. /** @hidden */
  97925. _irradianceTexture: Nullable<BaseTexture>;
  97926. /** @hidden */
  97927. _webGLTexture: Nullable<WebGLTexture>;
  97928. /** @hidden */
  97929. _references: number;
  97930. private _engine;
  97931. /**
  97932. * Gets the Engine the texture belongs to.
  97933. * @returns The babylon engine
  97934. */
  97935. getEngine(): ThinEngine;
  97936. /**
  97937. * Gets the data source type of the texture
  97938. */
  97939. readonly source: InternalTextureSource;
  97940. /**
  97941. * Creates a new InternalTexture
  97942. * @param engine defines the engine to use
  97943. * @param source defines the type of data that will be used
  97944. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97945. */
  97946. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97947. /**
  97948. * Increments the number of references (ie. the number of Texture that point to it)
  97949. */
  97950. incrementReferences(): void;
  97951. /**
  97952. * Change the size of the texture (not the size of the content)
  97953. * @param width defines the new width
  97954. * @param height defines the new height
  97955. * @param depth defines the new depth (1 by default)
  97956. */
  97957. updateSize(width: int, height: int, depth?: int): void;
  97958. /** @hidden */
  97959. _rebuild(): void;
  97960. /** @hidden */
  97961. _swapAndDie(target: InternalTexture): void;
  97962. /**
  97963. * Dispose the current allocated resources
  97964. */
  97965. dispose(): void;
  97966. }
  97967. }
  97968. declare module BABYLON {
  97969. /**
  97970. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97972. */
  97973. export class Analyser {
  97974. /**
  97975. * Gets or sets the smoothing
  97976. * @ignorenaming
  97977. */
  97978. SMOOTHING: number;
  97979. /**
  97980. * Gets or sets the FFT table size
  97981. * @ignorenaming
  97982. */
  97983. FFT_SIZE: number;
  97984. /**
  97985. * Gets or sets the bar graph amplitude
  97986. * @ignorenaming
  97987. */
  97988. BARGRAPHAMPLITUDE: number;
  97989. /**
  97990. * Gets or sets the position of the debug canvas
  97991. * @ignorenaming
  97992. */
  97993. DEBUGCANVASPOS: {
  97994. x: number;
  97995. y: number;
  97996. };
  97997. /**
  97998. * Gets or sets the debug canvas size
  97999. * @ignorenaming
  98000. */
  98001. DEBUGCANVASSIZE: {
  98002. width: number;
  98003. height: number;
  98004. };
  98005. private _byteFreqs;
  98006. private _byteTime;
  98007. private _floatFreqs;
  98008. private _webAudioAnalyser;
  98009. private _debugCanvas;
  98010. private _debugCanvasContext;
  98011. private _scene;
  98012. private _registerFunc;
  98013. private _audioEngine;
  98014. /**
  98015. * Creates a new analyser
  98016. * @param scene defines hosting scene
  98017. */
  98018. constructor(scene: Scene);
  98019. /**
  98020. * Get the number of data values you will have to play with for the visualization
  98021. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98022. * @returns a number
  98023. */
  98024. getFrequencyBinCount(): number;
  98025. /**
  98026. * Gets the current frequency data as a byte array
  98027. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98028. * @returns a Uint8Array
  98029. */
  98030. getByteFrequencyData(): Uint8Array;
  98031. /**
  98032. * Gets the current waveform as a byte array
  98033. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98034. * @returns a Uint8Array
  98035. */
  98036. getByteTimeDomainData(): Uint8Array;
  98037. /**
  98038. * Gets the current frequency data as a float array
  98039. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98040. * @returns a Float32Array
  98041. */
  98042. getFloatFrequencyData(): Float32Array;
  98043. /**
  98044. * Renders the debug canvas
  98045. */
  98046. drawDebugCanvas(): void;
  98047. /**
  98048. * Stops rendering the debug canvas and removes it
  98049. */
  98050. stopDebugCanvas(): void;
  98051. /**
  98052. * Connects two audio nodes
  98053. * @param inputAudioNode defines first node to connect
  98054. * @param outputAudioNode defines second node to connect
  98055. */
  98056. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98057. /**
  98058. * Releases all associated resources
  98059. */
  98060. dispose(): void;
  98061. }
  98062. }
  98063. declare module BABYLON {
  98064. /**
  98065. * This represents an audio engine and it is responsible
  98066. * to play, synchronize and analyse sounds throughout the application.
  98067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98068. */
  98069. export interface IAudioEngine extends IDisposable {
  98070. /**
  98071. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98072. */
  98073. readonly canUseWebAudio: boolean;
  98074. /**
  98075. * Gets the current AudioContext if available.
  98076. */
  98077. readonly audioContext: Nullable<AudioContext>;
  98078. /**
  98079. * The master gain node defines the global audio volume of your audio engine.
  98080. */
  98081. readonly masterGain: GainNode;
  98082. /**
  98083. * Gets whether or not mp3 are supported by your browser.
  98084. */
  98085. readonly isMP3supported: boolean;
  98086. /**
  98087. * Gets whether or not ogg are supported by your browser.
  98088. */
  98089. readonly isOGGsupported: boolean;
  98090. /**
  98091. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98092. * @ignoreNaming
  98093. */
  98094. WarnedWebAudioUnsupported: boolean;
  98095. /**
  98096. * Defines if the audio engine relies on a custom unlocked button.
  98097. * In this case, the embedded button will not be displayed.
  98098. */
  98099. useCustomUnlockedButton: boolean;
  98100. /**
  98101. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98102. */
  98103. readonly unlocked: boolean;
  98104. /**
  98105. * Event raised when audio has been unlocked on the browser.
  98106. */
  98107. onAudioUnlockedObservable: Observable<AudioEngine>;
  98108. /**
  98109. * Event raised when audio has been locked on the browser.
  98110. */
  98111. onAudioLockedObservable: Observable<AudioEngine>;
  98112. /**
  98113. * Flags the audio engine in Locked state.
  98114. * This happens due to new browser policies preventing audio to autoplay.
  98115. */
  98116. lock(): void;
  98117. /**
  98118. * Unlocks the audio engine once a user action has been done on the dom.
  98119. * This is helpful to resume play once browser policies have been satisfied.
  98120. */
  98121. unlock(): void;
  98122. }
  98123. /**
  98124. * This represents the default audio engine used in babylon.
  98125. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98127. */
  98128. export class AudioEngine implements IAudioEngine {
  98129. private _audioContext;
  98130. private _audioContextInitialized;
  98131. private _muteButton;
  98132. private _hostElement;
  98133. /**
  98134. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98135. */
  98136. canUseWebAudio: boolean;
  98137. /**
  98138. * The master gain node defines the global audio volume of your audio engine.
  98139. */
  98140. masterGain: GainNode;
  98141. /**
  98142. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98143. * @ignoreNaming
  98144. */
  98145. WarnedWebAudioUnsupported: boolean;
  98146. /**
  98147. * Gets whether or not mp3 are supported by your browser.
  98148. */
  98149. isMP3supported: boolean;
  98150. /**
  98151. * Gets whether or not ogg are supported by your browser.
  98152. */
  98153. isOGGsupported: boolean;
  98154. /**
  98155. * Gets whether audio has been unlocked on the device.
  98156. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98157. * a user interaction has happened.
  98158. */
  98159. unlocked: boolean;
  98160. /**
  98161. * Defines if the audio engine relies on a custom unlocked button.
  98162. * In this case, the embedded button will not be displayed.
  98163. */
  98164. useCustomUnlockedButton: boolean;
  98165. /**
  98166. * Event raised when audio has been unlocked on the browser.
  98167. */
  98168. onAudioUnlockedObservable: Observable<AudioEngine>;
  98169. /**
  98170. * Event raised when audio has been locked on the browser.
  98171. */
  98172. onAudioLockedObservable: Observable<AudioEngine>;
  98173. /**
  98174. * Gets the current AudioContext if available.
  98175. */
  98176. readonly audioContext: Nullable<AudioContext>;
  98177. private _connectedAnalyser;
  98178. /**
  98179. * Instantiates a new audio engine.
  98180. *
  98181. * There should be only one per page as some browsers restrict the number
  98182. * of audio contexts you can create.
  98183. * @param hostElement defines the host element where to display the mute icon if necessary
  98184. */
  98185. constructor(hostElement?: Nullable<HTMLElement>);
  98186. /**
  98187. * Flags the audio engine in Locked state.
  98188. * This happens due to new browser policies preventing audio to autoplay.
  98189. */
  98190. lock(): void;
  98191. /**
  98192. * Unlocks the audio engine once a user action has been done on the dom.
  98193. * This is helpful to resume play once browser policies have been satisfied.
  98194. */
  98195. unlock(): void;
  98196. private _resumeAudioContext;
  98197. private _initializeAudioContext;
  98198. private _tryToRun;
  98199. private _triggerRunningState;
  98200. private _triggerSuspendedState;
  98201. private _displayMuteButton;
  98202. private _moveButtonToTopLeft;
  98203. private _onResize;
  98204. private _hideMuteButton;
  98205. /**
  98206. * Destroy and release the resources associated with the audio ccontext.
  98207. */
  98208. dispose(): void;
  98209. /**
  98210. * Gets the global volume sets on the master gain.
  98211. * @returns the global volume if set or -1 otherwise
  98212. */
  98213. getGlobalVolume(): number;
  98214. /**
  98215. * Sets the global volume of your experience (sets on the master gain).
  98216. * @param newVolume Defines the new global volume of the application
  98217. */
  98218. setGlobalVolume(newVolume: number): void;
  98219. /**
  98220. * Connect the audio engine to an audio analyser allowing some amazing
  98221. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98223. * @param analyser The analyser to connect to the engine
  98224. */
  98225. connectToAnalyser(analyser: Analyser): void;
  98226. }
  98227. }
  98228. declare module BABYLON {
  98229. /**
  98230. * Interface used to present a loading screen while loading a scene
  98231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98232. */
  98233. export interface ILoadingScreen {
  98234. /**
  98235. * Function called to display the loading screen
  98236. */
  98237. displayLoadingUI: () => void;
  98238. /**
  98239. * Function called to hide the loading screen
  98240. */
  98241. hideLoadingUI: () => void;
  98242. /**
  98243. * Gets or sets the color to use for the background
  98244. */
  98245. loadingUIBackgroundColor: string;
  98246. /**
  98247. * Gets or sets the text to display while loading
  98248. */
  98249. loadingUIText: string;
  98250. }
  98251. /**
  98252. * Class used for the default loading screen
  98253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98254. */
  98255. export class DefaultLoadingScreen implements ILoadingScreen {
  98256. private _renderingCanvas;
  98257. private _loadingText;
  98258. private _loadingDivBackgroundColor;
  98259. private _loadingDiv;
  98260. private _loadingTextDiv;
  98261. /** Gets or sets the logo url to use for the default loading screen */
  98262. static DefaultLogoUrl: string;
  98263. /** Gets or sets the spinner url to use for the default loading screen */
  98264. static DefaultSpinnerUrl: string;
  98265. /**
  98266. * Creates a new default loading screen
  98267. * @param _renderingCanvas defines the canvas used to render the scene
  98268. * @param _loadingText defines the default text to display
  98269. * @param _loadingDivBackgroundColor defines the default background color
  98270. */
  98271. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98272. /**
  98273. * Function called to display the loading screen
  98274. */
  98275. displayLoadingUI(): void;
  98276. /**
  98277. * Function called to hide the loading screen
  98278. */
  98279. hideLoadingUI(): void;
  98280. /**
  98281. * Gets or sets the text to display while loading
  98282. */
  98283. loadingUIText: string;
  98284. /**
  98285. * Gets or sets the color to use for the background
  98286. */
  98287. loadingUIBackgroundColor: string;
  98288. private _resizeLoadingUI;
  98289. }
  98290. }
  98291. declare module BABYLON {
  98292. /**
  98293. * Interface for any object that can request an animation frame
  98294. */
  98295. export interface ICustomAnimationFrameRequester {
  98296. /**
  98297. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98298. */
  98299. renderFunction?: Function;
  98300. /**
  98301. * Called to request the next frame to render to
  98302. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98303. */
  98304. requestAnimationFrame: Function;
  98305. /**
  98306. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98307. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98308. */
  98309. requestID?: number;
  98310. }
  98311. }
  98312. declare module BABYLON {
  98313. /**
  98314. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98315. */
  98316. export class PerformanceMonitor {
  98317. private _enabled;
  98318. private _rollingFrameTime;
  98319. private _lastFrameTimeMs;
  98320. /**
  98321. * constructor
  98322. * @param frameSampleSize The number of samples required to saturate the sliding window
  98323. */
  98324. constructor(frameSampleSize?: number);
  98325. /**
  98326. * Samples current frame
  98327. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98328. */
  98329. sampleFrame(timeMs?: number): void;
  98330. /**
  98331. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98332. */
  98333. readonly averageFrameTime: number;
  98334. /**
  98335. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98336. */
  98337. readonly averageFrameTimeVariance: number;
  98338. /**
  98339. * Returns the frame time of the most recent frame
  98340. */
  98341. readonly instantaneousFrameTime: number;
  98342. /**
  98343. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98344. */
  98345. readonly averageFPS: number;
  98346. /**
  98347. * Returns the average framerate in frames per second using the most recent frame time
  98348. */
  98349. readonly instantaneousFPS: number;
  98350. /**
  98351. * Returns true if enough samples have been taken to completely fill the sliding window
  98352. */
  98353. readonly isSaturated: boolean;
  98354. /**
  98355. * Enables contributions to the sliding window sample set
  98356. */
  98357. enable(): void;
  98358. /**
  98359. * Disables contributions to the sliding window sample set
  98360. * Samples will not be interpolated over the disabled period
  98361. */
  98362. disable(): void;
  98363. /**
  98364. * Returns true if sampling is enabled
  98365. */
  98366. readonly isEnabled: boolean;
  98367. /**
  98368. * Resets performance monitor
  98369. */
  98370. reset(): void;
  98371. }
  98372. /**
  98373. * RollingAverage
  98374. *
  98375. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98376. */
  98377. export class RollingAverage {
  98378. /**
  98379. * Current average
  98380. */
  98381. average: number;
  98382. /**
  98383. * Current variance
  98384. */
  98385. variance: number;
  98386. protected _samples: Array<number>;
  98387. protected _sampleCount: number;
  98388. protected _pos: number;
  98389. protected _m2: number;
  98390. /**
  98391. * constructor
  98392. * @param length The number of samples required to saturate the sliding window
  98393. */
  98394. constructor(length: number);
  98395. /**
  98396. * Adds a sample to the sample set
  98397. * @param v The sample value
  98398. */
  98399. add(v: number): void;
  98400. /**
  98401. * Returns previously added values or null if outside of history or outside the sliding window domain
  98402. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98403. * @return Value previously recorded with add() or null if outside of range
  98404. */
  98405. history(i: number): number;
  98406. /**
  98407. * Returns true if enough samples have been taken to completely fill the sliding window
  98408. * @return true if sample-set saturated
  98409. */
  98410. isSaturated(): boolean;
  98411. /**
  98412. * Resets the rolling average (equivalent to 0 samples taken so far)
  98413. */
  98414. reset(): void;
  98415. /**
  98416. * Wraps a value around the sample range boundaries
  98417. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98418. * @return Wrapped position in sample range
  98419. */
  98420. protected _wrapPosition(i: number): number;
  98421. }
  98422. }
  98423. declare module BABYLON {
  98424. /**
  98425. * This class is used to track a performance counter which is number based.
  98426. * The user has access to many properties which give statistics of different nature.
  98427. *
  98428. * The implementer can track two kinds of Performance Counter: time and count.
  98429. * 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.
  98430. * 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.
  98431. */
  98432. export class PerfCounter {
  98433. /**
  98434. * Gets or sets a global boolean to turn on and off all the counters
  98435. */
  98436. static Enabled: boolean;
  98437. /**
  98438. * Returns the smallest value ever
  98439. */
  98440. readonly min: number;
  98441. /**
  98442. * Returns the biggest value ever
  98443. */
  98444. readonly max: number;
  98445. /**
  98446. * Returns the average value since the performance counter is running
  98447. */
  98448. readonly average: number;
  98449. /**
  98450. * Returns the average value of the last second the counter was monitored
  98451. */
  98452. readonly lastSecAverage: number;
  98453. /**
  98454. * Returns the current value
  98455. */
  98456. readonly current: number;
  98457. /**
  98458. * Gets the accumulated total
  98459. */
  98460. readonly total: number;
  98461. /**
  98462. * Gets the total value count
  98463. */
  98464. readonly count: number;
  98465. /**
  98466. * Creates a new counter
  98467. */
  98468. constructor();
  98469. /**
  98470. * Call this method to start monitoring a new frame.
  98471. * 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.
  98472. */
  98473. fetchNewFrame(): void;
  98474. /**
  98475. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98476. * @param newCount the count value to add to the monitored count
  98477. * @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.
  98478. */
  98479. addCount(newCount: number, fetchResult: boolean): void;
  98480. /**
  98481. * Start monitoring this performance counter
  98482. */
  98483. beginMonitoring(): void;
  98484. /**
  98485. * Compute the time lapsed since the previous beginMonitoring() call.
  98486. * @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
  98487. */
  98488. endMonitoring(newFrame?: boolean): void;
  98489. private _fetchResult;
  98490. private _startMonitoringTime;
  98491. private _min;
  98492. private _max;
  98493. private _average;
  98494. private _current;
  98495. private _totalValueCount;
  98496. private _totalAccumulated;
  98497. private _lastSecAverage;
  98498. private _lastSecAccumulated;
  98499. private _lastSecTime;
  98500. private _lastSecValueCount;
  98501. }
  98502. }
  98503. declare module BABYLON {
  98504. /**
  98505. * Defines the interface used by display changed events
  98506. */
  98507. export interface IDisplayChangedEventArgs {
  98508. /** Gets the vrDisplay object (if any) */
  98509. vrDisplay: Nullable<any>;
  98510. /** Gets a boolean indicating if webVR is supported */
  98511. vrSupported: boolean;
  98512. }
  98513. /**
  98514. * Defines the interface used by objects containing a viewport (like a camera)
  98515. */
  98516. interface IViewportOwnerLike {
  98517. /**
  98518. * Gets or sets the viewport
  98519. */
  98520. viewport: IViewportLike;
  98521. }
  98522. /**
  98523. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98524. */
  98525. export class Engine extends ThinEngine {
  98526. /** Defines that alpha blending is disabled */
  98527. static readonly ALPHA_DISABLE: number;
  98528. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98529. static readonly ALPHA_ADD: number;
  98530. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98531. static readonly ALPHA_COMBINE: number;
  98532. /** Defines that alpha blending to DEST - SRC * DEST */
  98533. static readonly ALPHA_SUBTRACT: number;
  98534. /** Defines that alpha blending to SRC * DEST */
  98535. static readonly ALPHA_MULTIPLY: number;
  98536. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98537. static readonly ALPHA_MAXIMIZED: number;
  98538. /** Defines that alpha blending to SRC + DEST */
  98539. static readonly ALPHA_ONEONE: number;
  98540. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98541. static readonly ALPHA_PREMULTIPLIED: number;
  98542. /**
  98543. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98544. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98545. */
  98546. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98547. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98548. static readonly ALPHA_INTERPOLATE: number;
  98549. /**
  98550. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98551. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98552. */
  98553. static readonly ALPHA_SCREENMODE: number;
  98554. /** Defines that the ressource is not delayed*/
  98555. static readonly DELAYLOADSTATE_NONE: number;
  98556. /** Defines that the ressource was successfully delay loaded */
  98557. static readonly DELAYLOADSTATE_LOADED: number;
  98558. /** Defines that the ressource is currently delay loading */
  98559. static readonly DELAYLOADSTATE_LOADING: number;
  98560. /** Defines that the ressource is delayed and has not started loading */
  98561. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98562. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98563. static readonly NEVER: number;
  98564. /** 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 */
  98565. static readonly ALWAYS: number;
  98566. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98567. static readonly LESS: number;
  98568. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98569. static readonly EQUAL: number;
  98570. /** 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 */
  98571. static readonly LEQUAL: number;
  98572. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98573. static readonly GREATER: number;
  98574. /** 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 */
  98575. static readonly GEQUAL: number;
  98576. /** 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 */
  98577. static readonly NOTEQUAL: number;
  98578. /** Passed to stencilOperation to specify that stencil value must be kept */
  98579. static readonly KEEP: number;
  98580. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98581. static readonly REPLACE: number;
  98582. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98583. static readonly INCR: number;
  98584. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98585. static readonly DECR: number;
  98586. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98587. static readonly INVERT: number;
  98588. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98589. static readonly INCR_WRAP: number;
  98590. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98591. static readonly DECR_WRAP: number;
  98592. /** Texture is not repeating outside of 0..1 UVs */
  98593. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98594. /** Texture is repeating outside of 0..1 UVs */
  98595. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98596. /** Texture is repeating and mirrored */
  98597. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98598. /** ALPHA */
  98599. static readonly TEXTUREFORMAT_ALPHA: number;
  98600. /** LUMINANCE */
  98601. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98602. /** LUMINANCE_ALPHA */
  98603. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98604. /** RGB */
  98605. static readonly TEXTUREFORMAT_RGB: number;
  98606. /** RGBA */
  98607. static readonly TEXTUREFORMAT_RGBA: number;
  98608. /** RED */
  98609. static readonly TEXTUREFORMAT_RED: number;
  98610. /** RED (2nd reference) */
  98611. static readonly TEXTUREFORMAT_R: number;
  98612. /** RG */
  98613. static readonly TEXTUREFORMAT_RG: number;
  98614. /** RED_INTEGER */
  98615. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98616. /** RED_INTEGER (2nd reference) */
  98617. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98618. /** RG_INTEGER */
  98619. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98620. /** RGB_INTEGER */
  98621. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98622. /** RGBA_INTEGER */
  98623. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98624. /** UNSIGNED_BYTE */
  98625. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98626. /** UNSIGNED_BYTE (2nd reference) */
  98627. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98628. /** FLOAT */
  98629. static readonly TEXTURETYPE_FLOAT: number;
  98630. /** HALF_FLOAT */
  98631. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98632. /** BYTE */
  98633. static readonly TEXTURETYPE_BYTE: number;
  98634. /** SHORT */
  98635. static readonly TEXTURETYPE_SHORT: number;
  98636. /** UNSIGNED_SHORT */
  98637. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98638. /** INT */
  98639. static readonly TEXTURETYPE_INT: number;
  98640. /** UNSIGNED_INT */
  98641. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98642. /** UNSIGNED_SHORT_4_4_4_4 */
  98643. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98644. /** UNSIGNED_SHORT_5_5_5_1 */
  98645. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98646. /** UNSIGNED_SHORT_5_6_5 */
  98647. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98648. /** UNSIGNED_INT_2_10_10_10_REV */
  98649. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98650. /** UNSIGNED_INT_24_8 */
  98651. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98652. /** UNSIGNED_INT_10F_11F_11F_REV */
  98653. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98654. /** UNSIGNED_INT_5_9_9_9_REV */
  98655. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98656. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98657. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98658. /** nearest is mag = nearest and min = nearest and mip = linear */
  98659. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98660. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98661. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98662. /** Trilinear is mag = linear and min = linear and mip = linear */
  98663. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98664. /** nearest is mag = nearest and min = nearest and mip = linear */
  98665. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98666. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98667. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98668. /** Trilinear is mag = linear and min = linear and mip = linear */
  98669. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98670. /** mag = nearest and min = nearest and mip = nearest */
  98671. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98672. /** mag = nearest and min = linear and mip = nearest */
  98673. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98674. /** mag = nearest and min = linear and mip = linear */
  98675. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98676. /** mag = nearest and min = linear and mip = none */
  98677. static readonly TEXTURE_NEAREST_LINEAR: number;
  98678. /** mag = nearest and min = nearest and mip = none */
  98679. static readonly TEXTURE_NEAREST_NEAREST: number;
  98680. /** mag = linear and min = nearest and mip = nearest */
  98681. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98682. /** mag = linear and min = nearest and mip = linear */
  98683. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98684. /** mag = linear and min = linear and mip = none */
  98685. static readonly TEXTURE_LINEAR_LINEAR: number;
  98686. /** mag = linear and min = nearest and mip = none */
  98687. static readonly TEXTURE_LINEAR_NEAREST: number;
  98688. /** Explicit coordinates mode */
  98689. static readonly TEXTURE_EXPLICIT_MODE: number;
  98690. /** Spherical coordinates mode */
  98691. static readonly TEXTURE_SPHERICAL_MODE: number;
  98692. /** Planar coordinates mode */
  98693. static readonly TEXTURE_PLANAR_MODE: number;
  98694. /** Cubic coordinates mode */
  98695. static readonly TEXTURE_CUBIC_MODE: number;
  98696. /** Projection coordinates mode */
  98697. static readonly TEXTURE_PROJECTION_MODE: number;
  98698. /** Skybox coordinates mode */
  98699. static readonly TEXTURE_SKYBOX_MODE: number;
  98700. /** Inverse Cubic coordinates mode */
  98701. static readonly TEXTURE_INVCUBIC_MODE: number;
  98702. /** Equirectangular coordinates mode */
  98703. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98704. /** Equirectangular Fixed coordinates mode */
  98705. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98706. /** Equirectangular Fixed Mirrored coordinates mode */
  98707. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98708. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98709. static readonly SCALEMODE_FLOOR: number;
  98710. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98711. static readonly SCALEMODE_NEAREST: number;
  98712. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98713. static readonly SCALEMODE_CEILING: number;
  98714. /**
  98715. * Returns the current npm package of the sdk
  98716. */
  98717. static readonly NpmPackage: string;
  98718. /**
  98719. * Returns the current version of the framework
  98720. */
  98721. static readonly Version: string;
  98722. /** Gets the list of created engines */
  98723. static readonly Instances: Engine[];
  98724. /**
  98725. * Gets the latest created engine
  98726. */
  98727. static readonly LastCreatedEngine: Nullable<Engine>;
  98728. /**
  98729. * Gets the latest created scene
  98730. */
  98731. static readonly LastCreatedScene: Nullable<Scene>;
  98732. /**
  98733. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98734. * @param flag defines which part of the materials must be marked as dirty
  98735. * @param predicate defines a predicate used to filter which materials should be affected
  98736. */
  98737. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98738. /**
  98739. * Method called to create the default loading screen.
  98740. * This can be overriden in your own app.
  98741. * @param canvas The rendering canvas element
  98742. * @returns The loading screen
  98743. */
  98744. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98745. /**
  98746. * Method called to create the default rescale post process on each engine.
  98747. */
  98748. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98749. /**
  98750. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98751. **/
  98752. enableOfflineSupport: boolean;
  98753. /**
  98754. * 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)
  98755. **/
  98756. disableManifestCheck: boolean;
  98757. /**
  98758. * Gets the list of created scenes
  98759. */
  98760. scenes: Scene[];
  98761. /**
  98762. * Event raised when a new scene is created
  98763. */
  98764. onNewSceneAddedObservable: Observable<Scene>;
  98765. /**
  98766. * Gets the list of created postprocesses
  98767. */
  98768. postProcesses: PostProcess[];
  98769. /**
  98770. * Gets a boolean indicating if the pointer is currently locked
  98771. */
  98772. isPointerLock: boolean;
  98773. /**
  98774. * Observable event triggered each time the rendering canvas is resized
  98775. */
  98776. onResizeObservable: Observable<Engine>;
  98777. /**
  98778. * Observable event triggered each time the canvas loses focus
  98779. */
  98780. onCanvasBlurObservable: Observable<Engine>;
  98781. /**
  98782. * Observable event triggered each time the canvas gains focus
  98783. */
  98784. onCanvasFocusObservable: Observable<Engine>;
  98785. /**
  98786. * Observable event triggered each time the canvas receives pointerout event
  98787. */
  98788. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98789. /**
  98790. * Observable raised when the engine begins a new frame
  98791. */
  98792. onBeginFrameObservable: Observable<Engine>;
  98793. /**
  98794. * If set, will be used to request the next animation frame for the render loop
  98795. */
  98796. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98797. /**
  98798. * Observable raised when the engine ends the current frame
  98799. */
  98800. onEndFrameObservable: Observable<Engine>;
  98801. /**
  98802. * Observable raised when the engine is about to compile a shader
  98803. */
  98804. onBeforeShaderCompilationObservable: Observable<Engine>;
  98805. /**
  98806. * Observable raised when the engine has jsut compiled a shader
  98807. */
  98808. onAfterShaderCompilationObservable: Observable<Engine>;
  98809. /**
  98810. * Gets the audio engine
  98811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98812. * @ignorenaming
  98813. */
  98814. static audioEngine: IAudioEngine;
  98815. /**
  98816. * Default AudioEngine factory responsible of creating the Audio Engine.
  98817. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98818. */
  98819. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98820. /**
  98821. * Default offline support factory responsible of creating a tool used to store data locally.
  98822. * By default, this will create a Database object if the workload has been embedded.
  98823. */
  98824. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98825. private _loadingScreen;
  98826. private _pointerLockRequested;
  98827. private _dummyFramebuffer;
  98828. private _rescalePostProcess;
  98829. /** @hidden */
  98830. protected _alphaMode: number;
  98831. /** @hidden */
  98832. protected _alphaEquation: number;
  98833. private _deterministicLockstep;
  98834. private _lockstepMaxSteps;
  98835. protected readonly _supportsHardwareTextureRescaling: boolean;
  98836. private _fps;
  98837. private _deltaTime;
  98838. /** @hidden */
  98839. _drawCalls: PerfCounter;
  98840. /**
  98841. * Turn this value on if you want to pause FPS computation when in background
  98842. */
  98843. disablePerformanceMonitorInBackground: boolean;
  98844. private _performanceMonitor;
  98845. /**
  98846. * Gets the performance monitor attached to this engine
  98847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98848. */
  98849. readonly performanceMonitor: PerformanceMonitor;
  98850. private _onFocus;
  98851. private _onBlur;
  98852. private _onCanvasPointerOut;
  98853. private _onCanvasBlur;
  98854. private _onCanvasFocus;
  98855. private _onFullscreenChange;
  98856. private _onPointerLockChange;
  98857. /**
  98858. * Creates a new engine
  98859. * @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
  98860. * @param antialias defines enable antialiasing (default: false)
  98861. * @param options defines further options to be sent to the getContext() function
  98862. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98863. */
  98864. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98865. /**
  98866. * Gets current aspect ratio
  98867. * @param viewportOwner defines the camera to use to get the aspect ratio
  98868. * @param useScreen defines if screen size must be used (or the current render target if any)
  98869. * @returns a number defining the aspect ratio
  98870. */
  98871. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98872. /**
  98873. * Gets current screen aspect ratio
  98874. * @returns a number defining the aspect ratio
  98875. */
  98876. getScreenAspectRatio(): number;
  98877. /**
  98878. * Gets host document
  98879. * @returns the host document object
  98880. */
  98881. getHostDocument(): Document;
  98882. /**
  98883. * Gets the client rect of the HTML canvas attached with the current webGL context
  98884. * @returns a client rectanglee
  98885. */
  98886. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98887. /**
  98888. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98889. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98890. * @returns true if engine is in deterministic lock step mode
  98891. */
  98892. isDeterministicLockStep(): boolean;
  98893. /**
  98894. * Gets the max steps when engine is running in deterministic lock step
  98895. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98896. * @returns the max steps
  98897. */
  98898. getLockstepMaxSteps(): number;
  98899. /**
  98900. * Force the mipmap generation for the given render target texture
  98901. * @param texture defines the render target texture to use
  98902. */
  98903. generateMipMapsForCubemap(texture: InternalTexture): void;
  98904. /** States */
  98905. /**
  98906. * Set various states to the webGL context
  98907. * @param culling defines backface culling state
  98908. * @param zOffset defines the value to apply to zOffset (0 by default)
  98909. * @param force defines if states must be applied even if cache is up to date
  98910. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98911. */
  98912. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98913. /**
  98914. * Set the z offset to apply to current rendering
  98915. * @param value defines the offset to apply
  98916. */
  98917. setZOffset(value: number): void;
  98918. /**
  98919. * Gets the current value of the zOffset
  98920. * @returns the current zOffset state
  98921. */
  98922. getZOffset(): number;
  98923. /**
  98924. * Enable or disable depth buffering
  98925. * @param enable defines the state to set
  98926. */
  98927. setDepthBuffer(enable: boolean): void;
  98928. /**
  98929. * Gets a boolean indicating if depth writing is enabled
  98930. * @returns the current depth writing state
  98931. */
  98932. getDepthWrite(): boolean;
  98933. /**
  98934. * Enable or disable depth writing
  98935. * @param enable defines the state to set
  98936. */
  98937. setDepthWrite(enable: boolean): void;
  98938. /**
  98939. * Enable or disable color writing
  98940. * @param enable defines the state to set
  98941. */
  98942. setColorWrite(enable: boolean): void;
  98943. /**
  98944. * Gets a boolean indicating if color writing is enabled
  98945. * @returns the current color writing state
  98946. */
  98947. getColorWrite(): boolean;
  98948. /**
  98949. * Sets alpha constants used by some alpha blending modes
  98950. * @param r defines the red component
  98951. * @param g defines the green component
  98952. * @param b defines the blue component
  98953. * @param a defines the alpha component
  98954. */
  98955. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98956. /**
  98957. * Sets the current alpha mode
  98958. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98959. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98960. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98961. */
  98962. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98963. /**
  98964. * Gets the current alpha mode
  98965. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98966. * @returns the current alpha mode
  98967. */
  98968. getAlphaMode(): number;
  98969. /**
  98970. * Sets the current alpha equation
  98971. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98972. */
  98973. setAlphaEquation(equation: number): void;
  98974. /**
  98975. * Gets the current alpha equation.
  98976. * @returns the current alpha equation
  98977. */
  98978. getAlphaEquation(): number;
  98979. /**
  98980. * Gets a boolean indicating if stencil buffer is enabled
  98981. * @returns the current stencil buffer state
  98982. */
  98983. getStencilBuffer(): boolean;
  98984. /**
  98985. * Enable or disable the stencil buffer
  98986. * @param enable defines if the stencil buffer must be enabled or disabled
  98987. */
  98988. setStencilBuffer(enable: boolean): void;
  98989. /**
  98990. * Gets the current stencil mask
  98991. * @returns a number defining the new stencil mask to use
  98992. */
  98993. getStencilMask(): number;
  98994. /**
  98995. * Sets the current stencil mask
  98996. * @param mask defines the new stencil mask to use
  98997. */
  98998. setStencilMask(mask: number): void;
  98999. /**
  99000. * Gets the current stencil function
  99001. * @returns a number defining the stencil function to use
  99002. */
  99003. getStencilFunction(): number;
  99004. /**
  99005. * Gets the current stencil reference value
  99006. * @returns a number defining the stencil reference value to use
  99007. */
  99008. getStencilFunctionReference(): number;
  99009. /**
  99010. * Gets the current stencil mask
  99011. * @returns a number defining the stencil mask to use
  99012. */
  99013. getStencilFunctionMask(): number;
  99014. /**
  99015. * Sets the current stencil function
  99016. * @param stencilFunc defines the new stencil function to use
  99017. */
  99018. setStencilFunction(stencilFunc: number): void;
  99019. /**
  99020. * Sets the current stencil reference
  99021. * @param reference defines the new stencil reference to use
  99022. */
  99023. setStencilFunctionReference(reference: number): void;
  99024. /**
  99025. * Sets the current stencil mask
  99026. * @param mask defines the new stencil mask to use
  99027. */
  99028. setStencilFunctionMask(mask: number): void;
  99029. /**
  99030. * Gets the current stencil operation when stencil fails
  99031. * @returns a number defining stencil operation to use when stencil fails
  99032. */
  99033. getStencilOperationFail(): number;
  99034. /**
  99035. * Gets the current stencil operation when depth fails
  99036. * @returns a number defining stencil operation to use when depth fails
  99037. */
  99038. getStencilOperationDepthFail(): number;
  99039. /**
  99040. * Gets the current stencil operation when stencil passes
  99041. * @returns a number defining stencil operation to use when stencil passes
  99042. */
  99043. getStencilOperationPass(): number;
  99044. /**
  99045. * Sets the stencil operation to use when stencil fails
  99046. * @param operation defines the stencil operation to use when stencil fails
  99047. */
  99048. setStencilOperationFail(operation: number): void;
  99049. /**
  99050. * Sets the stencil operation to use when depth fails
  99051. * @param operation defines the stencil operation to use when depth fails
  99052. */
  99053. setStencilOperationDepthFail(operation: number): void;
  99054. /**
  99055. * Sets the stencil operation to use when stencil passes
  99056. * @param operation defines the stencil operation to use when stencil passes
  99057. */
  99058. setStencilOperationPass(operation: number): void;
  99059. /**
  99060. * Sets a boolean indicating if the dithering state is enabled or disabled
  99061. * @param value defines the dithering state
  99062. */
  99063. setDitheringState(value: boolean): void;
  99064. /**
  99065. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99066. * @param value defines the rasterizer state
  99067. */
  99068. setRasterizerState(value: boolean): void;
  99069. /**
  99070. * Gets the current depth function
  99071. * @returns a number defining the depth function
  99072. */
  99073. getDepthFunction(): Nullable<number>;
  99074. /**
  99075. * Sets the current depth function
  99076. * @param depthFunc defines the function to use
  99077. */
  99078. setDepthFunction(depthFunc: number): void;
  99079. /**
  99080. * Sets the current depth function to GREATER
  99081. */
  99082. setDepthFunctionToGreater(): void;
  99083. /**
  99084. * Sets the current depth function to GEQUAL
  99085. */
  99086. setDepthFunctionToGreaterOrEqual(): void;
  99087. /**
  99088. * Sets the current depth function to LESS
  99089. */
  99090. setDepthFunctionToLess(): void;
  99091. /**
  99092. * Sets the current depth function to LEQUAL
  99093. */
  99094. setDepthFunctionToLessOrEqual(): void;
  99095. private _cachedStencilBuffer;
  99096. private _cachedStencilFunction;
  99097. private _cachedStencilMask;
  99098. private _cachedStencilOperationPass;
  99099. private _cachedStencilOperationFail;
  99100. private _cachedStencilOperationDepthFail;
  99101. private _cachedStencilReference;
  99102. /**
  99103. * Caches the the state of the stencil buffer
  99104. */
  99105. cacheStencilState(): void;
  99106. /**
  99107. * Restores the state of the stencil buffer
  99108. */
  99109. restoreStencilState(): void;
  99110. /**
  99111. * Directly set the WebGL Viewport
  99112. * @param x defines the x coordinate of the viewport (in screen space)
  99113. * @param y defines the y coordinate of the viewport (in screen space)
  99114. * @param width defines the width of the viewport (in screen space)
  99115. * @param height defines the height of the viewport (in screen space)
  99116. * @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
  99117. */
  99118. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99119. /**
  99120. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99121. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99122. * @param y defines the y-coordinate of the corner of the clear rectangle
  99123. * @param width defines the width of the clear rectangle
  99124. * @param height defines the height of the clear rectangle
  99125. * @param clearColor defines the clear color
  99126. */
  99127. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99128. /**
  99129. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99130. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99131. * @param y defines the y-coordinate of the corner of the clear rectangle
  99132. * @param width defines the width of the clear rectangle
  99133. * @param height defines the height of the clear rectangle
  99134. */
  99135. enableScissor(x: number, y: number, width: number, height: number): void;
  99136. /**
  99137. * Disable previously set scissor test rectangle
  99138. */
  99139. disableScissor(): void;
  99140. protected _reportDrawCall(): void;
  99141. /**
  99142. * Initializes a webVR display and starts listening to display change events
  99143. * The onVRDisplayChangedObservable will be notified upon these changes
  99144. * @returns The onVRDisplayChangedObservable
  99145. */
  99146. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99147. /** @hidden */
  99148. _prepareVRComponent(): void;
  99149. /** @hidden */
  99150. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99151. /** @hidden */
  99152. _submitVRFrame(): void;
  99153. /**
  99154. * Call this function to leave webVR mode
  99155. * Will do nothing if webVR is not supported or if there is no webVR device
  99156. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99157. */
  99158. disableVR(): void;
  99159. /**
  99160. * Gets a boolean indicating that the system is in VR mode and is presenting
  99161. * @returns true if VR mode is engaged
  99162. */
  99163. isVRPresenting(): boolean;
  99164. /** @hidden */
  99165. _requestVRFrame(): void;
  99166. /** @hidden */
  99167. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99168. /**
  99169. * Gets the source code of the vertex shader associated with a specific webGL program
  99170. * @param program defines the program to use
  99171. * @returns a string containing the source code of the vertex shader associated with the program
  99172. */
  99173. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99174. /**
  99175. * Gets the source code of the fragment shader associated with a specific webGL program
  99176. * @param program defines the program to use
  99177. * @returns a string containing the source code of the fragment shader associated with the program
  99178. */
  99179. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99180. /**
  99181. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99182. * @param x defines the x coordinate of the rectangle where pixels must be read
  99183. * @param y defines the y coordinate of the rectangle where pixels must be read
  99184. * @param width defines the width of the rectangle where pixels must be read
  99185. * @param height defines the height of the rectangle where pixels must be read
  99186. * @returns a Uint8Array containing RGBA colors
  99187. */
  99188. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99189. /**
  99190. * Sets a depth stencil texture from a render target to the according uniform.
  99191. * @param channel The texture channel
  99192. * @param uniform The uniform to set
  99193. * @param texture The render target texture containing the depth stencil texture to apply
  99194. */
  99195. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99196. /**
  99197. * Sets a texture to the webGL context from a postprocess
  99198. * @param channel defines the channel to use
  99199. * @param postProcess defines the source postprocess
  99200. */
  99201. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99202. /**
  99203. * Binds the output of the passed in post process to the texture channel specified
  99204. * @param channel The channel the texture should be bound to
  99205. * @param postProcess The post process which's output should be bound
  99206. */
  99207. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99208. /** @hidden */
  99209. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99210. protected _rebuildBuffers(): void;
  99211. _renderLoop(): void;
  99212. /**
  99213. * Toggle full screen mode
  99214. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99215. */
  99216. switchFullscreen(requestPointerLock: boolean): void;
  99217. /**
  99218. * Enters full screen mode
  99219. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99220. */
  99221. enterFullscreen(requestPointerLock: boolean): void;
  99222. /**
  99223. * Exits full screen mode
  99224. */
  99225. exitFullscreen(): void;
  99226. /**
  99227. * Enters Pointerlock mode
  99228. */
  99229. enterPointerlock(): void;
  99230. /**
  99231. * Exits Pointerlock mode
  99232. */
  99233. exitPointerlock(): void;
  99234. /**
  99235. * Begin a new frame
  99236. */
  99237. beginFrame(): void;
  99238. /**
  99239. * Enf the current frame
  99240. */
  99241. endFrame(): void;
  99242. resize(): void;
  99243. /**
  99244. * Set the compressed texture format to use, based on the formats you have, and the formats
  99245. * supported by the hardware / browser.
  99246. *
  99247. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99248. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99249. * to API arguments needed to compressed textures. This puts the burden on the container
  99250. * generator to house the arcane code for determining these for current & future formats.
  99251. *
  99252. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99253. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99254. *
  99255. * Note: The result of this call is not taken into account when a texture is base64.
  99256. *
  99257. * @param formatsAvailable defines the list of those format families you have created
  99258. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99259. *
  99260. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99261. * @returns The extension selected.
  99262. */
  99263. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99264. /**
  99265. * Force a specific size of the canvas
  99266. * @param width defines the new canvas' width
  99267. * @param height defines the new canvas' height
  99268. */
  99269. setSize(width: number, height: number): void;
  99270. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99272. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99273. _releaseTexture(texture: InternalTexture): void;
  99274. /**
  99275. * @hidden
  99276. * Rescales a texture
  99277. * @param source input texutre
  99278. * @param destination destination texture
  99279. * @param scene scene to use to render the resize
  99280. * @param internalFormat format to use when resizing
  99281. * @param onComplete callback to be called when resize has completed
  99282. */
  99283. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99284. /**
  99285. * Gets the current framerate
  99286. * @returns a number representing the framerate
  99287. */
  99288. getFps(): number;
  99289. /**
  99290. * Gets the time spent between current and previous frame
  99291. * @returns a number representing the delta time in ms
  99292. */
  99293. getDeltaTime(): number;
  99294. private _measureFps;
  99295. /**
  99296. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99297. * @param renderTarget The render target to set the frame buffer for
  99298. */
  99299. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99300. /**
  99301. * Update a dynamic index buffer
  99302. * @param indexBuffer defines the target index buffer
  99303. * @param indices defines the data to update
  99304. * @param offset defines the offset in the target index buffer where update should start
  99305. */
  99306. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99307. /**
  99308. * Updates the sample count of a render target texture
  99309. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99310. * @param texture defines the texture to update
  99311. * @param samples defines the sample count to set
  99312. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99313. */
  99314. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99315. /** @hidden */
  99316. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99317. dispose(): void;
  99318. private _disableTouchAction;
  99319. /**
  99320. * Display the loading screen
  99321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99322. */
  99323. displayLoadingUI(): void;
  99324. /**
  99325. * Hide the loading screen
  99326. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99327. */
  99328. hideLoadingUI(): void;
  99329. /**
  99330. * Gets the current loading screen object
  99331. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99332. */
  99333. /**
  99334. * Sets the current loading screen object
  99335. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99336. */
  99337. loadingScreen: ILoadingScreen;
  99338. /**
  99339. * Sets the current loading screen text
  99340. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99341. */
  99342. loadingUIText: string;
  99343. /**
  99344. * Sets the current loading screen background color
  99345. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99346. */
  99347. loadingUIBackgroundColor: string;
  99348. /** Pointerlock and fullscreen */
  99349. /**
  99350. * Ask the browser to promote the current element to pointerlock mode
  99351. * @param element defines the DOM element to promote
  99352. */
  99353. static _RequestPointerlock(element: HTMLElement): void;
  99354. /**
  99355. * Asks the browser to exit pointerlock mode
  99356. */
  99357. static _ExitPointerlock(): void;
  99358. /**
  99359. * Ask the browser to promote the current element to fullscreen rendering mode
  99360. * @param element defines the DOM element to promote
  99361. */
  99362. static _RequestFullscreen(element: HTMLElement): void;
  99363. /**
  99364. * Asks the browser to exit fullscreen mode
  99365. */
  99366. static _ExitFullscreen(): void;
  99367. }
  99368. }
  99369. declare module BABYLON {
  99370. /**
  99371. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99372. * during the life time of the application.
  99373. */
  99374. export class EngineStore {
  99375. /** Gets the list of created engines */
  99376. static Instances: Engine[];
  99377. /** @hidden */
  99378. static _LastCreatedScene: Nullable<Scene>;
  99379. /**
  99380. * Gets the latest created engine
  99381. */
  99382. static readonly LastCreatedEngine: Nullable<Engine>;
  99383. /**
  99384. * Gets the latest created scene
  99385. */
  99386. static readonly LastCreatedScene: Nullable<Scene>;
  99387. /**
  99388. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99389. * @ignorenaming
  99390. */
  99391. static UseFallbackTexture: boolean;
  99392. /**
  99393. * Texture content used if a texture cannot loaded
  99394. * @ignorenaming
  99395. */
  99396. static FallbackTexture: string;
  99397. }
  99398. }
  99399. declare module BABYLON {
  99400. /**
  99401. * Helper class that provides a small promise polyfill
  99402. */
  99403. export class PromisePolyfill {
  99404. /**
  99405. * Static function used to check if the polyfill is required
  99406. * If this is the case then the function will inject the polyfill to window.Promise
  99407. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99408. */
  99409. static Apply(force?: boolean): void;
  99410. }
  99411. }
  99412. declare module BABYLON {
  99413. /**
  99414. * Interface for screenshot methods with describe argument called `size` as object with options
  99415. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99416. */
  99417. export interface IScreenshotSize {
  99418. /**
  99419. * number in pixels for canvas height
  99420. */
  99421. height?: number;
  99422. /**
  99423. * multiplier allowing render at a higher or lower resolution
  99424. * If value is defined then height and width will be ignored and taken from camera
  99425. */
  99426. precision?: number;
  99427. /**
  99428. * number in pixels for canvas width
  99429. */
  99430. width?: number;
  99431. }
  99432. }
  99433. declare module BABYLON {
  99434. interface IColor4Like {
  99435. r: float;
  99436. g: float;
  99437. b: float;
  99438. a: float;
  99439. }
  99440. /**
  99441. * Class containing a set of static utilities functions
  99442. */
  99443. export class Tools {
  99444. /**
  99445. * Gets or sets the base URL to use to load assets
  99446. */
  99447. static BaseUrl: string;
  99448. /**
  99449. * Enable/Disable Custom HTTP Request Headers globally.
  99450. * default = false
  99451. * @see CustomRequestHeaders
  99452. */
  99453. static UseCustomRequestHeaders: boolean;
  99454. /**
  99455. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99456. * i.e. when loading files, where the server/service expects an Authorization header
  99457. */
  99458. static CustomRequestHeaders: {
  99459. [key: string]: string;
  99460. };
  99461. /**
  99462. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99463. */
  99464. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99465. /**
  99466. * Default behaviour for cors in the application.
  99467. * It can be a string if the expected behavior is identical in the entire app.
  99468. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99469. */
  99470. static CorsBehavior: string | ((url: string | string[]) => string);
  99471. /**
  99472. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99473. * @ignorenaming
  99474. */
  99475. static UseFallbackTexture: boolean;
  99476. /**
  99477. * Use this object to register external classes like custom textures or material
  99478. * to allow the laoders to instantiate them
  99479. */
  99480. static RegisteredExternalClasses: {
  99481. [key: string]: Object;
  99482. };
  99483. /**
  99484. * Texture content used if a texture cannot loaded
  99485. * @ignorenaming
  99486. */
  99487. static fallbackTexture: string;
  99488. /**
  99489. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99490. * @param u defines the coordinate on X axis
  99491. * @param v defines the coordinate on Y axis
  99492. * @param width defines the width of the source data
  99493. * @param height defines the height of the source data
  99494. * @param pixels defines the source byte array
  99495. * @param color defines the output color
  99496. */
  99497. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99498. /**
  99499. * Interpolates between a and b via alpha
  99500. * @param a The lower value (returned when alpha = 0)
  99501. * @param b The upper value (returned when alpha = 1)
  99502. * @param alpha The interpolation-factor
  99503. * @return The mixed value
  99504. */
  99505. static Mix(a: number, b: number, alpha: number): number;
  99506. /**
  99507. * Tries to instantiate a new object from a given class name
  99508. * @param className defines the class name to instantiate
  99509. * @returns the new object or null if the system was not able to do the instantiation
  99510. */
  99511. static Instantiate(className: string): any;
  99512. /**
  99513. * Provides a slice function that will work even on IE
  99514. * @param data defines the array to slice
  99515. * @param start defines the start of the data (optional)
  99516. * @param end defines the end of the data (optional)
  99517. * @returns the new sliced array
  99518. */
  99519. static Slice<T>(data: T, start?: number, end?: number): T;
  99520. /**
  99521. * Polyfill for setImmediate
  99522. * @param action defines the action to execute after the current execution block
  99523. */
  99524. static SetImmediate(action: () => void): void;
  99525. /**
  99526. * Function indicating if a number is an exponent of 2
  99527. * @param value defines the value to test
  99528. * @returns true if the value is an exponent of 2
  99529. */
  99530. static IsExponentOfTwo(value: number): boolean;
  99531. private static _tmpFloatArray;
  99532. /**
  99533. * Returns the nearest 32-bit single precision float representation of a Number
  99534. * @param value A Number. If the parameter is of a different type, it will get converted
  99535. * to a number or to NaN if it cannot be converted
  99536. * @returns number
  99537. */
  99538. static FloatRound(value: number): number;
  99539. /**
  99540. * Extracts the filename from a path
  99541. * @param path defines the path to use
  99542. * @returns the filename
  99543. */
  99544. static GetFilename(path: string): string;
  99545. /**
  99546. * Extracts the "folder" part of a path (everything before the filename).
  99547. * @param uri The URI to extract the info from
  99548. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99549. * @returns The "folder" part of the path
  99550. */
  99551. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99552. /**
  99553. * Extracts text content from a DOM element hierarchy
  99554. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99555. */
  99556. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99557. /**
  99558. * Convert an angle in radians to degrees
  99559. * @param angle defines the angle to convert
  99560. * @returns the angle in degrees
  99561. */
  99562. static ToDegrees(angle: number): number;
  99563. /**
  99564. * Convert an angle in degrees to radians
  99565. * @param angle defines the angle to convert
  99566. * @returns the angle in radians
  99567. */
  99568. static ToRadians(angle: number): number;
  99569. /**
  99570. * Encode a buffer to a base64 string
  99571. * @param buffer defines the buffer to encode
  99572. * @returns the encoded string
  99573. */
  99574. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  99575. /**
  99576. * Returns an array if obj is not an array
  99577. * @param obj defines the object to evaluate as an array
  99578. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99579. * @returns either obj directly if obj is an array or a new array containing obj
  99580. */
  99581. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99582. /**
  99583. * Gets the pointer prefix to use
  99584. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99585. */
  99586. static GetPointerPrefix(): string;
  99587. /**
  99588. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99589. * @param url define the url we are trying
  99590. * @param element define the dom element where to configure the cors policy
  99591. */
  99592. static SetCorsBehavior(url: string | string[], element: {
  99593. crossOrigin: string | null;
  99594. }): void;
  99595. /**
  99596. * Removes unwanted characters from an url
  99597. * @param url defines the url to clean
  99598. * @returns the cleaned url
  99599. */
  99600. static CleanUrl(url: string): string;
  99601. /**
  99602. * Gets or sets a function used to pre-process url before using them to load assets
  99603. */
  99604. static PreprocessUrl: (url: string) => string;
  99605. /**
  99606. * Loads an image as an HTMLImageElement.
  99607. * @param input url string, ArrayBuffer, or Blob to load
  99608. * @param onLoad callback called when the image successfully loads
  99609. * @param onError callback called when the image fails to load
  99610. * @param offlineProvider offline provider for caching
  99611. * @param mimeType optional mime type
  99612. * @returns the HTMLImageElement of the loaded image
  99613. */
  99614. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99615. /**
  99616. * Loads a file from a url
  99617. * @param url url string, ArrayBuffer, or Blob to load
  99618. * @param onSuccess callback called when the file successfully loads
  99619. * @param onProgress callback called while file is loading (if the server supports this mode)
  99620. * @param offlineProvider defines the offline provider for caching
  99621. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99622. * @param onError callback called when the file fails to load
  99623. * @returns a file request object
  99624. */
  99625. 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;
  99626. /**
  99627. * Loads a file from a url
  99628. * @param url the file url to load
  99629. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99630. */
  99631. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99632. /**
  99633. * Load a script (identified by an url). When the url returns, the
  99634. * content of this file is added into a new script element, attached to the DOM (body element)
  99635. * @param scriptUrl defines the url of the script to laod
  99636. * @param onSuccess defines the callback called when the script is loaded
  99637. * @param onError defines the callback to call if an error occurs
  99638. * @param scriptId defines the id of the script element
  99639. */
  99640. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99641. /**
  99642. * Load an asynchronous script (identified by an url). When the url returns, the
  99643. * content of this file is added into a new script element, attached to the DOM (body element)
  99644. * @param scriptUrl defines the url of the script to laod
  99645. * @param scriptId defines the id of the script element
  99646. * @returns a promise request object
  99647. */
  99648. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99649. /**
  99650. * Loads a file from a blob
  99651. * @param fileToLoad defines the blob to use
  99652. * @param callback defines the callback to call when data is loaded
  99653. * @param progressCallback defines the callback to call during loading process
  99654. * @returns a file request object
  99655. */
  99656. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99657. /**
  99658. * Reads a file from a File object
  99659. * @param file defines the file to load
  99660. * @param onSuccess defines the callback to call when data is loaded
  99661. * @param onProgress defines the callback to call during loading process
  99662. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99663. * @param onError defines the callback to call when an error occurs
  99664. * @returns a file request object
  99665. */
  99666. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  99667. /**
  99668. * Creates a data url from a given string content
  99669. * @param content defines the content to convert
  99670. * @returns the new data url link
  99671. */
  99672. static FileAsURL(content: string): string;
  99673. /**
  99674. * Format the given number to a specific decimal format
  99675. * @param value defines the number to format
  99676. * @param decimals defines the number of decimals to use
  99677. * @returns the formatted string
  99678. */
  99679. static Format(value: number, decimals?: number): string;
  99680. /**
  99681. * Tries to copy an object by duplicating every property
  99682. * @param source defines the source object
  99683. * @param destination defines the target object
  99684. * @param doNotCopyList defines a list of properties to avoid
  99685. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99686. */
  99687. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99688. /**
  99689. * Gets a boolean indicating if the given object has no own property
  99690. * @param obj defines the object to test
  99691. * @returns true if object has no own property
  99692. */
  99693. static IsEmpty(obj: any): boolean;
  99694. /**
  99695. * Function used to register events at window level
  99696. * @param windowElement defines the Window object to use
  99697. * @param events defines the events to register
  99698. */
  99699. static RegisterTopRootEvents(windowElement: Window, events: {
  99700. name: string;
  99701. handler: Nullable<(e: FocusEvent) => any>;
  99702. }[]): void;
  99703. /**
  99704. * Function used to unregister events from window level
  99705. * @param windowElement defines the Window object to use
  99706. * @param events defines the events to unregister
  99707. */
  99708. static UnregisterTopRootEvents(windowElement: Window, events: {
  99709. name: string;
  99710. handler: Nullable<(e: FocusEvent) => any>;
  99711. }[]): void;
  99712. /**
  99713. * @ignore
  99714. */
  99715. static _ScreenshotCanvas: HTMLCanvasElement;
  99716. /**
  99717. * Dumps the current bound framebuffer
  99718. * @param width defines the rendering width
  99719. * @param height defines the rendering height
  99720. * @param engine defines the hosting engine
  99721. * @param successCallback defines the callback triggered once the data are available
  99722. * @param mimeType defines the mime type of the result
  99723. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99724. */
  99725. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99726. /**
  99727. * Converts the canvas data to blob.
  99728. * This acts as a polyfill for browsers not supporting the to blob function.
  99729. * @param canvas Defines the canvas to extract the data from
  99730. * @param successCallback Defines the callback triggered once the data are available
  99731. * @param mimeType Defines the mime type of the result
  99732. */
  99733. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99734. /**
  99735. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99736. * @param successCallback defines the callback triggered once the data are available
  99737. * @param mimeType defines the mime type of the result
  99738. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99739. */
  99740. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99741. /**
  99742. * Downloads a blob in the browser
  99743. * @param blob defines the blob to download
  99744. * @param fileName defines the name of the downloaded file
  99745. */
  99746. static Download(blob: Blob, fileName: string): void;
  99747. /**
  99748. * Captures a screenshot of the current rendering
  99749. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99750. * @param engine defines the rendering engine
  99751. * @param camera defines the source camera
  99752. * @param size This parameter can be set to a single number or to an object with the
  99753. * following (optional) properties: precision, width, height. If a single number is passed,
  99754. * it will be used for both width and height. If an object is passed, the screenshot size
  99755. * will be derived from the parameters. The precision property is a multiplier allowing
  99756. * rendering at a higher or lower resolution
  99757. * @param successCallback defines the callback receives a single parameter which contains the
  99758. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99759. * src parameter of an <img> to display it
  99760. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99761. * Check your browser for supported MIME types
  99762. */
  99763. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99764. /**
  99765. * Captures a screenshot of the current rendering
  99766. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99767. * @param engine defines the rendering engine
  99768. * @param camera defines the source camera
  99769. * @param size This parameter can be set to a single number or to an object with the
  99770. * following (optional) properties: precision, width, height. If a single number is passed,
  99771. * it will be used for both width and height. If an object is passed, the screenshot size
  99772. * will be derived from the parameters. The precision property is a multiplier allowing
  99773. * rendering at a higher or lower resolution
  99774. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99775. * Check your browser for supported MIME types
  99776. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99777. * to the src parameter of an <img> to display it
  99778. */
  99779. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99780. /**
  99781. * Generates an image screenshot from the specified camera.
  99782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99783. * @param engine The engine to use for rendering
  99784. * @param camera The camera to use for rendering
  99785. * @param size This parameter can be set to a single number or to an object with the
  99786. * following (optional) properties: precision, width, height. If a single number is passed,
  99787. * it will be used for both width and height. If an object is passed, the screenshot size
  99788. * will be derived from the parameters. The precision property is a multiplier allowing
  99789. * rendering at a higher or lower resolution
  99790. * @param successCallback The callback receives a single parameter which contains the
  99791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99792. * src parameter of an <img> to display it
  99793. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99794. * Check your browser for supported MIME types
  99795. * @param samples Texture samples (default: 1)
  99796. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99797. * @param fileName A name for for the downloaded file.
  99798. */
  99799. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99800. /**
  99801. * Generates an image screenshot from the specified camera.
  99802. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99803. * @param engine The engine to use for rendering
  99804. * @param camera The camera to use for rendering
  99805. * @param size This parameter can be set to a single number or to an object with the
  99806. * following (optional) properties: precision, width, height. If a single number is passed,
  99807. * it will be used for both width and height. If an object is passed, the screenshot size
  99808. * will be derived from the parameters. The precision property is a multiplier allowing
  99809. * rendering at a higher or lower resolution
  99810. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99811. * Check your browser for supported MIME types
  99812. * @param samples Texture samples (default: 1)
  99813. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99814. * @param fileName A name for for the downloaded file.
  99815. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99816. * to the src parameter of an <img> to display it
  99817. */
  99818. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99819. /**
  99820. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99821. * Be aware Math.random() could cause collisions, but:
  99822. * "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"
  99823. * @returns a pseudo random id
  99824. */
  99825. static RandomId(): string;
  99826. /**
  99827. * Test if the given uri is a base64 string
  99828. * @param uri The uri to test
  99829. * @return True if the uri is a base64 string or false otherwise
  99830. */
  99831. static IsBase64(uri: string): boolean;
  99832. /**
  99833. * Decode the given base64 uri.
  99834. * @param uri The uri to decode
  99835. * @return The decoded base64 data.
  99836. */
  99837. static DecodeBase64(uri: string): ArrayBuffer;
  99838. /**
  99839. * Gets the absolute url.
  99840. * @param url the input url
  99841. * @return the absolute url
  99842. */
  99843. static GetAbsoluteUrl(url: string): string;
  99844. /**
  99845. * No log
  99846. */
  99847. static readonly NoneLogLevel: number;
  99848. /**
  99849. * Only message logs
  99850. */
  99851. static readonly MessageLogLevel: number;
  99852. /**
  99853. * Only warning logs
  99854. */
  99855. static readonly WarningLogLevel: number;
  99856. /**
  99857. * Only error logs
  99858. */
  99859. static readonly ErrorLogLevel: number;
  99860. /**
  99861. * All logs
  99862. */
  99863. static readonly AllLogLevel: number;
  99864. /**
  99865. * Gets a value indicating the number of loading errors
  99866. * @ignorenaming
  99867. */
  99868. static readonly errorsCount: number;
  99869. /**
  99870. * Callback called when a new log is added
  99871. */
  99872. static OnNewCacheEntry: (entry: string) => void;
  99873. /**
  99874. * Log a message to the console
  99875. * @param message defines the message to log
  99876. */
  99877. static Log(message: string): void;
  99878. /**
  99879. * Write a warning message to the console
  99880. * @param message defines the message to log
  99881. */
  99882. static Warn(message: string): void;
  99883. /**
  99884. * Write an error message to the console
  99885. * @param message defines the message to log
  99886. */
  99887. static Error(message: string): void;
  99888. /**
  99889. * Gets current log cache (list of logs)
  99890. */
  99891. static readonly LogCache: string;
  99892. /**
  99893. * Clears the log cache
  99894. */
  99895. static ClearLogCache(): void;
  99896. /**
  99897. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99898. */
  99899. static LogLevels: number;
  99900. /**
  99901. * Checks if the window object exists
  99902. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99903. */
  99904. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99905. /**
  99906. * No performance log
  99907. */
  99908. static readonly PerformanceNoneLogLevel: number;
  99909. /**
  99910. * Use user marks to log performance
  99911. */
  99912. static readonly PerformanceUserMarkLogLevel: number;
  99913. /**
  99914. * Log performance to the console
  99915. */
  99916. static readonly PerformanceConsoleLogLevel: number;
  99917. private static _performance;
  99918. /**
  99919. * Sets the current performance log level
  99920. */
  99921. static PerformanceLogLevel: number;
  99922. private static _StartPerformanceCounterDisabled;
  99923. private static _EndPerformanceCounterDisabled;
  99924. private static _StartUserMark;
  99925. private static _EndUserMark;
  99926. private static _StartPerformanceConsole;
  99927. private static _EndPerformanceConsole;
  99928. /**
  99929. * Starts a performance counter
  99930. */
  99931. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99932. /**
  99933. * Ends a specific performance coutner
  99934. */
  99935. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99936. /**
  99937. * Gets either window.performance.now() if supported or Date.now() else
  99938. */
  99939. static readonly Now: number;
  99940. /**
  99941. * This method will return the name of the class used to create the instance of the given object.
  99942. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99943. * @param object the object to get the class name from
  99944. * @param isType defines if the object is actually a type
  99945. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99946. */
  99947. static GetClassName(object: any, isType?: boolean): string;
  99948. /**
  99949. * Gets the first element of an array satisfying a given predicate
  99950. * @param array defines the array to browse
  99951. * @param predicate defines the predicate to use
  99952. * @returns null if not found or the element
  99953. */
  99954. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99955. /**
  99956. * This method will return the name of the full name of the class, including its owning module (if any).
  99957. * 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).
  99958. * @param object the object to get the class name from
  99959. * @param isType defines if the object is actually a type
  99960. * @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.
  99961. * @ignorenaming
  99962. */
  99963. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99964. /**
  99965. * Returns a promise that resolves after the given amount of time.
  99966. * @param delay Number of milliseconds to delay
  99967. * @returns Promise that resolves after the given amount of time
  99968. */
  99969. static DelayAsync(delay: number): Promise<void>;
  99970. }
  99971. /**
  99972. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99973. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99974. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99975. * @param name The name of the class, case should be preserved
  99976. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99977. */
  99978. export function className(name: string, module?: string): (target: Object) => void;
  99979. /**
  99980. * An implementation of a loop for asynchronous functions.
  99981. */
  99982. export class AsyncLoop {
  99983. /**
  99984. * Defines the number of iterations for the loop
  99985. */
  99986. iterations: number;
  99987. /**
  99988. * Defines the current index of the loop.
  99989. */
  99990. index: number;
  99991. private _done;
  99992. private _fn;
  99993. private _successCallback;
  99994. /**
  99995. * Constructor.
  99996. * @param iterations the number of iterations.
  99997. * @param func the function to run each iteration
  99998. * @param successCallback the callback that will be called upon succesful execution
  99999. * @param offset starting offset.
  100000. */
  100001. constructor(
  100002. /**
  100003. * Defines the number of iterations for the loop
  100004. */
  100005. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100006. /**
  100007. * Execute the next iteration. Must be called after the last iteration was finished.
  100008. */
  100009. executeNext(): void;
  100010. /**
  100011. * Break the loop and run the success callback.
  100012. */
  100013. breakLoop(): void;
  100014. /**
  100015. * Create and run an async loop.
  100016. * @param iterations the number of iterations.
  100017. * @param fn the function to run each iteration
  100018. * @param successCallback the callback that will be called upon succesful execution
  100019. * @param offset starting offset.
  100020. * @returns the created async loop object
  100021. */
  100022. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100023. /**
  100024. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100025. * @param iterations total number of iterations
  100026. * @param syncedIterations number of synchronous iterations in each async iteration.
  100027. * @param fn the function to call each iteration.
  100028. * @param callback a success call back that will be called when iterating stops.
  100029. * @param breakFunction a break condition (optional)
  100030. * @param timeout timeout settings for the setTimeout function. default - 0.
  100031. * @returns the created async loop object
  100032. */
  100033. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100034. }
  100035. }
  100036. declare module BABYLON {
  100037. /**
  100038. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100039. * The underlying implementation relies on an associative array to ensure the best performances.
  100040. * The value can be anything including 'null' but except 'undefined'
  100041. */
  100042. export class StringDictionary<T> {
  100043. /**
  100044. * This will clear this dictionary and copy the content from the 'source' one.
  100045. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100046. * @param source the dictionary to take the content from and copy to this dictionary
  100047. */
  100048. copyFrom(source: StringDictionary<T>): void;
  100049. /**
  100050. * Get a value based from its key
  100051. * @param key the given key to get the matching value from
  100052. * @return the value if found, otherwise undefined is returned
  100053. */
  100054. get(key: string): T | undefined;
  100055. /**
  100056. * Get a value from its key or add it if it doesn't exist.
  100057. * This method will ensure you that a given key/data will be present in the dictionary.
  100058. * @param key the given key to get the matching value from
  100059. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100060. * The factory will only be invoked if there's no data for the given key.
  100061. * @return the value corresponding to the key.
  100062. */
  100063. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100064. /**
  100065. * Get a value from its key if present in the dictionary otherwise add it
  100066. * @param key the key to get the value from
  100067. * @param val if there's no such key/value pair in the dictionary add it with this value
  100068. * @return the value corresponding to the key
  100069. */
  100070. getOrAdd(key: string, val: T): T;
  100071. /**
  100072. * Check if there's a given key in the dictionary
  100073. * @param key the key to check for
  100074. * @return true if the key is present, false otherwise
  100075. */
  100076. contains(key: string): boolean;
  100077. /**
  100078. * Add a new key and its corresponding value
  100079. * @param key the key to add
  100080. * @param value the value corresponding to the key
  100081. * @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
  100082. */
  100083. add(key: string, value: T): boolean;
  100084. /**
  100085. * Update a specific value associated to a key
  100086. * @param key defines the key to use
  100087. * @param value defines the value to store
  100088. * @returns true if the value was updated (or false if the key was not found)
  100089. */
  100090. set(key: string, value: T): boolean;
  100091. /**
  100092. * Get the element of the given key and remove it from the dictionary
  100093. * @param key defines the key to search
  100094. * @returns the value associated with the key or null if not found
  100095. */
  100096. getAndRemove(key: string): Nullable<T>;
  100097. /**
  100098. * Remove a key/value from the dictionary.
  100099. * @param key the key to remove
  100100. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100101. */
  100102. remove(key: string): boolean;
  100103. /**
  100104. * Clear the whole content of the dictionary
  100105. */
  100106. clear(): void;
  100107. /**
  100108. * Gets the current count
  100109. */
  100110. readonly count: number;
  100111. /**
  100112. * Execute a callback on each key/val of the dictionary.
  100113. * Note that you can remove any element in this dictionary in the callback implementation
  100114. * @param callback the callback to execute on a given key/value pair
  100115. */
  100116. forEach(callback: (key: string, val: T) => void): void;
  100117. /**
  100118. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100119. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100120. * Note that you can remove any element in this dictionary in the callback implementation
  100121. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100122. * @returns the first item
  100123. */
  100124. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100125. private _count;
  100126. private _data;
  100127. }
  100128. }
  100129. declare module BABYLON {
  100130. /** @hidden */
  100131. export interface ICollisionCoordinator {
  100132. createCollider(): Collider;
  100133. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100134. init(scene: Scene): void;
  100135. }
  100136. /** @hidden */
  100137. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100138. private _scene;
  100139. private _scaledPosition;
  100140. private _scaledVelocity;
  100141. private _finalPosition;
  100142. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100143. createCollider(): Collider;
  100144. init(scene: Scene): void;
  100145. private _collideWithWorld;
  100146. }
  100147. }
  100148. declare module BABYLON {
  100149. /**
  100150. * Class used to manage all inputs for the scene.
  100151. */
  100152. export class InputManager {
  100153. /** The distance in pixel that you have to move to prevent some events */
  100154. static DragMovementThreshold: number;
  100155. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100156. static LongPressDelay: number;
  100157. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100158. static DoubleClickDelay: number;
  100159. /** If you need to check double click without raising a single click at first click, enable this flag */
  100160. static ExclusiveDoubleClickMode: boolean;
  100161. private _wheelEventName;
  100162. private _onPointerMove;
  100163. private _onPointerDown;
  100164. private _onPointerUp;
  100165. private _initClickEvent;
  100166. private _initActionManager;
  100167. private _delayedSimpleClick;
  100168. private _delayedSimpleClickTimeout;
  100169. private _previousDelayedSimpleClickTimeout;
  100170. private _meshPickProceed;
  100171. private _previousButtonPressed;
  100172. private _currentPickResult;
  100173. private _previousPickResult;
  100174. private _totalPointersPressed;
  100175. private _doubleClickOccured;
  100176. private _pointerOverMesh;
  100177. private _pickedDownMesh;
  100178. private _pickedUpMesh;
  100179. private _pointerX;
  100180. private _pointerY;
  100181. private _unTranslatedPointerX;
  100182. private _unTranslatedPointerY;
  100183. private _startingPointerPosition;
  100184. private _previousStartingPointerPosition;
  100185. private _startingPointerTime;
  100186. private _previousStartingPointerTime;
  100187. private _pointerCaptures;
  100188. private _onKeyDown;
  100189. private _onKeyUp;
  100190. private _onCanvasFocusObserver;
  100191. private _onCanvasBlurObserver;
  100192. private _scene;
  100193. /**
  100194. * Creates a new InputManager
  100195. * @param scene defines the hosting scene
  100196. */
  100197. constructor(scene: Scene);
  100198. /**
  100199. * Gets the mesh that is currently under the pointer
  100200. */
  100201. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100202. /**
  100203. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100204. */
  100205. readonly unTranslatedPointer: Vector2;
  100206. /**
  100207. * Gets or sets the current on-screen X position of the pointer
  100208. */
  100209. pointerX: number;
  100210. /**
  100211. * Gets or sets the current on-screen Y position of the pointer
  100212. */
  100213. pointerY: number;
  100214. private _updatePointerPosition;
  100215. private _processPointerMove;
  100216. private _setRayOnPointerInfo;
  100217. private _checkPrePointerObservable;
  100218. /**
  100219. * Use this method to simulate a pointer move on a mesh
  100220. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100221. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100222. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100223. */
  100224. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100225. /**
  100226. * Use this method to simulate a pointer down on a mesh
  100227. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100228. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100229. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100230. */
  100231. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100232. private _processPointerDown;
  100233. /** @hidden */
  100234. _isPointerSwiping(): boolean;
  100235. /**
  100236. * Use this method to simulate a pointer up on a mesh
  100237. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100238. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100239. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100240. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100241. */
  100242. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100243. private _processPointerUp;
  100244. /**
  100245. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100246. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100247. * @returns true if the pointer was captured
  100248. */
  100249. isPointerCaptured(pointerId?: number): boolean;
  100250. /**
  100251. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100252. * @param attachUp defines if you want to attach events to pointerup
  100253. * @param attachDown defines if you want to attach events to pointerdown
  100254. * @param attachMove defines if you want to attach events to pointermove
  100255. */
  100256. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100257. /**
  100258. * Detaches all event handlers
  100259. */
  100260. detachControl(): void;
  100261. /**
  100262. * Force the value of meshUnderPointer
  100263. * @param mesh defines the mesh to use
  100264. */
  100265. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100266. /**
  100267. * Gets the mesh under the pointer
  100268. * @returns a Mesh or null if no mesh is under the pointer
  100269. */
  100270. getPointerOverMesh(): Nullable<AbstractMesh>;
  100271. }
  100272. }
  100273. declare module BABYLON {
  100274. /**
  100275. * Helper class used to generate session unique ID
  100276. */
  100277. export class UniqueIdGenerator {
  100278. private static _UniqueIdCounter;
  100279. /**
  100280. * Gets an unique (relatively to the current scene) Id
  100281. */
  100282. static readonly UniqueId: number;
  100283. }
  100284. }
  100285. declare module BABYLON {
  100286. /**
  100287. * This class defines the direct association between an animation and a target
  100288. */
  100289. export class TargetedAnimation {
  100290. /**
  100291. * Animation to perform
  100292. */
  100293. animation: Animation;
  100294. /**
  100295. * Target to animate
  100296. */
  100297. target: any;
  100298. /**
  100299. * Serialize the object
  100300. * @returns the JSON object representing the current entity
  100301. */
  100302. serialize(): any;
  100303. }
  100304. /**
  100305. * Use this class to create coordinated animations on multiple targets
  100306. */
  100307. export class AnimationGroup implements IDisposable {
  100308. /** The name of the animation group */
  100309. name: string;
  100310. private _scene;
  100311. private _targetedAnimations;
  100312. private _animatables;
  100313. private _from;
  100314. private _to;
  100315. private _isStarted;
  100316. private _isPaused;
  100317. private _speedRatio;
  100318. private _loopAnimation;
  100319. /**
  100320. * Gets or sets the unique id of the node
  100321. */
  100322. uniqueId: number;
  100323. /**
  100324. * This observable will notify when one animation have ended
  100325. */
  100326. onAnimationEndObservable: Observable<TargetedAnimation>;
  100327. /**
  100328. * Observer raised when one animation loops
  100329. */
  100330. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100331. /**
  100332. * This observable will notify when all animations have ended.
  100333. */
  100334. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100335. /**
  100336. * This observable will notify when all animations have paused.
  100337. */
  100338. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100339. /**
  100340. * This observable will notify when all animations are playing.
  100341. */
  100342. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100343. /**
  100344. * Gets the first frame
  100345. */
  100346. readonly from: number;
  100347. /**
  100348. * Gets the last frame
  100349. */
  100350. readonly to: number;
  100351. /**
  100352. * Define if the animations are started
  100353. */
  100354. readonly isStarted: boolean;
  100355. /**
  100356. * Gets a value indicating that the current group is playing
  100357. */
  100358. readonly isPlaying: boolean;
  100359. /**
  100360. * Gets or sets the speed ratio to use for all animations
  100361. */
  100362. /**
  100363. * Gets or sets the speed ratio to use for all animations
  100364. */
  100365. speedRatio: number;
  100366. /**
  100367. * Gets or sets if all animations should loop or not
  100368. */
  100369. loopAnimation: boolean;
  100370. /**
  100371. * Gets the targeted animations for this animation group
  100372. */
  100373. readonly targetedAnimations: Array<TargetedAnimation>;
  100374. /**
  100375. * returning the list of animatables controlled by this animation group.
  100376. */
  100377. readonly animatables: Array<Animatable>;
  100378. /**
  100379. * Instantiates a new Animation Group.
  100380. * This helps managing several animations at once.
  100381. * @see http://doc.babylonjs.com/how_to/group
  100382. * @param name Defines the name of the group
  100383. * @param scene Defines the scene the group belongs to
  100384. */
  100385. constructor(
  100386. /** The name of the animation group */
  100387. name: string, scene?: Nullable<Scene>);
  100388. /**
  100389. * Add an animation (with its target) in the group
  100390. * @param animation defines the animation we want to add
  100391. * @param target defines the target of the animation
  100392. * @returns the TargetedAnimation object
  100393. */
  100394. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100395. /**
  100396. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100397. * It can add constant keys at begin or end
  100398. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100399. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100400. * @returns the animation group
  100401. */
  100402. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100403. /**
  100404. * Start all animations on given targets
  100405. * @param loop defines if animations must loop
  100406. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100407. * @param from defines the from key (optional)
  100408. * @param to defines the to key (optional)
  100409. * @returns the current animation group
  100410. */
  100411. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100412. /**
  100413. * Pause all animations
  100414. * @returns the animation group
  100415. */
  100416. pause(): AnimationGroup;
  100417. /**
  100418. * Play all animations to initial state
  100419. * This function will start() the animations if they were not started or will restart() them if they were paused
  100420. * @param loop defines if animations must loop
  100421. * @returns the animation group
  100422. */
  100423. play(loop?: boolean): AnimationGroup;
  100424. /**
  100425. * Reset all animations to initial state
  100426. * @returns the animation group
  100427. */
  100428. reset(): AnimationGroup;
  100429. /**
  100430. * Restart animations from key 0
  100431. * @returns the animation group
  100432. */
  100433. restart(): AnimationGroup;
  100434. /**
  100435. * Stop all animations
  100436. * @returns the animation group
  100437. */
  100438. stop(): AnimationGroup;
  100439. /**
  100440. * Set animation weight for all animatables
  100441. * @param weight defines the weight to use
  100442. * @return the animationGroup
  100443. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100444. */
  100445. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100446. /**
  100447. * Synchronize and normalize all animatables with a source animatable
  100448. * @param root defines the root animatable to synchronize with
  100449. * @return the animationGroup
  100450. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100451. */
  100452. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100453. /**
  100454. * Goes to a specific frame in this animation group
  100455. * @param frame the frame number to go to
  100456. * @return the animationGroup
  100457. */
  100458. goToFrame(frame: number): AnimationGroup;
  100459. /**
  100460. * Dispose all associated resources
  100461. */
  100462. dispose(): void;
  100463. private _checkAnimationGroupEnded;
  100464. /**
  100465. * Clone the current animation group and returns a copy
  100466. * @param newName defines the name of the new group
  100467. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100468. * @returns the new aniamtion group
  100469. */
  100470. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100471. /**
  100472. * Serializes the animationGroup to an object
  100473. * @returns Serialized object
  100474. */
  100475. serialize(): any;
  100476. /**
  100477. * Returns a new AnimationGroup object parsed from the source provided.
  100478. * @param parsedAnimationGroup defines the source
  100479. * @param scene defines the scene that will receive the animationGroup
  100480. * @returns a new AnimationGroup
  100481. */
  100482. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100483. /**
  100484. * Returns the string "AnimationGroup"
  100485. * @returns "AnimationGroup"
  100486. */
  100487. getClassName(): string;
  100488. /**
  100489. * Creates a detailled string about the object
  100490. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100491. * @returns a string representing the object
  100492. */
  100493. toString(fullDetails?: boolean): string;
  100494. }
  100495. }
  100496. declare module BABYLON {
  100497. /**
  100498. * Define an interface for all classes that will hold resources
  100499. */
  100500. export interface IDisposable {
  100501. /**
  100502. * Releases all held resources
  100503. */
  100504. dispose(): void;
  100505. }
  100506. /** Interface defining initialization parameters for Scene class */
  100507. export interface SceneOptions {
  100508. /**
  100509. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100510. * It will improve performance when the number of geometries becomes important.
  100511. */
  100512. useGeometryUniqueIdsMap?: boolean;
  100513. /**
  100514. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100515. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100516. */
  100517. useMaterialMeshMap?: boolean;
  100518. /**
  100519. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100520. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100521. */
  100522. useClonedMeshhMap?: boolean;
  100523. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100524. virtual?: boolean;
  100525. }
  100526. /**
  100527. * Represents a scene to be rendered by the engine.
  100528. * @see http://doc.babylonjs.com/features/scene
  100529. */
  100530. export class Scene extends AbstractScene implements IAnimatable {
  100531. /** The fog is deactivated */
  100532. static readonly FOGMODE_NONE: number;
  100533. /** The fog density is following an exponential function */
  100534. static readonly FOGMODE_EXP: number;
  100535. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100536. static readonly FOGMODE_EXP2: number;
  100537. /** The fog density is following a linear function. */
  100538. static readonly FOGMODE_LINEAR: number;
  100539. /**
  100540. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100541. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100542. */
  100543. static MinDeltaTime: number;
  100544. /**
  100545. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100546. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100547. */
  100548. static MaxDeltaTime: number;
  100549. /**
  100550. * Factory used to create the default material.
  100551. * @param name The name of the material to create
  100552. * @param scene The scene to create the material for
  100553. * @returns The default material
  100554. */
  100555. static DefaultMaterialFactory(scene: Scene): Material;
  100556. /**
  100557. * Factory used to create the a collision coordinator.
  100558. * @returns The collision coordinator
  100559. */
  100560. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100561. /** @hidden */
  100562. _inputManager: InputManager;
  100563. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100564. cameraToUseForPointers: Nullable<Camera>;
  100565. /** @hidden */
  100566. readonly _isScene: boolean;
  100567. /**
  100568. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100569. */
  100570. autoClear: boolean;
  100571. /**
  100572. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100573. */
  100574. autoClearDepthAndStencil: boolean;
  100575. /**
  100576. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100577. */
  100578. clearColor: Color4;
  100579. /**
  100580. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100581. */
  100582. ambientColor: Color3;
  100583. /**
  100584. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100585. * It should only be one of the following (if not the default embedded one):
  100586. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100587. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100588. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100589. * The material properties need to be setup according to the type of texture in use.
  100590. */
  100591. environmentBRDFTexture: BaseTexture;
  100592. /** @hidden */
  100593. protected _environmentTexture: Nullable<BaseTexture>;
  100594. /**
  100595. * Texture used in all pbr material as the reflection texture.
  100596. * As in the majority of the scene they are the same (exception for multi room and so on),
  100597. * this is easier to reference from here than from all the materials.
  100598. */
  100599. /**
  100600. * Texture used in all pbr material as the reflection texture.
  100601. * As in the majority of the scene they are the same (exception for multi room and so on),
  100602. * this is easier to set here than in all the materials.
  100603. */
  100604. environmentTexture: Nullable<BaseTexture>;
  100605. /** @hidden */
  100606. protected _environmentIntensity: number;
  100607. /**
  100608. * Intensity of the environment in all pbr material.
  100609. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100610. * As in the majority of the scene they are the same (exception for multi room and so on),
  100611. * this is easier to reference from here than from all the materials.
  100612. */
  100613. /**
  100614. * Intensity of the environment in all pbr material.
  100615. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100616. * As in the majority of the scene they are the same (exception for multi room and so on),
  100617. * this is easier to set here than in all the materials.
  100618. */
  100619. environmentIntensity: number;
  100620. /** @hidden */
  100621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100622. /**
  100623. * Default image processing configuration used either in the rendering
  100624. * Forward main pass or through the imageProcessingPostProcess if present.
  100625. * As in the majority of the scene they are the same (exception for multi camera),
  100626. * this is easier to reference from here than from all the materials and post process.
  100627. *
  100628. * No setter as we it is a shared configuration, you can set the values instead.
  100629. */
  100630. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100631. private _forceWireframe;
  100632. /**
  100633. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100634. */
  100635. forceWireframe: boolean;
  100636. private _forcePointsCloud;
  100637. /**
  100638. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100639. */
  100640. forcePointsCloud: boolean;
  100641. /**
  100642. * Gets or sets the active clipplane 1
  100643. */
  100644. clipPlane: Nullable<Plane>;
  100645. /**
  100646. * Gets or sets the active clipplane 2
  100647. */
  100648. clipPlane2: Nullable<Plane>;
  100649. /**
  100650. * Gets or sets the active clipplane 3
  100651. */
  100652. clipPlane3: Nullable<Plane>;
  100653. /**
  100654. * Gets or sets the active clipplane 4
  100655. */
  100656. clipPlane4: Nullable<Plane>;
  100657. /**
  100658. * Gets or sets a boolean indicating if animations are enabled
  100659. */
  100660. animationsEnabled: boolean;
  100661. private _animationPropertiesOverride;
  100662. /**
  100663. * Gets or sets the animation properties override
  100664. */
  100665. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100666. /**
  100667. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100668. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100669. */
  100670. useConstantAnimationDeltaTime: boolean;
  100671. /**
  100672. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100673. * Please note that it requires to run a ray cast through the scene on every frame
  100674. */
  100675. constantlyUpdateMeshUnderPointer: boolean;
  100676. /**
  100677. * Defines the HTML cursor to use when hovering over interactive elements
  100678. */
  100679. hoverCursor: string;
  100680. /**
  100681. * Defines the HTML default cursor to use (empty by default)
  100682. */
  100683. defaultCursor: string;
  100684. /**
  100685. * Defines wether cursors are handled by the scene.
  100686. */
  100687. doNotHandleCursors: boolean;
  100688. /**
  100689. * This is used to call preventDefault() on pointer down
  100690. * in order to block unwanted artifacts like system double clicks
  100691. */
  100692. preventDefaultOnPointerDown: boolean;
  100693. /**
  100694. * This is used to call preventDefault() on pointer up
  100695. * in order to block unwanted artifacts like system double clicks
  100696. */
  100697. preventDefaultOnPointerUp: boolean;
  100698. /**
  100699. * Gets or sets user defined metadata
  100700. */
  100701. metadata: any;
  100702. /**
  100703. * For internal use only. Please do not use.
  100704. */
  100705. reservedDataStore: any;
  100706. /**
  100707. * Gets the name of the plugin used to load this scene (null by default)
  100708. */
  100709. loadingPluginName: string;
  100710. /**
  100711. * Use this array to add regular expressions used to disable offline support for specific urls
  100712. */
  100713. disableOfflineSupportExceptionRules: RegExp[];
  100714. /**
  100715. * An event triggered when the scene is disposed.
  100716. */
  100717. onDisposeObservable: Observable<Scene>;
  100718. private _onDisposeObserver;
  100719. /** Sets a function to be executed when this scene is disposed. */
  100720. onDispose: () => void;
  100721. /**
  100722. * An event triggered before rendering the scene (right after animations and physics)
  100723. */
  100724. onBeforeRenderObservable: Observable<Scene>;
  100725. private _onBeforeRenderObserver;
  100726. /** Sets a function to be executed before rendering this scene */
  100727. beforeRender: Nullable<() => void>;
  100728. /**
  100729. * An event triggered after rendering the scene
  100730. */
  100731. onAfterRenderObservable: Observable<Scene>;
  100732. /**
  100733. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100734. */
  100735. onAfterRenderCameraObservable: Observable<Camera>;
  100736. private _onAfterRenderObserver;
  100737. /** Sets a function to be executed after rendering this scene */
  100738. afterRender: Nullable<() => void>;
  100739. /**
  100740. * An event triggered before animating the scene
  100741. */
  100742. onBeforeAnimationsObservable: Observable<Scene>;
  100743. /**
  100744. * An event triggered after animations processing
  100745. */
  100746. onAfterAnimationsObservable: Observable<Scene>;
  100747. /**
  100748. * An event triggered before draw calls are ready to be sent
  100749. */
  100750. onBeforeDrawPhaseObservable: Observable<Scene>;
  100751. /**
  100752. * An event triggered after draw calls have been sent
  100753. */
  100754. onAfterDrawPhaseObservable: Observable<Scene>;
  100755. /**
  100756. * An event triggered when the scene is ready
  100757. */
  100758. onReadyObservable: Observable<Scene>;
  100759. /**
  100760. * An event triggered before rendering a camera
  100761. */
  100762. onBeforeCameraRenderObservable: Observable<Camera>;
  100763. private _onBeforeCameraRenderObserver;
  100764. /** Sets a function to be executed before rendering a camera*/
  100765. beforeCameraRender: () => void;
  100766. /**
  100767. * An event triggered after rendering a camera
  100768. */
  100769. onAfterCameraRenderObservable: Observable<Camera>;
  100770. private _onAfterCameraRenderObserver;
  100771. /** Sets a function to be executed after rendering a camera*/
  100772. afterCameraRender: () => void;
  100773. /**
  100774. * An event triggered when active meshes evaluation is about to start
  100775. */
  100776. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100777. /**
  100778. * An event triggered when active meshes evaluation is done
  100779. */
  100780. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100781. /**
  100782. * An event triggered when particles rendering is about to start
  100783. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100784. */
  100785. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100786. /**
  100787. * An event triggered when particles rendering is done
  100788. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100789. */
  100790. onAfterParticlesRenderingObservable: Observable<Scene>;
  100791. /**
  100792. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100793. */
  100794. onDataLoadedObservable: Observable<Scene>;
  100795. /**
  100796. * An event triggered when a camera is created
  100797. */
  100798. onNewCameraAddedObservable: Observable<Camera>;
  100799. /**
  100800. * An event triggered when a camera is removed
  100801. */
  100802. onCameraRemovedObservable: Observable<Camera>;
  100803. /**
  100804. * An event triggered when a light is created
  100805. */
  100806. onNewLightAddedObservable: Observable<Light>;
  100807. /**
  100808. * An event triggered when a light is removed
  100809. */
  100810. onLightRemovedObservable: Observable<Light>;
  100811. /**
  100812. * An event triggered when a geometry is created
  100813. */
  100814. onNewGeometryAddedObservable: Observable<Geometry>;
  100815. /**
  100816. * An event triggered when a geometry is removed
  100817. */
  100818. onGeometryRemovedObservable: Observable<Geometry>;
  100819. /**
  100820. * An event triggered when a transform node is created
  100821. */
  100822. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100823. /**
  100824. * An event triggered when a transform node is removed
  100825. */
  100826. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100827. /**
  100828. * An event triggered when a mesh is created
  100829. */
  100830. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100831. /**
  100832. * An event triggered when a mesh is removed
  100833. */
  100834. onMeshRemovedObservable: Observable<AbstractMesh>;
  100835. /**
  100836. * An event triggered when a skeleton is created
  100837. */
  100838. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100839. /**
  100840. * An event triggered when a skeleton is removed
  100841. */
  100842. onSkeletonRemovedObservable: Observable<Skeleton>;
  100843. /**
  100844. * An event triggered when a material is created
  100845. */
  100846. onNewMaterialAddedObservable: Observable<Material>;
  100847. /**
  100848. * An event triggered when a material is removed
  100849. */
  100850. onMaterialRemovedObservable: Observable<Material>;
  100851. /**
  100852. * An event triggered when a texture is created
  100853. */
  100854. onNewTextureAddedObservable: Observable<BaseTexture>;
  100855. /**
  100856. * An event triggered when a texture is removed
  100857. */
  100858. onTextureRemovedObservable: Observable<BaseTexture>;
  100859. /**
  100860. * An event triggered when render targets are about to be rendered
  100861. * Can happen multiple times per frame.
  100862. */
  100863. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100864. /**
  100865. * An event triggered when render targets were rendered.
  100866. * Can happen multiple times per frame.
  100867. */
  100868. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100869. /**
  100870. * An event triggered before calculating deterministic simulation step
  100871. */
  100872. onBeforeStepObservable: Observable<Scene>;
  100873. /**
  100874. * An event triggered after calculating deterministic simulation step
  100875. */
  100876. onAfterStepObservable: Observable<Scene>;
  100877. /**
  100878. * An event triggered when the activeCamera property is updated
  100879. */
  100880. onActiveCameraChanged: Observable<Scene>;
  100881. /**
  100882. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100883. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100884. * 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)
  100885. */
  100886. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100887. /**
  100888. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100889. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100890. * 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)
  100891. */
  100892. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100893. /**
  100894. * This Observable will when a mesh has been imported into the scene.
  100895. */
  100896. onMeshImportedObservable: Observable<AbstractMesh>;
  100897. /**
  100898. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100899. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100900. */
  100901. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100902. /** @hidden */
  100903. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100904. /**
  100905. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100906. */
  100907. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100908. /**
  100909. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100910. */
  100911. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100912. /**
  100913. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100914. */
  100915. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100916. /** Callback called when a pointer move is detected */
  100917. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100918. /** Callback called when a pointer down is detected */
  100919. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100920. /** Callback called when a pointer up is detected */
  100921. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100922. /** Callback called when a pointer pick is detected */
  100923. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100924. /**
  100925. * 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).
  100926. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100927. */
  100928. onPrePointerObservable: Observable<PointerInfoPre>;
  100929. /**
  100930. * Observable event triggered each time an input event is received from the rendering canvas
  100931. */
  100932. onPointerObservable: Observable<PointerInfo>;
  100933. /**
  100934. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100935. */
  100936. readonly unTranslatedPointer: Vector2;
  100937. /**
  100938. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100939. */
  100940. static DragMovementThreshold: number;
  100941. /**
  100942. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100943. */
  100944. static LongPressDelay: number;
  100945. /**
  100946. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100947. */
  100948. static DoubleClickDelay: number;
  100949. /** If you need to check double click without raising a single click at first click, enable this flag */
  100950. static ExclusiveDoubleClickMode: boolean;
  100951. /** @hidden */
  100952. _mirroredCameraPosition: Nullable<Vector3>;
  100953. /**
  100954. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100955. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100956. */
  100957. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100958. /**
  100959. * Observable event triggered each time an keyboard event is received from the hosting window
  100960. */
  100961. onKeyboardObservable: Observable<KeyboardInfo>;
  100962. private _useRightHandedSystem;
  100963. /**
  100964. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100965. */
  100966. useRightHandedSystem: boolean;
  100967. private _timeAccumulator;
  100968. private _currentStepId;
  100969. private _currentInternalStep;
  100970. /**
  100971. * Sets the step Id used by deterministic lock step
  100972. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100973. * @param newStepId defines the step Id
  100974. */
  100975. setStepId(newStepId: number): void;
  100976. /**
  100977. * Gets the step Id used by deterministic lock step
  100978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100979. * @returns the step Id
  100980. */
  100981. getStepId(): number;
  100982. /**
  100983. * Gets the internal step used by deterministic lock step
  100984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100985. * @returns the internal step
  100986. */
  100987. getInternalStep(): number;
  100988. private _fogEnabled;
  100989. /**
  100990. * Gets or sets a boolean indicating if fog is enabled on this scene
  100991. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100992. * (Default is true)
  100993. */
  100994. fogEnabled: boolean;
  100995. private _fogMode;
  100996. /**
  100997. * Gets or sets the fog mode to use
  100998. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100999. * | mode | value |
  101000. * | --- | --- |
  101001. * | FOGMODE_NONE | 0 |
  101002. * | FOGMODE_EXP | 1 |
  101003. * | FOGMODE_EXP2 | 2 |
  101004. * | FOGMODE_LINEAR | 3 |
  101005. */
  101006. fogMode: number;
  101007. /**
  101008. * Gets or sets the fog color to use
  101009. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101010. * (Default is Color3(0.2, 0.2, 0.3))
  101011. */
  101012. fogColor: Color3;
  101013. /**
  101014. * Gets or sets the fog density to use
  101015. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101016. * (Default is 0.1)
  101017. */
  101018. fogDensity: number;
  101019. /**
  101020. * Gets or sets the fog start distance to use
  101021. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101022. * (Default is 0)
  101023. */
  101024. fogStart: number;
  101025. /**
  101026. * Gets or sets the fog end distance to use
  101027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101028. * (Default is 1000)
  101029. */
  101030. fogEnd: number;
  101031. private _shadowsEnabled;
  101032. /**
  101033. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101034. */
  101035. shadowsEnabled: boolean;
  101036. private _lightsEnabled;
  101037. /**
  101038. * Gets or sets a boolean indicating if lights are enabled on this scene
  101039. */
  101040. lightsEnabled: boolean;
  101041. /** All of the active cameras added to this scene. */
  101042. activeCameras: Camera[];
  101043. /** @hidden */
  101044. _activeCamera: Nullable<Camera>;
  101045. /** Gets or sets the current active camera */
  101046. activeCamera: Nullable<Camera>;
  101047. private _defaultMaterial;
  101048. /** The default material used on meshes when no material is affected */
  101049. /** The default material used on meshes when no material is affected */
  101050. defaultMaterial: Material;
  101051. private _texturesEnabled;
  101052. /**
  101053. * Gets or sets a boolean indicating if textures are enabled on this scene
  101054. */
  101055. texturesEnabled: boolean;
  101056. /**
  101057. * Gets or sets a boolean indicating if particles are enabled on this scene
  101058. */
  101059. particlesEnabled: boolean;
  101060. /**
  101061. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101062. */
  101063. spritesEnabled: boolean;
  101064. private _skeletonsEnabled;
  101065. /**
  101066. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101067. */
  101068. skeletonsEnabled: boolean;
  101069. /**
  101070. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101071. */
  101072. lensFlaresEnabled: boolean;
  101073. /**
  101074. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101076. */
  101077. collisionsEnabled: boolean;
  101078. private _collisionCoordinator;
  101079. /** @hidden */
  101080. readonly collisionCoordinator: ICollisionCoordinator;
  101081. /**
  101082. * Defines the gravity applied to this scene (used only for collisions)
  101083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101084. */
  101085. gravity: Vector3;
  101086. /**
  101087. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101088. */
  101089. postProcessesEnabled: boolean;
  101090. /**
  101091. * The list of postprocesses added to the scene
  101092. */
  101093. postProcesses: PostProcess[];
  101094. /**
  101095. * Gets the current postprocess manager
  101096. */
  101097. postProcessManager: PostProcessManager;
  101098. /**
  101099. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101100. */
  101101. renderTargetsEnabled: boolean;
  101102. /**
  101103. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101104. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101105. */
  101106. dumpNextRenderTargets: boolean;
  101107. /**
  101108. * The list of user defined render targets added to the scene
  101109. */
  101110. customRenderTargets: RenderTargetTexture[];
  101111. /**
  101112. * Defines if texture loading must be delayed
  101113. * If true, textures will only be loaded when they need to be rendered
  101114. */
  101115. useDelayedTextureLoading: boolean;
  101116. /**
  101117. * Gets the list of meshes imported to the scene through SceneLoader
  101118. */
  101119. importedMeshesFiles: String[];
  101120. /**
  101121. * Gets or sets a boolean indicating if probes are enabled on this scene
  101122. */
  101123. probesEnabled: boolean;
  101124. /**
  101125. * Gets or sets the current offline provider to use to store scene data
  101126. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101127. */
  101128. offlineProvider: IOfflineProvider;
  101129. /**
  101130. * Gets or sets the action manager associated with the scene
  101131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101132. */
  101133. actionManager: AbstractActionManager;
  101134. private _meshesForIntersections;
  101135. /**
  101136. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101137. */
  101138. proceduralTexturesEnabled: boolean;
  101139. private _engine;
  101140. private _totalVertices;
  101141. /** @hidden */
  101142. _activeIndices: PerfCounter;
  101143. /** @hidden */
  101144. _activeParticles: PerfCounter;
  101145. /** @hidden */
  101146. _activeBones: PerfCounter;
  101147. private _animationRatio;
  101148. /** @hidden */
  101149. _animationTimeLast: number;
  101150. /** @hidden */
  101151. _animationTime: number;
  101152. /**
  101153. * Gets or sets a general scale for animation speed
  101154. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101155. */
  101156. animationTimeScale: number;
  101157. /** @hidden */
  101158. _cachedMaterial: Nullable<Material>;
  101159. /** @hidden */
  101160. _cachedEffect: Nullable<Effect>;
  101161. /** @hidden */
  101162. _cachedVisibility: Nullable<number>;
  101163. private _renderId;
  101164. private _frameId;
  101165. private _executeWhenReadyTimeoutId;
  101166. private _intermediateRendering;
  101167. private _viewUpdateFlag;
  101168. private _projectionUpdateFlag;
  101169. /** @hidden */
  101170. _toBeDisposed: Nullable<IDisposable>[];
  101171. private _activeRequests;
  101172. /** @hidden */
  101173. _pendingData: any[];
  101174. private _isDisposed;
  101175. /**
  101176. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101177. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101178. */
  101179. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101180. private _activeMeshes;
  101181. private _processedMaterials;
  101182. private _renderTargets;
  101183. /** @hidden */
  101184. _activeParticleSystems: SmartArray<IParticleSystem>;
  101185. private _activeSkeletons;
  101186. private _softwareSkinnedMeshes;
  101187. private _renderingManager;
  101188. /** @hidden */
  101189. _activeAnimatables: Animatable[];
  101190. private _transformMatrix;
  101191. private _sceneUbo;
  101192. /** @hidden */
  101193. _viewMatrix: Matrix;
  101194. private _projectionMatrix;
  101195. /** @hidden */
  101196. _forcedViewPosition: Nullable<Vector3>;
  101197. /** @hidden */
  101198. _frustumPlanes: Plane[];
  101199. /**
  101200. * Gets the list of frustum planes (built from the active camera)
  101201. */
  101202. readonly frustumPlanes: Plane[];
  101203. /**
  101204. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101205. * This is useful if there are more lights that the maximum simulteanous authorized
  101206. */
  101207. requireLightSorting: boolean;
  101208. /** @hidden */
  101209. readonly useMaterialMeshMap: boolean;
  101210. /** @hidden */
  101211. readonly useClonedMeshhMap: boolean;
  101212. private _externalData;
  101213. private _uid;
  101214. /**
  101215. * @hidden
  101216. * Backing store of defined scene components.
  101217. */
  101218. _components: ISceneComponent[];
  101219. /**
  101220. * @hidden
  101221. * Backing store of defined scene components.
  101222. */
  101223. _serializableComponents: ISceneSerializableComponent[];
  101224. /**
  101225. * List of components to register on the next registration step.
  101226. */
  101227. private _transientComponents;
  101228. /**
  101229. * Registers the transient components if needed.
  101230. */
  101231. private _registerTransientComponents;
  101232. /**
  101233. * @hidden
  101234. * Add a component to the scene.
  101235. * Note that the ccomponent could be registered on th next frame if this is called after
  101236. * the register component stage.
  101237. * @param component Defines the component to add to the scene
  101238. */
  101239. _addComponent(component: ISceneComponent): void;
  101240. /**
  101241. * @hidden
  101242. * Gets a component from the scene.
  101243. * @param name defines the name of the component to retrieve
  101244. * @returns the component or null if not present
  101245. */
  101246. _getComponent(name: string): Nullable<ISceneComponent>;
  101247. /**
  101248. * @hidden
  101249. * Defines the actions happening before camera updates.
  101250. */
  101251. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101252. /**
  101253. * @hidden
  101254. * Defines the actions happening before clear the canvas.
  101255. */
  101256. _beforeClearStage: Stage<SimpleStageAction>;
  101257. /**
  101258. * @hidden
  101259. * Defines the actions when collecting render targets for the frame.
  101260. */
  101261. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101262. /**
  101263. * @hidden
  101264. * Defines the actions happening for one camera in the frame.
  101265. */
  101266. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101267. /**
  101268. * @hidden
  101269. * Defines the actions happening during the per mesh ready checks.
  101270. */
  101271. _isReadyForMeshStage: Stage<MeshStageAction>;
  101272. /**
  101273. * @hidden
  101274. * Defines the actions happening before evaluate active mesh checks.
  101275. */
  101276. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101277. /**
  101278. * @hidden
  101279. * Defines the actions happening during the evaluate sub mesh checks.
  101280. */
  101281. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101282. /**
  101283. * @hidden
  101284. * Defines the actions happening during the active mesh stage.
  101285. */
  101286. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101287. /**
  101288. * @hidden
  101289. * Defines the actions happening during the per camera render target step.
  101290. */
  101291. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101292. /**
  101293. * @hidden
  101294. * Defines the actions happening just before the active camera is drawing.
  101295. */
  101296. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101297. /**
  101298. * @hidden
  101299. * Defines the actions happening just before a render target is drawing.
  101300. */
  101301. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101302. /**
  101303. * @hidden
  101304. * Defines the actions happening just before a rendering group is drawing.
  101305. */
  101306. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101307. /**
  101308. * @hidden
  101309. * Defines the actions happening just before a mesh is drawing.
  101310. */
  101311. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101312. /**
  101313. * @hidden
  101314. * Defines the actions happening just after a mesh has been drawn.
  101315. */
  101316. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101317. /**
  101318. * @hidden
  101319. * Defines the actions happening just after a rendering group has been drawn.
  101320. */
  101321. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101322. /**
  101323. * @hidden
  101324. * Defines the actions happening just after the active camera has been drawn.
  101325. */
  101326. _afterCameraDrawStage: Stage<CameraStageAction>;
  101327. /**
  101328. * @hidden
  101329. * Defines the actions happening just after a render target has been drawn.
  101330. */
  101331. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101332. /**
  101333. * @hidden
  101334. * Defines the actions happening just after rendering all cameras and computing intersections.
  101335. */
  101336. _afterRenderStage: Stage<SimpleStageAction>;
  101337. /**
  101338. * @hidden
  101339. * Defines the actions happening when a pointer move event happens.
  101340. */
  101341. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101342. /**
  101343. * @hidden
  101344. * Defines the actions happening when a pointer down event happens.
  101345. */
  101346. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101347. /**
  101348. * @hidden
  101349. * Defines the actions happening when a pointer up event happens.
  101350. */
  101351. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101352. /**
  101353. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101354. */
  101355. private geometriesByUniqueId;
  101356. /**
  101357. * Creates a new Scene
  101358. * @param engine defines the engine to use to render this scene
  101359. * @param options defines the scene options
  101360. */
  101361. constructor(engine: Engine, options?: SceneOptions);
  101362. /**
  101363. * Gets a string idenfifying the name of the class
  101364. * @returns "Scene" string
  101365. */
  101366. getClassName(): string;
  101367. private _defaultMeshCandidates;
  101368. /**
  101369. * @hidden
  101370. */
  101371. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101372. private _defaultSubMeshCandidates;
  101373. /**
  101374. * @hidden
  101375. */
  101376. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101377. /**
  101378. * Sets the default candidate providers for the scene.
  101379. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101380. * and getCollidingSubMeshCandidates to their default function
  101381. */
  101382. setDefaultCandidateProviders(): void;
  101383. /**
  101384. * Gets the mesh that is currently under the pointer
  101385. */
  101386. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101387. /**
  101388. * Gets or sets the current on-screen X position of the pointer
  101389. */
  101390. pointerX: number;
  101391. /**
  101392. * Gets or sets the current on-screen Y position of the pointer
  101393. */
  101394. pointerY: number;
  101395. /**
  101396. * Gets the cached material (ie. the latest rendered one)
  101397. * @returns the cached material
  101398. */
  101399. getCachedMaterial(): Nullable<Material>;
  101400. /**
  101401. * Gets the cached effect (ie. the latest rendered one)
  101402. * @returns the cached effect
  101403. */
  101404. getCachedEffect(): Nullable<Effect>;
  101405. /**
  101406. * Gets the cached visibility state (ie. the latest rendered one)
  101407. * @returns the cached visibility state
  101408. */
  101409. getCachedVisibility(): Nullable<number>;
  101410. /**
  101411. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101412. * @param material defines the current material
  101413. * @param effect defines the current effect
  101414. * @param visibility defines the current visibility state
  101415. * @returns true if one parameter is not cached
  101416. */
  101417. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101418. /**
  101419. * Gets the engine associated with the scene
  101420. * @returns an Engine
  101421. */
  101422. getEngine(): Engine;
  101423. /**
  101424. * Gets the total number of vertices rendered per frame
  101425. * @returns the total number of vertices rendered per frame
  101426. */
  101427. getTotalVertices(): number;
  101428. /**
  101429. * Gets the performance counter for total vertices
  101430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101431. */
  101432. readonly totalVerticesPerfCounter: PerfCounter;
  101433. /**
  101434. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101435. * @returns the total number of active indices rendered per frame
  101436. */
  101437. getActiveIndices(): number;
  101438. /**
  101439. * Gets the performance counter for active indices
  101440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101441. */
  101442. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101443. /**
  101444. * Gets the total number of active particles rendered per frame
  101445. * @returns the total number of active particles rendered per frame
  101446. */
  101447. getActiveParticles(): number;
  101448. /**
  101449. * Gets the performance counter for active particles
  101450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101451. */
  101452. readonly activeParticlesPerfCounter: PerfCounter;
  101453. /**
  101454. * Gets the total number of active bones rendered per frame
  101455. * @returns the total number of active bones rendered per frame
  101456. */
  101457. getActiveBones(): number;
  101458. /**
  101459. * Gets the performance counter for active bones
  101460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101461. */
  101462. readonly activeBonesPerfCounter: PerfCounter;
  101463. /**
  101464. * Gets the array of active meshes
  101465. * @returns an array of AbstractMesh
  101466. */
  101467. getActiveMeshes(): SmartArray<AbstractMesh>;
  101468. /**
  101469. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101470. * @returns a number
  101471. */
  101472. getAnimationRatio(): number;
  101473. /**
  101474. * Gets an unique Id for the current render phase
  101475. * @returns a number
  101476. */
  101477. getRenderId(): number;
  101478. /**
  101479. * Gets an unique Id for the current frame
  101480. * @returns a number
  101481. */
  101482. getFrameId(): number;
  101483. /** Call this function if you want to manually increment the render Id*/
  101484. incrementRenderId(): void;
  101485. private _createUbo;
  101486. /**
  101487. * Use this method to simulate a pointer move on a mesh
  101488. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101489. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101490. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101491. * @returns the current scene
  101492. */
  101493. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101494. /**
  101495. * Use this method to simulate a pointer down on a mesh
  101496. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101497. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101498. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101499. * @returns the current scene
  101500. */
  101501. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101502. /**
  101503. * Use this method to simulate a pointer up on a mesh
  101504. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101505. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101506. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101507. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101508. * @returns the current scene
  101509. */
  101510. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101511. /**
  101512. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101513. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101514. * @returns true if the pointer was captured
  101515. */
  101516. isPointerCaptured(pointerId?: number): boolean;
  101517. /**
  101518. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101519. * @param attachUp defines if you want to attach events to pointerup
  101520. * @param attachDown defines if you want to attach events to pointerdown
  101521. * @param attachMove defines if you want to attach events to pointermove
  101522. */
  101523. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101524. /** Detaches all event handlers*/
  101525. detachControl(): void;
  101526. /**
  101527. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101528. * Delay loaded resources are not taking in account
  101529. * @return true if all required resources are ready
  101530. */
  101531. isReady(): boolean;
  101532. /** Resets all cached information relative to material (including effect and visibility) */
  101533. resetCachedMaterial(): void;
  101534. /**
  101535. * Registers a function to be called before every frame render
  101536. * @param func defines the function to register
  101537. */
  101538. registerBeforeRender(func: () => void): void;
  101539. /**
  101540. * Unregisters a function called before every frame render
  101541. * @param func defines the function to unregister
  101542. */
  101543. unregisterBeforeRender(func: () => void): void;
  101544. /**
  101545. * Registers a function to be called after every frame render
  101546. * @param func defines the function to register
  101547. */
  101548. registerAfterRender(func: () => void): void;
  101549. /**
  101550. * Unregisters a function called after every frame render
  101551. * @param func defines the function to unregister
  101552. */
  101553. unregisterAfterRender(func: () => void): void;
  101554. private _executeOnceBeforeRender;
  101555. /**
  101556. * The provided function will run before render once and will be disposed afterwards.
  101557. * A timeout delay can be provided so that the function will be executed in N ms.
  101558. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101559. * @param func The function to be executed.
  101560. * @param timeout optional delay in ms
  101561. */
  101562. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101563. /** @hidden */
  101564. _addPendingData(data: any): void;
  101565. /** @hidden */
  101566. _removePendingData(data: any): void;
  101567. /**
  101568. * Returns the number of items waiting to be loaded
  101569. * @returns the number of items waiting to be loaded
  101570. */
  101571. getWaitingItemsCount(): number;
  101572. /**
  101573. * Returns a boolean indicating if the scene is still loading data
  101574. */
  101575. readonly isLoading: boolean;
  101576. /**
  101577. * Registers a function to be executed when the scene is ready
  101578. * @param {Function} func - the function to be executed
  101579. */
  101580. executeWhenReady(func: () => void): void;
  101581. /**
  101582. * Returns a promise that resolves when the scene is ready
  101583. * @returns A promise that resolves when the scene is ready
  101584. */
  101585. whenReadyAsync(): Promise<void>;
  101586. /** @hidden */
  101587. _checkIsReady(): void;
  101588. /**
  101589. * Gets all animatable attached to the scene
  101590. */
  101591. readonly animatables: Animatable[];
  101592. /**
  101593. * Resets the last animation time frame.
  101594. * Useful to override when animations start running when loading a scene for the first time.
  101595. */
  101596. resetLastAnimationTimeFrame(): void;
  101597. /**
  101598. * Gets the current view matrix
  101599. * @returns a Matrix
  101600. */
  101601. getViewMatrix(): Matrix;
  101602. /**
  101603. * Gets the current projection matrix
  101604. * @returns a Matrix
  101605. */
  101606. getProjectionMatrix(): Matrix;
  101607. /**
  101608. * Gets the current transform matrix
  101609. * @returns a Matrix made of View * Projection
  101610. */
  101611. getTransformMatrix(): Matrix;
  101612. /**
  101613. * Sets the current transform matrix
  101614. * @param viewL defines the View matrix to use
  101615. * @param projectionL defines the Projection matrix to use
  101616. * @param viewR defines the right View matrix to use (if provided)
  101617. * @param projectionR defines the right Projection matrix to use (if provided)
  101618. */
  101619. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101620. /**
  101621. * Gets the uniform buffer used to store scene data
  101622. * @returns a UniformBuffer
  101623. */
  101624. getSceneUniformBuffer(): UniformBuffer;
  101625. /**
  101626. * Gets an unique (relatively to the current scene) Id
  101627. * @returns an unique number for the scene
  101628. */
  101629. getUniqueId(): number;
  101630. /**
  101631. * Add a mesh to the list of scene's meshes
  101632. * @param newMesh defines the mesh to add
  101633. * @param recursive if all child meshes should also be added to the scene
  101634. */
  101635. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101636. /**
  101637. * Remove a mesh for the list of scene's meshes
  101638. * @param toRemove defines the mesh to remove
  101639. * @param recursive if all child meshes should also be removed from the scene
  101640. * @returns the index where the mesh was in the mesh list
  101641. */
  101642. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101643. /**
  101644. * Add a transform node to the list of scene's transform nodes
  101645. * @param newTransformNode defines the transform node to add
  101646. */
  101647. addTransformNode(newTransformNode: TransformNode): void;
  101648. /**
  101649. * Remove a transform node for the list of scene's transform nodes
  101650. * @param toRemove defines the transform node to remove
  101651. * @returns the index where the transform node was in the transform node list
  101652. */
  101653. removeTransformNode(toRemove: TransformNode): number;
  101654. /**
  101655. * Remove a skeleton for the list of scene's skeletons
  101656. * @param toRemove defines the skeleton to remove
  101657. * @returns the index where the skeleton was in the skeleton list
  101658. */
  101659. removeSkeleton(toRemove: Skeleton): number;
  101660. /**
  101661. * Remove a morph target for the list of scene's morph targets
  101662. * @param toRemove defines the morph target to remove
  101663. * @returns the index where the morph target was in the morph target list
  101664. */
  101665. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101666. /**
  101667. * Remove a light for the list of scene's lights
  101668. * @param toRemove defines the light to remove
  101669. * @returns the index where the light was in the light list
  101670. */
  101671. removeLight(toRemove: Light): number;
  101672. /**
  101673. * Remove a camera for the list of scene's cameras
  101674. * @param toRemove defines the camera to remove
  101675. * @returns the index where the camera was in the camera list
  101676. */
  101677. removeCamera(toRemove: Camera): number;
  101678. /**
  101679. * Remove a particle system for the list of scene's particle systems
  101680. * @param toRemove defines the particle system to remove
  101681. * @returns the index where the particle system was in the particle system list
  101682. */
  101683. removeParticleSystem(toRemove: IParticleSystem): number;
  101684. /**
  101685. * Remove a animation for the list of scene's animations
  101686. * @param toRemove defines the animation to remove
  101687. * @returns the index where the animation was in the animation list
  101688. */
  101689. removeAnimation(toRemove: Animation): number;
  101690. /**
  101691. * Will stop the animation of the given target
  101692. * @param target - the target
  101693. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101694. * @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)
  101695. */
  101696. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101697. /**
  101698. * Removes the given animation group from this scene.
  101699. * @param toRemove The animation group to remove
  101700. * @returns The index of the removed animation group
  101701. */
  101702. removeAnimationGroup(toRemove: AnimationGroup): number;
  101703. /**
  101704. * Removes the given multi-material from this scene.
  101705. * @param toRemove The multi-material to remove
  101706. * @returns The index of the removed multi-material
  101707. */
  101708. removeMultiMaterial(toRemove: MultiMaterial): number;
  101709. /**
  101710. * Removes the given material from this scene.
  101711. * @param toRemove The material to remove
  101712. * @returns The index of the removed material
  101713. */
  101714. removeMaterial(toRemove: Material): number;
  101715. /**
  101716. * Removes the given action manager from this scene.
  101717. * @param toRemove The action manager to remove
  101718. * @returns The index of the removed action manager
  101719. */
  101720. removeActionManager(toRemove: AbstractActionManager): number;
  101721. /**
  101722. * Removes the given texture from this scene.
  101723. * @param toRemove The texture to remove
  101724. * @returns The index of the removed texture
  101725. */
  101726. removeTexture(toRemove: BaseTexture): number;
  101727. /**
  101728. * Adds the given light to this scene
  101729. * @param newLight The light to add
  101730. */
  101731. addLight(newLight: Light): void;
  101732. /**
  101733. * Sorts the list list based on light priorities
  101734. */
  101735. sortLightsByPriority(): void;
  101736. /**
  101737. * Adds the given camera to this scene
  101738. * @param newCamera The camera to add
  101739. */
  101740. addCamera(newCamera: Camera): void;
  101741. /**
  101742. * Adds the given skeleton to this scene
  101743. * @param newSkeleton The skeleton to add
  101744. */
  101745. addSkeleton(newSkeleton: Skeleton): void;
  101746. /**
  101747. * Adds the given particle system to this scene
  101748. * @param newParticleSystem The particle system to add
  101749. */
  101750. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101751. /**
  101752. * Adds the given animation to this scene
  101753. * @param newAnimation The animation to add
  101754. */
  101755. addAnimation(newAnimation: Animation): void;
  101756. /**
  101757. * Adds the given animation group to this scene.
  101758. * @param newAnimationGroup The animation group to add
  101759. */
  101760. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101761. /**
  101762. * Adds the given multi-material to this scene
  101763. * @param newMultiMaterial The multi-material to add
  101764. */
  101765. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101766. /**
  101767. * Adds the given material to this scene
  101768. * @param newMaterial The material to add
  101769. */
  101770. addMaterial(newMaterial: Material): void;
  101771. /**
  101772. * Adds the given morph target to this scene
  101773. * @param newMorphTargetManager The morph target to add
  101774. */
  101775. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101776. /**
  101777. * Adds the given geometry to this scene
  101778. * @param newGeometry The geometry to add
  101779. */
  101780. addGeometry(newGeometry: Geometry): void;
  101781. /**
  101782. * Adds the given action manager to this scene
  101783. * @param newActionManager The action manager to add
  101784. */
  101785. addActionManager(newActionManager: AbstractActionManager): void;
  101786. /**
  101787. * Adds the given texture to this scene.
  101788. * @param newTexture The texture to add
  101789. */
  101790. addTexture(newTexture: BaseTexture): void;
  101791. /**
  101792. * Switch active camera
  101793. * @param newCamera defines the new active camera
  101794. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101795. */
  101796. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101797. /**
  101798. * sets the active camera of the scene using its ID
  101799. * @param id defines the camera's ID
  101800. * @return the new active camera or null if none found.
  101801. */
  101802. setActiveCameraByID(id: string): Nullable<Camera>;
  101803. /**
  101804. * sets the active camera of the scene using its name
  101805. * @param name defines the camera's name
  101806. * @returns the new active camera or null if none found.
  101807. */
  101808. setActiveCameraByName(name: string): Nullable<Camera>;
  101809. /**
  101810. * get an animation group using its name
  101811. * @param name defines the material's name
  101812. * @return the animation group or null if none found.
  101813. */
  101814. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101815. /**
  101816. * Get a material using its unique id
  101817. * @param uniqueId defines the material's unique id
  101818. * @return the material or null if none found.
  101819. */
  101820. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101821. /**
  101822. * get a material using its id
  101823. * @param id defines the material's ID
  101824. * @return the material or null if none found.
  101825. */
  101826. getMaterialByID(id: string): Nullable<Material>;
  101827. /**
  101828. * Gets a the last added material using a given id
  101829. * @param id defines the material's ID
  101830. * @return the last material with the given id or null if none found.
  101831. */
  101832. getLastMaterialByID(id: string): Nullable<Material>;
  101833. /**
  101834. * Gets a material using its name
  101835. * @param name defines the material's name
  101836. * @return the material or null if none found.
  101837. */
  101838. getMaterialByName(name: string): Nullable<Material>;
  101839. /**
  101840. * Get a texture using its unique id
  101841. * @param uniqueId defines the texture's unique id
  101842. * @return the texture or null if none found.
  101843. */
  101844. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101845. /**
  101846. * Gets a camera using its id
  101847. * @param id defines the id to look for
  101848. * @returns the camera or null if not found
  101849. */
  101850. getCameraByID(id: string): Nullable<Camera>;
  101851. /**
  101852. * Gets a camera using its unique id
  101853. * @param uniqueId defines the unique id to look for
  101854. * @returns the camera or null if not found
  101855. */
  101856. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101857. /**
  101858. * Gets a camera using its name
  101859. * @param name defines the camera's name
  101860. * @return the camera or null if none found.
  101861. */
  101862. getCameraByName(name: string): Nullable<Camera>;
  101863. /**
  101864. * Gets a bone using its id
  101865. * @param id defines the bone's id
  101866. * @return the bone or null if not found
  101867. */
  101868. getBoneByID(id: string): Nullable<Bone>;
  101869. /**
  101870. * Gets a bone using its id
  101871. * @param name defines the bone's name
  101872. * @return the bone or null if not found
  101873. */
  101874. getBoneByName(name: string): Nullable<Bone>;
  101875. /**
  101876. * Gets a light node using its name
  101877. * @param name defines the the light's name
  101878. * @return the light or null if none found.
  101879. */
  101880. getLightByName(name: string): Nullable<Light>;
  101881. /**
  101882. * Gets a light node using its id
  101883. * @param id defines the light's id
  101884. * @return the light or null if none found.
  101885. */
  101886. getLightByID(id: string): Nullable<Light>;
  101887. /**
  101888. * Gets a light node using its scene-generated unique ID
  101889. * @param uniqueId defines the light's unique id
  101890. * @return the light or null if none found.
  101891. */
  101892. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101893. /**
  101894. * Gets a particle system by id
  101895. * @param id defines the particle system id
  101896. * @return the corresponding system or null if none found
  101897. */
  101898. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101899. /**
  101900. * Gets a geometry using its ID
  101901. * @param id defines the geometry's id
  101902. * @return the geometry or null if none found.
  101903. */
  101904. getGeometryByID(id: string): Nullable<Geometry>;
  101905. private _getGeometryByUniqueID;
  101906. /**
  101907. * Add a new geometry to this scene
  101908. * @param geometry defines the geometry to be added to the scene.
  101909. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101910. * @return a boolean defining if the geometry was added or not
  101911. */
  101912. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101913. /**
  101914. * Removes an existing geometry
  101915. * @param geometry defines the geometry to be removed from the scene
  101916. * @return a boolean defining if the geometry was removed or not
  101917. */
  101918. removeGeometry(geometry: Geometry): boolean;
  101919. /**
  101920. * Gets the list of geometries attached to the scene
  101921. * @returns an array of Geometry
  101922. */
  101923. getGeometries(): Geometry[];
  101924. /**
  101925. * Gets the first added mesh found of a given ID
  101926. * @param id defines the id to search for
  101927. * @return the mesh found or null if not found at all
  101928. */
  101929. getMeshByID(id: string): Nullable<AbstractMesh>;
  101930. /**
  101931. * Gets a list of meshes using their id
  101932. * @param id defines the id to search for
  101933. * @returns a list of meshes
  101934. */
  101935. getMeshesByID(id: string): Array<AbstractMesh>;
  101936. /**
  101937. * Gets the first added transform node found of a given ID
  101938. * @param id defines the id to search for
  101939. * @return the found transform node or null if not found at all.
  101940. */
  101941. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101942. /**
  101943. * Gets a transform node with its auto-generated unique id
  101944. * @param uniqueId efines the unique id to search for
  101945. * @return the found transform node or null if not found at all.
  101946. */
  101947. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101948. /**
  101949. * Gets a list of transform nodes using their id
  101950. * @param id defines the id to search for
  101951. * @returns a list of transform nodes
  101952. */
  101953. getTransformNodesByID(id: string): Array<TransformNode>;
  101954. /**
  101955. * Gets a mesh with its auto-generated unique id
  101956. * @param uniqueId defines the unique id to search for
  101957. * @return the found mesh or null if not found at all.
  101958. */
  101959. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101960. /**
  101961. * Gets a the last added mesh using a given id
  101962. * @param id defines the id to search for
  101963. * @return the found mesh or null if not found at all.
  101964. */
  101965. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101966. /**
  101967. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101968. * @param id defines the id to search for
  101969. * @return the found node or null if not found at all
  101970. */
  101971. getLastEntryByID(id: string): Nullable<Node>;
  101972. /**
  101973. * Gets a node (Mesh, Camera, Light) using a given id
  101974. * @param id defines the id to search for
  101975. * @return the found node or null if not found at all
  101976. */
  101977. getNodeByID(id: string): Nullable<Node>;
  101978. /**
  101979. * Gets a node (Mesh, Camera, Light) using a given name
  101980. * @param name defines the name to search for
  101981. * @return the found node or null if not found at all.
  101982. */
  101983. getNodeByName(name: string): Nullable<Node>;
  101984. /**
  101985. * Gets a mesh using a given name
  101986. * @param name defines the name to search for
  101987. * @return the found mesh or null if not found at all.
  101988. */
  101989. getMeshByName(name: string): Nullable<AbstractMesh>;
  101990. /**
  101991. * Gets a transform node using a given name
  101992. * @param name defines the name to search for
  101993. * @return the found transform node or null if not found at all.
  101994. */
  101995. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101996. /**
  101997. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101998. * @param id defines the id to search for
  101999. * @return the found skeleton or null if not found at all.
  102000. */
  102001. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102002. /**
  102003. * Gets a skeleton using a given auto generated unique id
  102004. * @param uniqueId defines the unique id to search for
  102005. * @return the found skeleton or null if not found at all.
  102006. */
  102007. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102008. /**
  102009. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102010. * @param id defines the id to search for
  102011. * @return the found skeleton or null if not found at all.
  102012. */
  102013. getSkeletonById(id: string): Nullable<Skeleton>;
  102014. /**
  102015. * Gets a skeleton using a given name
  102016. * @param name defines the name to search for
  102017. * @return the found skeleton or null if not found at all.
  102018. */
  102019. getSkeletonByName(name: string): Nullable<Skeleton>;
  102020. /**
  102021. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102022. * @param id defines the id to search for
  102023. * @return the found morph target manager or null if not found at all.
  102024. */
  102025. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102026. /**
  102027. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102028. * @param id defines the id to search for
  102029. * @return the found morph target or null if not found at all.
  102030. */
  102031. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102032. /**
  102033. * Gets a boolean indicating if the given mesh is active
  102034. * @param mesh defines the mesh to look for
  102035. * @returns true if the mesh is in the active list
  102036. */
  102037. isActiveMesh(mesh: AbstractMesh): boolean;
  102038. /**
  102039. * Return a unique id as a string which can serve as an identifier for the scene
  102040. */
  102041. readonly uid: string;
  102042. /**
  102043. * Add an externaly attached data from its key.
  102044. * This method call will fail and return false, if such key already exists.
  102045. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102046. * @param key the unique key that identifies the data
  102047. * @param data the data object to associate to the key for this Engine instance
  102048. * @return true if no such key were already present and the data was added successfully, false otherwise
  102049. */
  102050. addExternalData<T>(key: string, data: T): boolean;
  102051. /**
  102052. * Get an externaly attached data from its key
  102053. * @param key the unique key that identifies the data
  102054. * @return the associated data, if present (can be null), or undefined if not present
  102055. */
  102056. getExternalData<T>(key: string): Nullable<T>;
  102057. /**
  102058. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102059. * @param key the unique key that identifies the data
  102060. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102061. * @return the associated data, can be null if the factory returned null.
  102062. */
  102063. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102064. /**
  102065. * Remove an externaly attached data from the Engine instance
  102066. * @param key the unique key that identifies the data
  102067. * @return true if the data was successfully removed, false if it doesn't exist
  102068. */
  102069. removeExternalData(key: string): boolean;
  102070. private _evaluateSubMesh;
  102071. /**
  102072. * Clear the processed materials smart array preventing retention point in material dispose.
  102073. */
  102074. freeProcessedMaterials(): void;
  102075. private _preventFreeActiveMeshesAndRenderingGroups;
  102076. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102077. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102078. * when disposing several meshes in a row or a hierarchy of meshes.
  102079. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102080. */
  102081. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102082. /**
  102083. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102084. */
  102085. freeActiveMeshes(): void;
  102086. /**
  102087. * Clear the info related to rendering groups preventing retention points during dispose.
  102088. */
  102089. freeRenderingGroups(): void;
  102090. /** @hidden */
  102091. _isInIntermediateRendering(): boolean;
  102092. /**
  102093. * Lambda returning the list of potentially active meshes.
  102094. */
  102095. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102096. /**
  102097. * Lambda returning the list of potentially active sub meshes.
  102098. */
  102099. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102100. /**
  102101. * Lambda returning the list of potentially intersecting sub meshes.
  102102. */
  102103. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102104. /**
  102105. * Lambda returning the list of potentially colliding sub meshes.
  102106. */
  102107. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102108. private _activeMeshesFrozen;
  102109. /**
  102110. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102111. * @returns the current scene
  102112. */
  102113. freezeActiveMeshes(): Scene;
  102114. /**
  102115. * Use this function to restart evaluating active meshes on every frame
  102116. * @returns the current scene
  102117. */
  102118. unfreezeActiveMeshes(): Scene;
  102119. private _evaluateActiveMeshes;
  102120. private _activeMesh;
  102121. /**
  102122. * Update the transform matrix to update from the current active camera
  102123. * @param force defines a boolean used to force the update even if cache is up to date
  102124. */
  102125. updateTransformMatrix(force?: boolean): void;
  102126. private _bindFrameBuffer;
  102127. /** @hidden */
  102128. _allowPostProcessClearColor: boolean;
  102129. /** @hidden */
  102130. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102131. private _processSubCameras;
  102132. private _checkIntersections;
  102133. /** @hidden */
  102134. _advancePhysicsEngineStep(step: number): void;
  102135. /**
  102136. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102137. */
  102138. getDeterministicFrameTime: () => number;
  102139. /** @hidden */
  102140. _animate(): void;
  102141. /** Execute all animations (for a frame) */
  102142. animate(): void;
  102143. /**
  102144. * Render the scene
  102145. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102146. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102147. */
  102148. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102149. /**
  102150. * Freeze all materials
  102151. * A frozen material will not be updatable but should be faster to render
  102152. */
  102153. freezeMaterials(): void;
  102154. /**
  102155. * Unfreeze all materials
  102156. * A frozen material will not be updatable but should be faster to render
  102157. */
  102158. unfreezeMaterials(): void;
  102159. /**
  102160. * Releases all held ressources
  102161. */
  102162. dispose(): void;
  102163. /**
  102164. * Gets if the scene is already disposed
  102165. */
  102166. readonly isDisposed: boolean;
  102167. /**
  102168. * Call this function to reduce memory footprint of the scene.
  102169. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102170. */
  102171. clearCachedVertexData(): void;
  102172. /**
  102173. * This function will remove the local cached buffer data from texture.
  102174. * It will save memory but will prevent the texture from being rebuilt
  102175. */
  102176. cleanCachedTextureBuffer(): void;
  102177. /**
  102178. * Get the world extend vectors with an optional filter
  102179. *
  102180. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102181. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102182. */
  102183. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102184. min: Vector3;
  102185. max: Vector3;
  102186. };
  102187. /**
  102188. * Creates a ray that can be used to pick in the scene
  102189. * @param x defines the x coordinate of the origin (on-screen)
  102190. * @param y defines the y coordinate of the origin (on-screen)
  102191. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102192. * @param camera defines the camera to use for the picking
  102193. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102194. * @returns a Ray
  102195. */
  102196. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102197. /**
  102198. * Creates a ray that can be used to pick in the scene
  102199. * @param x defines the x coordinate of the origin (on-screen)
  102200. * @param y defines the y coordinate of the origin (on-screen)
  102201. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102202. * @param result defines the ray where to store the picking ray
  102203. * @param camera defines the camera to use for the picking
  102204. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102205. * @returns the current scene
  102206. */
  102207. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102208. /**
  102209. * Creates a ray that can be used to pick in the scene
  102210. * @param x defines the x coordinate of the origin (on-screen)
  102211. * @param y defines the y coordinate of the origin (on-screen)
  102212. * @param camera defines the camera to use for the picking
  102213. * @returns a Ray
  102214. */
  102215. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102216. /**
  102217. * Creates a ray that can be used to pick in the scene
  102218. * @param x defines the x coordinate of the origin (on-screen)
  102219. * @param y defines the y coordinate of the origin (on-screen)
  102220. * @param result defines the ray where to store the picking ray
  102221. * @param camera defines the camera to use for the picking
  102222. * @returns the current scene
  102223. */
  102224. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102225. /** Launch a ray to try to pick a mesh in the scene
  102226. * @param x position on screen
  102227. * @param y position on screen
  102228. * @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
  102229. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102230. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102232. * @returns a PickingInfo
  102233. */
  102234. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102235. /** Use the given ray to pick a mesh in the scene
  102236. * @param ray The ray to use to pick meshes
  102237. * @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
  102238. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102240. * @returns a PickingInfo
  102241. */
  102242. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102243. /**
  102244. * Launch a ray to try to pick a mesh in the scene
  102245. * @param x X position on screen
  102246. * @param y Y position on screen
  102247. * @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
  102248. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102249. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102250. * @returns an array of PickingInfo
  102251. */
  102252. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102253. /**
  102254. * Launch a ray to try to pick a mesh in the scene
  102255. * @param ray Ray to use
  102256. * @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
  102257. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102258. * @returns an array of PickingInfo
  102259. */
  102260. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102261. /**
  102262. * Force the value of meshUnderPointer
  102263. * @param mesh defines the mesh to use
  102264. */
  102265. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102266. /**
  102267. * Gets the mesh under the pointer
  102268. * @returns a Mesh or null if no mesh is under the pointer
  102269. */
  102270. getPointerOverMesh(): Nullable<AbstractMesh>;
  102271. /** @hidden */
  102272. _rebuildGeometries(): void;
  102273. /** @hidden */
  102274. _rebuildTextures(): void;
  102275. private _getByTags;
  102276. /**
  102277. * Get a list of meshes by tags
  102278. * @param tagsQuery defines the tags query to use
  102279. * @param forEach defines a predicate used to filter results
  102280. * @returns an array of Mesh
  102281. */
  102282. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102283. /**
  102284. * Get a list of cameras by tags
  102285. * @param tagsQuery defines the tags query to use
  102286. * @param forEach defines a predicate used to filter results
  102287. * @returns an array of Camera
  102288. */
  102289. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102290. /**
  102291. * Get a list of lights by tags
  102292. * @param tagsQuery defines the tags query to use
  102293. * @param forEach defines a predicate used to filter results
  102294. * @returns an array of Light
  102295. */
  102296. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102297. /**
  102298. * Get a list of materials by tags
  102299. * @param tagsQuery defines the tags query to use
  102300. * @param forEach defines a predicate used to filter results
  102301. * @returns an array of Material
  102302. */
  102303. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102304. /**
  102305. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102306. * This allowed control for front to back rendering or reversly depending of the special needs.
  102307. *
  102308. * @param renderingGroupId The rendering group id corresponding to its index
  102309. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102310. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102311. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102312. */
  102313. 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;
  102314. /**
  102315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102316. *
  102317. * @param renderingGroupId The rendering group id corresponding to its index
  102318. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102319. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102320. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102321. */
  102322. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102323. /**
  102324. * Gets the current auto clear configuration for one rendering group of the rendering
  102325. * manager.
  102326. * @param index the rendering group index to get the information for
  102327. * @returns The auto clear setup for the requested rendering group
  102328. */
  102329. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102330. private _blockMaterialDirtyMechanism;
  102331. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102332. blockMaterialDirtyMechanism: boolean;
  102333. /**
  102334. * Will flag all materials as dirty to trigger new shader compilation
  102335. * @param flag defines the flag used to specify which material part must be marked as dirty
  102336. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102337. */
  102338. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102339. /** @hidden */
  102340. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  102341. /** @hidden */
  102342. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102343. /** @hidden */
  102344. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  102345. /** @hidden */
  102346. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102347. /** @hidden */
  102348. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102349. /** @hidden */
  102350. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102351. }
  102352. }
  102353. declare module BABYLON {
  102354. /**
  102355. * Set of assets to keep when moving a scene into an asset container.
  102356. */
  102357. export class KeepAssets extends AbstractScene {
  102358. }
  102359. /**
  102360. * Container with a set of assets that can be added or removed from a scene.
  102361. */
  102362. export class AssetContainer extends AbstractScene {
  102363. /**
  102364. * The scene the AssetContainer belongs to.
  102365. */
  102366. scene: Scene;
  102367. /**
  102368. * Instantiates an AssetContainer.
  102369. * @param scene The scene the AssetContainer belongs to.
  102370. */
  102371. constructor(scene: Scene);
  102372. /**
  102373. * Adds all the assets from the container to the scene.
  102374. */
  102375. addAllToScene(): void;
  102376. /**
  102377. * Removes all the assets in the container from the scene
  102378. */
  102379. removeAllFromScene(): void;
  102380. /**
  102381. * Disposes all the assets in the container
  102382. */
  102383. dispose(): void;
  102384. private _moveAssets;
  102385. /**
  102386. * Removes all the assets contained in the scene and adds them to the container.
  102387. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102388. */
  102389. moveAllFromScene(keepAssets?: KeepAssets): void;
  102390. /**
  102391. * 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.
  102392. * @returns the root mesh
  102393. */
  102394. createRootMesh(): Mesh;
  102395. }
  102396. }
  102397. declare module BABYLON {
  102398. /**
  102399. * Defines how the parser contract is defined.
  102400. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102401. */
  102402. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102403. /**
  102404. * Defines how the individual parser contract is defined.
  102405. * These parser can parse an individual asset
  102406. */
  102407. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102408. /**
  102409. * Base class of the scene acting as a container for the different elements composing a scene.
  102410. * This class is dynamically extended by the different components of the scene increasing
  102411. * flexibility and reducing coupling
  102412. */
  102413. export abstract class AbstractScene {
  102414. /**
  102415. * Stores the list of available parsers in the application.
  102416. */
  102417. private static _BabylonFileParsers;
  102418. /**
  102419. * Stores the list of available individual parsers in the application.
  102420. */
  102421. private static _IndividualBabylonFileParsers;
  102422. /**
  102423. * Adds a parser in the list of available ones
  102424. * @param name Defines the name of the parser
  102425. * @param parser Defines the parser to add
  102426. */
  102427. static AddParser(name: string, parser: BabylonFileParser): void;
  102428. /**
  102429. * Gets a general parser from the list of avaialble ones
  102430. * @param name Defines the name of the parser
  102431. * @returns the requested parser or null
  102432. */
  102433. static GetParser(name: string): Nullable<BabylonFileParser>;
  102434. /**
  102435. * Adds n individual parser in the list of available ones
  102436. * @param name Defines the name of the parser
  102437. * @param parser Defines the parser to add
  102438. */
  102439. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102440. /**
  102441. * Gets an individual parser from the list of avaialble ones
  102442. * @param name Defines the name of the parser
  102443. * @returns the requested parser or null
  102444. */
  102445. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102446. /**
  102447. * Parser json data and populate both a scene and its associated container object
  102448. * @param jsonData Defines the data to parse
  102449. * @param scene Defines the scene to parse the data for
  102450. * @param container Defines the container attached to the parsing sequence
  102451. * @param rootUrl Defines the root url of the data
  102452. */
  102453. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102454. /**
  102455. * Gets the list of root nodes (ie. nodes with no parent)
  102456. */
  102457. rootNodes: Node[];
  102458. /** All of the cameras added to this scene
  102459. * @see http://doc.babylonjs.com/babylon101/cameras
  102460. */
  102461. cameras: Camera[];
  102462. /**
  102463. * All of the lights added to this scene
  102464. * @see http://doc.babylonjs.com/babylon101/lights
  102465. */
  102466. lights: Light[];
  102467. /**
  102468. * All of the (abstract) meshes added to this scene
  102469. */
  102470. meshes: AbstractMesh[];
  102471. /**
  102472. * The list of skeletons added to the scene
  102473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102474. */
  102475. skeletons: Skeleton[];
  102476. /**
  102477. * All of the particle systems added to this scene
  102478. * @see http://doc.babylonjs.com/babylon101/particles
  102479. */
  102480. particleSystems: IParticleSystem[];
  102481. /**
  102482. * Gets a list of Animations associated with the scene
  102483. */
  102484. animations: Animation[];
  102485. /**
  102486. * All of the animation groups added to this scene
  102487. * @see http://doc.babylonjs.com/how_to/group
  102488. */
  102489. animationGroups: AnimationGroup[];
  102490. /**
  102491. * All of the multi-materials added to this scene
  102492. * @see http://doc.babylonjs.com/how_to/multi_materials
  102493. */
  102494. multiMaterials: MultiMaterial[];
  102495. /**
  102496. * All of the materials added to this scene
  102497. * In the context of a Scene, it is not supposed to be modified manually.
  102498. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102499. * Note also that the order of the Material wihin the array is not significant and might change.
  102500. * @see http://doc.babylonjs.com/babylon101/materials
  102501. */
  102502. materials: Material[];
  102503. /**
  102504. * The list of morph target managers added to the scene
  102505. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102506. */
  102507. morphTargetManagers: MorphTargetManager[];
  102508. /**
  102509. * The list of geometries used in the scene.
  102510. */
  102511. geometries: Geometry[];
  102512. /**
  102513. * All of the tranform nodes added to this scene
  102514. * In the context of a Scene, it is not supposed to be modified manually.
  102515. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102516. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102517. * @see http://doc.babylonjs.com/how_to/transformnode
  102518. */
  102519. transformNodes: TransformNode[];
  102520. /**
  102521. * ActionManagers available on the scene.
  102522. */
  102523. actionManagers: AbstractActionManager[];
  102524. /**
  102525. * Textures to keep.
  102526. */
  102527. textures: BaseTexture[];
  102528. /**
  102529. * Environment texture for the scene
  102530. */
  102531. environmentTexture: Nullable<BaseTexture>;
  102532. }
  102533. }
  102534. declare module BABYLON {
  102535. /**
  102536. * Interface used to define options for Sound class
  102537. */
  102538. export interface ISoundOptions {
  102539. /**
  102540. * Does the sound autoplay once loaded.
  102541. */
  102542. autoplay?: boolean;
  102543. /**
  102544. * Does the sound loop after it finishes playing once.
  102545. */
  102546. loop?: boolean;
  102547. /**
  102548. * Sound's volume
  102549. */
  102550. volume?: number;
  102551. /**
  102552. * Is it a spatial sound?
  102553. */
  102554. spatialSound?: boolean;
  102555. /**
  102556. * Maximum distance to hear that sound
  102557. */
  102558. maxDistance?: number;
  102559. /**
  102560. * Uses user defined attenuation function
  102561. */
  102562. useCustomAttenuation?: boolean;
  102563. /**
  102564. * Define the roll off factor of spatial sounds.
  102565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102566. */
  102567. rolloffFactor?: number;
  102568. /**
  102569. * Define the reference distance the sound should be heard perfectly.
  102570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102571. */
  102572. refDistance?: number;
  102573. /**
  102574. * Define the distance attenuation model the sound will follow.
  102575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102576. */
  102577. distanceModel?: string;
  102578. /**
  102579. * Defines the playback speed (1 by default)
  102580. */
  102581. playbackRate?: number;
  102582. /**
  102583. * Defines if the sound is from a streaming source
  102584. */
  102585. streaming?: boolean;
  102586. /**
  102587. * Defines an optional length (in seconds) inside the sound file
  102588. */
  102589. length?: number;
  102590. /**
  102591. * Defines an optional offset (in seconds) inside the sound file
  102592. */
  102593. offset?: number;
  102594. /**
  102595. * If true, URLs will not be required to state the audio file codec to use.
  102596. */
  102597. skipCodecCheck?: boolean;
  102598. }
  102599. /**
  102600. * Defines a sound that can be played in the application.
  102601. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102603. */
  102604. export class Sound {
  102605. /**
  102606. * The name of the sound in the scene.
  102607. */
  102608. name: string;
  102609. /**
  102610. * Does the sound autoplay once loaded.
  102611. */
  102612. autoplay: boolean;
  102613. /**
  102614. * Does the sound loop after it finishes playing once.
  102615. */
  102616. loop: boolean;
  102617. /**
  102618. * Does the sound use a custom attenuation curve to simulate the falloff
  102619. * happening when the source gets further away from the camera.
  102620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102621. */
  102622. useCustomAttenuation: boolean;
  102623. /**
  102624. * The sound track id this sound belongs to.
  102625. */
  102626. soundTrackId: number;
  102627. /**
  102628. * Is this sound currently played.
  102629. */
  102630. isPlaying: boolean;
  102631. /**
  102632. * Is this sound currently paused.
  102633. */
  102634. isPaused: boolean;
  102635. /**
  102636. * Does this sound enables spatial sound.
  102637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102638. */
  102639. spatialSound: boolean;
  102640. /**
  102641. * Define the reference distance the sound should be heard perfectly.
  102642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102643. */
  102644. refDistance: number;
  102645. /**
  102646. * Define the roll off factor of spatial sounds.
  102647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102648. */
  102649. rolloffFactor: number;
  102650. /**
  102651. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102653. */
  102654. maxDistance: number;
  102655. /**
  102656. * Define the distance attenuation model the sound will follow.
  102657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102658. */
  102659. distanceModel: string;
  102660. /**
  102661. * @hidden
  102662. * Back Compat
  102663. **/
  102664. onended: () => any;
  102665. /**
  102666. * Observable event when the current playing sound finishes.
  102667. */
  102668. onEndedObservable: Observable<Sound>;
  102669. private _panningModel;
  102670. private _playbackRate;
  102671. private _streaming;
  102672. private _startTime;
  102673. private _startOffset;
  102674. private _position;
  102675. /** @hidden */
  102676. _positionInEmitterSpace: boolean;
  102677. private _localDirection;
  102678. private _volume;
  102679. private _isReadyToPlay;
  102680. private _isDirectional;
  102681. private _readyToPlayCallback;
  102682. private _audioBuffer;
  102683. private _soundSource;
  102684. private _streamingSource;
  102685. private _soundPanner;
  102686. private _soundGain;
  102687. private _inputAudioNode;
  102688. private _outputAudioNode;
  102689. private _coneInnerAngle;
  102690. private _coneOuterAngle;
  102691. private _coneOuterGain;
  102692. private _scene;
  102693. private _connectedTransformNode;
  102694. private _customAttenuationFunction;
  102695. private _registerFunc;
  102696. private _isOutputConnected;
  102697. private _htmlAudioElement;
  102698. private _urlType;
  102699. private _length?;
  102700. private _offset?;
  102701. /** @hidden */
  102702. static _SceneComponentInitialization: (scene: Scene) => void;
  102703. /**
  102704. * Create a sound and attach it to a scene
  102705. * @param name Name of your sound
  102706. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102707. * @param scene defines the scene the sound belongs to
  102708. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102709. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102710. */
  102711. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102712. /**
  102713. * Release the sound and its associated resources
  102714. */
  102715. dispose(): void;
  102716. /**
  102717. * Gets if the sounds is ready to be played or not.
  102718. * @returns true if ready, otherwise false
  102719. */
  102720. isReady(): boolean;
  102721. private _soundLoaded;
  102722. /**
  102723. * Sets the data of the sound from an audiobuffer
  102724. * @param audioBuffer The audioBuffer containing the data
  102725. */
  102726. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102727. /**
  102728. * Updates the current sounds options such as maxdistance, loop...
  102729. * @param options A JSON object containing values named as the object properties
  102730. */
  102731. updateOptions(options: ISoundOptions): void;
  102732. private _createSpatialParameters;
  102733. private _updateSpatialParameters;
  102734. /**
  102735. * Switch the panning model to HRTF:
  102736. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102738. */
  102739. switchPanningModelToHRTF(): void;
  102740. /**
  102741. * Switch the panning model to Equal Power:
  102742. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102744. */
  102745. switchPanningModelToEqualPower(): void;
  102746. private _switchPanningModel;
  102747. /**
  102748. * Connect this sound to a sound track audio node like gain...
  102749. * @param soundTrackAudioNode the sound track audio node to connect to
  102750. */
  102751. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102752. /**
  102753. * Transform this sound into a directional source
  102754. * @param coneInnerAngle Size of the inner cone in degree
  102755. * @param coneOuterAngle Size of the outer cone in degree
  102756. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102757. */
  102758. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102759. /**
  102760. * Gets or sets the inner angle for the directional cone.
  102761. */
  102762. /**
  102763. * Gets or sets the inner angle for the directional cone.
  102764. */
  102765. directionalConeInnerAngle: number;
  102766. /**
  102767. * Gets or sets the outer angle for the directional cone.
  102768. */
  102769. /**
  102770. * Gets or sets the outer angle for the directional cone.
  102771. */
  102772. directionalConeOuterAngle: number;
  102773. /**
  102774. * Sets the position of the emitter if spatial sound is enabled
  102775. * @param newPosition Defines the new posisiton
  102776. */
  102777. setPosition(newPosition: Vector3): void;
  102778. /**
  102779. * Sets the local direction of the emitter if spatial sound is enabled
  102780. * @param newLocalDirection Defines the new local direction
  102781. */
  102782. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102783. private _updateDirection;
  102784. /** @hidden */
  102785. updateDistanceFromListener(): void;
  102786. /**
  102787. * Sets a new custom attenuation function for the sound.
  102788. * @param callback Defines the function used for the attenuation
  102789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102790. */
  102791. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102792. /**
  102793. * Play the sound
  102794. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102795. * @param offset (optional) Start the sound at a specific time in seconds
  102796. * @param length (optional) Sound duration (in seconds)
  102797. */
  102798. play(time?: number, offset?: number, length?: number): void;
  102799. private _onended;
  102800. /**
  102801. * Stop the sound
  102802. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102803. */
  102804. stop(time?: number): void;
  102805. /**
  102806. * Put the sound in pause
  102807. */
  102808. pause(): void;
  102809. /**
  102810. * Sets a dedicated volume for this sounds
  102811. * @param newVolume Define the new volume of the sound
  102812. * @param time Define time for gradual change to new volume
  102813. */
  102814. setVolume(newVolume: number, time?: number): void;
  102815. /**
  102816. * Set the sound play back rate
  102817. * @param newPlaybackRate Define the playback rate the sound should be played at
  102818. */
  102819. setPlaybackRate(newPlaybackRate: number): void;
  102820. /**
  102821. * Gets the volume of the sound.
  102822. * @returns the volume of the sound
  102823. */
  102824. getVolume(): number;
  102825. /**
  102826. * Attach the sound to a dedicated mesh
  102827. * @param transformNode The transform node to connect the sound with
  102828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102829. */
  102830. attachToMesh(transformNode: TransformNode): void;
  102831. /**
  102832. * Detach the sound from the previously attached mesh
  102833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102834. */
  102835. detachFromMesh(): void;
  102836. private _onRegisterAfterWorldMatrixUpdate;
  102837. /**
  102838. * Clone the current sound in the scene.
  102839. * @returns the new sound clone
  102840. */
  102841. clone(): Nullable<Sound>;
  102842. /**
  102843. * Gets the current underlying audio buffer containing the data
  102844. * @returns the audio buffer
  102845. */
  102846. getAudioBuffer(): Nullable<AudioBuffer>;
  102847. /**
  102848. * Serializes the Sound in a JSON representation
  102849. * @returns the JSON representation of the sound
  102850. */
  102851. serialize(): any;
  102852. /**
  102853. * Parse a JSON representation of a sound to innstantiate in a given scene
  102854. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102855. * @param scene Define the scene the new parsed sound should be created in
  102856. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102857. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102858. * @returns the newly parsed sound
  102859. */
  102860. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102861. }
  102862. }
  102863. declare module BABYLON {
  102864. /**
  102865. * This defines an action helpful to play a defined sound on a triggered action.
  102866. */
  102867. export class PlaySoundAction extends Action {
  102868. private _sound;
  102869. /**
  102870. * Instantiate the action
  102871. * @param triggerOptions defines the trigger options
  102872. * @param sound defines the sound to play
  102873. * @param condition defines the trigger related conditions
  102874. */
  102875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102876. /** @hidden */
  102877. _prepare(): void;
  102878. /**
  102879. * Execute the action and play the sound.
  102880. */
  102881. execute(): void;
  102882. /**
  102883. * Serializes the actions and its related information.
  102884. * @param parent defines the object to serialize in
  102885. * @returns the serialized object
  102886. */
  102887. serialize(parent: any): any;
  102888. }
  102889. /**
  102890. * This defines an action helpful to stop a defined sound on a triggered action.
  102891. */
  102892. export class StopSoundAction extends Action {
  102893. private _sound;
  102894. /**
  102895. * Instantiate the action
  102896. * @param triggerOptions defines the trigger options
  102897. * @param sound defines the sound to stop
  102898. * @param condition defines the trigger related conditions
  102899. */
  102900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102901. /** @hidden */
  102902. _prepare(): void;
  102903. /**
  102904. * Execute the action and stop the sound.
  102905. */
  102906. execute(): void;
  102907. /**
  102908. * Serializes the actions and its related information.
  102909. * @param parent defines the object to serialize in
  102910. * @returns the serialized object
  102911. */
  102912. serialize(parent: any): any;
  102913. }
  102914. }
  102915. declare module BABYLON {
  102916. /**
  102917. * This defines an action responsible to change the value of a property
  102918. * by interpolating between its current value and the newly set one once triggered.
  102919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102920. */
  102921. export class InterpolateValueAction extends Action {
  102922. /**
  102923. * Defines the path of the property where the value should be interpolated
  102924. */
  102925. propertyPath: string;
  102926. /**
  102927. * Defines the target value at the end of the interpolation.
  102928. */
  102929. value: any;
  102930. /**
  102931. * Defines the time it will take for the property to interpolate to the value.
  102932. */
  102933. duration: number;
  102934. /**
  102935. * Defines if the other scene animations should be stopped when the action has been triggered
  102936. */
  102937. stopOtherAnimations?: boolean;
  102938. /**
  102939. * Defines a callback raised once the interpolation animation has been done.
  102940. */
  102941. onInterpolationDone?: () => void;
  102942. /**
  102943. * Observable triggered once the interpolation animation has been done.
  102944. */
  102945. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102946. private _target;
  102947. private _effectiveTarget;
  102948. private _property;
  102949. /**
  102950. * Instantiate the action
  102951. * @param triggerOptions defines the trigger options
  102952. * @param target defines the object containing the value to interpolate
  102953. * @param propertyPath defines the path to the property in the target object
  102954. * @param value defines the target value at the end of the interpolation
  102955. * @param duration deines the time it will take for the property to interpolate to the value.
  102956. * @param condition defines the trigger related conditions
  102957. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102958. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102959. */
  102960. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102961. /** @hidden */
  102962. _prepare(): void;
  102963. /**
  102964. * Execute the action starts the value interpolation.
  102965. */
  102966. execute(): void;
  102967. /**
  102968. * Serializes the actions and its related information.
  102969. * @param parent defines the object to serialize in
  102970. * @returns the serialized object
  102971. */
  102972. serialize(parent: any): any;
  102973. }
  102974. }
  102975. declare module BABYLON {
  102976. /**
  102977. * Options allowed during the creation of a sound track.
  102978. */
  102979. export interface ISoundTrackOptions {
  102980. /**
  102981. * The volume the sound track should take during creation
  102982. */
  102983. volume?: number;
  102984. /**
  102985. * Define if the sound track is the main sound track of the scene
  102986. */
  102987. mainTrack?: boolean;
  102988. }
  102989. /**
  102990. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102991. * It will be also used in a future release to apply effects on a specific track.
  102992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102993. */
  102994. export class SoundTrack {
  102995. /**
  102996. * The unique identifier of the sound track in the scene.
  102997. */
  102998. id: number;
  102999. /**
  103000. * The list of sounds included in the sound track.
  103001. */
  103002. soundCollection: Array<Sound>;
  103003. private _outputAudioNode;
  103004. private _scene;
  103005. private _isMainTrack;
  103006. private _connectedAnalyser;
  103007. private _options;
  103008. private _isInitialized;
  103009. /**
  103010. * Creates a new sound track.
  103011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103012. * @param scene Define the scene the sound track belongs to
  103013. * @param options
  103014. */
  103015. constructor(scene: Scene, options?: ISoundTrackOptions);
  103016. private _initializeSoundTrackAudioGraph;
  103017. /**
  103018. * Release the sound track and its associated resources
  103019. */
  103020. dispose(): void;
  103021. /**
  103022. * Adds a sound to this sound track
  103023. * @param sound define the cound to add
  103024. * @ignoreNaming
  103025. */
  103026. AddSound(sound: Sound): void;
  103027. /**
  103028. * Removes a sound to this sound track
  103029. * @param sound define the cound to remove
  103030. * @ignoreNaming
  103031. */
  103032. RemoveSound(sound: Sound): void;
  103033. /**
  103034. * Set a global volume for the full sound track.
  103035. * @param newVolume Define the new volume of the sound track
  103036. */
  103037. setVolume(newVolume: number): void;
  103038. /**
  103039. * Switch the panning model to HRTF:
  103040. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103042. */
  103043. switchPanningModelToHRTF(): void;
  103044. /**
  103045. * Switch the panning model to Equal Power:
  103046. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103048. */
  103049. switchPanningModelToEqualPower(): void;
  103050. /**
  103051. * Connect the sound track to an audio analyser allowing some amazing
  103052. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103054. * @param analyser The analyser to connect to the engine
  103055. */
  103056. connectToAnalyser(analyser: Analyser): void;
  103057. }
  103058. }
  103059. declare module BABYLON {
  103060. interface AbstractScene {
  103061. /**
  103062. * The list of sounds used in the scene.
  103063. */
  103064. sounds: Nullable<Array<Sound>>;
  103065. }
  103066. interface Scene {
  103067. /**
  103068. * @hidden
  103069. * Backing field
  103070. */
  103071. _mainSoundTrack: SoundTrack;
  103072. /**
  103073. * The main sound track played by the scene.
  103074. * It cotains your primary collection of sounds.
  103075. */
  103076. mainSoundTrack: SoundTrack;
  103077. /**
  103078. * The list of sound tracks added to the scene
  103079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103080. */
  103081. soundTracks: Nullable<Array<SoundTrack>>;
  103082. /**
  103083. * Gets a sound using a given name
  103084. * @param name defines the name to search for
  103085. * @return the found sound or null if not found at all.
  103086. */
  103087. getSoundByName(name: string): Nullable<Sound>;
  103088. /**
  103089. * Gets or sets if audio support is enabled
  103090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103091. */
  103092. audioEnabled: boolean;
  103093. /**
  103094. * Gets or sets if audio will be output to headphones
  103095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103096. */
  103097. headphone: boolean;
  103098. /**
  103099. * Gets or sets custom audio listener position provider
  103100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103101. */
  103102. audioListenerPositionProvider: Nullable<() => Vector3>;
  103103. }
  103104. /**
  103105. * Defines the sound scene component responsible to manage any sounds
  103106. * in a given scene.
  103107. */
  103108. export class AudioSceneComponent implements ISceneSerializableComponent {
  103109. /**
  103110. * The component name helpfull to identify the component in the list of scene components.
  103111. */
  103112. readonly name: string;
  103113. /**
  103114. * The scene the component belongs to.
  103115. */
  103116. scene: Scene;
  103117. private _audioEnabled;
  103118. /**
  103119. * Gets whether audio is enabled or not.
  103120. * Please use related enable/disable method to switch state.
  103121. */
  103122. readonly audioEnabled: boolean;
  103123. private _headphone;
  103124. /**
  103125. * Gets whether audio is outputing to headphone or not.
  103126. * Please use the according Switch methods to change output.
  103127. */
  103128. readonly headphone: boolean;
  103129. private _audioListenerPositionProvider;
  103130. /**
  103131. * Gets the current audio listener position provider
  103132. */
  103133. /**
  103134. * Sets a custom listener position for all sounds in the scene
  103135. * By default, this is the position of the first active camera
  103136. */
  103137. audioListenerPositionProvider: Nullable<() => Vector3>;
  103138. /**
  103139. * Creates a new instance of the component for the given scene
  103140. * @param scene Defines the scene to register the component in
  103141. */
  103142. constructor(scene: Scene);
  103143. /**
  103144. * Registers the component in a given scene
  103145. */
  103146. register(): void;
  103147. /**
  103148. * Rebuilds the elements related to this component in case of
  103149. * context lost for instance.
  103150. */
  103151. rebuild(): void;
  103152. /**
  103153. * Serializes the component data to the specified json object
  103154. * @param serializationObject The object to serialize to
  103155. */
  103156. serialize(serializationObject: any): void;
  103157. /**
  103158. * Adds all the elements from the container to the scene
  103159. * @param container the container holding the elements
  103160. */
  103161. addFromContainer(container: AbstractScene): void;
  103162. /**
  103163. * Removes all the elements in the container from the scene
  103164. * @param container contains the elements to remove
  103165. * @param dispose if the removed element should be disposed (default: false)
  103166. */
  103167. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103168. /**
  103169. * Disposes the component and the associated ressources.
  103170. */
  103171. dispose(): void;
  103172. /**
  103173. * Disables audio in the associated scene.
  103174. */
  103175. disableAudio(): void;
  103176. /**
  103177. * Enables audio in the associated scene.
  103178. */
  103179. enableAudio(): void;
  103180. /**
  103181. * Switch audio to headphone output.
  103182. */
  103183. switchAudioModeForHeadphones(): void;
  103184. /**
  103185. * Switch audio to normal speakers.
  103186. */
  103187. switchAudioModeForNormalSpeakers(): void;
  103188. private _afterRender;
  103189. }
  103190. }
  103191. declare module BABYLON {
  103192. /**
  103193. * Wraps one or more Sound objects and selects one with random weight for playback.
  103194. */
  103195. export class WeightedSound {
  103196. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103197. loop: boolean;
  103198. private _coneInnerAngle;
  103199. private _coneOuterAngle;
  103200. private _volume;
  103201. /** A Sound is currently playing. */
  103202. isPlaying: boolean;
  103203. /** A Sound is currently paused. */
  103204. isPaused: boolean;
  103205. private _sounds;
  103206. private _weights;
  103207. private _currentIndex?;
  103208. /**
  103209. * Creates a new WeightedSound from the list of sounds given.
  103210. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103211. * @param sounds Array of Sounds that will be selected from.
  103212. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103213. */
  103214. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103215. /**
  103216. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103217. */
  103218. /**
  103219. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103220. */
  103221. directionalConeInnerAngle: number;
  103222. /**
  103223. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103224. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103225. */
  103226. /**
  103227. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103228. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103229. */
  103230. directionalConeOuterAngle: number;
  103231. /**
  103232. * Playback volume.
  103233. */
  103234. /**
  103235. * Playback volume.
  103236. */
  103237. volume: number;
  103238. private _onended;
  103239. /**
  103240. * Suspend playback
  103241. */
  103242. pause(): void;
  103243. /**
  103244. * Stop playback
  103245. */
  103246. stop(): void;
  103247. /**
  103248. * Start playback.
  103249. * @param startOffset Position the clip head at a specific time in seconds.
  103250. */
  103251. play(startOffset?: number): void;
  103252. }
  103253. }
  103254. declare module BABYLON {
  103255. /**
  103256. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103258. */
  103259. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103260. /**
  103261. * Gets the name of the behavior.
  103262. */
  103263. readonly name: string;
  103264. /**
  103265. * The easing function used by animations
  103266. */
  103267. static EasingFunction: BackEase;
  103268. /**
  103269. * The easing mode used by animations
  103270. */
  103271. static EasingMode: number;
  103272. /**
  103273. * The duration of the animation, in milliseconds
  103274. */
  103275. transitionDuration: number;
  103276. /**
  103277. * Length of the distance animated by the transition when lower radius is reached
  103278. */
  103279. lowerRadiusTransitionRange: number;
  103280. /**
  103281. * Length of the distance animated by the transition when upper radius is reached
  103282. */
  103283. upperRadiusTransitionRange: number;
  103284. private _autoTransitionRange;
  103285. /**
  103286. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103287. */
  103288. /**
  103289. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103290. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103291. */
  103292. autoTransitionRange: boolean;
  103293. private _attachedCamera;
  103294. private _onAfterCheckInputsObserver;
  103295. private _onMeshTargetChangedObserver;
  103296. /**
  103297. * Initializes the behavior.
  103298. */
  103299. init(): void;
  103300. /**
  103301. * Attaches the behavior to its arc rotate camera.
  103302. * @param camera Defines the camera to attach the behavior to
  103303. */
  103304. attach(camera: ArcRotateCamera): void;
  103305. /**
  103306. * Detaches the behavior from its current arc rotate camera.
  103307. */
  103308. detach(): void;
  103309. private _radiusIsAnimating;
  103310. private _radiusBounceTransition;
  103311. private _animatables;
  103312. private _cachedWheelPrecision;
  103313. /**
  103314. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103315. * @param radiusLimit The limit to check against.
  103316. * @return Bool to indicate if at limit.
  103317. */
  103318. private _isRadiusAtLimit;
  103319. /**
  103320. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103321. * @param radiusDelta The delta by which to animate to. Can be negative.
  103322. */
  103323. private _applyBoundRadiusAnimation;
  103324. /**
  103325. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103326. */
  103327. protected _clearAnimationLocks(): void;
  103328. /**
  103329. * Stops and removes all animations that have been applied to the camera
  103330. */
  103331. stopAllAnimations(): void;
  103332. }
  103333. }
  103334. declare module BABYLON {
  103335. /**
  103336. * 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.
  103337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103338. */
  103339. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103340. /**
  103341. * Gets the name of the behavior.
  103342. */
  103343. readonly name: string;
  103344. private _mode;
  103345. private _radiusScale;
  103346. private _positionScale;
  103347. private _defaultElevation;
  103348. private _elevationReturnTime;
  103349. private _elevationReturnWaitTime;
  103350. private _zoomStopsAnimation;
  103351. private _framingTime;
  103352. /**
  103353. * The easing function used by animations
  103354. */
  103355. static EasingFunction: ExponentialEase;
  103356. /**
  103357. * The easing mode used by animations
  103358. */
  103359. static EasingMode: number;
  103360. /**
  103361. * Sets the current mode used by the behavior
  103362. */
  103363. /**
  103364. * Gets current mode used by the behavior.
  103365. */
  103366. mode: number;
  103367. /**
  103368. * Sets the scale applied to the radius (1 by default)
  103369. */
  103370. /**
  103371. * Gets the scale applied to the radius
  103372. */
  103373. radiusScale: number;
  103374. /**
  103375. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103376. */
  103377. /**
  103378. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103379. */
  103380. positionScale: number;
  103381. /**
  103382. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103383. * behaviour is triggered, in radians.
  103384. */
  103385. /**
  103386. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103387. * behaviour is triggered, in radians.
  103388. */
  103389. defaultElevation: number;
  103390. /**
  103391. * Sets the time (in milliseconds) taken to return to the default beta position.
  103392. * Negative value indicates camera should not return to default.
  103393. */
  103394. /**
  103395. * Gets the time (in milliseconds) taken to return to the default beta position.
  103396. * Negative value indicates camera should not return to default.
  103397. */
  103398. elevationReturnTime: number;
  103399. /**
  103400. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103401. */
  103402. /**
  103403. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103404. */
  103405. elevationReturnWaitTime: number;
  103406. /**
  103407. * Sets the flag that indicates if user zooming should stop animation.
  103408. */
  103409. /**
  103410. * Gets the flag that indicates if user zooming should stop animation.
  103411. */
  103412. zoomStopsAnimation: boolean;
  103413. /**
  103414. * Sets the transition time when framing the mesh, in milliseconds
  103415. */
  103416. /**
  103417. * Gets the transition time when framing the mesh, in milliseconds
  103418. */
  103419. framingTime: number;
  103420. /**
  103421. * Define if the behavior should automatically change the configured
  103422. * camera limits and sensibilities.
  103423. */
  103424. autoCorrectCameraLimitsAndSensibility: boolean;
  103425. private _onPrePointerObservableObserver;
  103426. private _onAfterCheckInputsObserver;
  103427. private _onMeshTargetChangedObserver;
  103428. private _attachedCamera;
  103429. private _isPointerDown;
  103430. private _lastInteractionTime;
  103431. /**
  103432. * Initializes the behavior.
  103433. */
  103434. init(): void;
  103435. /**
  103436. * Attaches the behavior to its arc rotate camera.
  103437. * @param camera Defines the camera to attach the behavior to
  103438. */
  103439. attach(camera: ArcRotateCamera): void;
  103440. /**
  103441. * Detaches the behavior from its current arc rotate camera.
  103442. */
  103443. detach(): void;
  103444. private _animatables;
  103445. private _betaIsAnimating;
  103446. private _betaTransition;
  103447. private _radiusTransition;
  103448. private _vectorTransition;
  103449. /**
  103450. * Targets the given mesh and updates zoom level accordingly.
  103451. * @param mesh The mesh to target.
  103452. * @param radius Optional. If a cached radius position already exists, overrides default.
  103453. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103454. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103455. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103456. */
  103457. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103458. /**
  103459. * Targets the given mesh with its children and updates zoom level accordingly.
  103460. * @param mesh The mesh to target.
  103461. * @param radius Optional. If a cached radius position already exists, overrides default.
  103462. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103463. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103464. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103465. */
  103466. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103467. /**
  103468. * Targets the given meshes with their children and updates zoom level accordingly.
  103469. * @param meshes The mesh to target.
  103470. * @param radius Optional. If a cached radius position already exists, overrides default.
  103471. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103472. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103473. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103474. */
  103475. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103476. /**
  103477. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103478. * @param minimumWorld Determines the smaller position of the bounding box extend
  103479. * @param maximumWorld Determines the bigger position of the bounding box extend
  103480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103482. */
  103483. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103484. /**
  103485. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103486. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103487. * frustum width.
  103488. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103489. * to fully enclose the mesh in the viewing frustum.
  103490. */
  103491. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103492. /**
  103493. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103494. * is automatically returned to its default position (expected to be above ground plane).
  103495. */
  103496. private _maintainCameraAboveGround;
  103497. /**
  103498. * Returns the frustum slope based on the canvas ratio and camera FOV
  103499. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103500. */
  103501. private _getFrustumSlope;
  103502. /**
  103503. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103504. */
  103505. private _clearAnimationLocks;
  103506. /**
  103507. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103508. */
  103509. private _applyUserInteraction;
  103510. /**
  103511. * Stops and removes all animations that have been applied to the camera
  103512. */
  103513. stopAllAnimations(): void;
  103514. /**
  103515. * Gets a value indicating if the user is moving the camera
  103516. */
  103517. readonly isUserIsMoving: boolean;
  103518. /**
  103519. * The camera can move all the way towards the mesh.
  103520. */
  103521. static IgnoreBoundsSizeMode: number;
  103522. /**
  103523. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103524. */
  103525. static FitFrustumSidesMode: number;
  103526. }
  103527. }
  103528. declare module BABYLON {
  103529. /**
  103530. * Base class for Camera Pointer Inputs.
  103531. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103532. * for example usage.
  103533. */
  103534. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103535. /**
  103536. * Defines the camera the input is attached to.
  103537. */
  103538. abstract camera: Camera;
  103539. /**
  103540. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103541. */
  103542. protected _altKey: boolean;
  103543. protected _ctrlKey: boolean;
  103544. protected _metaKey: boolean;
  103545. protected _shiftKey: boolean;
  103546. /**
  103547. * Which mouse buttons were pressed at time of last mouse event.
  103548. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103549. */
  103550. protected _buttonsPressed: number;
  103551. /**
  103552. * Defines the buttons associated with the input to handle camera move.
  103553. */
  103554. buttons: number[];
  103555. /**
  103556. * Attach the input controls to a specific dom element to get the input from.
  103557. * @param element Defines the element the controls should be listened from
  103558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103559. */
  103560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103561. /**
  103562. * Detach the current controls from the specified dom element.
  103563. * @param element Defines the element to stop listening the inputs from
  103564. */
  103565. detachControl(element: Nullable<HTMLElement>): void;
  103566. /**
  103567. * Gets the class name of the current input.
  103568. * @returns the class name
  103569. */
  103570. getClassName(): string;
  103571. /**
  103572. * Get the friendly name associated with the input class.
  103573. * @returns the input friendly name
  103574. */
  103575. getSimpleName(): string;
  103576. /**
  103577. * Called on pointer POINTERDOUBLETAP event.
  103578. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103579. */
  103580. protected onDoubleTap(type: string): void;
  103581. /**
  103582. * Called on pointer POINTERMOVE event if only a single touch is active.
  103583. * Override this method to provide functionality.
  103584. */
  103585. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103586. /**
  103587. * Called on pointer POINTERMOVE event if multiple touches are active.
  103588. * Override this method to provide functionality.
  103589. */
  103590. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103591. /**
  103592. * Called on JS contextmenu event.
  103593. * Override this method to provide functionality.
  103594. */
  103595. protected onContextMenu(evt: PointerEvent): void;
  103596. /**
  103597. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103598. * press.
  103599. * Override this method to provide functionality.
  103600. */
  103601. protected onButtonDown(evt: PointerEvent): void;
  103602. /**
  103603. * Called each time a new POINTERUP event occurs. Ie, for each button
  103604. * release.
  103605. * Override this method to provide functionality.
  103606. */
  103607. protected onButtonUp(evt: PointerEvent): void;
  103608. /**
  103609. * Called when window becomes inactive.
  103610. * Override this method to provide functionality.
  103611. */
  103612. protected onLostFocus(): void;
  103613. private _pointerInput;
  103614. private _observer;
  103615. private _onLostFocus;
  103616. private pointA;
  103617. private pointB;
  103618. }
  103619. }
  103620. declare module BABYLON {
  103621. /**
  103622. * Manage the pointers inputs to control an arc rotate camera.
  103623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103624. */
  103625. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103626. /**
  103627. * Defines the camera the input is attached to.
  103628. */
  103629. camera: ArcRotateCamera;
  103630. /**
  103631. * Gets the class name of the current input.
  103632. * @returns the class name
  103633. */
  103634. getClassName(): string;
  103635. /**
  103636. * Defines the buttons associated with the input to handle camera move.
  103637. */
  103638. buttons: number[];
  103639. /**
  103640. * Defines the pointer angular sensibility along the X axis or how fast is
  103641. * the camera rotating.
  103642. */
  103643. angularSensibilityX: number;
  103644. /**
  103645. * Defines the pointer angular sensibility along the Y axis or how fast is
  103646. * the camera rotating.
  103647. */
  103648. angularSensibilityY: number;
  103649. /**
  103650. * Defines the pointer pinch precision or how fast is the camera zooming.
  103651. */
  103652. pinchPrecision: number;
  103653. /**
  103654. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103655. * from 0.
  103656. * It defines the percentage of current camera.radius to use as delta when
  103657. * pinch zoom is used.
  103658. */
  103659. pinchDeltaPercentage: number;
  103660. /**
  103661. * Defines the pointer panning sensibility or how fast is the camera moving.
  103662. */
  103663. panningSensibility: number;
  103664. /**
  103665. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103666. */
  103667. multiTouchPanning: boolean;
  103668. /**
  103669. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103670. * zoom (pinch) through multitouch.
  103671. */
  103672. multiTouchPanAndZoom: boolean;
  103673. /**
  103674. * Revers pinch action direction.
  103675. */
  103676. pinchInwards: boolean;
  103677. private _isPanClick;
  103678. private _twoFingerActivityCount;
  103679. private _isPinching;
  103680. /**
  103681. * Called on pointer POINTERMOVE event if only a single touch is active.
  103682. */
  103683. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103684. /**
  103685. * Called on pointer POINTERDOUBLETAP event.
  103686. */
  103687. protected onDoubleTap(type: string): void;
  103688. /**
  103689. * Called on pointer POINTERMOVE event if multiple touches are active.
  103690. */
  103691. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103692. /**
  103693. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103694. * press.
  103695. */
  103696. protected onButtonDown(evt: PointerEvent): void;
  103697. /**
  103698. * Called each time a new POINTERUP event occurs. Ie, for each button
  103699. * release.
  103700. */
  103701. protected onButtonUp(evt: PointerEvent): void;
  103702. /**
  103703. * Called when window becomes inactive.
  103704. */
  103705. protected onLostFocus(): void;
  103706. }
  103707. }
  103708. declare module BABYLON {
  103709. /**
  103710. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103712. */
  103713. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103714. /**
  103715. * Defines the camera the input is attached to.
  103716. */
  103717. camera: ArcRotateCamera;
  103718. /**
  103719. * Defines the list of key codes associated with the up action (increase alpha)
  103720. */
  103721. keysUp: number[];
  103722. /**
  103723. * Defines the list of key codes associated with the down action (decrease alpha)
  103724. */
  103725. keysDown: number[];
  103726. /**
  103727. * Defines the list of key codes associated with the left action (increase beta)
  103728. */
  103729. keysLeft: number[];
  103730. /**
  103731. * Defines the list of key codes associated with the right action (decrease beta)
  103732. */
  103733. keysRight: number[];
  103734. /**
  103735. * Defines the list of key codes associated with the reset action.
  103736. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103737. */
  103738. keysReset: number[];
  103739. /**
  103740. * Defines the panning sensibility of the inputs.
  103741. * (How fast is the camera paning)
  103742. */
  103743. panningSensibility: number;
  103744. /**
  103745. * Defines the zooming sensibility of the inputs.
  103746. * (How fast is the camera zooming)
  103747. */
  103748. zoomingSensibility: number;
  103749. /**
  103750. * Defines wether maintaining the alt key down switch the movement mode from
  103751. * orientation to zoom.
  103752. */
  103753. useAltToZoom: boolean;
  103754. /**
  103755. * Rotation speed of the camera
  103756. */
  103757. angularSpeed: number;
  103758. private _keys;
  103759. private _ctrlPressed;
  103760. private _altPressed;
  103761. private _onCanvasBlurObserver;
  103762. private _onKeyboardObserver;
  103763. private _engine;
  103764. private _scene;
  103765. /**
  103766. * Attach the input controls to a specific dom element to get the input from.
  103767. * @param element Defines the element the controls should be listened from
  103768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103769. */
  103770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103771. /**
  103772. * Detach the current controls from the specified dom element.
  103773. * @param element Defines the element to stop listening the inputs from
  103774. */
  103775. detachControl(element: Nullable<HTMLElement>): void;
  103776. /**
  103777. * Update the current camera state depending on the inputs that have been used this frame.
  103778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103779. */
  103780. checkInputs(): void;
  103781. /**
  103782. * Gets the class name of the current intput.
  103783. * @returns the class name
  103784. */
  103785. getClassName(): string;
  103786. /**
  103787. * Get the friendly name associated with the input class.
  103788. * @returns the input friendly name
  103789. */
  103790. getSimpleName(): string;
  103791. }
  103792. }
  103793. declare module BABYLON {
  103794. /**
  103795. * Manage the mouse wheel inputs to control an arc rotate camera.
  103796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103797. */
  103798. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103799. /**
  103800. * Defines the camera the input is attached to.
  103801. */
  103802. camera: ArcRotateCamera;
  103803. /**
  103804. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103805. */
  103806. wheelPrecision: number;
  103807. /**
  103808. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103809. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103810. */
  103811. wheelDeltaPercentage: number;
  103812. private _wheel;
  103813. private _observer;
  103814. private computeDeltaFromMouseWheelLegacyEvent;
  103815. /**
  103816. * Attach the input controls to a specific dom element to get the input from.
  103817. * @param element Defines the element the controls should be listened from
  103818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103819. */
  103820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103821. /**
  103822. * Detach the current controls from the specified dom element.
  103823. * @param element Defines the element to stop listening the inputs from
  103824. */
  103825. detachControl(element: Nullable<HTMLElement>): void;
  103826. /**
  103827. * Gets the class name of the current intput.
  103828. * @returns the class name
  103829. */
  103830. getClassName(): string;
  103831. /**
  103832. * Get the friendly name associated with the input class.
  103833. * @returns the input friendly name
  103834. */
  103835. getSimpleName(): string;
  103836. }
  103837. }
  103838. declare module BABYLON {
  103839. /**
  103840. * Default Inputs manager for the ArcRotateCamera.
  103841. * It groups all the default supported inputs for ease of use.
  103842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103843. */
  103844. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103845. /**
  103846. * Instantiates a new ArcRotateCameraInputsManager.
  103847. * @param camera Defines the camera the inputs belong to
  103848. */
  103849. constructor(camera: ArcRotateCamera);
  103850. /**
  103851. * Add mouse wheel input support to the input manager.
  103852. * @returns the current input manager
  103853. */
  103854. addMouseWheel(): ArcRotateCameraInputsManager;
  103855. /**
  103856. * Add pointers input support to the input manager.
  103857. * @returns the current input manager
  103858. */
  103859. addPointers(): ArcRotateCameraInputsManager;
  103860. /**
  103861. * Add keyboard input support to the input manager.
  103862. * @returns the current input manager
  103863. */
  103864. addKeyboard(): ArcRotateCameraInputsManager;
  103865. }
  103866. }
  103867. declare module BABYLON {
  103868. /**
  103869. * This represents an orbital type of camera.
  103870. *
  103871. * 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.
  103872. * 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.
  103873. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103874. */
  103875. export class ArcRotateCamera extends TargetCamera {
  103876. /**
  103877. * Defines the rotation angle of the camera along the longitudinal axis.
  103878. */
  103879. alpha: number;
  103880. /**
  103881. * Defines the rotation angle of the camera along the latitudinal axis.
  103882. */
  103883. beta: number;
  103884. /**
  103885. * Defines the radius of the camera from it s target point.
  103886. */
  103887. radius: number;
  103888. protected _target: Vector3;
  103889. protected _targetHost: Nullable<AbstractMesh>;
  103890. /**
  103891. * Defines the target point of the camera.
  103892. * The camera looks towards it form the radius distance.
  103893. */
  103894. target: Vector3;
  103895. /**
  103896. * Define the current local position of the camera in the scene
  103897. */
  103898. position: Vector3;
  103899. protected _upVector: Vector3;
  103900. protected _upToYMatrix: Matrix;
  103901. protected _YToUpMatrix: Matrix;
  103902. /**
  103903. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103904. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103905. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103906. */
  103907. upVector: Vector3;
  103908. /**
  103909. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103910. */
  103911. setMatUp(): void;
  103912. /**
  103913. * Current inertia value on the longitudinal axis.
  103914. * The bigger this number the longer it will take for the camera to stop.
  103915. */
  103916. inertialAlphaOffset: number;
  103917. /**
  103918. * Current inertia value on the latitudinal axis.
  103919. * The bigger this number the longer it will take for the camera to stop.
  103920. */
  103921. inertialBetaOffset: number;
  103922. /**
  103923. * Current inertia value on the radius axis.
  103924. * The bigger this number the longer it will take for the camera to stop.
  103925. */
  103926. inertialRadiusOffset: number;
  103927. /**
  103928. * Minimum allowed angle on the longitudinal axis.
  103929. * This can help limiting how the Camera is able to move in the scene.
  103930. */
  103931. lowerAlphaLimit: Nullable<number>;
  103932. /**
  103933. * Maximum allowed angle on the longitudinal axis.
  103934. * This can help limiting how the Camera is able to move in the scene.
  103935. */
  103936. upperAlphaLimit: Nullable<number>;
  103937. /**
  103938. * Minimum allowed angle on the latitudinal axis.
  103939. * This can help limiting how the Camera is able to move in the scene.
  103940. */
  103941. lowerBetaLimit: number;
  103942. /**
  103943. * Maximum allowed angle on the latitudinal axis.
  103944. * This can help limiting how the Camera is able to move in the scene.
  103945. */
  103946. upperBetaLimit: number;
  103947. /**
  103948. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103949. * This can help limiting how the Camera is able to move in the scene.
  103950. */
  103951. lowerRadiusLimit: Nullable<number>;
  103952. /**
  103953. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103954. * This can help limiting how the Camera is able to move in the scene.
  103955. */
  103956. upperRadiusLimit: Nullable<number>;
  103957. /**
  103958. * Defines the current inertia value used during panning of the camera along the X axis.
  103959. */
  103960. inertialPanningX: number;
  103961. /**
  103962. * Defines the current inertia value used during panning of the camera along the Y axis.
  103963. */
  103964. inertialPanningY: number;
  103965. /**
  103966. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103967. * Basically if your fingers moves away from more than this distance you will be considered
  103968. * in pinch mode.
  103969. */
  103970. pinchToPanMaxDistance: number;
  103971. /**
  103972. * Defines the maximum distance the camera can pan.
  103973. * This could help keeping the cammera always in your scene.
  103974. */
  103975. panningDistanceLimit: Nullable<number>;
  103976. /**
  103977. * Defines the target of the camera before paning.
  103978. */
  103979. panningOriginTarget: Vector3;
  103980. /**
  103981. * Defines the value of the inertia used during panning.
  103982. * 0 would mean stop inertia and one would mean no decelleration at all.
  103983. */
  103984. panningInertia: number;
  103985. /**
  103986. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103987. */
  103988. angularSensibilityX: number;
  103989. /**
  103990. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103991. */
  103992. angularSensibilityY: number;
  103993. /**
  103994. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103995. */
  103996. pinchPrecision: number;
  103997. /**
  103998. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103999. * It will be used instead of pinchDeltaPrecision if different from 0.
  104000. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104001. */
  104002. pinchDeltaPercentage: number;
  104003. /**
  104004. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104005. */
  104006. panningSensibility: number;
  104007. /**
  104008. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104009. */
  104010. keysUp: number[];
  104011. /**
  104012. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104013. */
  104014. keysDown: number[];
  104015. /**
  104016. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104017. */
  104018. keysLeft: number[];
  104019. /**
  104020. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104021. */
  104022. keysRight: number[];
  104023. /**
  104024. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104025. */
  104026. wheelPrecision: number;
  104027. /**
  104028. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104029. * It will be used instead of pinchDeltaPrecision if different from 0.
  104030. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104031. */
  104032. wheelDeltaPercentage: number;
  104033. /**
  104034. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104035. */
  104036. zoomOnFactor: number;
  104037. /**
  104038. * Defines a screen offset for the camera position.
  104039. */
  104040. targetScreenOffset: Vector2;
  104041. /**
  104042. * Allows the camera to be completely reversed.
  104043. * If false the camera can not arrive upside down.
  104044. */
  104045. allowUpsideDown: boolean;
  104046. /**
  104047. * Define if double tap/click is used to restore the previously saved state of the camera.
  104048. */
  104049. useInputToRestoreState: boolean;
  104050. /** @hidden */
  104051. _viewMatrix: Matrix;
  104052. /** @hidden */
  104053. _useCtrlForPanning: boolean;
  104054. /** @hidden */
  104055. _panningMouseButton: number;
  104056. /**
  104057. * Defines the input associated to the camera.
  104058. */
  104059. inputs: ArcRotateCameraInputsManager;
  104060. /** @hidden */
  104061. _reset: () => void;
  104062. /**
  104063. * Defines the allowed panning axis.
  104064. */
  104065. panningAxis: Vector3;
  104066. protected _localDirection: Vector3;
  104067. protected _transformedDirection: Vector3;
  104068. private _bouncingBehavior;
  104069. /**
  104070. * Gets the bouncing behavior of the camera if it has been enabled.
  104071. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104072. */
  104073. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104074. /**
  104075. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104076. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104077. */
  104078. useBouncingBehavior: boolean;
  104079. private _framingBehavior;
  104080. /**
  104081. * Gets the framing behavior of the camera if it has been enabled.
  104082. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104083. */
  104084. readonly framingBehavior: Nullable<FramingBehavior>;
  104085. /**
  104086. * Defines if the framing behavior of the camera is enabled on the camera.
  104087. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104088. */
  104089. useFramingBehavior: boolean;
  104090. private _autoRotationBehavior;
  104091. /**
  104092. * Gets the auto rotation behavior of the camera if it has been enabled.
  104093. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104094. */
  104095. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104096. /**
  104097. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104098. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104099. */
  104100. useAutoRotationBehavior: boolean;
  104101. /**
  104102. * Observable triggered when the mesh target has been changed on the camera.
  104103. */
  104104. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104105. /**
  104106. * Event raised when the camera is colliding with a mesh.
  104107. */
  104108. onCollide: (collidedMesh: AbstractMesh) => void;
  104109. /**
  104110. * Defines whether the camera should check collision with the objects oh the scene.
  104111. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104112. */
  104113. checkCollisions: boolean;
  104114. /**
  104115. * Defines the collision radius of the camera.
  104116. * This simulates a sphere around the camera.
  104117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104118. */
  104119. collisionRadius: Vector3;
  104120. protected _collider: Collider;
  104121. protected _previousPosition: Vector3;
  104122. protected _collisionVelocity: Vector3;
  104123. protected _newPosition: Vector3;
  104124. protected _previousAlpha: number;
  104125. protected _previousBeta: number;
  104126. protected _previousRadius: number;
  104127. protected _collisionTriggered: boolean;
  104128. protected _targetBoundingCenter: Nullable<Vector3>;
  104129. private _computationVector;
  104130. /**
  104131. * Instantiates a new ArcRotateCamera in a given scene
  104132. * @param name Defines the name of the camera
  104133. * @param alpha Defines the camera rotation along the logitudinal axis
  104134. * @param beta Defines the camera rotation along the latitudinal axis
  104135. * @param radius Defines the camera distance from its target
  104136. * @param target Defines the camera target
  104137. * @param scene Defines the scene the camera belongs to
  104138. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104139. */
  104140. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104141. /** @hidden */
  104142. _initCache(): void;
  104143. /** @hidden */
  104144. _updateCache(ignoreParentClass?: boolean): void;
  104145. protected _getTargetPosition(): Vector3;
  104146. private _storedAlpha;
  104147. private _storedBeta;
  104148. private _storedRadius;
  104149. private _storedTarget;
  104150. private _storedTargetScreenOffset;
  104151. /**
  104152. * Stores the current state of the camera (alpha, beta, radius and target)
  104153. * @returns the camera itself
  104154. */
  104155. storeState(): Camera;
  104156. /**
  104157. * @hidden
  104158. * Restored camera state. You must call storeState() first
  104159. */
  104160. _restoreStateValues(): boolean;
  104161. /** @hidden */
  104162. _isSynchronizedViewMatrix(): boolean;
  104163. /**
  104164. * Attached controls to the current camera.
  104165. * @param element Defines the element the controls should be listened from
  104166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104167. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104168. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104169. */
  104170. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104171. /**
  104172. * Detach the current controls from the camera.
  104173. * The camera will stop reacting to inputs.
  104174. * @param element Defines the element to stop listening the inputs from
  104175. */
  104176. detachControl(element: HTMLElement): void;
  104177. /** @hidden */
  104178. _checkInputs(): void;
  104179. protected _checkLimits(): void;
  104180. /**
  104181. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104182. */
  104183. rebuildAnglesAndRadius(): void;
  104184. /**
  104185. * Use a position to define the current camera related information like alpha, beta and radius
  104186. * @param position Defines the position to set the camera at
  104187. */
  104188. setPosition(position: Vector3): void;
  104189. /**
  104190. * Defines the target the camera should look at.
  104191. * This will automatically adapt alpha beta and radius to fit within the new target.
  104192. * @param target Defines the new target as a Vector or a mesh
  104193. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104194. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104195. */
  104196. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104197. /** @hidden */
  104198. _getViewMatrix(): Matrix;
  104199. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104200. /**
  104201. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104202. * @param meshes Defines the mesh to zoom on
  104203. * @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)
  104204. */
  104205. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104206. /**
  104207. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104208. * The target will be changed but the radius
  104209. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104210. * @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)
  104211. */
  104212. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104213. min: Vector3;
  104214. max: Vector3;
  104215. distance: number;
  104216. }, doNotUpdateMaxZ?: boolean): void;
  104217. /**
  104218. * @override
  104219. * Override Camera.createRigCamera
  104220. */
  104221. createRigCamera(name: string, cameraIndex: number): Camera;
  104222. /**
  104223. * @hidden
  104224. * @override
  104225. * Override Camera._updateRigCameras
  104226. */
  104227. _updateRigCameras(): void;
  104228. /**
  104229. * Destroy the camera and release the current resources hold by it.
  104230. */
  104231. dispose(): void;
  104232. /**
  104233. * Gets the current object class name.
  104234. * @return the class name
  104235. */
  104236. getClassName(): string;
  104237. }
  104238. }
  104239. declare module BABYLON {
  104240. /**
  104241. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104243. */
  104244. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104245. /**
  104246. * Gets the name of the behavior.
  104247. */
  104248. readonly name: string;
  104249. private _zoomStopsAnimation;
  104250. private _idleRotationSpeed;
  104251. private _idleRotationWaitTime;
  104252. private _idleRotationSpinupTime;
  104253. /**
  104254. * Sets the flag that indicates if user zooming should stop animation.
  104255. */
  104256. /**
  104257. * Gets the flag that indicates if user zooming should stop animation.
  104258. */
  104259. zoomStopsAnimation: boolean;
  104260. /**
  104261. * Sets the default speed at which the camera rotates around the model.
  104262. */
  104263. /**
  104264. * Gets the default speed at which the camera rotates around the model.
  104265. */
  104266. idleRotationSpeed: number;
  104267. /**
  104268. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104269. */
  104270. /**
  104271. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104272. */
  104273. idleRotationWaitTime: number;
  104274. /**
  104275. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104276. */
  104277. /**
  104278. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104279. */
  104280. idleRotationSpinupTime: number;
  104281. /**
  104282. * Gets a value indicating if the camera is currently rotating because of this behavior
  104283. */
  104284. readonly rotationInProgress: boolean;
  104285. private _onPrePointerObservableObserver;
  104286. private _onAfterCheckInputsObserver;
  104287. private _attachedCamera;
  104288. private _isPointerDown;
  104289. private _lastFrameTime;
  104290. private _lastInteractionTime;
  104291. private _cameraRotationSpeed;
  104292. /**
  104293. * Initializes the behavior.
  104294. */
  104295. init(): void;
  104296. /**
  104297. * Attaches the behavior to its arc rotate camera.
  104298. * @param camera Defines the camera to attach the behavior to
  104299. */
  104300. attach(camera: ArcRotateCamera): void;
  104301. /**
  104302. * Detaches the behavior from its current arc rotate camera.
  104303. */
  104304. detach(): void;
  104305. /**
  104306. * Returns true if user is scrolling.
  104307. * @return true if user is scrolling.
  104308. */
  104309. private _userIsZooming;
  104310. private _lastFrameRadius;
  104311. private _shouldAnimationStopForInteraction;
  104312. /**
  104313. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104314. */
  104315. private _applyUserInteraction;
  104316. private _userIsMoving;
  104317. }
  104318. }
  104319. declare module BABYLON {
  104320. /**
  104321. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104322. */
  104323. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104324. private ui;
  104325. /**
  104326. * The name of the behavior
  104327. */
  104328. name: string;
  104329. /**
  104330. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104331. */
  104332. distanceAwayFromFace: number;
  104333. /**
  104334. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104335. */
  104336. distanceAwayFromBottomOfFace: number;
  104337. private _faceVectors;
  104338. private _target;
  104339. private _scene;
  104340. private _onRenderObserver;
  104341. private _tmpMatrix;
  104342. private _tmpVector;
  104343. /**
  104344. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104345. * @param ui The transform node that should be attched to the mesh
  104346. */
  104347. constructor(ui: TransformNode);
  104348. /**
  104349. * Initializes the behavior
  104350. */
  104351. init(): void;
  104352. private _closestFace;
  104353. private _zeroVector;
  104354. private _lookAtTmpMatrix;
  104355. private _lookAtToRef;
  104356. /**
  104357. * Attaches the AttachToBoxBehavior to the passed in mesh
  104358. * @param target The mesh that the specified node will be attached to
  104359. */
  104360. attach(target: Mesh): void;
  104361. /**
  104362. * Detaches the behavior from the mesh
  104363. */
  104364. detach(): void;
  104365. }
  104366. }
  104367. declare module BABYLON {
  104368. /**
  104369. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104370. */
  104371. export class FadeInOutBehavior implements Behavior<Mesh> {
  104372. /**
  104373. * Time in milliseconds to delay before fading in (Default: 0)
  104374. */
  104375. delay: number;
  104376. /**
  104377. * Time in milliseconds for the mesh to fade in (Default: 300)
  104378. */
  104379. fadeInTime: number;
  104380. private _millisecondsPerFrame;
  104381. private _hovered;
  104382. private _hoverValue;
  104383. private _ownerNode;
  104384. /**
  104385. * Instatiates the FadeInOutBehavior
  104386. */
  104387. constructor();
  104388. /**
  104389. * The name of the behavior
  104390. */
  104391. readonly name: string;
  104392. /**
  104393. * Initializes the behavior
  104394. */
  104395. init(): void;
  104396. /**
  104397. * Attaches the fade behavior on the passed in mesh
  104398. * @param ownerNode The mesh that will be faded in/out once attached
  104399. */
  104400. attach(ownerNode: Mesh): void;
  104401. /**
  104402. * Detaches the behavior from the mesh
  104403. */
  104404. detach(): void;
  104405. /**
  104406. * Triggers the mesh to begin fading in or out
  104407. * @param value if the object should fade in or out (true to fade in)
  104408. */
  104409. fadeIn(value: boolean): void;
  104410. private _update;
  104411. private _setAllVisibility;
  104412. }
  104413. }
  104414. declare module BABYLON {
  104415. /**
  104416. * Class containing a set of static utilities functions for managing Pivots
  104417. * @hidden
  104418. */
  104419. export class PivotTools {
  104420. private static _PivotCached;
  104421. private static _OldPivotPoint;
  104422. private static _PivotTranslation;
  104423. private static _PivotTmpVector;
  104424. /** @hidden */
  104425. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104426. /** @hidden */
  104427. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104428. }
  104429. }
  104430. declare module BABYLON {
  104431. /**
  104432. * Class containing static functions to help procedurally build meshes
  104433. */
  104434. export class PlaneBuilder {
  104435. /**
  104436. * Creates a plane mesh
  104437. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104438. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104439. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104443. * @param name defines the name of the mesh
  104444. * @param options defines the options used to create the mesh
  104445. * @param scene defines the hosting scene
  104446. * @returns the plane mesh
  104447. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104448. */
  104449. static CreatePlane(name: string, options: {
  104450. size?: number;
  104451. width?: number;
  104452. height?: number;
  104453. sideOrientation?: number;
  104454. frontUVs?: Vector4;
  104455. backUVs?: Vector4;
  104456. updatable?: boolean;
  104457. sourcePlane?: Plane;
  104458. }, scene?: Nullable<Scene>): Mesh;
  104459. }
  104460. }
  104461. declare module BABYLON {
  104462. /**
  104463. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104464. */
  104465. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104466. private static _AnyMouseID;
  104467. /**
  104468. * Abstract mesh the behavior is set on
  104469. */
  104470. attachedNode: AbstractMesh;
  104471. private _dragPlane;
  104472. private _scene;
  104473. private _pointerObserver;
  104474. private _beforeRenderObserver;
  104475. private static _planeScene;
  104476. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104477. /**
  104478. * 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)
  104479. */
  104480. maxDragAngle: number;
  104481. /**
  104482. * @hidden
  104483. */
  104484. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104485. /**
  104486. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104487. */
  104488. currentDraggingPointerID: number;
  104489. /**
  104490. * The last position where the pointer hit the drag plane in world space
  104491. */
  104492. lastDragPosition: Vector3;
  104493. /**
  104494. * If the behavior is currently in a dragging state
  104495. */
  104496. dragging: boolean;
  104497. /**
  104498. * 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)
  104499. */
  104500. dragDeltaRatio: number;
  104501. /**
  104502. * If the drag plane orientation should be updated during the dragging (Default: true)
  104503. */
  104504. updateDragPlane: boolean;
  104505. private _debugMode;
  104506. private _moving;
  104507. /**
  104508. * Fires each time the attached mesh is dragged with the pointer
  104509. * * delta between last drag position and current drag position in world space
  104510. * * dragDistance along the drag axis
  104511. * * dragPlaneNormal normal of the current drag plane used during the drag
  104512. * * dragPlanePoint in world space where the drag intersects the drag plane
  104513. */
  104514. onDragObservable: Observable<{
  104515. delta: Vector3;
  104516. dragPlanePoint: Vector3;
  104517. dragPlaneNormal: Vector3;
  104518. dragDistance: number;
  104519. pointerId: number;
  104520. }>;
  104521. /**
  104522. * Fires each time a drag begins (eg. mouse down on mesh)
  104523. */
  104524. onDragStartObservable: Observable<{
  104525. dragPlanePoint: Vector3;
  104526. pointerId: number;
  104527. }>;
  104528. /**
  104529. * Fires each time a drag ends (eg. mouse release after drag)
  104530. */
  104531. onDragEndObservable: Observable<{
  104532. dragPlanePoint: Vector3;
  104533. pointerId: number;
  104534. }>;
  104535. /**
  104536. * If the attached mesh should be moved when dragged
  104537. */
  104538. moveAttached: boolean;
  104539. /**
  104540. * If the drag behavior will react to drag events (Default: true)
  104541. */
  104542. enabled: boolean;
  104543. /**
  104544. * If pointer events should start and release the drag (Default: true)
  104545. */
  104546. startAndReleaseDragOnPointerEvents: boolean;
  104547. /**
  104548. * If camera controls should be detached during the drag
  104549. */
  104550. detachCameraControls: boolean;
  104551. /**
  104552. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104553. */
  104554. useObjectOrienationForDragging: boolean;
  104555. private _options;
  104556. /**
  104557. * Creates a pointer drag behavior that can be attached to a mesh
  104558. * @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)
  104559. */
  104560. constructor(options?: {
  104561. dragAxis?: Vector3;
  104562. dragPlaneNormal?: Vector3;
  104563. });
  104564. /**
  104565. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104566. */
  104567. validateDrag: (targetPosition: Vector3) => boolean;
  104568. /**
  104569. * The name of the behavior
  104570. */
  104571. readonly name: string;
  104572. /**
  104573. * Initializes the behavior
  104574. */
  104575. init(): void;
  104576. private _tmpVector;
  104577. private _alternatePickedPoint;
  104578. private _worldDragAxis;
  104579. private _targetPosition;
  104580. private _attachedElement;
  104581. /**
  104582. * Attaches the drag behavior the passed in mesh
  104583. * @param ownerNode The mesh that will be dragged around once attached
  104584. * @param predicate Predicate to use for pick filtering
  104585. */
  104586. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104587. /**
  104588. * Force relase the drag action by code.
  104589. */
  104590. releaseDrag(): void;
  104591. private _startDragRay;
  104592. private _lastPointerRay;
  104593. /**
  104594. * Simulates the start of a pointer drag event on the behavior
  104595. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104596. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104597. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104598. */
  104599. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104600. private _startDrag;
  104601. private _dragDelta;
  104602. private _moveDrag;
  104603. private _pickWithRayOnDragPlane;
  104604. private _pointA;
  104605. private _pointB;
  104606. private _pointC;
  104607. private _lineA;
  104608. private _lineB;
  104609. private _localAxis;
  104610. private _lookAt;
  104611. private _updateDragPlanePosition;
  104612. /**
  104613. * Detaches the behavior from the mesh
  104614. */
  104615. detach(): void;
  104616. }
  104617. }
  104618. declare module BABYLON {
  104619. /**
  104620. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104621. */
  104622. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104623. private _dragBehaviorA;
  104624. private _dragBehaviorB;
  104625. private _startDistance;
  104626. private _initialScale;
  104627. private _targetScale;
  104628. private _ownerNode;
  104629. private _sceneRenderObserver;
  104630. /**
  104631. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104632. */
  104633. constructor();
  104634. /**
  104635. * The name of the behavior
  104636. */
  104637. readonly name: string;
  104638. /**
  104639. * Initializes the behavior
  104640. */
  104641. init(): void;
  104642. private _getCurrentDistance;
  104643. /**
  104644. * Attaches the scale behavior the passed in mesh
  104645. * @param ownerNode The mesh that will be scaled around once attached
  104646. */
  104647. attach(ownerNode: Mesh): void;
  104648. /**
  104649. * Detaches the behavior from the mesh
  104650. */
  104651. detach(): void;
  104652. }
  104653. }
  104654. declare module BABYLON {
  104655. /**
  104656. * 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
  104657. */
  104658. export class SixDofDragBehavior implements Behavior<Mesh> {
  104659. private static _virtualScene;
  104660. private _ownerNode;
  104661. private _sceneRenderObserver;
  104662. private _scene;
  104663. private _targetPosition;
  104664. private _virtualOriginMesh;
  104665. private _virtualDragMesh;
  104666. private _pointerObserver;
  104667. private _moving;
  104668. private _startingOrientation;
  104669. /**
  104670. * 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)
  104671. */
  104672. private zDragFactor;
  104673. /**
  104674. * If the object should rotate to face the drag origin
  104675. */
  104676. rotateDraggedObject: boolean;
  104677. /**
  104678. * If the behavior is currently in a dragging state
  104679. */
  104680. dragging: boolean;
  104681. /**
  104682. * 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)
  104683. */
  104684. dragDeltaRatio: number;
  104685. /**
  104686. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104687. */
  104688. currentDraggingPointerID: number;
  104689. /**
  104690. * If camera controls should be detached during the drag
  104691. */
  104692. detachCameraControls: boolean;
  104693. /**
  104694. * Fires each time a drag starts
  104695. */
  104696. onDragStartObservable: Observable<{}>;
  104697. /**
  104698. * Fires each time a drag ends (eg. mouse release after drag)
  104699. */
  104700. onDragEndObservable: Observable<{}>;
  104701. /**
  104702. * 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
  104703. */
  104704. constructor();
  104705. /**
  104706. * The name of the behavior
  104707. */
  104708. readonly name: string;
  104709. /**
  104710. * Initializes the behavior
  104711. */
  104712. init(): void;
  104713. /**
  104714. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104715. */
  104716. private readonly _pointerCamera;
  104717. /**
  104718. * Attaches the scale behavior the passed in mesh
  104719. * @param ownerNode The mesh that will be scaled around once attached
  104720. */
  104721. attach(ownerNode: Mesh): void;
  104722. /**
  104723. * Detaches the behavior from the mesh
  104724. */
  104725. detach(): void;
  104726. }
  104727. }
  104728. declare module BABYLON {
  104729. /**
  104730. * Class used to apply inverse kinematics to bones
  104731. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104732. */
  104733. export class BoneIKController {
  104734. private static _tmpVecs;
  104735. private static _tmpQuat;
  104736. private static _tmpMats;
  104737. /**
  104738. * Gets or sets the target mesh
  104739. */
  104740. targetMesh: AbstractMesh;
  104741. /** Gets or sets the mesh used as pole */
  104742. poleTargetMesh: AbstractMesh;
  104743. /**
  104744. * Gets or sets the bone used as pole
  104745. */
  104746. poleTargetBone: Nullable<Bone>;
  104747. /**
  104748. * Gets or sets the target position
  104749. */
  104750. targetPosition: Vector3;
  104751. /**
  104752. * Gets or sets the pole target position
  104753. */
  104754. poleTargetPosition: Vector3;
  104755. /**
  104756. * Gets or sets the pole target local offset
  104757. */
  104758. poleTargetLocalOffset: Vector3;
  104759. /**
  104760. * Gets or sets the pole angle
  104761. */
  104762. poleAngle: number;
  104763. /**
  104764. * Gets or sets the mesh associated with the controller
  104765. */
  104766. mesh: AbstractMesh;
  104767. /**
  104768. * 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)
  104769. */
  104770. slerpAmount: number;
  104771. private _bone1Quat;
  104772. private _bone1Mat;
  104773. private _bone2Ang;
  104774. private _bone1;
  104775. private _bone2;
  104776. private _bone1Length;
  104777. private _bone2Length;
  104778. private _maxAngle;
  104779. private _maxReach;
  104780. private _rightHandedSystem;
  104781. private _bendAxis;
  104782. private _slerping;
  104783. private _adjustRoll;
  104784. /**
  104785. * Gets or sets maximum allowed angle
  104786. */
  104787. maxAngle: number;
  104788. /**
  104789. * Creates a new BoneIKController
  104790. * @param mesh defines the mesh to control
  104791. * @param bone defines the bone to control
  104792. * @param options defines options to set up the controller
  104793. */
  104794. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104795. targetMesh?: AbstractMesh;
  104796. poleTargetMesh?: AbstractMesh;
  104797. poleTargetBone?: Bone;
  104798. poleTargetLocalOffset?: Vector3;
  104799. poleAngle?: number;
  104800. bendAxis?: Vector3;
  104801. maxAngle?: number;
  104802. slerpAmount?: number;
  104803. });
  104804. private _setMaxAngle;
  104805. /**
  104806. * Force the controller to update the bones
  104807. */
  104808. update(): void;
  104809. }
  104810. }
  104811. declare module BABYLON {
  104812. /**
  104813. * Class used to make a bone look toward a point in space
  104814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104815. */
  104816. export class BoneLookController {
  104817. private static _tmpVecs;
  104818. private static _tmpQuat;
  104819. private static _tmpMats;
  104820. /**
  104821. * The target Vector3 that the bone will look at
  104822. */
  104823. target: Vector3;
  104824. /**
  104825. * The mesh that the bone is attached to
  104826. */
  104827. mesh: AbstractMesh;
  104828. /**
  104829. * The bone that will be looking to the target
  104830. */
  104831. bone: Bone;
  104832. /**
  104833. * The up axis of the coordinate system that is used when the bone is rotated
  104834. */
  104835. upAxis: Vector3;
  104836. /**
  104837. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104838. */
  104839. upAxisSpace: Space;
  104840. /**
  104841. * Used to make an adjustment to the yaw of the bone
  104842. */
  104843. adjustYaw: number;
  104844. /**
  104845. * Used to make an adjustment to the pitch of the bone
  104846. */
  104847. adjustPitch: number;
  104848. /**
  104849. * Used to make an adjustment to the roll of the bone
  104850. */
  104851. adjustRoll: number;
  104852. /**
  104853. * 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)
  104854. */
  104855. slerpAmount: number;
  104856. private _minYaw;
  104857. private _maxYaw;
  104858. private _minPitch;
  104859. private _maxPitch;
  104860. private _minYawSin;
  104861. private _minYawCos;
  104862. private _maxYawSin;
  104863. private _maxYawCos;
  104864. private _midYawConstraint;
  104865. private _minPitchTan;
  104866. private _maxPitchTan;
  104867. private _boneQuat;
  104868. private _slerping;
  104869. private _transformYawPitch;
  104870. private _transformYawPitchInv;
  104871. private _firstFrameSkipped;
  104872. private _yawRange;
  104873. private _fowardAxis;
  104874. /**
  104875. * Gets or sets the minimum yaw angle that the bone can look to
  104876. */
  104877. minYaw: number;
  104878. /**
  104879. * Gets or sets the maximum yaw angle that the bone can look to
  104880. */
  104881. maxYaw: number;
  104882. /**
  104883. * Gets or sets the minimum pitch angle that the bone can look to
  104884. */
  104885. minPitch: number;
  104886. /**
  104887. * Gets or sets the maximum pitch angle that the bone can look to
  104888. */
  104889. maxPitch: number;
  104890. /**
  104891. * Create a BoneLookController
  104892. * @param mesh the mesh that the bone belongs to
  104893. * @param bone the bone that will be looking to the target
  104894. * @param target the target Vector3 to look at
  104895. * @param options optional settings:
  104896. * * maxYaw: the maximum angle the bone will yaw to
  104897. * * minYaw: the minimum angle the bone will yaw to
  104898. * * maxPitch: the maximum angle the bone will pitch to
  104899. * * minPitch: the minimum angle the bone will yaw to
  104900. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104901. * * upAxis: the up axis of the coordinate system
  104902. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104903. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104904. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104905. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104906. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104907. * * adjustRoll: used to make an adjustment to the roll of the bone
  104908. **/
  104909. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104910. maxYaw?: number;
  104911. minYaw?: number;
  104912. maxPitch?: number;
  104913. minPitch?: number;
  104914. slerpAmount?: number;
  104915. upAxis?: Vector3;
  104916. upAxisSpace?: Space;
  104917. yawAxis?: Vector3;
  104918. pitchAxis?: Vector3;
  104919. adjustYaw?: number;
  104920. adjustPitch?: number;
  104921. adjustRoll?: number;
  104922. });
  104923. /**
  104924. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104925. */
  104926. update(): void;
  104927. private _getAngleDiff;
  104928. private _getAngleBetween;
  104929. private _isAngleBetween;
  104930. }
  104931. }
  104932. declare module BABYLON {
  104933. /**
  104934. * Manage the gamepad inputs to control an arc rotate camera.
  104935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104936. */
  104937. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104938. /**
  104939. * Defines the camera the input is attached to.
  104940. */
  104941. camera: ArcRotateCamera;
  104942. /**
  104943. * Defines the gamepad the input is gathering event from.
  104944. */
  104945. gamepad: Nullable<Gamepad>;
  104946. /**
  104947. * Defines the gamepad rotation sensiblity.
  104948. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104949. */
  104950. gamepadRotationSensibility: number;
  104951. /**
  104952. * Defines the gamepad move sensiblity.
  104953. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104954. */
  104955. gamepadMoveSensibility: number;
  104956. private _yAxisScale;
  104957. /**
  104958. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104959. */
  104960. invertYAxis: boolean;
  104961. private _onGamepadConnectedObserver;
  104962. private _onGamepadDisconnectedObserver;
  104963. /**
  104964. * Attach the input controls to a specific dom element to get the input from.
  104965. * @param element Defines the element the controls should be listened from
  104966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104967. */
  104968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104969. /**
  104970. * Detach the current controls from the specified dom element.
  104971. * @param element Defines the element to stop listening the inputs from
  104972. */
  104973. detachControl(element: Nullable<HTMLElement>): void;
  104974. /**
  104975. * Update the current camera state depending on the inputs that have been used this frame.
  104976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104977. */
  104978. checkInputs(): void;
  104979. /**
  104980. * Gets the class name of the current intput.
  104981. * @returns the class name
  104982. */
  104983. getClassName(): string;
  104984. /**
  104985. * Get the friendly name associated with the input class.
  104986. * @returns the input friendly name
  104987. */
  104988. getSimpleName(): string;
  104989. }
  104990. }
  104991. declare module BABYLON {
  104992. interface ArcRotateCameraInputsManager {
  104993. /**
  104994. * Add orientation input support to the input manager.
  104995. * @returns the current input manager
  104996. */
  104997. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104998. }
  104999. /**
  105000. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105002. */
  105003. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105004. /**
  105005. * Defines the camera the input is attached to.
  105006. */
  105007. camera: ArcRotateCamera;
  105008. /**
  105009. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105010. */
  105011. alphaCorrection: number;
  105012. /**
  105013. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105014. */
  105015. gammaCorrection: number;
  105016. private _alpha;
  105017. private _gamma;
  105018. private _dirty;
  105019. private _deviceOrientationHandler;
  105020. /**
  105021. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105022. */
  105023. constructor();
  105024. /**
  105025. * Attach the input controls to a specific dom element to get the input from.
  105026. * @param element Defines the element the controls should be listened from
  105027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105028. */
  105029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105030. /** @hidden */
  105031. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105032. /**
  105033. * Update the current camera state depending on the inputs that have been used this frame.
  105034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105035. */
  105036. checkInputs(): void;
  105037. /**
  105038. * Detach the current controls from the specified dom element.
  105039. * @param element Defines the element to stop listening the inputs from
  105040. */
  105041. detachControl(element: Nullable<HTMLElement>): void;
  105042. /**
  105043. * Gets the class name of the current intput.
  105044. * @returns the class name
  105045. */
  105046. getClassName(): string;
  105047. /**
  105048. * Get the friendly name associated with the input class.
  105049. * @returns the input friendly name
  105050. */
  105051. getSimpleName(): string;
  105052. }
  105053. }
  105054. declare module BABYLON {
  105055. /**
  105056. * Listen to mouse events to control the camera.
  105057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105058. */
  105059. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105060. /**
  105061. * Defines the camera the input is attached to.
  105062. */
  105063. camera: FlyCamera;
  105064. /**
  105065. * Defines if touch is enabled. (Default is true.)
  105066. */
  105067. touchEnabled: boolean;
  105068. /**
  105069. * Defines the buttons associated with the input to handle camera rotation.
  105070. */
  105071. buttons: number[];
  105072. /**
  105073. * Assign buttons for Yaw control.
  105074. */
  105075. buttonsYaw: number[];
  105076. /**
  105077. * Assign buttons for Pitch control.
  105078. */
  105079. buttonsPitch: number[];
  105080. /**
  105081. * Assign buttons for Roll control.
  105082. */
  105083. buttonsRoll: number[];
  105084. /**
  105085. * Detect if any button is being pressed while mouse is moved.
  105086. * -1 = Mouse locked.
  105087. * 0 = Left button.
  105088. * 1 = Middle Button.
  105089. * 2 = Right Button.
  105090. */
  105091. activeButton: number;
  105092. /**
  105093. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105094. * Higher values reduce its sensitivity.
  105095. */
  105096. angularSensibility: number;
  105097. private _mousemoveCallback;
  105098. private _observer;
  105099. private _rollObserver;
  105100. private previousPosition;
  105101. private noPreventDefault;
  105102. private element;
  105103. /**
  105104. * Listen to mouse events to control the camera.
  105105. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105107. */
  105108. constructor(touchEnabled?: boolean);
  105109. /**
  105110. * Attach the mouse control to the HTML DOM element.
  105111. * @param element Defines the element that listens to the input events.
  105112. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105113. */
  105114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105115. /**
  105116. * Detach the current controls from the specified dom element.
  105117. * @param element Defines the element to stop listening the inputs from
  105118. */
  105119. detachControl(element: Nullable<HTMLElement>): void;
  105120. /**
  105121. * Gets the class name of the current input.
  105122. * @returns the class name.
  105123. */
  105124. getClassName(): string;
  105125. /**
  105126. * Get the friendly name associated with the input class.
  105127. * @returns the input's friendly name.
  105128. */
  105129. getSimpleName(): string;
  105130. private _pointerInput;
  105131. private _onMouseMove;
  105132. /**
  105133. * Rotate camera by mouse offset.
  105134. */
  105135. private rotateCamera;
  105136. }
  105137. }
  105138. declare module BABYLON {
  105139. /**
  105140. * Default Inputs manager for the FlyCamera.
  105141. * It groups all the default supported inputs for ease of use.
  105142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105143. */
  105144. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105145. /**
  105146. * Instantiates a new FlyCameraInputsManager.
  105147. * @param camera Defines the camera the inputs belong to.
  105148. */
  105149. constructor(camera: FlyCamera);
  105150. /**
  105151. * Add keyboard input support to the input manager.
  105152. * @returns the new FlyCameraKeyboardMoveInput().
  105153. */
  105154. addKeyboard(): FlyCameraInputsManager;
  105155. /**
  105156. * Add mouse input support to the input manager.
  105157. * @param touchEnabled Enable touch screen support.
  105158. * @returns the new FlyCameraMouseInput().
  105159. */
  105160. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105161. }
  105162. }
  105163. declare module BABYLON {
  105164. /**
  105165. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105166. * such as in a 3D Space Shooter or a Flight Simulator.
  105167. */
  105168. export class FlyCamera extends TargetCamera {
  105169. /**
  105170. * Define the collision ellipsoid of the camera.
  105171. * This is helpful for simulating a camera body, like a player's body.
  105172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105173. */
  105174. ellipsoid: Vector3;
  105175. /**
  105176. * Define an offset for the position of the ellipsoid around the camera.
  105177. * This can be helpful if the camera is attached away from the player's body center,
  105178. * such as at its head.
  105179. */
  105180. ellipsoidOffset: Vector3;
  105181. /**
  105182. * Enable or disable collisions of the camera with the rest of the scene objects.
  105183. */
  105184. checkCollisions: boolean;
  105185. /**
  105186. * Enable or disable gravity on the camera.
  105187. */
  105188. applyGravity: boolean;
  105189. /**
  105190. * Define the current direction the camera is moving to.
  105191. */
  105192. cameraDirection: Vector3;
  105193. /**
  105194. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105195. * This overrides and empties cameraRotation.
  105196. */
  105197. rotationQuaternion: Quaternion;
  105198. /**
  105199. * Track Roll to maintain the wanted Rolling when looking around.
  105200. */
  105201. _trackRoll: number;
  105202. /**
  105203. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105204. */
  105205. rollCorrect: number;
  105206. /**
  105207. * Mimic a banked turn, Rolling the camera when Yawing.
  105208. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105209. */
  105210. bankedTurn: boolean;
  105211. /**
  105212. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105213. */
  105214. bankedTurnLimit: number;
  105215. /**
  105216. * Value of 0 disables the banked Roll.
  105217. * Value of 1 is equal to the Yaw angle in radians.
  105218. */
  105219. bankedTurnMultiplier: number;
  105220. /**
  105221. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105222. */
  105223. inputs: FlyCameraInputsManager;
  105224. /**
  105225. * Gets the input sensibility for mouse input.
  105226. * Higher values reduce sensitivity.
  105227. */
  105228. /**
  105229. * Sets the input sensibility for a mouse input.
  105230. * Higher values reduce sensitivity.
  105231. */
  105232. angularSensibility: number;
  105233. /**
  105234. * Get the keys for camera movement forward.
  105235. */
  105236. /**
  105237. * Set the keys for camera movement forward.
  105238. */
  105239. keysForward: number[];
  105240. /**
  105241. * Get the keys for camera movement backward.
  105242. */
  105243. keysBackward: number[];
  105244. /**
  105245. * Get the keys for camera movement up.
  105246. */
  105247. /**
  105248. * Set the keys for camera movement up.
  105249. */
  105250. keysUp: number[];
  105251. /**
  105252. * Get the keys for camera movement down.
  105253. */
  105254. /**
  105255. * Set the keys for camera movement down.
  105256. */
  105257. keysDown: number[];
  105258. /**
  105259. * Get the keys for camera movement left.
  105260. */
  105261. /**
  105262. * Set the keys for camera movement left.
  105263. */
  105264. keysLeft: number[];
  105265. /**
  105266. * Set the keys for camera movement right.
  105267. */
  105268. /**
  105269. * Set the keys for camera movement right.
  105270. */
  105271. keysRight: number[];
  105272. /**
  105273. * Event raised when the camera collides with a mesh in the scene.
  105274. */
  105275. onCollide: (collidedMesh: AbstractMesh) => void;
  105276. private _collider;
  105277. private _needMoveForGravity;
  105278. private _oldPosition;
  105279. private _diffPosition;
  105280. private _newPosition;
  105281. /** @hidden */
  105282. _localDirection: Vector3;
  105283. /** @hidden */
  105284. _transformedDirection: Vector3;
  105285. /**
  105286. * Instantiates a FlyCamera.
  105287. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105288. * such as in a 3D Space Shooter or a Flight Simulator.
  105289. * @param name Define the name of the camera in the scene.
  105290. * @param position Define the starting position of the camera in the scene.
  105291. * @param scene Define the scene the camera belongs to.
  105292. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105293. */
  105294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105295. /**
  105296. * Attach a control to the HTML DOM element.
  105297. * @param element Defines the element that listens to the input events.
  105298. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105299. */
  105300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105301. /**
  105302. * Detach a control from the HTML DOM element.
  105303. * The camera will stop reacting to that input.
  105304. * @param element Defines the element that listens to the input events.
  105305. */
  105306. detachControl(element: HTMLElement): void;
  105307. private _collisionMask;
  105308. /**
  105309. * Get the mask that the camera ignores in collision events.
  105310. */
  105311. /**
  105312. * Set the mask that the camera ignores in collision events.
  105313. */
  105314. collisionMask: number;
  105315. /** @hidden */
  105316. _collideWithWorld(displacement: Vector3): void;
  105317. /** @hidden */
  105318. private _onCollisionPositionChange;
  105319. /** @hidden */
  105320. _checkInputs(): void;
  105321. /** @hidden */
  105322. _decideIfNeedsToMove(): boolean;
  105323. /** @hidden */
  105324. _updatePosition(): void;
  105325. /**
  105326. * Restore the Roll to its target value at the rate specified.
  105327. * @param rate - Higher means slower restoring.
  105328. * @hidden
  105329. */
  105330. restoreRoll(rate: number): void;
  105331. /**
  105332. * Destroy the camera and release the current resources held by it.
  105333. */
  105334. dispose(): void;
  105335. /**
  105336. * Get the current object class name.
  105337. * @returns the class name.
  105338. */
  105339. getClassName(): string;
  105340. }
  105341. }
  105342. declare module BABYLON {
  105343. /**
  105344. * Listen to keyboard events to control the camera.
  105345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105346. */
  105347. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105348. /**
  105349. * Defines the camera the input is attached to.
  105350. */
  105351. camera: FlyCamera;
  105352. /**
  105353. * The list of keyboard keys used to control the forward move of the camera.
  105354. */
  105355. keysForward: number[];
  105356. /**
  105357. * The list of keyboard keys used to control the backward move of the camera.
  105358. */
  105359. keysBackward: number[];
  105360. /**
  105361. * The list of keyboard keys used to control the forward move of the camera.
  105362. */
  105363. keysUp: number[];
  105364. /**
  105365. * The list of keyboard keys used to control the backward move of the camera.
  105366. */
  105367. keysDown: number[];
  105368. /**
  105369. * The list of keyboard keys used to control the right strafe move of the camera.
  105370. */
  105371. keysRight: number[];
  105372. /**
  105373. * The list of keyboard keys used to control the left strafe move of the camera.
  105374. */
  105375. keysLeft: number[];
  105376. private _keys;
  105377. private _onCanvasBlurObserver;
  105378. private _onKeyboardObserver;
  105379. private _engine;
  105380. private _scene;
  105381. /**
  105382. * Attach the input controls to a specific dom element to get the input from.
  105383. * @param element Defines the element the controls should be listened from
  105384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105385. */
  105386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105387. /**
  105388. * Detach the current controls from the specified dom element.
  105389. * @param element Defines the element to stop listening the inputs from
  105390. */
  105391. detachControl(element: Nullable<HTMLElement>): void;
  105392. /**
  105393. * Gets the class name of the current intput.
  105394. * @returns the class name
  105395. */
  105396. getClassName(): string;
  105397. /** @hidden */
  105398. _onLostFocus(e: FocusEvent): void;
  105399. /**
  105400. * Get the friendly name associated with the input class.
  105401. * @returns the input friendly name
  105402. */
  105403. getSimpleName(): string;
  105404. /**
  105405. * Update the current camera state depending on the inputs that have been used this frame.
  105406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105407. */
  105408. checkInputs(): void;
  105409. }
  105410. }
  105411. declare module BABYLON {
  105412. /**
  105413. * Manage the mouse wheel inputs to control a follow camera.
  105414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105415. */
  105416. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105417. /**
  105418. * Defines the camera the input is attached to.
  105419. */
  105420. camera: FollowCamera;
  105421. /**
  105422. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105423. */
  105424. axisControlRadius: boolean;
  105425. /**
  105426. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105427. */
  105428. axisControlHeight: boolean;
  105429. /**
  105430. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105431. */
  105432. axisControlRotation: boolean;
  105433. /**
  105434. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105435. * relation to mouseWheel events.
  105436. */
  105437. wheelPrecision: number;
  105438. /**
  105439. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105440. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105441. */
  105442. wheelDeltaPercentage: number;
  105443. private _wheel;
  105444. private _observer;
  105445. /**
  105446. * Attach the input controls to a specific dom element to get the input from.
  105447. * @param element Defines the element the controls should be listened from
  105448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105449. */
  105450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105451. /**
  105452. * Detach the current controls from the specified dom element.
  105453. * @param element Defines the element to stop listening the inputs from
  105454. */
  105455. detachControl(element: Nullable<HTMLElement>): void;
  105456. /**
  105457. * Gets the class name of the current intput.
  105458. * @returns the class name
  105459. */
  105460. getClassName(): string;
  105461. /**
  105462. * Get the friendly name associated with the input class.
  105463. * @returns the input friendly name
  105464. */
  105465. getSimpleName(): string;
  105466. }
  105467. }
  105468. declare module BABYLON {
  105469. /**
  105470. * Manage the pointers inputs to control an follow camera.
  105471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105472. */
  105473. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105474. /**
  105475. * Defines the camera the input is attached to.
  105476. */
  105477. camera: FollowCamera;
  105478. /**
  105479. * Gets the class name of the current input.
  105480. * @returns the class name
  105481. */
  105482. getClassName(): string;
  105483. /**
  105484. * Defines the pointer angular sensibility along the X axis or how fast is
  105485. * the camera rotating.
  105486. * A negative number will reverse the axis direction.
  105487. */
  105488. angularSensibilityX: number;
  105489. /**
  105490. * Defines the pointer angular sensibility along the Y axis or how fast is
  105491. * the camera rotating.
  105492. * A negative number will reverse the axis direction.
  105493. */
  105494. angularSensibilityY: number;
  105495. /**
  105496. * Defines the pointer pinch precision or how fast is the camera zooming.
  105497. * A negative number will reverse the axis direction.
  105498. */
  105499. pinchPrecision: number;
  105500. /**
  105501. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105502. * from 0.
  105503. * It defines the percentage of current camera.radius to use as delta when
  105504. * pinch zoom is used.
  105505. */
  105506. pinchDeltaPercentage: number;
  105507. /**
  105508. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105509. */
  105510. axisXControlRadius: boolean;
  105511. /**
  105512. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105513. */
  105514. axisXControlHeight: boolean;
  105515. /**
  105516. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105517. */
  105518. axisXControlRotation: boolean;
  105519. /**
  105520. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105521. */
  105522. axisYControlRadius: boolean;
  105523. /**
  105524. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105525. */
  105526. axisYControlHeight: boolean;
  105527. /**
  105528. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105529. */
  105530. axisYControlRotation: boolean;
  105531. /**
  105532. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105533. */
  105534. axisPinchControlRadius: boolean;
  105535. /**
  105536. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105537. */
  105538. axisPinchControlHeight: boolean;
  105539. /**
  105540. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105541. */
  105542. axisPinchControlRotation: boolean;
  105543. /**
  105544. * Log error messages if basic misconfiguration has occurred.
  105545. */
  105546. warningEnable: boolean;
  105547. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105548. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105549. private _warningCounter;
  105550. private _warning;
  105551. }
  105552. }
  105553. declare module BABYLON {
  105554. /**
  105555. * Default Inputs manager for the FollowCamera.
  105556. * It groups all the default supported inputs for ease of use.
  105557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105558. */
  105559. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105560. /**
  105561. * Instantiates a new FollowCameraInputsManager.
  105562. * @param camera Defines the camera the inputs belong to
  105563. */
  105564. constructor(camera: FollowCamera);
  105565. /**
  105566. * Add keyboard input support to the input manager.
  105567. * @returns the current input manager
  105568. */
  105569. addKeyboard(): FollowCameraInputsManager;
  105570. /**
  105571. * Add mouse wheel input support to the input manager.
  105572. * @returns the current input manager
  105573. */
  105574. addMouseWheel(): FollowCameraInputsManager;
  105575. /**
  105576. * Add pointers input support to the input manager.
  105577. * @returns the current input manager
  105578. */
  105579. addPointers(): FollowCameraInputsManager;
  105580. /**
  105581. * Add orientation input support to the input manager.
  105582. * @returns the current input manager
  105583. */
  105584. addVRDeviceOrientation(): FollowCameraInputsManager;
  105585. }
  105586. }
  105587. declare module BABYLON {
  105588. /**
  105589. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105590. * an arc rotate version arcFollowCamera are available.
  105591. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105592. */
  105593. export class FollowCamera extends TargetCamera {
  105594. /**
  105595. * Distance the follow camera should follow an object at
  105596. */
  105597. radius: number;
  105598. /**
  105599. * Minimum allowed distance of the camera to the axis of rotation
  105600. * (The camera can not get closer).
  105601. * This can help limiting how the Camera is able to move in the scene.
  105602. */
  105603. lowerRadiusLimit: Nullable<number>;
  105604. /**
  105605. * Maximum allowed distance of the camera to the axis of rotation
  105606. * (The camera can not get further).
  105607. * This can help limiting how the Camera is able to move in the scene.
  105608. */
  105609. upperRadiusLimit: Nullable<number>;
  105610. /**
  105611. * Define a rotation offset between the camera and the object it follows
  105612. */
  105613. rotationOffset: number;
  105614. /**
  105615. * Minimum allowed angle to camera position relative to target object.
  105616. * This can help limiting how the Camera is able to move in the scene.
  105617. */
  105618. lowerRotationOffsetLimit: Nullable<number>;
  105619. /**
  105620. * Maximum allowed angle to camera position relative to target object.
  105621. * This can help limiting how the Camera is able to move in the scene.
  105622. */
  105623. upperRotationOffsetLimit: Nullable<number>;
  105624. /**
  105625. * Define a height offset between the camera and the object it follows.
  105626. * It can help following an object from the top (like a car chaing a plane)
  105627. */
  105628. heightOffset: number;
  105629. /**
  105630. * Minimum allowed height of camera position relative to target object.
  105631. * This can help limiting how the Camera is able to move in the scene.
  105632. */
  105633. lowerHeightOffsetLimit: Nullable<number>;
  105634. /**
  105635. * Maximum allowed height of camera position relative to target object.
  105636. * This can help limiting how the Camera is able to move in the scene.
  105637. */
  105638. upperHeightOffsetLimit: Nullable<number>;
  105639. /**
  105640. * Define how fast the camera can accelerate to follow it s target.
  105641. */
  105642. cameraAcceleration: number;
  105643. /**
  105644. * Define the speed limit of the camera following an object.
  105645. */
  105646. maxCameraSpeed: number;
  105647. /**
  105648. * Define the target of the camera.
  105649. */
  105650. lockedTarget: Nullable<AbstractMesh>;
  105651. /**
  105652. * Defines the input associated with the camera.
  105653. */
  105654. inputs: FollowCameraInputsManager;
  105655. /**
  105656. * Instantiates the follow camera.
  105657. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105658. * @param name Define the name of the camera in the scene
  105659. * @param position Define the position of the camera
  105660. * @param scene Define the scene the camera belong to
  105661. * @param lockedTarget Define the target of the camera
  105662. */
  105663. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105664. private _follow;
  105665. /**
  105666. * Attached controls to the current camera.
  105667. * @param element Defines the element the controls should be listened from
  105668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105669. */
  105670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105671. /**
  105672. * Detach the current controls from the camera.
  105673. * The camera will stop reacting to inputs.
  105674. * @param element Defines the element to stop listening the inputs from
  105675. */
  105676. detachControl(element: HTMLElement): void;
  105677. /** @hidden */
  105678. _checkInputs(): void;
  105679. private _checkLimits;
  105680. /**
  105681. * Gets the camera class name.
  105682. * @returns the class name
  105683. */
  105684. getClassName(): string;
  105685. }
  105686. /**
  105687. * Arc Rotate version of the follow camera.
  105688. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105690. */
  105691. export class ArcFollowCamera extends TargetCamera {
  105692. /** The longitudinal angle of the camera */
  105693. alpha: number;
  105694. /** The latitudinal angle of the camera */
  105695. beta: number;
  105696. /** The radius of the camera from its target */
  105697. radius: number;
  105698. /** Define the camera target (the messh it should follow) */
  105699. target: Nullable<AbstractMesh>;
  105700. private _cartesianCoordinates;
  105701. /**
  105702. * Instantiates a new ArcFollowCamera
  105703. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105704. * @param name Define the name of the camera
  105705. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105706. * @param beta Define the rotation angle of the camera around the elevation axis
  105707. * @param radius Define the radius of the camera from its target point
  105708. * @param target Define the target of the camera
  105709. * @param scene Define the scene the camera belongs to
  105710. */
  105711. constructor(name: string,
  105712. /** The longitudinal angle of the camera */
  105713. alpha: number,
  105714. /** The latitudinal angle of the camera */
  105715. beta: number,
  105716. /** The radius of the camera from its target */
  105717. radius: number,
  105718. /** Define the camera target (the messh it should follow) */
  105719. target: Nullable<AbstractMesh>, scene: Scene);
  105720. private _follow;
  105721. /** @hidden */
  105722. _checkInputs(): void;
  105723. /**
  105724. * Returns the class name of the object.
  105725. * It is mostly used internally for serialization purposes.
  105726. */
  105727. getClassName(): string;
  105728. }
  105729. }
  105730. declare module BABYLON {
  105731. /**
  105732. * Manage the keyboard inputs to control the movement of a follow camera.
  105733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105734. */
  105735. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105736. /**
  105737. * Defines the camera the input is attached to.
  105738. */
  105739. camera: FollowCamera;
  105740. /**
  105741. * Defines the list of key codes associated with the up action (increase heightOffset)
  105742. */
  105743. keysHeightOffsetIncr: number[];
  105744. /**
  105745. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105746. */
  105747. keysHeightOffsetDecr: number[];
  105748. /**
  105749. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105750. */
  105751. keysHeightOffsetModifierAlt: boolean;
  105752. /**
  105753. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105754. */
  105755. keysHeightOffsetModifierCtrl: boolean;
  105756. /**
  105757. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105758. */
  105759. keysHeightOffsetModifierShift: boolean;
  105760. /**
  105761. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105762. */
  105763. keysRotationOffsetIncr: number[];
  105764. /**
  105765. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105766. */
  105767. keysRotationOffsetDecr: number[];
  105768. /**
  105769. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105770. */
  105771. keysRotationOffsetModifierAlt: boolean;
  105772. /**
  105773. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105774. */
  105775. keysRotationOffsetModifierCtrl: boolean;
  105776. /**
  105777. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105778. */
  105779. keysRotationOffsetModifierShift: boolean;
  105780. /**
  105781. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105782. */
  105783. keysRadiusIncr: number[];
  105784. /**
  105785. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105786. */
  105787. keysRadiusDecr: number[];
  105788. /**
  105789. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105790. */
  105791. keysRadiusModifierAlt: boolean;
  105792. /**
  105793. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105794. */
  105795. keysRadiusModifierCtrl: boolean;
  105796. /**
  105797. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105798. */
  105799. keysRadiusModifierShift: boolean;
  105800. /**
  105801. * Defines the rate of change of heightOffset.
  105802. */
  105803. heightSensibility: number;
  105804. /**
  105805. * Defines the rate of change of rotationOffset.
  105806. */
  105807. rotationSensibility: number;
  105808. /**
  105809. * Defines the rate of change of radius.
  105810. */
  105811. radiusSensibility: number;
  105812. private _keys;
  105813. private _ctrlPressed;
  105814. private _altPressed;
  105815. private _shiftPressed;
  105816. private _onCanvasBlurObserver;
  105817. private _onKeyboardObserver;
  105818. private _engine;
  105819. private _scene;
  105820. /**
  105821. * Attach the input controls to a specific dom element to get the input from.
  105822. * @param element Defines the element the controls should be listened from
  105823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105824. */
  105825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105826. /**
  105827. * Detach the current controls from the specified dom element.
  105828. * @param element Defines the element to stop listening the inputs from
  105829. */
  105830. detachControl(element: Nullable<HTMLElement>): void;
  105831. /**
  105832. * Update the current camera state depending on the inputs that have been used this frame.
  105833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105834. */
  105835. checkInputs(): void;
  105836. /**
  105837. * Gets the class name of the current input.
  105838. * @returns the class name
  105839. */
  105840. getClassName(): string;
  105841. /**
  105842. * Get the friendly name associated with the input class.
  105843. * @returns the input friendly name
  105844. */
  105845. getSimpleName(): string;
  105846. /**
  105847. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105848. * allow modification of the heightOffset value.
  105849. */
  105850. private _modifierHeightOffset;
  105851. /**
  105852. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105853. * allow modification of the rotationOffset value.
  105854. */
  105855. private _modifierRotationOffset;
  105856. /**
  105857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105858. * allow modification of the radius value.
  105859. */
  105860. private _modifierRadius;
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. interface FreeCameraInputsManager {
  105865. /**
  105866. * @hidden
  105867. */
  105868. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105869. /**
  105870. * Add orientation input support to the input manager.
  105871. * @returns the current input manager
  105872. */
  105873. addDeviceOrientation(): FreeCameraInputsManager;
  105874. }
  105875. /**
  105876. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105877. * Screen rotation is taken into account.
  105878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105879. */
  105880. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105881. private _camera;
  105882. private _screenOrientationAngle;
  105883. private _constantTranform;
  105884. private _screenQuaternion;
  105885. private _alpha;
  105886. private _beta;
  105887. private _gamma;
  105888. /**
  105889. * Can be used to detect if a device orientation sensor is availible on a device
  105890. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105891. * @returns a promise that will resolve on orientation change
  105892. */
  105893. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105894. /**
  105895. * @hidden
  105896. */
  105897. _onDeviceOrientationChangedObservable: Observable<void>;
  105898. /**
  105899. * Instantiates a new input
  105900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105901. */
  105902. constructor();
  105903. /**
  105904. * Define the camera controlled by the input.
  105905. */
  105906. camera: FreeCamera;
  105907. /**
  105908. * Attach the input controls to a specific dom element to get the input from.
  105909. * @param element Defines the element the controls should be listened from
  105910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105911. */
  105912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105913. private _orientationChanged;
  105914. private _deviceOrientation;
  105915. /**
  105916. * Detach the current controls from the specified dom element.
  105917. * @param element Defines the element to stop listening the inputs from
  105918. */
  105919. detachControl(element: Nullable<HTMLElement>): void;
  105920. /**
  105921. * Update the current camera state depending on the inputs that have been used this frame.
  105922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105923. */
  105924. checkInputs(): void;
  105925. /**
  105926. * Gets the class name of the current intput.
  105927. * @returns the class name
  105928. */
  105929. getClassName(): string;
  105930. /**
  105931. * Get the friendly name associated with the input class.
  105932. * @returns the input friendly name
  105933. */
  105934. getSimpleName(): string;
  105935. }
  105936. }
  105937. declare module BABYLON {
  105938. /**
  105939. * Manage the gamepad inputs to control a free camera.
  105940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105941. */
  105942. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105943. /**
  105944. * Define the camera the input is attached to.
  105945. */
  105946. camera: FreeCamera;
  105947. /**
  105948. * Define the Gamepad controlling the input
  105949. */
  105950. gamepad: Nullable<Gamepad>;
  105951. /**
  105952. * Defines the gamepad rotation sensiblity.
  105953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105954. */
  105955. gamepadAngularSensibility: number;
  105956. /**
  105957. * Defines the gamepad move sensiblity.
  105958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105959. */
  105960. gamepadMoveSensibility: number;
  105961. private _yAxisScale;
  105962. /**
  105963. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105964. */
  105965. invertYAxis: boolean;
  105966. private _onGamepadConnectedObserver;
  105967. private _onGamepadDisconnectedObserver;
  105968. private _cameraTransform;
  105969. private _deltaTransform;
  105970. private _vector3;
  105971. private _vector2;
  105972. /**
  105973. * Attach the input controls to a specific dom element to get the input from.
  105974. * @param element Defines the element the controls should be listened from
  105975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105976. */
  105977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105978. /**
  105979. * Detach the current controls from the specified dom element.
  105980. * @param element Defines the element to stop listening the inputs from
  105981. */
  105982. detachControl(element: Nullable<HTMLElement>): void;
  105983. /**
  105984. * Update the current camera state depending on the inputs that have been used this frame.
  105985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105986. */
  105987. checkInputs(): void;
  105988. /**
  105989. * Gets the class name of the current intput.
  105990. * @returns the class name
  105991. */
  105992. getClassName(): string;
  105993. /**
  105994. * Get the friendly name associated with the input class.
  105995. * @returns the input friendly name
  105996. */
  105997. getSimpleName(): string;
  105998. }
  105999. }
  106000. declare module BABYLON {
  106001. /**
  106002. * Defines the potential axis of a Joystick
  106003. */
  106004. export enum JoystickAxis {
  106005. /** X axis */
  106006. X = 0,
  106007. /** Y axis */
  106008. Y = 1,
  106009. /** Z axis */
  106010. Z = 2
  106011. }
  106012. /**
  106013. * Class used to define virtual joystick (used in touch mode)
  106014. */
  106015. export class VirtualJoystick {
  106016. /**
  106017. * Gets or sets a boolean indicating that left and right values must be inverted
  106018. */
  106019. reverseLeftRight: boolean;
  106020. /**
  106021. * Gets or sets a boolean indicating that up and down values must be inverted
  106022. */
  106023. reverseUpDown: boolean;
  106024. /**
  106025. * Gets the offset value for the position (ie. the change of the position value)
  106026. */
  106027. deltaPosition: Vector3;
  106028. /**
  106029. * Gets a boolean indicating if the virtual joystick was pressed
  106030. */
  106031. pressed: boolean;
  106032. /**
  106033. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106034. */
  106035. static Canvas: Nullable<HTMLCanvasElement>;
  106036. private static _globalJoystickIndex;
  106037. private static vjCanvasContext;
  106038. private static vjCanvasWidth;
  106039. private static vjCanvasHeight;
  106040. private static halfWidth;
  106041. private _action;
  106042. private _axisTargetedByLeftAndRight;
  106043. private _axisTargetedByUpAndDown;
  106044. private _joystickSensibility;
  106045. private _inversedSensibility;
  106046. private _joystickPointerID;
  106047. private _joystickColor;
  106048. private _joystickPointerPos;
  106049. private _joystickPreviousPointerPos;
  106050. private _joystickPointerStartPos;
  106051. private _deltaJoystickVector;
  106052. private _leftJoystick;
  106053. private _touches;
  106054. private _onPointerDownHandlerRef;
  106055. private _onPointerMoveHandlerRef;
  106056. private _onPointerUpHandlerRef;
  106057. private _onResize;
  106058. /**
  106059. * Creates a new virtual joystick
  106060. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106061. */
  106062. constructor(leftJoystick?: boolean);
  106063. /**
  106064. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106065. * @param newJoystickSensibility defines the new sensibility
  106066. */
  106067. setJoystickSensibility(newJoystickSensibility: number): void;
  106068. private _onPointerDown;
  106069. private _onPointerMove;
  106070. private _onPointerUp;
  106071. /**
  106072. * Change the color of the virtual joystick
  106073. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106074. */
  106075. setJoystickColor(newColor: string): void;
  106076. /**
  106077. * Defines a callback to call when the joystick is touched
  106078. * @param action defines the callback
  106079. */
  106080. setActionOnTouch(action: () => any): void;
  106081. /**
  106082. * Defines which axis you'd like to control for left & right
  106083. * @param axis defines the axis to use
  106084. */
  106085. setAxisForLeftRight(axis: JoystickAxis): void;
  106086. /**
  106087. * Defines which axis you'd like to control for up & down
  106088. * @param axis defines the axis to use
  106089. */
  106090. setAxisForUpDown(axis: JoystickAxis): void;
  106091. private _drawVirtualJoystick;
  106092. /**
  106093. * Release internal HTML canvas
  106094. */
  106095. releaseCanvas(): void;
  106096. }
  106097. }
  106098. declare module BABYLON {
  106099. interface FreeCameraInputsManager {
  106100. /**
  106101. * Add virtual joystick input support to the input manager.
  106102. * @returns the current input manager
  106103. */
  106104. addVirtualJoystick(): FreeCameraInputsManager;
  106105. }
  106106. /**
  106107. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106109. */
  106110. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106111. /**
  106112. * Defines the camera the input is attached to.
  106113. */
  106114. camera: FreeCamera;
  106115. private _leftjoystick;
  106116. private _rightjoystick;
  106117. /**
  106118. * Gets the left stick of the virtual joystick.
  106119. * @returns The virtual Joystick
  106120. */
  106121. getLeftJoystick(): VirtualJoystick;
  106122. /**
  106123. * Gets the right stick of the virtual joystick.
  106124. * @returns The virtual Joystick
  106125. */
  106126. getRightJoystick(): VirtualJoystick;
  106127. /**
  106128. * Update the current camera state depending on the inputs that have been used this frame.
  106129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106130. */
  106131. checkInputs(): void;
  106132. /**
  106133. * Attach the input controls to a specific dom element to get the input from.
  106134. * @param element Defines the element the controls should be listened from
  106135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106136. */
  106137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106138. /**
  106139. * Detach the current controls from the specified dom element.
  106140. * @param element Defines the element to stop listening the inputs from
  106141. */
  106142. detachControl(element: Nullable<HTMLElement>): void;
  106143. /**
  106144. * Gets the class name of the current intput.
  106145. * @returns the class name
  106146. */
  106147. getClassName(): string;
  106148. /**
  106149. * Get the friendly name associated with the input class.
  106150. * @returns the input friendly name
  106151. */
  106152. getSimpleName(): string;
  106153. }
  106154. }
  106155. declare module BABYLON {
  106156. /**
  106157. * This represents a FPS type of camera controlled by touch.
  106158. * This is like a universal camera minus the Gamepad controls.
  106159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106160. */
  106161. export class TouchCamera extends FreeCamera {
  106162. /**
  106163. * Defines the touch sensibility for rotation.
  106164. * The higher the faster.
  106165. */
  106166. touchAngularSensibility: number;
  106167. /**
  106168. * Defines the touch sensibility for move.
  106169. * The higher the faster.
  106170. */
  106171. touchMoveSensibility: number;
  106172. /**
  106173. * Instantiates a new touch camera.
  106174. * This represents a FPS type of camera controlled by touch.
  106175. * This is like a universal camera minus the Gamepad controls.
  106176. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106177. * @param name Define the name of the camera in the scene
  106178. * @param position Define the start position of the camera in the scene
  106179. * @param scene Define the scene the camera belongs to
  106180. */
  106181. constructor(name: string, position: Vector3, scene: Scene);
  106182. /**
  106183. * Gets the current object class name.
  106184. * @return the class name
  106185. */
  106186. getClassName(): string;
  106187. /** @hidden */
  106188. _setupInputs(): void;
  106189. }
  106190. }
  106191. declare module BABYLON {
  106192. /**
  106193. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106194. * being tilted forward or back and left or right.
  106195. */
  106196. export class DeviceOrientationCamera extends FreeCamera {
  106197. private _initialQuaternion;
  106198. private _quaternionCache;
  106199. private _tmpDragQuaternion;
  106200. private _disablePointerInputWhenUsingDeviceOrientation;
  106201. /**
  106202. * Creates a new device orientation camera
  106203. * @param name The name of the camera
  106204. * @param position The start position camera
  106205. * @param scene The scene the camera belongs to
  106206. */
  106207. constructor(name: string, position: Vector3, scene: Scene);
  106208. /**
  106209. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106210. */
  106211. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106212. private _dragFactor;
  106213. /**
  106214. * Enabled turning on the y axis when the orientation sensor is active
  106215. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106216. */
  106217. enableHorizontalDragging(dragFactor?: number): void;
  106218. /**
  106219. * Gets the current instance class name ("DeviceOrientationCamera").
  106220. * This helps avoiding instanceof at run time.
  106221. * @returns the class name
  106222. */
  106223. getClassName(): string;
  106224. /**
  106225. * @hidden
  106226. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106227. */
  106228. _checkInputs(): void;
  106229. /**
  106230. * Reset the camera to its default orientation on the specified axis only.
  106231. * @param axis The axis to reset
  106232. */
  106233. resetToCurrentRotation(axis?: Axis): void;
  106234. }
  106235. }
  106236. declare module BABYLON {
  106237. /**
  106238. * Defines supported buttons for XBox360 compatible gamepads
  106239. */
  106240. export enum Xbox360Button {
  106241. /** A */
  106242. A = 0,
  106243. /** B */
  106244. B = 1,
  106245. /** X */
  106246. X = 2,
  106247. /** Y */
  106248. Y = 3,
  106249. /** Start */
  106250. Start = 4,
  106251. /** Back */
  106252. Back = 5,
  106253. /** Left button */
  106254. LB = 6,
  106255. /** Right button */
  106256. RB = 7,
  106257. /** Left stick */
  106258. LeftStick = 8,
  106259. /** Right stick */
  106260. RightStick = 9
  106261. }
  106262. /** Defines values for XBox360 DPad */
  106263. export enum Xbox360Dpad {
  106264. /** Up */
  106265. Up = 0,
  106266. /** Down */
  106267. Down = 1,
  106268. /** Left */
  106269. Left = 2,
  106270. /** Right */
  106271. Right = 3
  106272. }
  106273. /**
  106274. * Defines a XBox360 gamepad
  106275. */
  106276. export class Xbox360Pad extends Gamepad {
  106277. private _leftTrigger;
  106278. private _rightTrigger;
  106279. private _onlefttriggerchanged;
  106280. private _onrighttriggerchanged;
  106281. private _onbuttondown;
  106282. private _onbuttonup;
  106283. private _ondpaddown;
  106284. private _ondpadup;
  106285. /** Observable raised when a button is pressed */
  106286. onButtonDownObservable: Observable<Xbox360Button>;
  106287. /** Observable raised when a button is released */
  106288. onButtonUpObservable: Observable<Xbox360Button>;
  106289. /** Observable raised when a pad is pressed */
  106290. onPadDownObservable: Observable<Xbox360Dpad>;
  106291. /** Observable raised when a pad is released */
  106292. onPadUpObservable: Observable<Xbox360Dpad>;
  106293. private _buttonA;
  106294. private _buttonB;
  106295. private _buttonX;
  106296. private _buttonY;
  106297. private _buttonBack;
  106298. private _buttonStart;
  106299. private _buttonLB;
  106300. private _buttonRB;
  106301. private _buttonLeftStick;
  106302. private _buttonRightStick;
  106303. private _dPadUp;
  106304. private _dPadDown;
  106305. private _dPadLeft;
  106306. private _dPadRight;
  106307. private _isXboxOnePad;
  106308. /**
  106309. * Creates a new XBox360 gamepad object
  106310. * @param id defines the id of this gamepad
  106311. * @param index defines its index
  106312. * @param gamepad defines the internal HTML gamepad object
  106313. * @param xboxOne defines if it is a XBox One gamepad
  106314. */
  106315. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106316. /**
  106317. * Defines the callback to call when left trigger is pressed
  106318. * @param callback defines the callback to use
  106319. */
  106320. onlefttriggerchanged(callback: (value: number) => void): void;
  106321. /**
  106322. * Defines the callback to call when right trigger is pressed
  106323. * @param callback defines the callback to use
  106324. */
  106325. onrighttriggerchanged(callback: (value: number) => void): void;
  106326. /**
  106327. * Gets the left trigger value
  106328. */
  106329. /**
  106330. * Sets the left trigger value
  106331. */
  106332. leftTrigger: number;
  106333. /**
  106334. * Gets the right trigger value
  106335. */
  106336. /**
  106337. * Sets the right trigger value
  106338. */
  106339. rightTrigger: number;
  106340. /**
  106341. * Defines the callback to call when a button is pressed
  106342. * @param callback defines the callback to use
  106343. */
  106344. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106345. /**
  106346. * Defines the callback to call when a button is released
  106347. * @param callback defines the callback to use
  106348. */
  106349. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106350. /**
  106351. * Defines the callback to call when a pad is pressed
  106352. * @param callback defines the callback to use
  106353. */
  106354. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106355. /**
  106356. * Defines the callback to call when a pad is released
  106357. * @param callback defines the callback to use
  106358. */
  106359. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106360. private _setButtonValue;
  106361. private _setDPadValue;
  106362. /**
  106363. * Gets the value of the `A` button
  106364. */
  106365. /**
  106366. * Sets the value of the `A` button
  106367. */
  106368. buttonA: number;
  106369. /**
  106370. * Gets the value of the `B` button
  106371. */
  106372. /**
  106373. * Sets the value of the `B` button
  106374. */
  106375. buttonB: number;
  106376. /**
  106377. * Gets the value of the `X` button
  106378. */
  106379. /**
  106380. * Sets the value of the `X` button
  106381. */
  106382. buttonX: number;
  106383. /**
  106384. * Gets the value of the `Y` button
  106385. */
  106386. /**
  106387. * Sets the value of the `Y` button
  106388. */
  106389. buttonY: number;
  106390. /**
  106391. * Gets the value of the `Start` button
  106392. */
  106393. /**
  106394. * Sets the value of the `Start` button
  106395. */
  106396. buttonStart: number;
  106397. /**
  106398. * Gets the value of the `Back` button
  106399. */
  106400. /**
  106401. * Sets the value of the `Back` button
  106402. */
  106403. buttonBack: number;
  106404. /**
  106405. * Gets the value of the `Left` button
  106406. */
  106407. /**
  106408. * Sets the value of the `Left` button
  106409. */
  106410. buttonLB: number;
  106411. /**
  106412. * Gets the value of the `Right` button
  106413. */
  106414. /**
  106415. * Sets the value of the `Right` button
  106416. */
  106417. buttonRB: number;
  106418. /**
  106419. * Gets the value of the Left joystick
  106420. */
  106421. /**
  106422. * Sets the value of the Left joystick
  106423. */
  106424. buttonLeftStick: number;
  106425. /**
  106426. * Gets the value of the Right joystick
  106427. */
  106428. /**
  106429. * Sets the value of the Right joystick
  106430. */
  106431. buttonRightStick: number;
  106432. /**
  106433. * Gets the value of D-pad up
  106434. */
  106435. /**
  106436. * Sets the value of D-pad up
  106437. */
  106438. dPadUp: number;
  106439. /**
  106440. * Gets the value of D-pad down
  106441. */
  106442. /**
  106443. * Sets the value of D-pad down
  106444. */
  106445. dPadDown: number;
  106446. /**
  106447. * Gets the value of D-pad left
  106448. */
  106449. /**
  106450. * Sets the value of D-pad left
  106451. */
  106452. dPadLeft: number;
  106453. /**
  106454. * Gets the value of D-pad right
  106455. */
  106456. /**
  106457. * Sets the value of D-pad right
  106458. */
  106459. dPadRight: number;
  106460. /**
  106461. * Force the gamepad to synchronize with device values
  106462. */
  106463. update(): void;
  106464. /**
  106465. * Disposes the gamepad
  106466. */
  106467. dispose(): void;
  106468. }
  106469. }
  106470. declare module BABYLON {
  106471. /**
  106472. * Defines supported buttons for DualShock compatible gamepads
  106473. */
  106474. export enum DualShockButton {
  106475. /** Cross */
  106476. Cross = 0,
  106477. /** Circle */
  106478. Circle = 1,
  106479. /** Square */
  106480. Square = 2,
  106481. /** Triangle */
  106482. Triangle = 3,
  106483. /** Options */
  106484. Options = 4,
  106485. /** Share */
  106486. Share = 5,
  106487. /** L1 */
  106488. L1 = 6,
  106489. /** R1 */
  106490. R1 = 7,
  106491. /** Left stick */
  106492. LeftStick = 8,
  106493. /** Right stick */
  106494. RightStick = 9
  106495. }
  106496. /** Defines values for DualShock DPad */
  106497. export enum DualShockDpad {
  106498. /** Up */
  106499. Up = 0,
  106500. /** Down */
  106501. Down = 1,
  106502. /** Left */
  106503. Left = 2,
  106504. /** Right */
  106505. Right = 3
  106506. }
  106507. /**
  106508. * Defines a DualShock gamepad
  106509. */
  106510. export class DualShockPad extends Gamepad {
  106511. private _leftTrigger;
  106512. private _rightTrigger;
  106513. private _onlefttriggerchanged;
  106514. private _onrighttriggerchanged;
  106515. private _onbuttondown;
  106516. private _onbuttonup;
  106517. private _ondpaddown;
  106518. private _ondpadup;
  106519. /** Observable raised when a button is pressed */
  106520. onButtonDownObservable: Observable<DualShockButton>;
  106521. /** Observable raised when a button is released */
  106522. onButtonUpObservable: Observable<DualShockButton>;
  106523. /** Observable raised when a pad is pressed */
  106524. onPadDownObservable: Observable<DualShockDpad>;
  106525. /** Observable raised when a pad is released */
  106526. onPadUpObservable: Observable<DualShockDpad>;
  106527. private _buttonCross;
  106528. private _buttonCircle;
  106529. private _buttonSquare;
  106530. private _buttonTriangle;
  106531. private _buttonShare;
  106532. private _buttonOptions;
  106533. private _buttonL1;
  106534. private _buttonR1;
  106535. private _buttonLeftStick;
  106536. private _buttonRightStick;
  106537. private _dPadUp;
  106538. private _dPadDown;
  106539. private _dPadLeft;
  106540. private _dPadRight;
  106541. /**
  106542. * Creates a new DualShock gamepad object
  106543. * @param id defines the id of this gamepad
  106544. * @param index defines its index
  106545. * @param gamepad defines the internal HTML gamepad object
  106546. */
  106547. constructor(id: string, index: number, gamepad: any);
  106548. /**
  106549. * Defines the callback to call when left trigger is pressed
  106550. * @param callback defines the callback to use
  106551. */
  106552. onlefttriggerchanged(callback: (value: number) => void): void;
  106553. /**
  106554. * Defines the callback to call when right trigger is pressed
  106555. * @param callback defines the callback to use
  106556. */
  106557. onrighttriggerchanged(callback: (value: number) => void): void;
  106558. /**
  106559. * Gets the left trigger value
  106560. */
  106561. /**
  106562. * Sets the left trigger value
  106563. */
  106564. leftTrigger: number;
  106565. /**
  106566. * Gets the right trigger value
  106567. */
  106568. /**
  106569. * Sets the right trigger value
  106570. */
  106571. rightTrigger: number;
  106572. /**
  106573. * Defines the callback to call when a button is pressed
  106574. * @param callback defines the callback to use
  106575. */
  106576. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106577. /**
  106578. * Defines the callback to call when a button is released
  106579. * @param callback defines the callback to use
  106580. */
  106581. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106582. /**
  106583. * Defines the callback to call when a pad is pressed
  106584. * @param callback defines the callback to use
  106585. */
  106586. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106587. /**
  106588. * Defines the callback to call when a pad is released
  106589. * @param callback defines the callback to use
  106590. */
  106591. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106592. private _setButtonValue;
  106593. private _setDPadValue;
  106594. /**
  106595. * Gets the value of the `Cross` button
  106596. */
  106597. /**
  106598. * Sets the value of the `Cross` button
  106599. */
  106600. buttonCross: number;
  106601. /**
  106602. * Gets the value of the `Circle` button
  106603. */
  106604. /**
  106605. * Sets the value of the `Circle` button
  106606. */
  106607. buttonCircle: number;
  106608. /**
  106609. * Gets the value of the `Square` button
  106610. */
  106611. /**
  106612. * Sets the value of the `Square` button
  106613. */
  106614. buttonSquare: number;
  106615. /**
  106616. * Gets the value of the `Triangle` button
  106617. */
  106618. /**
  106619. * Sets the value of the `Triangle` button
  106620. */
  106621. buttonTriangle: number;
  106622. /**
  106623. * Gets the value of the `Options` button
  106624. */
  106625. /**
  106626. * Sets the value of the `Options` button
  106627. */
  106628. buttonOptions: number;
  106629. /**
  106630. * Gets the value of the `Share` button
  106631. */
  106632. /**
  106633. * Sets the value of the `Share` button
  106634. */
  106635. buttonShare: number;
  106636. /**
  106637. * Gets the value of the `L1` button
  106638. */
  106639. /**
  106640. * Sets the value of the `L1` button
  106641. */
  106642. buttonL1: number;
  106643. /**
  106644. * Gets the value of the `R1` button
  106645. */
  106646. /**
  106647. * Sets the value of the `R1` button
  106648. */
  106649. buttonR1: number;
  106650. /**
  106651. * Gets the value of the Left joystick
  106652. */
  106653. /**
  106654. * Sets the value of the Left joystick
  106655. */
  106656. buttonLeftStick: number;
  106657. /**
  106658. * Gets the value of the Right joystick
  106659. */
  106660. /**
  106661. * Sets the value of the Right joystick
  106662. */
  106663. buttonRightStick: number;
  106664. /**
  106665. * Gets the value of D-pad up
  106666. */
  106667. /**
  106668. * Sets the value of D-pad up
  106669. */
  106670. dPadUp: number;
  106671. /**
  106672. * Gets the value of D-pad down
  106673. */
  106674. /**
  106675. * Sets the value of D-pad down
  106676. */
  106677. dPadDown: number;
  106678. /**
  106679. * Gets the value of D-pad left
  106680. */
  106681. /**
  106682. * Sets the value of D-pad left
  106683. */
  106684. dPadLeft: number;
  106685. /**
  106686. * Gets the value of D-pad right
  106687. */
  106688. /**
  106689. * Sets the value of D-pad right
  106690. */
  106691. dPadRight: number;
  106692. /**
  106693. * Force the gamepad to synchronize with device values
  106694. */
  106695. update(): void;
  106696. /**
  106697. * Disposes the gamepad
  106698. */
  106699. dispose(): void;
  106700. }
  106701. }
  106702. declare module BABYLON {
  106703. /**
  106704. * Manager for handling gamepads
  106705. */
  106706. export class GamepadManager {
  106707. private _scene?;
  106708. private _babylonGamepads;
  106709. private _oneGamepadConnected;
  106710. /** @hidden */
  106711. _isMonitoring: boolean;
  106712. private _gamepadEventSupported;
  106713. private _gamepadSupport;
  106714. /**
  106715. * observable to be triggered when the gamepad controller has been connected
  106716. */
  106717. onGamepadConnectedObservable: Observable<Gamepad>;
  106718. /**
  106719. * observable to be triggered when the gamepad controller has been disconnected
  106720. */
  106721. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106722. private _onGamepadConnectedEvent;
  106723. private _onGamepadDisconnectedEvent;
  106724. /**
  106725. * Initializes the gamepad manager
  106726. * @param _scene BabylonJS scene
  106727. */
  106728. constructor(_scene?: Scene | undefined);
  106729. /**
  106730. * The gamepads in the game pad manager
  106731. */
  106732. readonly gamepads: Gamepad[];
  106733. /**
  106734. * Get the gamepad controllers based on type
  106735. * @param type The type of gamepad controller
  106736. * @returns Nullable gamepad
  106737. */
  106738. getGamepadByType(type?: number): Nullable<Gamepad>;
  106739. /**
  106740. * Disposes the gamepad manager
  106741. */
  106742. dispose(): void;
  106743. private _addNewGamepad;
  106744. private _startMonitoringGamepads;
  106745. private _stopMonitoringGamepads;
  106746. /** @hidden */
  106747. _checkGamepadsStatus(): void;
  106748. private _updateGamepadObjects;
  106749. }
  106750. }
  106751. declare module BABYLON {
  106752. interface Scene {
  106753. /** @hidden */
  106754. _gamepadManager: Nullable<GamepadManager>;
  106755. /**
  106756. * Gets the gamepad manager associated with the scene
  106757. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106758. */
  106759. gamepadManager: GamepadManager;
  106760. }
  106761. /**
  106762. * Interface representing a free camera inputs manager
  106763. */
  106764. interface FreeCameraInputsManager {
  106765. /**
  106766. * Adds gamepad input support to the FreeCameraInputsManager.
  106767. * @returns the FreeCameraInputsManager
  106768. */
  106769. addGamepad(): FreeCameraInputsManager;
  106770. }
  106771. /**
  106772. * Interface representing an arc rotate camera inputs manager
  106773. */
  106774. interface ArcRotateCameraInputsManager {
  106775. /**
  106776. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106777. * @returns the camera inputs manager
  106778. */
  106779. addGamepad(): ArcRotateCameraInputsManager;
  106780. }
  106781. /**
  106782. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106783. */
  106784. export class GamepadSystemSceneComponent implements ISceneComponent {
  106785. /**
  106786. * The component name helpfull to identify the component in the list of scene components.
  106787. */
  106788. readonly name: string;
  106789. /**
  106790. * The scene the component belongs to.
  106791. */
  106792. scene: Scene;
  106793. /**
  106794. * Creates a new instance of the component for the given scene
  106795. * @param scene Defines the scene to register the component in
  106796. */
  106797. constructor(scene: Scene);
  106798. /**
  106799. * Registers the component in a given scene
  106800. */
  106801. register(): void;
  106802. /**
  106803. * Rebuilds the elements related to this component in case of
  106804. * context lost for instance.
  106805. */
  106806. rebuild(): void;
  106807. /**
  106808. * Disposes the component and the associated ressources
  106809. */
  106810. dispose(): void;
  106811. private _beforeCameraUpdate;
  106812. }
  106813. }
  106814. declare module BABYLON {
  106815. /**
  106816. * 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,
  106817. * which still works and will still be found in many Playgrounds.
  106818. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106819. */
  106820. export class UniversalCamera extends TouchCamera {
  106821. /**
  106822. * Defines the gamepad rotation sensiblity.
  106823. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106824. */
  106825. gamepadAngularSensibility: number;
  106826. /**
  106827. * Defines the gamepad move sensiblity.
  106828. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106829. */
  106830. gamepadMoveSensibility: number;
  106831. /**
  106832. * 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,
  106833. * which still works and will still be found in many Playgrounds.
  106834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106835. * @param name Define the name of the camera in the scene
  106836. * @param position Define the start position of the camera in the scene
  106837. * @param scene Define the scene the camera belongs to
  106838. */
  106839. constructor(name: string, position: Vector3, scene: Scene);
  106840. /**
  106841. * Gets the current object class name.
  106842. * @return the class name
  106843. */
  106844. getClassName(): string;
  106845. }
  106846. }
  106847. declare module BABYLON {
  106848. /**
  106849. * This represents a FPS type of camera. This is only here for back compat purpose.
  106850. * Please use the UniversalCamera instead as both are identical.
  106851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106852. */
  106853. export class GamepadCamera extends UniversalCamera {
  106854. /**
  106855. * Instantiates a new Gamepad Camera
  106856. * This represents a FPS type of camera. This is only here for back compat purpose.
  106857. * Please use the UniversalCamera instead as both are identical.
  106858. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106859. * @param name Define the name of the camera in the scene
  106860. * @param position Define the start position of the camera in the scene
  106861. * @param scene Define the scene the camera belongs to
  106862. */
  106863. constructor(name: string, position: Vector3, scene: Scene);
  106864. /**
  106865. * Gets the current object class name.
  106866. * @return the class name
  106867. */
  106868. getClassName(): string;
  106869. }
  106870. }
  106871. declare module BABYLON {
  106872. /** @hidden */
  106873. export var passPixelShader: {
  106874. name: string;
  106875. shader: string;
  106876. };
  106877. }
  106878. declare module BABYLON {
  106879. /** @hidden */
  106880. export var passCubePixelShader: {
  106881. name: string;
  106882. shader: string;
  106883. };
  106884. }
  106885. declare module BABYLON {
  106886. /**
  106887. * PassPostProcess which produces an output the same as it's input
  106888. */
  106889. export class PassPostProcess extends PostProcess {
  106890. /**
  106891. * Creates the PassPostProcess
  106892. * @param name The name of the effect.
  106893. * @param options The required width/height ratio to downsize to before computing the render pass.
  106894. * @param camera The camera to apply the render pass to.
  106895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106896. * @param engine The engine which the post process will be applied. (default: current engine)
  106897. * @param reusable If the post process can be reused on the same frame. (default: false)
  106898. * @param textureType The type of texture to be used when performing the post processing.
  106899. * @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)
  106900. */
  106901. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106902. }
  106903. /**
  106904. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106905. */
  106906. export class PassCubePostProcess extends PostProcess {
  106907. private _face;
  106908. /**
  106909. * Gets or sets the cube face to display.
  106910. * * 0 is +X
  106911. * * 1 is -X
  106912. * * 2 is +Y
  106913. * * 3 is -Y
  106914. * * 4 is +Z
  106915. * * 5 is -Z
  106916. */
  106917. face: number;
  106918. /**
  106919. * Creates the PassCubePostProcess
  106920. * @param name The name of the effect.
  106921. * @param options The required width/height ratio to downsize to before computing the render pass.
  106922. * @param camera The camera to apply the render pass to.
  106923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106924. * @param engine The engine which the post process will be applied. (default: current engine)
  106925. * @param reusable If the post process can be reused on the same frame. (default: false)
  106926. * @param textureType The type of texture to be used when performing the post processing.
  106927. * @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)
  106928. */
  106929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106930. }
  106931. }
  106932. declare module BABYLON {
  106933. /** @hidden */
  106934. export var anaglyphPixelShader: {
  106935. name: string;
  106936. shader: string;
  106937. };
  106938. }
  106939. declare module BABYLON {
  106940. /**
  106941. * Postprocess used to generate anaglyphic rendering
  106942. */
  106943. export class AnaglyphPostProcess extends PostProcess {
  106944. private _passedProcess;
  106945. /**
  106946. * Creates a new AnaglyphPostProcess
  106947. * @param name defines postprocess name
  106948. * @param options defines creation options or target ratio scale
  106949. * @param rigCameras defines cameras using this postprocess
  106950. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106951. * @param engine defines hosting engine
  106952. * @param reusable defines if the postprocess will be reused multiple times per frame
  106953. */
  106954. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106955. }
  106956. }
  106957. declare module BABYLON {
  106958. /**
  106959. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106960. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106961. */
  106962. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106963. /**
  106964. * Creates a new AnaglyphArcRotateCamera
  106965. * @param name defines camera name
  106966. * @param alpha defines alpha angle (in radians)
  106967. * @param beta defines beta angle (in radians)
  106968. * @param radius defines radius
  106969. * @param target defines camera target
  106970. * @param interaxialDistance defines distance between each color axis
  106971. * @param scene defines the hosting scene
  106972. */
  106973. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106974. /**
  106975. * Gets camera class name
  106976. * @returns AnaglyphArcRotateCamera
  106977. */
  106978. getClassName(): string;
  106979. }
  106980. }
  106981. declare module BABYLON {
  106982. /**
  106983. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106984. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106985. */
  106986. export class AnaglyphFreeCamera extends FreeCamera {
  106987. /**
  106988. * Creates a new AnaglyphFreeCamera
  106989. * @param name defines camera name
  106990. * @param position defines initial position
  106991. * @param interaxialDistance defines distance between each color axis
  106992. * @param scene defines the hosting scene
  106993. */
  106994. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106995. /**
  106996. * Gets camera class name
  106997. * @returns AnaglyphFreeCamera
  106998. */
  106999. getClassName(): string;
  107000. }
  107001. }
  107002. declare module BABYLON {
  107003. /**
  107004. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107005. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107006. */
  107007. export class AnaglyphGamepadCamera extends GamepadCamera {
  107008. /**
  107009. * Creates a new AnaglyphGamepadCamera
  107010. * @param name defines camera name
  107011. * @param position defines initial position
  107012. * @param interaxialDistance defines distance between each color axis
  107013. * @param scene defines the hosting scene
  107014. */
  107015. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107016. /**
  107017. * Gets camera class name
  107018. * @returns AnaglyphGamepadCamera
  107019. */
  107020. getClassName(): string;
  107021. }
  107022. }
  107023. declare module BABYLON {
  107024. /**
  107025. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107026. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107027. */
  107028. export class AnaglyphUniversalCamera extends UniversalCamera {
  107029. /**
  107030. * Creates a new AnaglyphUniversalCamera
  107031. * @param name defines camera name
  107032. * @param position defines initial position
  107033. * @param interaxialDistance defines distance between each color axis
  107034. * @param scene defines the hosting scene
  107035. */
  107036. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107037. /**
  107038. * Gets camera class name
  107039. * @returns AnaglyphUniversalCamera
  107040. */
  107041. getClassName(): string;
  107042. }
  107043. }
  107044. declare module BABYLON {
  107045. /** @hidden */
  107046. export var stereoscopicInterlacePixelShader: {
  107047. name: string;
  107048. shader: string;
  107049. };
  107050. }
  107051. declare module BABYLON {
  107052. /**
  107053. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107054. */
  107055. export class StereoscopicInterlacePostProcess extends PostProcess {
  107056. private _stepSize;
  107057. private _passedProcess;
  107058. /**
  107059. * Initializes a StereoscopicInterlacePostProcess
  107060. * @param name The name of the effect.
  107061. * @param rigCameras The rig cameras to be appled to the post process
  107062. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107064. * @param engine The engine which the post process will be applied. (default: current engine)
  107065. * @param reusable If the post process can be reused on the same frame. (default: false)
  107066. */
  107067. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107068. }
  107069. }
  107070. declare module BABYLON {
  107071. /**
  107072. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107073. * @see http://doc.babylonjs.com/features/cameras
  107074. */
  107075. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107076. /**
  107077. * Creates a new StereoscopicArcRotateCamera
  107078. * @param name defines camera name
  107079. * @param alpha defines alpha angle (in radians)
  107080. * @param beta defines beta angle (in radians)
  107081. * @param radius defines radius
  107082. * @param target defines camera target
  107083. * @param interaxialDistance defines distance between each color axis
  107084. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107085. * @param scene defines the hosting scene
  107086. */
  107087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107088. /**
  107089. * Gets camera class name
  107090. * @returns StereoscopicArcRotateCamera
  107091. */
  107092. getClassName(): string;
  107093. }
  107094. }
  107095. declare module BABYLON {
  107096. /**
  107097. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107098. * @see http://doc.babylonjs.com/features/cameras
  107099. */
  107100. export class StereoscopicFreeCamera extends FreeCamera {
  107101. /**
  107102. * Creates a new StereoscopicFreeCamera
  107103. * @param name defines camera name
  107104. * @param position defines initial position
  107105. * @param interaxialDistance defines distance between each color axis
  107106. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107107. * @param scene defines the hosting scene
  107108. */
  107109. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107110. /**
  107111. * Gets camera class name
  107112. * @returns StereoscopicFreeCamera
  107113. */
  107114. getClassName(): string;
  107115. }
  107116. }
  107117. declare module BABYLON {
  107118. /**
  107119. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107120. * @see http://doc.babylonjs.com/features/cameras
  107121. */
  107122. export class StereoscopicGamepadCamera extends GamepadCamera {
  107123. /**
  107124. * Creates a new StereoscopicGamepadCamera
  107125. * @param name defines camera name
  107126. * @param position defines initial position
  107127. * @param interaxialDistance defines distance between each color axis
  107128. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107129. * @param scene defines the hosting scene
  107130. */
  107131. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107132. /**
  107133. * Gets camera class name
  107134. * @returns StereoscopicGamepadCamera
  107135. */
  107136. getClassName(): string;
  107137. }
  107138. }
  107139. declare module BABYLON {
  107140. /**
  107141. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107142. * @see http://doc.babylonjs.com/features/cameras
  107143. */
  107144. export class StereoscopicUniversalCamera extends UniversalCamera {
  107145. /**
  107146. * Creates a new StereoscopicUniversalCamera
  107147. * @param name defines camera name
  107148. * @param position defines initial position
  107149. * @param interaxialDistance defines distance between each color axis
  107150. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107151. * @param scene defines the hosting scene
  107152. */
  107153. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107154. /**
  107155. * Gets camera class name
  107156. * @returns StereoscopicUniversalCamera
  107157. */
  107158. getClassName(): string;
  107159. }
  107160. }
  107161. declare module BABYLON {
  107162. /**
  107163. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107164. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107165. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107166. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107167. */
  107168. export class VirtualJoysticksCamera extends FreeCamera {
  107169. /**
  107170. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107171. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107172. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107173. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107174. * @param name Define the name of the camera in the scene
  107175. * @param position Define the start position of the camera in the scene
  107176. * @param scene Define the scene the camera belongs to
  107177. */
  107178. constructor(name: string, position: Vector3, scene: Scene);
  107179. /**
  107180. * Gets the current object class name.
  107181. * @return the class name
  107182. */
  107183. getClassName(): string;
  107184. }
  107185. }
  107186. declare module BABYLON {
  107187. /**
  107188. * This represents all the required metrics to create a VR camera.
  107189. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107190. */
  107191. export class VRCameraMetrics {
  107192. /**
  107193. * Define the horizontal resolution off the screen.
  107194. */
  107195. hResolution: number;
  107196. /**
  107197. * Define the vertical resolution off the screen.
  107198. */
  107199. vResolution: number;
  107200. /**
  107201. * Define the horizontal screen size.
  107202. */
  107203. hScreenSize: number;
  107204. /**
  107205. * Define the vertical screen size.
  107206. */
  107207. vScreenSize: number;
  107208. /**
  107209. * Define the vertical screen center position.
  107210. */
  107211. vScreenCenter: number;
  107212. /**
  107213. * Define the distance of the eyes to the screen.
  107214. */
  107215. eyeToScreenDistance: number;
  107216. /**
  107217. * Define the distance between both lenses
  107218. */
  107219. lensSeparationDistance: number;
  107220. /**
  107221. * Define the distance between both viewer's eyes.
  107222. */
  107223. interpupillaryDistance: number;
  107224. /**
  107225. * Define the distortion factor of the VR postprocess.
  107226. * Please, touch with care.
  107227. */
  107228. distortionK: number[];
  107229. /**
  107230. * Define the chromatic aberration correction factors for the VR post process.
  107231. */
  107232. chromaAbCorrection: number[];
  107233. /**
  107234. * Define the scale factor of the post process.
  107235. * The smaller the better but the slower.
  107236. */
  107237. postProcessScaleFactor: number;
  107238. /**
  107239. * Define an offset for the lens center.
  107240. */
  107241. lensCenterOffset: number;
  107242. /**
  107243. * Define if the current vr camera should compensate the distortion of the lense or not.
  107244. */
  107245. compensateDistortion: boolean;
  107246. /**
  107247. * Defines if multiview should be enabled when rendering (Default: false)
  107248. */
  107249. multiviewEnabled: boolean;
  107250. /**
  107251. * Gets the rendering aspect ratio based on the provided resolutions.
  107252. */
  107253. readonly aspectRatio: number;
  107254. /**
  107255. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107256. */
  107257. readonly aspectRatioFov: number;
  107258. /**
  107259. * @hidden
  107260. */
  107261. readonly leftHMatrix: Matrix;
  107262. /**
  107263. * @hidden
  107264. */
  107265. readonly rightHMatrix: Matrix;
  107266. /**
  107267. * @hidden
  107268. */
  107269. readonly leftPreViewMatrix: Matrix;
  107270. /**
  107271. * @hidden
  107272. */
  107273. readonly rightPreViewMatrix: Matrix;
  107274. /**
  107275. * Get the default VRMetrics based on the most generic setup.
  107276. * @returns the default vr metrics
  107277. */
  107278. static GetDefault(): VRCameraMetrics;
  107279. }
  107280. }
  107281. declare module BABYLON {
  107282. /** @hidden */
  107283. export var vrDistortionCorrectionPixelShader: {
  107284. name: string;
  107285. shader: string;
  107286. };
  107287. }
  107288. declare module BABYLON {
  107289. /**
  107290. * VRDistortionCorrectionPostProcess used for mobile VR
  107291. */
  107292. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107293. private _isRightEye;
  107294. private _distortionFactors;
  107295. private _postProcessScaleFactor;
  107296. private _lensCenterOffset;
  107297. private _scaleIn;
  107298. private _scaleFactor;
  107299. private _lensCenter;
  107300. /**
  107301. * Initializes the VRDistortionCorrectionPostProcess
  107302. * @param name The name of the effect.
  107303. * @param camera The camera to apply the render pass to.
  107304. * @param isRightEye If this is for the right eye distortion
  107305. * @param vrMetrics All the required metrics for the VR camera
  107306. */
  107307. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107308. }
  107309. }
  107310. declare module BABYLON {
  107311. /**
  107312. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107313. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107314. */
  107315. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107316. /**
  107317. * Creates a new VRDeviceOrientationArcRotateCamera
  107318. * @param name defines camera name
  107319. * @param alpha defines the camera rotation along the logitudinal axis
  107320. * @param beta defines the camera rotation along the latitudinal axis
  107321. * @param radius defines the camera distance from its target
  107322. * @param target defines the camera target
  107323. * @param scene defines the scene the camera belongs to
  107324. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107325. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107326. */
  107327. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107328. /**
  107329. * Gets camera class name
  107330. * @returns VRDeviceOrientationArcRotateCamera
  107331. */
  107332. getClassName(): string;
  107333. }
  107334. }
  107335. declare module BABYLON {
  107336. /**
  107337. * Camera used to simulate VR rendering (based on FreeCamera)
  107338. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107339. */
  107340. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107341. /**
  107342. * Creates a new VRDeviceOrientationFreeCamera
  107343. * @param name defines camera name
  107344. * @param position defines the start position of the camera
  107345. * @param scene defines the scene the camera belongs to
  107346. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107347. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107348. */
  107349. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107350. /**
  107351. * Gets camera class name
  107352. * @returns VRDeviceOrientationFreeCamera
  107353. */
  107354. getClassName(): string;
  107355. }
  107356. }
  107357. declare module BABYLON {
  107358. /**
  107359. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107360. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107361. */
  107362. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107363. /**
  107364. * Creates a new VRDeviceOrientationGamepadCamera
  107365. * @param name defines camera name
  107366. * @param position defines the start position of the camera
  107367. * @param scene defines the scene the camera belongs to
  107368. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107369. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107370. */
  107371. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107372. /**
  107373. * Gets camera class name
  107374. * @returns VRDeviceOrientationGamepadCamera
  107375. */
  107376. getClassName(): string;
  107377. }
  107378. }
  107379. declare module BABYLON {
  107380. /**
  107381. * Base class of materials working in push mode in babylon JS
  107382. * @hidden
  107383. */
  107384. export class PushMaterial extends Material {
  107385. protected _activeEffect: Effect;
  107386. protected _normalMatrix: Matrix;
  107387. /**
  107388. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107389. * This means that the material can keep using a previous shader while a new one is being compiled.
  107390. * This is mostly used when shader parallel compilation is supported (true by default)
  107391. */
  107392. allowShaderHotSwapping: boolean;
  107393. constructor(name: string, scene: Scene);
  107394. getEffect(): Effect;
  107395. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107396. /**
  107397. * Binds the given world matrix to the active effect
  107398. *
  107399. * @param world the matrix to bind
  107400. */
  107401. bindOnlyWorldMatrix(world: Matrix): void;
  107402. /**
  107403. * Binds the given normal matrix to the active effect
  107404. *
  107405. * @param normalMatrix the matrix to bind
  107406. */
  107407. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107408. bind(world: Matrix, mesh?: Mesh): void;
  107409. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107410. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107411. }
  107412. }
  107413. declare module BABYLON {
  107414. /**
  107415. * This groups all the flags used to control the materials channel.
  107416. */
  107417. export class MaterialFlags {
  107418. private static _DiffuseTextureEnabled;
  107419. /**
  107420. * Are diffuse textures enabled in the application.
  107421. */
  107422. static DiffuseTextureEnabled: boolean;
  107423. private static _AmbientTextureEnabled;
  107424. /**
  107425. * Are ambient textures enabled in the application.
  107426. */
  107427. static AmbientTextureEnabled: boolean;
  107428. private static _OpacityTextureEnabled;
  107429. /**
  107430. * Are opacity textures enabled in the application.
  107431. */
  107432. static OpacityTextureEnabled: boolean;
  107433. private static _ReflectionTextureEnabled;
  107434. /**
  107435. * Are reflection textures enabled in the application.
  107436. */
  107437. static ReflectionTextureEnabled: boolean;
  107438. private static _EmissiveTextureEnabled;
  107439. /**
  107440. * Are emissive textures enabled in the application.
  107441. */
  107442. static EmissiveTextureEnabled: boolean;
  107443. private static _SpecularTextureEnabled;
  107444. /**
  107445. * Are specular textures enabled in the application.
  107446. */
  107447. static SpecularTextureEnabled: boolean;
  107448. private static _BumpTextureEnabled;
  107449. /**
  107450. * Are bump textures enabled in the application.
  107451. */
  107452. static BumpTextureEnabled: boolean;
  107453. private static _LightmapTextureEnabled;
  107454. /**
  107455. * Are lightmap textures enabled in the application.
  107456. */
  107457. static LightmapTextureEnabled: boolean;
  107458. private static _RefractionTextureEnabled;
  107459. /**
  107460. * Are refraction textures enabled in the application.
  107461. */
  107462. static RefractionTextureEnabled: boolean;
  107463. private static _ColorGradingTextureEnabled;
  107464. /**
  107465. * Are color grading textures enabled in the application.
  107466. */
  107467. static ColorGradingTextureEnabled: boolean;
  107468. private static _FresnelEnabled;
  107469. /**
  107470. * Are fresnels enabled in the application.
  107471. */
  107472. static FresnelEnabled: boolean;
  107473. private static _ClearCoatTextureEnabled;
  107474. /**
  107475. * Are clear coat textures enabled in the application.
  107476. */
  107477. static ClearCoatTextureEnabled: boolean;
  107478. private static _ClearCoatBumpTextureEnabled;
  107479. /**
  107480. * Are clear coat bump textures enabled in the application.
  107481. */
  107482. static ClearCoatBumpTextureEnabled: boolean;
  107483. private static _ClearCoatTintTextureEnabled;
  107484. /**
  107485. * Are clear coat tint textures enabled in the application.
  107486. */
  107487. static ClearCoatTintTextureEnabled: boolean;
  107488. private static _SheenTextureEnabled;
  107489. /**
  107490. * Are sheen textures enabled in the application.
  107491. */
  107492. static SheenTextureEnabled: boolean;
  107493. private static _AnisotropicTextureEnabled;
  107494. /**
  107495. * Are anisotropic textures enabled in the application.
  107496. */
  107497. static AnisotropicTextureEnabled: boolean;
  107498. private static _ThicknessTextureEnabled;
  107499. /**
  107500. * Are thickness textures enabled in the application.
  107501. */
  107502. static ThicknessTextureEnabled: boolean;
  107503. }
  107504. }
  107505. declare module BABYLON {
  107506. /** @hidden */
  107507. export var defaultFragmentDeclaration: {
  107508. name: string;
  107509. shader: string;
  107510. };
  107511. }
  107512. declare module BABYLON {
  107513. /** @hidden */
  107514. export var defaultUboDeclaration: {
  107515. name: string;
  107516. shader: string;
  107517. };
  107518. }
  107519. declare module BABYLON {
  107520. /** @hidden */
  107521. export var lightFragmentDeclaration: {
  107522. name: string;
  107523. shader: string;
  107524. };
  107525. }
  107526. declare module BABYLON {
  107527. /** @hidden */
  107528. export var lightUboDeclaration: {
  107529. name: string;
  107530. shader: string;
  107531. };
  107532. }
  107533. declare module BABYLON {
  107534. /** @hidden */
  107535. export var lightsFragmentFunctions: {
  107536. name: string;
  107537. shader: string;
  107538. };
  107539. }
  107540. declare module BABYLON {
  107541. /** @hidden */
  107542. export var shadowsFragmentFunctions: {
  107543. name: string;
  107544. shader: string;
  107545. };
  107546. }
  107547. declare module BABYLON {
  107548. /** @hidden */
  107549. export var fresnelFunction: {
  107550. name: string;
  107551. shader: string;
  107552. };
  107553. }
  107554. declare module BABYLON {
  107555. /** @hidden */
  107556. export var reflectionFunction: {
  107557. name: string;
  107558. shader: string;
  107559. };
  107560. }
  107561. declare module BABYLON {
  107562. /** @hidden */
  107563. export var bumpFragmentFunctions: {
  107564. name: string;
  107565. shader: string;
  107566. };
  107567. }
  107568. declare module BABYLON {
  107569. /** @hidden */
  107570. export var logDepthDeclaration: {
  107571. name: string;
  107572. shader: string;
  107573. };
  107574. }
  107575. declare module BABYLON {
  107576. /** @hidden */
  107577. export var bumpFragment: {
  107578. name: string;
  107579. shader: string;
  107580. };
  107581. }
  107582. declare module BABYLON {
  107583. /** @hidden */
  107584. export var depthPrePass: {
  107585. name: string;
  107586. shader: string;
  107587. };
  107588. }
  107589. declare module BABYLON {
  107590. /** @hidden */
  107591. export var lightFragment: {
  107592. name: string;
  107593. shader: string;
  107594. };
  107595. }
  107596. declare module BABYLON {
  107597. /** @hidden */
  107598. export var logDepthFragment: {
  107599. name: string;
  107600. shader: string;
  107601. };
  107602. }
  107603. declare module BABYLON {
  107604. /** @hidden */
  107605. export var defaultPixelShader: {
  107606. name: string;
  107607. shader: string;
  107608. };
  107609. }
  107610. declare module BABYLON {
  107611. /** @hidden */
  107612. export var defaultVertexDeclaration: {
  107613. name: string;
  107614. shader: string;
  107615. };
  107616. }
  107617. declare module BABYLON {
  107618. /** @hidden */
  107619. export var bumpVertexDeclaration: {
  107620. name: string;
  107621. shader: string;
  107622. };
  107623. }
  107624. declare module BABYLON {
  107625. /** @hidden */
  107626. export var bumpVertex: {
  107627. name: string;
  107628. shader: string;
  107629. };
  107630. }
  107631. declare module BABYLON {
  107632. /** @hidden */
  107633. export var fogVertex: {
  107634. name: string;
  107635. shader: string;
  107636. };
  107637. }
  107638. declare module BABYLON {
  107639. /** @hidden */
  107640. export var shadowsVertex: {
  107641. name: string;
  107642. shader: string;
  107643. };
  107644. }
  107645. declare module BABYLON {
  107646. /** @hidden */
  107647. export var pointCloudVertex: {
  107648. name: string;
  107649. shader: string;
  107650. };
  107651. }
  107652. declare module BABYLON {
  107653. /** @hidden */
  107654. export var logDepthVertex: {
  107655. name: string;
  107656. shader: string;
  107657. };
  107658. }
  107659. declare module BABYLON {
  107660. /** @hidden */
  107661. export var defaultVertexShader: {
  107662. name: string;
  107663. shader: string;
  107664. };
  107665. }
  107666. declare module BABYLON {
  107667. /** @hidden */
  107668. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107669. MAINUV1: boolean;
  107670. MAINUV2: boolean;
  107671. DIFFUSE: boolean;
  107672. DIFFUSEDIRECTUV: number;
  107673. AMBIENT: boolean;
  107674. AMBIENTDIRECTUV: number;
  107675. OPACITY: boolean;
  107676. OPACITYDIRECTUV: number;
  107677. OPACITYRGB: boolean;
  107678. REFLECTION: boolean;
  107679. EMISSIVE: boolean;
  107680. EMISSIVEDIRECTUV: number;
  107681. SPECULAR: boolean;
  107682. SPECULARDIRECTUV: number;
  107683. BUMP: boolean;
  107684. BUMPDIRECTUV: number;
  107685. PARALLAX: boolean;
  107686. PARALLAXOCCLUSION: boolean;
  107687. SPECULAROVERALPHA: boolean;
  107688. CLIPPLANE: boolean;
  107689. CLIPPLANE2: boolean;
  107690. CLIPPLANE3: boolean;
  107691. CLIPPLANE4: boolean;
  107692. ALPHATEST: boolean;
  107693. DEPTHPREPASS: boolean;
  107694. ALPHAFROMDIFFUSE: boolean;
  107695. POINTSIZE: boolean;
  107696. FOG: boolean;
  107697. SPECULARTERM: boolean;
  107698. DIFFUSEFRESNEL: boolean;
  107699. OPACITYFRESNEL: boolean;
  107700. REFLECTIONFRESNEL: boolean;
  107701. REFRACTIONFRESNEL: boolean;
  107702. EMISSIVEFRESNEL: boolean;
  107703. FRESNEL: boolean;
  107704. NORMAL: boolean;
  107705. UV1: boolean;
  107706. UV2: boolean;
  107707. VERTEXCOLOR: boolean;
  107708. VERTEXALPHA: boolean;
  107709. NUM_BONE_INFLUENCERS: number;
  107710. BonesPerMesh: number;
  107711. BONETEXTURE: boolean;
  107712. INSTANCES: boolean;
  107713. GLOSSINESS: boolean;
  107714. ROUGHNESS: boolean;
  107715. EMISSIVEASILLUMINATION: boolean;
  107716. LINKEMISSIVEWITHDIFFUSE: boolean;
  107717. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107718. LIGHTMAP: boolean;
  107719. LIGHTMAPDIRECTUV: number;
  107720. OBJECTSPACE_NORMALMAP: boolean;
  107721. USELIGHTMAPASSHADOWMAP: boolean;
  107722. REFLECTIONMAP_3D: boolean;
  107723. REFLECTIONMAP_SPHERICAL: boolean;
  107724. REFLECTIONMAP_PLANAR: boolean;
  107725. REFLECTIONMAP_CUBIC: boolean;
  107726. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107727. REFLECTIONMAP_PROJECTION: boolean;
  107728. REFLECTIONMAP_SKYBOX: boolean;
  107729. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107730. REFLECTIONMAP_EXPLICIT: boolean;
  107731. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107732. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107733. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107734. INVERTCUBICMAP: boolean;
  107735. LOGARITHMICDEPTH: boolean;
  107736. REFRACTION: boolean;
  107737. REFRACTIONMAP_3D: boolean;
  107738. REFLECTIONOVERALPHA: boolean;
  107739. TWOSIDEDLIGHTING: boolean;
  107740. SHADOWFLOAT: boolean;
  107741. MORPHTARGETS: boolean;
  107742. MORPHTARGETS_NORMAL: boolean;
  107743. MORPHTARGETS_TANGENT: boolean;
  107744. MORPHTARGETS_UV: boolean;
  107745. NUM_MORPH_INFLUENCERS: number;
  107746. NONUNIFORMSCALING: boolean;
  107747. PREMULTIPLYALPHA: boolean;
  107748. IMAGEPROCESSING: boolean;
  107749. VIGNETTE: boolean;
  107750. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107751. VIGNETTEBLENDMODEOPAQUE: boolean;
  107752. TONEMAPPING: boolean;
  107753. TONEMAPPING_ACES: boolean;
  107754. CONTRAST: boolean;
  107755. COLORCURVES: boolean;
  107756. COLORGRADING: boolean;
  107757. COLORGRADING3D: boolean;
  107758. SAMPLER3DGREENDEPTH: boolean;
  107759. SAMPLER3DBGRMAP: boolean;
  107760. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107761. MULTIVIEW: boolean;
  107762. /**
  107763. * If the reflection texture on this material is in linear color space
  107764. * @hidden
  107765. */
  107766. IS_REFLECTION_LINEAR: boolean;
  107767. /**
  107768. * If the refraction texture on this material is in linear color space
  107769. * @hidden
  107770. */
  107771. IS_REFRACTION_LINEAR: boolean;
  107772. EXPOSURE: boolean;
  107773. constructor();
  107774. setReflectionMode(modeToEnable: string): void;
  107775. }
  107776. /**
  107777. * This is the default material used in Babylon. It is the best trade off between quality
  107778. * and performances.
  107779. * @see http://doc.babylonjs.com/babylon101/materials
  107780. */
  107781. export class StandardMaterial extends PushMaterial {
  107782. private _diffuseTexture;
  107783. /**
  107784. * The basic texture of the material as viewed under a light.
  107785. */
  107786. diffuseTexture: Nullable<BaseTexture>;
  107787. private _ambientTexture;
  107788. /**
  107789. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107790. */
  107791. ambientTexture: Nullable<BaseTexture>;
  107792. private _opacityTexture;
  107793. /**
  107794. * Define the transparency of the material from a texture.
  107795. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107796. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107797. */
  107798. opacityTexture: Nullable<BaseTexture>;
  107799. private _reflectionTexture;
  107800. /**
  107801. * Define the texture used to display the reflection.
  107802. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107803. */
  107804. reflectionTexture: Nullable<BaseTexture>;
  107805. private _emissiveTexture;
  107806. /**
  107807. * Define texture of the material as if self lit.
  107808. * This will be mixed in the final result even in the absence of light.
  107809. */
  107810. emissiveTexture: Nullable<BaseTexture>;
  107811. private _specularTexture;
  107812. /**
  107813. * Define how the color and intensity of the highlight given by the light in the material.
  107814. */
  107815. specularTexture: Nullable<BaseTexture>;
  107816. private _bumpTexture;
  107817. /**
  107818. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107819. * 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.
  107820. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107821. */
  107822. bumpTexture: Nullable<BaseTexture>;
  107823. private _lightmapTexture;
  107824. /**
  107825. * Complex lighting can be computationally expensive to compute at runtime.
  107826. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107827. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107828. */
  107829. lightmapTexture: Nullable<BaseTexture>;
  107830. private _refractionTexture;
  107831. /**
  107832. * Define the texture used to display the refraction.
  107833. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107834. */
  107835. refractionTexture: Nullable<BaseTexture>;
  107836. /**
  107837. * The color of the material lit by the environmental background lighting.
  107838. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107839. */
  107840. ambientColor: Color3;
  107841. /**
  107842. * The basic color of the material as viewed under a light.
  107843. */
  107844. diffuseColor: Color3;
  107845. /**
  107846. * Define how the color and intensity of the highlight given by the light in the material.
  107847. */
  107848. specularColor: Color3;
  107849. /**
  107850. * Define the color of the material as if self lit.
  107851. * This will be mixed in the final result even in the absence of light.
  107852. */
  107853. emissiveColor: Color3;
  107854. /**
  107855. * Defines how sharp are the highlights in the material.
  107856. * The bigger the value the sharper giving a more glossy feeling to the result.
  107857. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107858. */
  107859. specularPower: number;
  107860. private _useAlphaFromDiffuseTexture;
  107861. /**
  107862. * Does the transparency come from the diffuse texture alpha channel.
  107863. */
  107864. useAlphaFromDiffuseTexture: boolean;
  107865. private _useEmissiveAsIllumination;
  107866. /**
  107867. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107868. */
  107869. useEmissiveAsIllumination: boolean;
  107870. private _linkEmissiveWithDiffuse;
  107871. /**
  107872. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107873. * the emissive level when the final color is close to one.
  107874. */
  107875. linkEmissiveWithDiffuse: boolean;
  107876. private _useSpecularOverAlpha;
  107877. /**
  107878. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107879. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107880. */
  107881. useSpecularOverAlpha: boolean;
  107882. private _useReflectionOverAlpha;
  107883. /**
  107884. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107885. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107886. */
  107887. useReflectionOverAlpha: boolean;
  107888. private _disableLighting;
  107889. /**
  107890. * Does lights from the scene impacts this material.
  107891. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107892. */
  107893. disableLighting: boolean;
  107894. private _useObjectSpaceNormalMap;
  107895. /**
  107896. * Allows using an object space normal map (instead of tangent space).
  107897. */
  107898. useObjectSpaceNormalMap: boolean;
  107899. private _useParallax;
  107900. /**
  107901. * Is parallax enabled or not.
  107902. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107903. */
  107904. useParallax: boolean;
  107905. private _useParallaxOcclusion;
  107906. /**
  107907. * Is parallax occlusion enabled or not.
  107908. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107909. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107910. */
  107911. useParallaxOcclusion: boolean;
  107912. /**
  107913. * 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.
  107914. */
  107915. parallaxScaleBias: number;
  107916. private _roughness;
  107917. /**
  107918. * Helps to define how blurry the reflections should appears in the material.
  107919. */
  107920. roughness: number;
  107921. /**
  107922. * In case of refraction, define the value of the index of refraction.
  107923. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107924. */
  107925. indexOfRefraction: number;
  107926. /**
  107927. * Invert the refraction texture alongside the y axis.
  107928. * It can be useful with procedural textures or probe for instance.
  107929. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107930. */
  107931. invertRefractionY: boolean;
  107932. /**
  107933. * Defines the alpha limits in alpha test mode.
  107934. */
  107935. alphaCutOff: number;
  107936. private _useLightmapAsShadowmap;
  107937. /**
  107938. * In case of light mapping, define whether the map contains light or shadow informations.
  107939. */
  107940. useLightmapAsShadowmap: boolean;
  107941. private _diffuseFresnelParameters;
  107942. /**
  107943. * Define the diffuse fresnel parameters of the material.
  107944. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107945. */
  107946. diffuseFresnelParameters: FresnelParameters;
  107947. private _opacityFresnelParameters;
  107948. /**
  107949. * Define the opacity fresnel parameters of the material.
  107950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107951. */
  107952. opacityFresnelParameters: FresnelParameters;
  107953. private _reflectionFresnelParameters;
  107954. /**
  107955. * Define the reflection fresnel parameters of the material.
  107956. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107957. */
  107958. reflectionFresnelParameters: FresnelParameters;
  107959. private _refractionFresnelParameters;
  107960. /**
  107961. * Define the refraction fresnel parameters of the material.
  107962. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107963. */
  107964. refractionFresnelParameters: FresnelParameters;
  107965. private _emissiveFresnelParameters;
  107966. /**
  107967. * Define the emissive fresnel parameters of the material.
  107968. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107969. */
  107970. emissiveFresnelParameters: FresnelParameters;
  107971. private _useReflectionFresnelFromSpecular;
  107972. /**
  107973. * If true automatically deducts the fresnels values from the material specularity.
  107974. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107975. */
  107976. useReflectionFresnelFromSpecular: boolean;
  107977. private _useGlossinessFromSpecularMapAlpha;
  107978. /**
  107979. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107980. */
  107981. useGlossinessFromSpecularMapAlpha: boolean;
  107982. private _maxSimultaneousLights;
  107983. /**
  107984. * Defines the maximum number of lights that can be used in the material
  107985. */
  107986. maxSimultaneousLights: number;
  107987. private _invertNormalMapX;
  107988. /**
  107989. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107990. */
  107991. invertNormalMapX: boolean;
  107992. private _invertNormalMapY;
  107993. /**
  107994. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107995. */
  107996. invertNormalMapY: boolean;
  107997. private _twoSidedLighting;
  107998. /**
  107999. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108000. */
  108001. twoSidedLighting: boolean;
  108002. /**
  108003. * Default configuration related to image processing available in the standard Material.
  108004. */
  108005. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108006. /**
  108007. * Gets the image processing configuration used either in this material.
  108008. */
  108009. /**
  108010. * Sets the Default image processing configuration used either in the this material.
  108011. *
  108012. * If sets to null, the scene one is in use.
  108013. */
  108014. imageProcessingConfiguration: ImageProcessingConfiguration;
  108015. /**
  108016. * Keep track of the image processing observer to allow dispose and replace.
  108017. */
  108018. private _imageProcessingObserver;
  108019. /**
  108020. * Attaches a new image processing configuration to the Standard Material.
  108021. * @param configuration
  108022. */
  108023. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108024. /**
  108025. * Gets wether the color curves effect is enabled.
  108026. */
  108027. /**
  108028. * Sets wether the color curves effect is enabled.
  108029. */
  108030. cameraColorCurvesEnabled: boolean;
  108031. /**
  108032. * Gets wether the color grading effect is enabled.
  108033. */
  108034. /**
  108035. * Gets wether the color grading effect is enabled.
  108036. */
  108037. cameraColorGradingEnabled: boolean;
  108038. /**
  108039. * Gets wether tonemapping is enabled or not.
  108040. */
  108041. /**
  108042. * Sets wether tonemapping is enabled or not
  108043. */
  108044. cameraToneMappingEnabled: boolean;
  108045. /**
  108046. * The camera exposure used on this material.
  108047. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108048. * This corresponds to a photographic exposure.
  108049. */
  108050. /**
  108051. * The camera exposure used on this material.
  108052. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108053. * This corresponds to a photographic exposure.
  108054. */
  108055. cameraExposure: number;
  108056. /**
  108057. * Gets The camera contrast used on this material.
  108058. */
  108059. /**
  108060. * Sets The camera contrast used on this material.
  108061. */
  108062. cameraContrast: number;
  108063. /**
  108064. * Gets the Color Grading 2D Lookup Texture.
  108065. */
  108066. /**
  108067. * Sets the Color Grading 2D Lookup Texture.
  108068. */
  108069. cameraColorGradingTexture: Nullable<BaseTexture>;
  108070. /**
  108071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108073. * 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;
  108074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108075. */
  108076. /**
  108077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108079. * 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;
  108080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108081. */
  108082. cameraColorCurves: Nullable<ColorCurves>;
  108083. /**
  108084. * Custom callback helping to override the default shader used in the material.
  108085. */
  108086. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108087. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108088. protected _worldViewProjectionMatrix: Matrix;
  108089. protected _globalAmbientColor: Color3;
  108090. protected _useLogarithmicDepth: boolean;
  108091. protected _rebuildInParallel: boolean;
  108092. /**
  108093. * Instantiates a new standard material.
  108094. * This is the default material used in Babylon. It is the best trade off between quality
  108095. * and performances.
  108096. * @see http://doc.babylonjs.com/babylon101/materials
  108097. * @param name Define the name of the material in the scene
  108098. * @param scene Define the scene the material belong to
  108099. */
  108100. constructor(name: string, scene: Scene);
  108101. /**
  108102. * Gets a boolean indicating that current material needs to register RTT
  108103. */
  108104. readonly hasRenderTargetTextures: boolean;
  108105. /**
  108106. * Gets the current class name of the material e.g. "StandardMaterial"
  108107. * Mainly use in serialization.
  108108. * @returns the class name
  108109. */
  108110. getClassName(): string;
  108111. /**
  108112. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108113. * You can try switching to logarithmic depth.
  108114. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108115. */
  108116. useLogarithmicDepth: boolean;
  108117. /**
  108118. * Specifies if the material will require alpha blending
  108119. * @returns a boolean specifying if alpha blending is needed
  108120. */
  108121. needAlphaBlending(): boolean;
  108122. /**
  108123. * Specifies if this material should be rendered in alpha test mode
  108124. * @returns a boolean specifying if an alpha test is needed.
  108125. */
  108126. needAlphaTesting(): boolean;
  108127. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108128. /**
  108129. * Get the texture used for alpha test purpose.
  108130. * @returns the diffuse texture in case of the standard material.
  108131. */
  108132. getAlphaTestTexture(): Nullable<BaseTexture>;
  108133. /**
  108134. * Get if the submesh is ready to be used and all its information available.
  108135. * Child classes can use it to update shaders
  108136. * @param mesh defines the mesh to check
  108137. * @param subMesh defines which submesh to check
  108138. * @param useInstances specifies that instances should be used
  108139. * @returns a boolean indicating that the submesh is ready or not
  108140. */
  108141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108142. /**
  108143. * Builds the material UBO layouts.
  108144. * Used internally during the effect preparation.
  108145. */
  108146. buildUniformLayout(): void;
  108147. /**
  108148. * Unbinds the material from the mesh
  108149. */
  108150. unbind(): void;
  108151. /**
  108152. * Binds the submesh to this material by preparing the effect and shader to draw
  108153. * @param world defines the world transformation matrix
  108154. * @param mesh defines the mesh containing the submesh
  108155. * @param subMesh defines the submesh to bind the material to
  108156. */
  108157. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108158. /**
  108159. * Get the list of animatables in the material.
  108160. * @returns the list of animatables object used in the material
  108161. */
  108162. getAnimatables(): IAnimatable[];
  108163. /**
  108164. * Gets the active textures from the material
  108165. * @returns an array of textures
  108166. */
  108167. getActiveTextures(): BaseTexture[];
  108168. /**
  108169. * Specifies if the material uses a texture
  108170. * @param texture defines the texture to check against the material
  108171. * @returns a boolean specifying if the material uses the texture
  108172. */
  108173. hasTexture(texture: BaseTexture): boolean;
  108174. /**
  108175. * Disposes the material
  108176. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108177. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108178. */
  108179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108180. /**
  108181. * Makes a duplicate of the material, and gives it a new name
  108182. * @param name defines the new name for the duplicated material
  108183. * @returns the cloned material
  108184. */
  108185. clone(name: string): StandardMaterial;
  108186. /**
  108187. * Serializes this material in a JSON representation
  108188. * @returns the serialized material object
  108189. */
  108190. serialize(): any;
  108191. /**
  108192. * Creates a standard material from parsed material data
  108193. * @param source defines the JSON representation of the material
  108194. * @param scene defines the hosting scene
  108195. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108196. * @returns a new standard material
  108197. */
  108198. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108199. /**
  108200. * Are diffuse textures enabled in the application.
  108201. */
  108202. static DiffuseTextureEnabled: boolean;
  108203. /**
  108204. * Are ambient textures enabled in the application.
  108205. */
  108206. static AmbientTextureEnabled: boolean;
  108207. /**
  108208. * Are opacity textures enabled in the application.
  108209. */
  108210. static OpacityTextureEnabled: boolean;
  108211. /**
  108212. * Are reflection textures enabled in the application.
  108213. */
  108214. static ReflectionTextureEnabled: boolean;
  108215. /**
  108216. * Are emissive textures enabled in the application.
  108217. */
  108218. static EmissiveTextureEnabled: boolean;
  108219. /**
  108220. * Are specular textures enabled in the application.
  108221. */
  108222. static SpecularTextureEnabled: boolean;
  108223. /**
  108224. * Are bump textures enabled in the application.
  108225. */
  108226. static BumpTextureEnabled: boolean;
  108227. /**
  108228. * Are lightmap textures enabled in the application.
  108229. */
  108230. static LightmapTextureEnabled: boolean;
  108231. /**
  108232. * Are refraction textures enabled in the application.
  108233. */
  108234. static RefractionTextureEnabled: boolean;
  108235. /**
  108236. * Are color grading textures enabled in the application.
  108237. */
  108238. static ColorGradingTextureEnabled: boolean;
  108239. /**
  108240. * Are fresnels enabled in the application.
  108241. */
  108242. static FresnelEnabled: boolean;
  108243. }
  108244. }
  108245. declare module BABYLON {
  108246. /** @hidden */
  108247. export var imageProcessingPixelShader: {
  108248. name: string;
  108249. shader: string;
  108250. };
  108251. }
  108252. declare module BABYLON {
  108253. /**
  108254. * ImageProcessingPostProcess
  108255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108256. */
  108257. export class ImageProcessingPostProcess extends PostProcess {
  108258. /**
  108259. * Default configuration related to image processing available in the PBR Material.
  108260. */
  108261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108262. /**
  108263. * Gets the image processing configuration used either in this material.
  108264. */
  108265. /**
  108266. * Sets the Default image processing configuration used either in the this material.
  108267. *
  108268. * If sets to null, the scene one is in use.
  108269. */
  108270. imageProcessingConfiguration: ImageProcessingConfiguration;
  108271. /**
  108272. * Keep track of the image processing observer to allow dispose and replace.
  108273. */
  108274. private _imageProcessingObserver;
  108275. /**
  108276. * Attaches a new image processing configuration to the PBR Material.
  108277. * @param configuration
  108278. */
  108279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108280. /**
  108281. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108282. */
  108283. /**
  108284. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108285. */
  108286. colorCurves: Nullable<ColorCurves>;
  108287. /**
  108288. * Gets wether the color curves effect is enabled.
  108289. */
  108290. /**
  108291. * Sets wether the color curves effect is enabled.
  108292. */
  108293. colorCurvesEnabled: boolean;
  108294. /**
  108295. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108296. */
  108297. /**
  108298. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108299. */
  108300. colorGradingTexture: Nullable<BaseTexture>;
  108301. /**
  108302. * Gets wether the color grading effect is enabled.
  108303. */
  108304. /**
  108305. * Gets wether the color grading effect is enabled.
  108306. */
  108307. colorGradingEnabled: boolean;
  108308. /**
  108309. * Gets exposure used in the effect.
  108310. */
  108311. /**
  108312. * Sets exposure used in the effect.
  108313. */
  108314. exposure: number;
  108315. /**
  108316. * Gets wether tonemapping is enabled or not.
  108317. */
  108318. /**
  108319. * Sets wether tonemapping is enabled or not
  108320. */
  108321. toneMappingEnabled: boolean;
  108322. /**
  108323. * Gets the type of tone mapping effect.
  108324. */
  108325. /**
  108326. * Sets the type of tone mapping effect.
  108327. */
  108328. toneMappingType: number;
  108329. /**
  108330. * Gets contrast used in the effect.
  108331. */
  108332. /**
  108333. * Sets contrast used in the effect.
  108334. */
  108335. contrast: number;
  108336. /**
  108337. * Gets Vignette stretch size.
  108338. */
  108339. /**
  108340. * Sets Vignette stretch size.
  108341. */
  108342. vignetteStretch: number;
  108343. /**
  108344. * Gets Vignette centre X Offset.
  108345. */
  108346. /**
  108347. * Sets Vignette centre X Offset.
  108348. */
  108349. vignetteCentreX: number;
  108350. /**
  108351. * Gets Vignette centre Y Offset.
  108352. */
  108353. /**
  108354. * Sets Vignette centre Y Offset.
  108355. */
  108356. vignetteCentreY: number;
  108357. /**
  108358. * Gets Vignette weight or intensity of the vignette effect.
  108359. */
  108360. /**
  108361. * Sets Vignette weight or intensity of the vignette effect.
  108362. */
  108363. vignetteWeight: number;
  108364. /**
  108365. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108366. * if vignetteEnabled is set to true.
  108367. */
  108368. /**
  108369. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108370. * if vignetteEnabled is set to true.
  108371. */
  108372. vignetteColor: Color4;
  108373. /**
  108374. * Gets Camera field of view used by the Vignette effect.
  108375. */
  108376. /**
  108377. * Sets Camera field of view used by the Vignette effect.
  108378. */
  108379. vignetteCameraFov: number;
  108380. /**
  108381. * Gets the vignette blend mode allowing different kind of effect.
  108382. */
  108383. /**
  108384. * Sets the vignette blend mode allowing different kind of effect.
  108385. */
  108386. vignetteBlendMode: number;
  108387. /**
  108388. * Gets wether the vignette effect is enabled.
  108389. */
  108390. /**
  108391. * Sets wether the vignette effect is enabled.
  108392. */
  108393. vignetteEnabled: boolean;
  108394. private _fromLinearSpace;
  108395. /**
  108396. * Gets wether the input of the processing is in Gamma or Linear Space.
  108397. */
  108398. /**
  108399. * Sets wether the input of the processing is in Gamma or Linear Space.
  108400. */
  108401. fromLinearSpace: boolean;
  108402. /**
  108403. * Defines cache preventing GC.
  108404. */
  108405. private _defines;
  108406. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108407. /**
  108408. * "ImageProcessingPostProcess"
  108409. * @returns "ImageProcessingPostProcess"
  108410. */
  108411. getClassName(): string;
  108412. protected _updateParameters(): void;
  108413. dispose(camera?: Camera): void;
  108414. }
  108415. }
  108416. declare module BABYLON {
  108417. /**
  108418. * Class containing static functions to help procedurally build meshes
  108419. */
  108420. export class GroundBuilder {
  108421. /**
  108422. * Creates a ground mesh
  108423. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108424. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108426. * @param name defines the name of the mesh
  108427. * @param options defines the options used to create the mesh
  108428. * @param scene defines the hosting scene
  108429. * @returns the ground mesh
  108430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108431. */
  108432. static CreateGround(name: string, options: {
  108433. width?: number;
  108434. height?: number;
  108435. subdivisions?: number;
  108436. subdivisionsX?: number;
  108437. subdivisionsY?: number;
  108438. updatable?: boolean;
  108439. }, scene: any): Mesh;
  108440. /**
  108441. * Creates a tiled ground mesh
  108442. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108443. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108444. * * 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
  108445. * * 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
  108446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108447. * @param name defines the name of the mesh
  108448. * @param options defines the options used to create the mesh
  108449. * @param scene defines the hosting scene
  108450. * @returns the tiled ground mesh
  108451. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108452. */
  108453. static CreateTiledGround(name: string, options: {
  108454. xmin: number;
  108455. zmin: number;
  108456. xmax: number;
  108457. zmax: number;
  108458. subdivisions?: {
  108459. w: number;
  108460. h: number;
  108461. };
  108462. precision?: {
  108463. w: number;
  108464. h: number;
  108465. };
  108466. updatable?: boolean;
  108467. }, scene?: Nullable<Scene>): Mesh;
  108468. /**
  108469. * Creates a ground mesh from a height map
  108470. * * The parameter `url` sets the URL of the height map image resource.
  108471. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108472. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108473. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108474. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108475. * * 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.
  108476. * * 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).
  108477. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108479. * @param name defines the name of the mesh
  108480. * @param url defines the url to the height map
  108481. * @param options defines the options used to create the mesh
  108482. * @param scene defines the hosting scene
  108483. * @returns the ground mesh
  108484. * @see https://doc.babylonjs.com/babylon101/height_map
  108485. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108486. */
  108487. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108488. width?: number;
  108489. height?: number;
  108490. subdivisions?: number;
  108491. minHeight?: number;
  108492. maxHeight?: number;
  108493. colorFilter?: Color3;
  108494. alphaFilter?: number;
  108495. updatable?: boolean;
  108496. onReady?: (mesh: GroundMesh) => void;
  108497. }, scene?: Nullable<Scene>): GroundMesh;
  108498. }
  108499. }
  108500. declare module BABYLON {
  108501. /**
  108502. * Class containing static functions to help procedurally build meshes
  108503. */
  108504. export class TorusBuilder {
  108505. /**
  108506. * Creates a torus mesh
  108507. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108508. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108509. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108513. * @param name defines the name of the mesh
  108514. * @param options defines the options used to create the mesh
  108515. * @param scene defines the hosting scene
  108516. * @returns the torus mesh
  108517. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108518. */
  108519. static CreateTorus(name: string, options: {
  108520. diameter?: number;
  108521. thickness?: number;
  108522. tessellation?: number;
  108523. updatable?: boolean;
  108524. sideOrientation?: number;
  108525. frontUVs?: Vector4;
  108526. backUVs?: Vector4;
  108527. }, scene: any): Mesh;
  108528. }
  108529. }
  108530. declare module BABYLON {
  108531. /**
  108532. * Class containing static functions to help procedurally build meshes
  108533. */
  108534. export class CylinderBuilder {
  108535. /**
  108536. * Creates a cylinder or a cone mesh
  108537. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108538. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108539. * * 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.
  108540. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108541. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108542. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108543. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108544. * * 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).
  108545. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108546. * * 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).
  108547. * * 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
  108548. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108549. * * 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
  108550. * * 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.
  108551. * * If `enclose` is false, a ring surface is one element.
  108552. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108553. * * 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
  108554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108557. * @param name defines the name of the mesh
  108558. * @param options defines the options used to create the mesh
  108559. * @param scene defines the hosting scene
  108560. * @returns the cylinder mesh
  108561. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108562. */
  108563. static CreateCylinder(name: string, options: {
  108564. height?: number;
  108565. diameterTop?: number;
  108566. diameterBottom?: number;
  108567. diameter?: number;
  108568. tessellation?: number;
  108569. subdivisions?: number;
  108570. arc?: number;
  108571. faceColors?: Color4[];
  108572. faceUV?: Vector4[];
  108573. updatable?: boolean;
  108574. hasRings?: boolean;
  108575. enclose?: boolean;
  108576. cap?: number;
  108577. sideOrientation?: number;
  108578. frontUVs?: Vector4;
  108579. backUVs?: Vector4;
  108580. }, scene: any): Mesh;
  108581. }
  108582. }
  108583. declare module BABYLON {
  108584. /**
  108585. * Options to modify the vr teleportation behavior.
  108586. */
  108587. export interface VRTeleportationOptions {
  108588. /**
  108589. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108590. */
  108591. floorMeshName?: string;
  108592. /**
  108593. * A list of meshes to be used as the teleportation floor. (default: empty)
  108594. */
  108595. floorMeshes?: Mesh[];
  108596. }
  108597. /**
  108598. * Options to modify the vr experience helper's behavior.
  108599. */
  108600. export interface VRExperienceHelperOptions extends WebVROptions {
  108601. /**
  108602. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108603. */
  108604. createDeviceOrientationCamera?: boolean;
  108605. /**
  108606. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108607. */
  108608. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108609. /**
  108610. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108611. */
  108612. laserToggle?: boolean;
  108613. /**
  108614. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108615. */
  108616. floorMeshes?: Mesh[];
  108617. /**
  108618. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108619. */
  108620. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108621. }
  108622. /**
  108623. * Event containing information after VR has been entered
  108624. */
  108625. export class OnAfterEnteringVRObservableEvent {
  108626. /**
  108627. * If entering vr was successful
  108628. */
  108629. success: boolean;
  108630. }
  108631. /**
  108632. * Helps to quickly add VR support to an existing scene.
  108633. * See http://doc.babylonjs.com/how_to/webvr_helper
  108634. */
  108635. export class VRExperienceHelper {
  108636. /** Options to modify the vr experience helper's behavior. */
  108637. webVROptions: VRExperienceHelperOptions;
  108638. private _scene;
  108639. private _position;
  108640. private _btnVR;
  108641. private _btnVRDisplayed;
  108642. private _webVRsupported;
  108643. private _webVRready;
  108644. private _webVRrequesting;
  108645. private _webVRpresenting;
  108646. private _hasEnteredVR;
  108647. private _fullscreenVRpresenting;
  108648. private _canvas;
  108649. private _webVRCamera;
  108650. private _vrDeviceOrientationCamera;
  108651. private _deviceOrientationCamera;
  108652. private _existingCamera;
  108653. private _onKeyDown;
  108654. private _onVrDisplayPresentChange;
  108655. private _onVRDisplayChanged;
  108656. private _onVRRequestPresentStart;
  108657. private _onVRRequestPresentComplete;
  108658. /**
  108659. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  108660. */
  108661. enableGazeEvenWhenNoPointerLock: boolean;
  108662. /**
  108663. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108664. */
  108665. exitVROnDoubleTap: boolean;
  108666. /**
  108667. * Observable raised right before entering VR.
  108668. */
  108669. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108670. /**
  108671. * Observable raised when entering VR has completed.
  108672. */
  108673. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108674. /**
  108675. * Observable raised when exiting VR.
  108676. */
  108677. onExitingVRObservable: Observable<VRExperienceHelper>;
  108678. /**
  108679. * Observable raised when controller mesh is loaded.
  108680. */
  108681. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108682. /** Return this.onEnteringVRObservable
  108683. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108684. */
  108685. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108686. /** Return this.onExitingVRObservable
  108687. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108688. */
  108689. readonly onExitingVR: Observable<VRExperienceHelper>;
  108690. /** Return this.onControllerMeshLoadedObservable
  108691. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108692. */
  108693. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108694. private _rayLength;
  108695. private _useCustomVRButton;
  108696. private _teleportationRequested;
  108697. private _teleportActive;
  108698. private _floorMeshName;
  108699. private _floorMeshesCollection;
  108700. private _rotationAllowed;
  108701. private _teleportBackwardsVector;
  108702. private _teleportationTarget;
  108703. private _isDefaultTeleportationTarget;
  108704. private _postProcessMove;
  108705. private _teleportationFillColor;
  108706. private _teleportationBorderColor;
  108707. private _rotationAngle;
  108708. private _haloCenter;
  108709. private _cameraGazer;
  108710. private _padSensibilityUp;
  108711. private _padSensibilityDown;
  108712. private _leftController;
  108713. private _rightController;
  108714. /**
  108715. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108716. */
  108717. onNewMeshSelected: Observable<AbstractMesh>;
  108718. /**
  108719. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108720. * This observable will provide the mesh and the controller used to select the mesh
  108721. */
  108722. onMeshSelectedWithController: Observable<{
  108723. mesh: AbstractMesh;
  108724. controller: WebVRController;
  108725. }>;
  108726. /**
  108727. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108728. */
  108729. onNewMeshPicked: Observable<PickingInfo>;
  108730. private _circleEase;
  108731. /**
  108732. * Observable raised before camera teleportation
  108733. */
  108734. onBeforeCameraTeleport: Observable<Vector3>;
  108735. /**
  108736. * Observable raised after camera teleportation
  108737. */
  108738. onAfterCameraTeleport: Observable<Vector3>;
  108739. /**
  108740. * Observable raised when current selected mesh gets unselected
  108741. */
  108742. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108743. private _raySelectionPredicate;
  108744. /**
  108745. * To be optionaly changed by user to define custom ray selection
  108746. */
  108747. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108748. /**
  108749. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108750. */
  108751. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108752. /**
  108753. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108754. */
  108755. teleportationEnabled: boolean;
  108756. private _defaultHeight;
  108757. private _teleportationInitialized;
  108758. private _interactionsEnabled;
  108759. private _interactionsRequested;
  108760. private _displayGaze;
  108761. private _displayLaserPointer;
  108762. /**
  108763. * The mesh used to display where the user is going to teleport.
  108764. */
  108765. /**
  108766. * Sets the mesh to be used to display where the user is going to teleport.
  108767. */
  108768. teleportationTarget: Mesh;
  108769. /**
  108770. * 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
  108771. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108772. * See http://doc.babylonjs.com/resources/baking_transformations
  108773. */
  108774. gazeTrackerMesh: Mesh;
  108775. /**
  108776. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108777. */
  108778. updateGazeTrackerScale: boolean;
  108779. /**
  108780. * If the gaze trackers color should be updated when selecting meshes
  108781. */
  108782. updateGazeTrackerColor: boolean;
  108783. /**
  108784. * If the controller laser color should be updated when selecting meshes
  108785. */
  108786. updateControllerLaserColor: boolean;
  108787. /**
  108788. * The gaze tracking mesh corresponding to the left controller
  108789. */
  108790. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108791. /**
  108792. * The gaze tracking mesh corresponding to the right controller
  108793. */
  108794. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108795. /**
  108796. * If the ray of the gaze should be displayed.
  108797. */
  108798. /**
  108799. * Sets if the ray of the gaze should be displayed.
  108800. */
  108801. displayGaze: boolean;
  108802. /**
  108803. * If the ray of the LaserPointer should be displayed.
  108804. */
  108805. /**
  108806. * Sets if the ray of the LaserPointer should be displayed.
  108807. */
  108808. displayLaserPointer: boolean;
  108809. /**
  108810. * The deviceOrientationCamera used as the camera when not in VR.
  108811. */
  108812. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108813. /**
  108814. * Based on the current WebVR support, returns the current VR camera used.
  108815. */
  108816. readonly currentVRCamera: Nullable<Camera>;
  108817. /**
  108818. * The webVRCamera which is used when in VR.
  108819. */
  108820. readonly webVRCamera: WebVRFreeCamera;
  108821. /**
  108822. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108823. */
  108824. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108825. /**
  108826. * The html button that is used to trigger entering into VR.
  108827. */
  108828. readonly vrButton: Nullable<HTMLButtonElement>;
  108829. private readonly _teleportationRequestInitiated;
  108830. /**
  108831. * Defines wether or not Pointer lock should be requested when switching to
  108832. * full screen.
  108833. */
  108834. requestPointerLockOnFullScreen: boolean;
  108835. /**
  108836. * Instantiates a VRExperienceHelper.
  108837. * Helps to quickly add VR support to an existing scene.
  108838. * @param scene The scene the VRExperienceHelper belongs to.
  108839. * @param webVROptions Options to modify the vr experience helper's behavior.
  108840. */
  108841. constructor(scene: Scene,
  108842. /** Options to modify the vr experience helper's behavior. */
  108843. webVROptions?: VRExperienceHelperOptions);
  108844. private _onDefaultMeshLoaded;
  108845. private _onResize;
  108846. private _onFullscreenChange;
  108847. /**
  108848. * Gets a value indicating if we are currently in VR mode.
  108849. */
  108850. readonly isInVRMode: boolean;
  108851. private onVrDisplayPresentChange;
  108852. private onVRDisplayChanged;
  108853. private moveButtonToBottomRight;
  108854. private displayVRButton;
  108855. private updateButtonVisibility;
  108856. private _cachedAngularSensibility;
  108857. /**
  108858. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108859. * Otherwise, will use the fullscreen API.
  108860. */
  108861. enterVR(): void;
  108862. /**
  108863. * Attempt to exit VR, or fullscreen.
  108864. */
  108865. exitVR(): void;
  108866. /**
  108867. * The position of the vr experience helper.
  108868. */
  108869. /**
  108870. * Sets the position of the vr experience helper.
  108871. */
  108872. position: Vector3;
  108873. /**
  108874. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108875. */
  108876. enableInteractions(): void;
  108877. private readonly _noControllerIsActive;
  108878. private beforeRender;
  108879. private _isTeleportationFloor;
  108880. /**
  108881. * Adds a floor mesh to be used for teleportation.
  108882. * @param floorMesh the mesh to be used for teleportation.
  108883. */
  108884. addFloorMesh(floorMesh: Mesh): void;
  108885. /**
  108886. * Removes a floor mesh from being used for teleportation.
  108887. * @param floorMesh the mesh to be removed.
  108888. */
  108889. removeFloorMesh(floorMesh: Mesh): void;
  108890. /**
  108891. * Enables interactions and teleportation using the VR controllers and gaze.
  108892. * @param vrTeleportationOptions options to modify teleportation behavior.
  108893. */
  108894. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108895. private _onNewGamepadConnected;
  108896. private _tryEnableInteractionOnController;
  108897. private _onNewGamepadDisconnected;
  108898. private _enableInteractionOnController;
  108899. private _checkTeleportWithRay;
  108900. private _checkRotate;
  108901. private _checkTeleportBackwards;
  108902. private _enableTeleportationOnController;
  108903. private _createTeleportationCircles;
  108904. private _displayTeleportationTarget;
  108905. private _hideTeleportationTarget;
  108906. private _rotateCamera;
  108907. private _moveTeleportationSelectorTo;
  108908. private _workingVector;
  108909. private _workingQuaternion;
  108910. private _workingMatrix;
  108911. /**
  108912. * Teleports the users feet to the desired location
  108913. * @param location The location where the user's feet should be placed
  108914. */
  108915. teleportCamera(location: Vector3): void;
  108916. private _convertNormalToDirectionOfRay;
  108917. private _castRayAndSelectObject;
  108918. private _notifySelectedMeshUnselected;
  108919. /**
  108920. * Sets the color of the laser ray from the vr controllers.
  108921. * @param color new color for the ray.
  108922. */
  108923. changeLaserColor(color: Color3): void;
  108924. /**
  108925. * Sets the color of the ray from the vr headsets gaze.
  108926. * @param color new color for the ray.
  108927. */
  108928. changeGazeColor(color: Color3): void;
  108929. /**
  108930. * Exits VR and disposes of the vr experience helper
  108931. */
  108932. dispose(): void;
  108933. /**
  108934. * Gets the name of the VRExperienceHelper class
  108935. * @returns "VRExperienceHelper"
  108936. */
  108937. getClassName(): string;
  108938. }
  108939. }
  108940. declare module BABYLON {
  108941. /**
  108942. * Manages an XRSession to work with Babylon's engine
  108943. * @see https://doc.babylonjs.com/how_to/webxr
  108944. */
  108945. export class WebXRSessionManager implements IDisposable {
  108946. private scene;
  108947. /**
  108948. * Fires every time a new xrFrame arrives which can be used to update the camera
  108949. */
  108950. onXRFrameObservable: Observable<any>;
  108951. /**
  108952. * Fires when the xr session is ended either by the device or manually done
  108953. */
  108954. onXRSessionEnded: Observable<any>;
  108955. /**
  108956. * Underlying xr session
  108957. */
  108958. session: XRSession;
  108959. /**
  108960. * Type of reference space used when creating the session
  108961. */
  108962. referenceSpace: XRReferenceSpace;
  108963. /** @hidden */
  108964. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108965. /**
  108966. * Current XR frame
  108967. */
  108968. currentFrame: Nullable<XRFrame>;
  108969. private _xrNavigator;
  108970. private baseLayer;
  108971. /**
  108972. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108973. * @param scene The scene which the session should be created for
  108974. */
  108975. constructor(scene: Scene);
  108976. /**
  108977. * Initializes the manager
  108978. * After initialization enterXR can be called to start an XR session
  108979. * @returns Promise which resolves after it is initialized
  108980. */
  108981. initializeAsync(): Promise<void>;
  108982. /**
  108983. * Initializes an xr session
  108984. * @param xrSessionMode mode to initialize
  108985. * @returns a promise which will resolve once the session has been initialized
  108986. */
  108987. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108988. /**
  108989. * Sets the reference space on the xr session
  108990. * @param referenceSpace space to set
  108991. * @returns a promise that will resolve once the reference space has been set
  108992. */
  108993. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108994. /**
  108995. * Updates the render state of the session
  108996. * @param state state to set
  108997. * @returns a promise that resolves once the render state has been updated
  108998. */
  108999. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109000. /**
  109001. * Starts rendering to the xr layer
  109002. * @returns a promise that will resolve once rendering has started
  109003. */
  109004. startRenderingToXRAsync(): Promise<void>;
  109005. /**
  109006. * Stops the xrSession and restores the renderloop
  109007. * @returns Promise which resolves after it exits XR
  109008. */
  109009. exitXRAsync(): Promise<unknown>;
  109010. /**
  109011. * Checks if a session would be supported for the creation options specified
  109012. * @param sessionMode session mode to check if supported eg. immersive-vr
  109013. * @returns true if supported
  109014. */
  109015. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109016. /**
  109017. * @hidden
  109018. * Converts the render layer of xrSession to a render target
  109019. * @param session session to create render target for
  109020. * @param scene scene the new render target should be created for
  109021. */
  109022. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109023. /**
  109024. * Disposes of the session manager
  109025. */
  109026. dispose(): void;
  109027. }
  109028. }
  109029. declare module BABYLON {
  109030. /**
  109031. * WebXR Camera which holds the views for the xrSession
  109032. * @see https://doc.babylonjs.com/how_to/webxr
  109033. */
  109034. export class WebXRCamera extends FreeCamera {
  109035. private static _TmpMatrix;
  109036. /**
  109037. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109038. * @param name the name of the camera
  109039. * @param scene the scene to add the camera to
  109040. */
  109041. constructor(name: string, scene: Scene);
  109042. private _updateNumberOfRigCameras;
  109043. /** @hidden */
  109044. _updateForDualEyeDebugging(pupilDistance?: number): void;
  109045. /**
  109046. * Updates the cameras position from the current pose information of the XR session
  109047. * @param xrSessionManager the session containing pose information
  109048. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109049. */
  109050. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109051. }
  109052. }
  109053. declare module BABYLON {
  109054. /**
  109055. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109056. */
  109057. export class WebXRManagedOutputCanvas implements IDisposable {
  109058. private helper;
  109059. private _canvas;
  109060. /**
  109061. * xrpresent context of the canvas which can be used to display/mirror xr content
  109062. */
  109063. canvasContext: WebGLRenderingContext;
  109064. /**
  109065. * xr layer for the canvas
  109066. */
  109067. xrLayer: Nullable<XRWebGLLayer>;
  109068. /**
  109069. * Initializes the xr layer for the session
  109070. * @param xrSession xr session
  109071. * @returns a promise that will resolve once the XR Layer has been created
  109072. */
  109073. initializeXRLayerAsync(xrSession: any): any;
  109074. /**
  109075. * Initializes the canvas to be added/removed upon entering/exiting xr
  109076. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  109077. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109078. */
  109079. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  109080. /**
  109081. * Disposes of the object
  109082. */
  109083. dispose(): void;
  109084. private _setManagedOutputCanvas;
  109085. private _addCanvas;
  109086. private _removeCanvas;
  109087. }
  109088. }
  109089. declare module BABYLON {
  109090. /**
  109091. * States of the webXR experience
  109092. */
  109093. export enum WebXRState {
  109094. /**
  109095. * Transitioning to being in XR mode
  109096. */
  109097. ENTERING_XR = 0,
  109098. /**
  109099. * Transitioning to non XR mode
  109100. */
  109101. EXITING_XR = 1,
  109102. /**
  109103. * In XR mode and presenting
  109104. */
  109105. IN_XR = 2,
  109106. /**
  109107. * Not entered XR mode
  109108. */
  109109. NOT_IN_XR = 3
  109110. }
  109111. /**
  109112. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109113. * @see https://doc.babylonjs.com/how_to/webxr
  109114. */
  109115. export class WebXRExperienceHelper implements IDisposable {
  109116. private scene;
  109117. /**
  109118. * 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
  109119. */
  109120. container: AbstractMesh;
  109121. /**
  109122. * Camera used to render xr content
  109123. */
  109124. camera: WebXRCamera;
  109125. /**
  109126. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109127. */
  109128. state: WebXRState;
  109129. private _setState;
  109130. private static _TmpVector;
  109131. /**
  109132. * Fires when the state of the experience helper has changed
  109133. */
  109134. onStateChangedObservable: Observable<WebXRState>;
  109135. /** Session manager used to keep track of xr session */
  109136. sessionManager: WebXRSessionManager;
  109137. private _nonVRCamera;
  109138. private _originalSceneAutoClear;
  109139. private _supported;
  109140. /**
  109141. * Creates the experience helper
  109142. * @param scene the scene to attach the experience helper to
  109143. * @returns a promise for the experience helper
  109144. */
  109145. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109146. /**
  109147. * Creates a WebXRExperienceHelper
  109148. * @param scene The scene the helper should be created in
  109149. */
  109150. private constructor();
  109151. /**
  109152. * Exits XR mode and returns the scene to its original state
  109153. * @returns promise that resolves after xr mode has exited
  109154. */
  109155. exitXRAsync(): Promise<unknown>;
  109156. /**
  109157. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109158. * @param sessionCreationOptions options for the XR session
  109159. * @param referenceSpaceType frame of reference of the XR session
  109160. * @param outputCanvas the output canvas that will be used to enter XR mode
  109161. * @returns promise that resolves after xr mode has entered
  109162. */
  109163. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  109164. /**
  109165. * Updates the global position of the camera by moving the camera's container
  109166. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109167. * @param position The desired global position of the camera
  109168. */
  109169. setPositionOfCameraUsingContainer(position: Vector3): void;
  109170. /**
  109171. * Rotates the xr camera by rotating the camera's container around the camera's position
  109172. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109173. * @param rotation the desired quaternion rotation to apply to the camera
  109174. */
  109175. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109176. /**
  109177. * Disposes of the experience helper
  109178. */
  109179. dispose(): void;
  109180. }
  109181. }
  109182. declare module BABYLON {
  109183. /**
  109184. * Button which can be used to enter a different mode of XR
  109185. */
  109186. export class WebXREnterExitUIButton {
  109187. /** button element */
  109188. element: HTMLElement;
  109189. /** XR initialization options for the button */
  109190. sessionMode: XRSessionMode;
  109191. /** Reference space type */
  109192. referenceSpaceType: XRReferenceSpaceType;
  109193. /**
  109194. * Creates a WebXREnterExitUIButton
  109195. * @param element button element
  109196. * @param sessionMode XR initialization session mode
  109197. * @param referenceSpaceType the type of reference space to be used
  109198. */
  109199. constructor(
  109200. /** button element */
  109201. element: HTMLElement,
  109202. /** XR initialization options for the button */
  109203. sessionMode: XRSessionMode,
  109204. /** Reference space type */
  109205. referenceSpaceType: XRReferenceSpaceType);
  109206. /**
  109207. * Overwritable function which can be used to update the button's visuals when the state changes
  109208. * @param activeButton the current active button in the UI
  109209. */
  109210. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109211. }
  109212. /**
  109213. * Options to create the webXR UI
  109214. */
  109215. export class WebXREnterExitUIOptions {
  109216. /**
  109217. * Context to enter xr with
  109218. */
  109219. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  109220. /**
  109221. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109222. */
  109223. customButtons?: Array<WebXREnterExitUIButton>;
  109224. }
  109225. /**
  109226. * UI to allow the user to enter/exit XR mode
  109227. */
  109228. export class WebXREnterExitUI implements IDisposable {
  109229. private scene;
  109230. private _overlay;
  109231. private _buttons;
  109232. private _activeButton;
  109233. /**
  109234. * Fired every time the active button is changed.
  109235. *
  109236. * When xr is entered via a button that launches xr that button will be the callback parameter
  109237. *
  109238. * When exiting xr the callback parameter will be null)
  109239. */
  109240. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109241. /**
  109242. * Creates UI to allow the user to enter/exit XR mode
  109243. * @param scene the scene to add the ui to
  109244. * @param helper the xr experience helper to enter/exit xr with
  109245. * @param options options to configure the UI
  109246. * @returns the created ui
  109247. */
  109248. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109249. private constructor();
  109250. private _updateButtons;
  109251. /**
  109252. * Disposes of the object
  109253. */
  109254. dispose(): void;
  109255. }
  109256. }
  109257. declare module BABYLON {
  109258. /**
  109259. * Represents an XR input
  109260. */
  109261. export class WebXRController {
  109262. private scene;
  109263. /** The underlying input source for the controller */
  109264. inputSource: XRInputSource;
  109265. private parentContainer;
  109266. /**
  109267. * 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
  109268. */
  109269. grip?: AbstractMesh;
  109270. /**
  109271. * Pointer which can be used to select objects or attach a visible laser to
  109272. */
  109273. pointer: AbstractMesh;
  109274. /**
  109275. * Event that fires when the controller is removed/disposed
  109276. */
  109277. onDisposeObservable: Observable<{}>;
  109278. private _tmpMatrix;
  109279. private _tmpQuaternion;
  109280. private _tmpVector;
  109281. /**
  109282. * Creates the controller
  109283. * @see https://doc.babylonjs.com/how_to/webxr
  109284. * @param scene the scene which the controller should be associated to
  109285. * @param inputSource the underlying input source for the controller
  109286. * @param parentContainer parent that the controller meshes should be children of
  109287. */
  109288. constructor(scene: Scene,
  109289. /** The underlying input source for the controller */
  109290. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109291. /**
  109292. * Updates the controller pose based on the given XRFrame
  109293. * @param xrFrame xr frame to update the pose with
  109294. * @param referenceSpace reference space to use
  109295. */
  109296. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109297. /**
  109298. * Gets a world space ray coming from the controller
  109299. * @param result the resulting ray
  109300. */
  109301. getWorldPointerRayToRef(result: Ray): void;
  109302. /**
  109303. * Disposes of the object
  109304. */
  109305. dispose(): void;
  109306. }
  109307. }
  109308. declare module BABYLON {
  109309. /**
  109310. * XR input used to track XR inputs such as controllers/rays
  109311. */
  109312. export class WebXRInput implements IDisposable {
  109313. /**
  109314. * Base experience the input listens to
  109315. */
  109316. baseExperience: WebXRExperienceHelper;
  109317. /**
  109318. * XR controllers being tracked
  109319. */
  109320. controllers: Array<WebXRController>;
  109321. private _frameObserver;
  109322. private _stateObserver;
  109323. /**
  109324. * Event when a controller has been connected/added
  109325. */
  109326. onControllerAddedObservable: Observable<WebXRController>;
  109327. /**
  109328. * Event when a controller has been removed/disconnected
  109329. */
  109330. onControllerRemovedObservable: Observable<WebXRController>;
  109331. /**
  109332. * Initializes the WebXRInput
  109333. * @param baseExperience experience helper which the input should be created for
  109334. */
  109335. constructor(
  109336. /**
  109337. * Base experience the input listens to
  109338. */
  109339. baseExperience: WebXRExperienceHelper);
  109340. private _onInputSourcesChange;
  109341. private _addAndRemoveControllers;
  109342. /**
  109343. * Disposes of the object
  109344. */
  109345. dispose(): void;
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. /**
  109350. * Enables teleportation
  109351. */
  109352. export class WebXRControllerTeleportation {
  109353. private _teleportationFillColor;
  109354. private _teleportationBorderColor;
  109355. private _tmpRay;
  109356. private _tmpVector;
  109357. /**
  109358. * Creates a WebXRControllerTeleportation
  109359. * @param input input manager to add teleportation to
  109360. * @param floorMeshes floormeshes which can be teleported to
  109361. */
  109362. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109363. }
  109364. }
  109365. declare module BABYLON {
  109366. /**
  109367. * Handles pointer input automatically for the pointer of XR controllers
  109368. */
  109369. export class WebXRControllerPointerSelection {
  109370. private static _idCounter;
  109371. private _tmpRay;
  109372. /**
  109373. * Creates a WebXRControllerPointerSelection
  109374. * @param input input manager to setup pointer selection
  109375. */
  109376. constructor(input: WebXRInput);
  109377. private _convertNormalToDirectionOfRay;
  109378. private _updatePointerDistance;
  109379. }
  109380. }
  109381. declare module BABYLON {
  109382. /**
  109383. * Class used to represent data loading progression
  109384. */
  109385. export class SceneLoaderProgressEvent {
  109386. /** defines if data length to load can be evaluated */
  109387. readonly lengthComputable: boolean;
  109388. /** defines the loaded data length */
  109389. readonly loaded: number;
  109390. /** defines the data length to load */
  109391. readonly total: number;
  109392. /**
  109393. * Create a new progress event
  109394. * @param lengthComputable defines if data length to load can be evaluated
  109395. * @param loaded defines the loaded data length
  109396. * @param total defines the data length to load
  109397. */
  109398. constructor(
  109399. /** defines if data length to load can be evaluated */
  109400. lengthComputable: boolean,
  109401. /** defines the loaded data length */
  109402. loaded: number,
  109403. /** defines the data length to load */
  109404. total: number);
  109405. /**
  109406. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109407. * @param event defines the source event
  109408. * @returns a new SceneLoaderProgressEvent
  109409. */
  109410. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109411. }
  109412. /**
  109413. * Interface used by SceneLoader plugins to define supported file extensions
  109414. */
  109415. export interface ISceneLoaderPluginExtensions {
  109416. /**
  109417. * Defines the list of supported extensions
  109418. */
  109419. [extension: string]: {
  109420. isBinary: boolean;
  109421. };
  109422. }
  109423. /**
  109424. * Interface used by SceneLoader plugin factory
  109425. */
  109426. export interface ISceneLoaderPluginFactory {
  109427. /**
  109428. * Defines the name of the factory
  109429. */
  109430. name: string;
  109431. /**
  109432. * Function called to create a new plugin
  109433. * @return the new plugin
  109434. */
  109435. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109436. /**
  109437. * The callback that returns true if the data can be directly loaded.
  109438. * @param data string containing the file data
  109439. * @returns if the data can be loaded directly
  109440. */
  109441. canDirectLoad?(data: string): boolean;
  109442. }
  109443. /**
  109444. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  109445. */
  109446. export interface ISceneLoaderPluginBase {
  109447. /**
  109448. * The friendly name of this plugin.
  109449. */
  109450. name: string;
  109451. /**
  109452. * The file extensions supported by this plugin.
  109453. */
  109454. extensions: string | ISceneLoaderPluginExtensions;
  109455. /**
  109456. * The callback called when loading from a url.
  109457. * @param scene scene loading this url
  109458. * @param url url to load
  109459. * @param onSuccess callback called when the file successfully loads
  109460. * @param onProgress callback called while file is loading (if the server supports this mode)
  109461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109462. * @param onError callback called when the file fails to load
  109463. * @returns a file request object
  109464. */
  109465. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109466. /**
  109467. * The callback called when loading from a file object.
  109468. * @param scene scene loading this file
  109469. * @param file defines the file to load
  109470. * @param onSuccess defines the callback to call when data is loaded
  109471. * @param onProgress defines the callback to call during loading process
  109472. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109473. * @param onError defines the callback to call when an error occurs
  109474. * @returns a file request object
  109475. */
  109476. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109477. /**
  109478. * The callback that returns true if the data can be directly loaded.
  109479. * @param data string containing the file data
  109480. * @returns if the data can be loaded directly
  109481. */
  109482. canDirectLoad?(data: string): boolean;
  109483. /**
  109484. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  109485. * @param scene scene loading this data
  109486. * @param data string containing the data
  109487. * @returns data to pass to the plugin
  109488. */
  109489. directLoad?(scene: Scene, data: string): any;
  109490. /**
  109491. * The callback that allows custom handling of the root url based on the response url.
  109492. * @param rootUrl the original root url
  109493. * @param responseURL the response url if available
  109494. * @returns the new root url
  109495. */
  109496. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  109497. }
  109498. /**
  109499. * Interface used to define a SceneLoader plugin
  109500. */
  109501. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  109502. /**
  109503. * Import meshes into a scene.
  109504. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109505. * @param scene The scene to import into
  109506. * @param data The data to import
  109507. * @param rootUrl The root url for scene and resources
  109508. * @param meshes The meshes array to import into
  109509. * @param particleSystems The particle systems array to import into
  109510. * @param skeletons The skeletons array to import into
  109511. * @param onError The callback when import fails
  109512. * @returns True if successful or false otherwise
  109513. */
  109514. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109515. /**
  109516. * Load into a scene.
  109517. * @param scene The scene to load into
  109518. * @param data The data to import
  109519. * @param rootUrl The root url for scene and resources
  109520. * @param onError The callback when import fails
  109521. * @returns True if successful or false otherwise
  109522. */
  109523. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109524. /**
  109525. * Load into an asset container.
  109526. * @param scene The scene to load into
  109527. * @param data The data to import
  109528. * @param rootUrl The root url for scene and resources
  109529. * @param onError The callback when import fails
  109530. * @returns The loaded asset container
  109531. */
  109532. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109533. }
  109534. /**
  109535. * Interface used to define an async SceneLoader plugin
  109536. */
  109537. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  109538. /**
  109539. * Import meshes into a scene.
  109540. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109541. * @param scene The scene to import into
  109542. * @param data The data to import
  109543. * @param rootUrl The root url for scene and resources
  109544. * @param onProgress The callback when the load progresses
  109545. * @param fileName Defines the name of the file to load
  109546. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109547. */
  109548. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109549. meshes: AbstractMesh[];
  109550. particleSystems: IParticleSystem[];
  109551. skeletons: Skeleton[];
  109552. animationGroups: AnimationGroup[];
  109553. }>;
  109554. /**
  109555. * Load into a scene.
  109556. * @param scene The scene to load into
  109557. * @param data The data to import
  109558. * @param rootUrl The root url for scene and resources
  109559. * @param onProgress The callback when the load progresses
  109560. * @param fileName Defines the name of the file to load
  109561. * @returns Nothing
  109562. */
  109563. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109564. /**
  109565. * Load into an asset container.
  109566. * @param scene The scene to load into
  109567. * @param data The data to import
  109568. * @param rootUrl The root url for scene and resources
  109569. * @param onProgress The callback when the load progresses
  109570. * @param fileName Defines the name of the file to load
  109571. * @returns The loaded asset container
  109572. */
  109573. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109574. }
  109575. /**
  109576. * Class used to load scene from various file formats using registered plugins
  109577. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109578. */
  109579. export class SceneLoader {
  109580. /**
  109581. * No logging while loading
  109582. */
  109583. static readonly NO_LOGGING: number;
  109584. /**
  109585. * Minimal logging while loading
  109586. */
  109587. static readonly MINIMAL_LOGGING: number;
  109588. /**
  109589. * Summary logging while loading
  109590. */
  109591. static readonly SUMMARY_LOGGING: number;
  109592. /**
  109593. * Detailled logging while loading
  109594. */
  109595. static readonly DETAILED_LOGGING: number;
  109596. /**
  109597. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109598. */
  109599. static ForceFullSceneLoadingForIncremental: boolean;
  109600. /**
  109601. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109602. */
  109603. static ShowLoadingScreen: boolean;
  109604. /**
  109605. * Defines the current logging level (while loading the scene)
  109606. * @ignorenaming
  109607. */
  109608. static loggingLevel: number;
  109609. /**
  109610. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109611. */
  109612. static CleanBoneMatrixWeights: boolean;
  109613. /**
  109614. * Event raised when a plugin is used to load a scene
  109615. */
  109616. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109617. private static _registeredPlugins;
  109618. private static _getDefaultPlugin;
  109619. private static _getPluginForExtension;
  109620. private static _getPluginForDirectLoad;
  109621. private static _getPluginForFilename;
  109622. private static _getDirectLoad;
  109623. private static _loadData;
  109624. private static _getFileInfo;
  109625. /**
  109626. * Gets a plugin that can load the given extension
  109627. * @param extension defines the extension to load
  109628. * @returns a plugin or null if none works
  109629. */
  109630. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109631. /**
  109632. * Gets a boolean indicating that the given extension can be loaded
  109633. * @param extension defines the extension to load
  109634. * @returns true if the extension is supported
  109635. */
  109636. static IsPluginForExtensionAvailable(extension: string): boolean;
  109637. /**
  109638. * Adds a new plugin to the list of registered plugins
  109639. * @param plugin defines the plugin to add
  109640. */
  109641. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109642. /**
  109643. * Import meshes into a scene
  109644. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109645. * @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)
  109646. * @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)
  109647. * @param scene the instance of BABYLON.Scene to append to
  109648. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109649. * @param onProgress a callback with a progress event for each file being loaded
  109650. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109651. * @param pluginExtension the extension used to determine the plugin
  109652. * @returns The loaded plugin
  109653. */
  109654. 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>;
  109655. /**
  109656. * Import meshes into a scene
  109657. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109658. * @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)
  109659. * @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)
  109660. * @param scene the instance of BABYLON.Scene to append to
  109661. * @param onProgress a callback with a progress event for each file being loaded
  109662. * @param pluginExtension the extension used to determine the plugin
  109663. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109664. */
  109665. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109666. meshes: AbstractMesh[];
  109667. particleSystems: IParticleSystem[];
  109668. skeletons: Skeleton[];
  109669. animationGroups: AnimationGroup[];
  109670. }>;
  109671. /**
  109672. * Load a scene
  109673. * @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)
  109674. * @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)
  109675. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109676. * @param onSuccess a callback with the scene when import succeeds
  109677. * @param onProgress a callback with a progress event for each file being loaded
  109678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109679. * @param pluginExtension the extension used to determine the plugin
  109680. * @returns The loaded plugin
  109681. */
  109682. 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>;
  109683. /**
  109684. * Load a scene
  109685. * @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)
  109686. * @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)
  109687. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109688. * @param onProgress a callback with a progress event for each file being loaded
  109689. * @param pluginExtension the extension used to determine the plugin
  109690. * @returns The loaded scene
  109691. */
  109692. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109693. /**
  109694. * Append a scene
  109695. * @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)
  109696. * @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)
  109697. * @param scene is the instance of BABYLON.Scene to append to
  109698. * @param onSuccess a callback with the scene when import succeeds
  109699. * @param onProgress a callback with a progress event for each file being loaded
  109700. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109701. * @param pluginExtension the extension used to determine the plugin
  109702. * @returns The loaded plugin
  109703. */
  109704. 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>;
  109705. /**
  109706. * Append a scene
  109707. * @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)
  109708. * @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)
  109709. * @param scene is the instance of BABYLON.Scene to append to
  109710. * @param onProgress a callback with a progress event for each file being loaded
  109711. * @param pluginExtension the extension used to determine the plugin
  109712. * @returns The given scene
  109713. */
  109714. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109715. /**
  109716. * Load a scene into an asset container
  109717. * @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)
  109718. * @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)
  109719. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109720. * @param onSuccess a callback with the scene when import succeeds
  109721. * @param onProgress a callback with a progress event for each file being loaded
  109722. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109723. * @param pluginExtension the extension used to determine the plugin
  109724. * @returns The loaded plugin
  109725. */
  109726. 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>;
  109727. /**
  109728. * Load a scene into an asset container
  109729. * @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)
  109730. * @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)
  109731. * @param scene is the instance of Scene to append to
  109732. * @param onProgress a callback with a progress event for each file being loaded
  109733. * @param pluginExtension the extension used to determine the plugin
  109734. * @returns The loaded asset container
  109735. */
  109736. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109737. }
  109738. }
  109739. declare module BABYLON {
  109740. /**
  109741. * Generic Controller
  109742. */
  109743. export class GenericController extends WebVRController {
  109744. /**
  109745. * Base Url for the controller model.
  109746. */
  109747. static readonly MODEL_BASE_URL: string;
  109748. /**
  109749. * File name for the controller model.
  109750. */
  109751. static readonly MODEL_FILENAME: string;
  109752. /**
  109753. * Creates a new GenericController from a gamepad
  109754. * @param vrGamepad the gamepad that the controller should be created from
  109755. */
  109756. constructor(vrGamepad: any);
  109757. /**
  109758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109759. * @param scene scene in which to add meshes
  109760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109761. */
  109762. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109763. /**
  109764. * Called once for each button that changed state since the last frame
  109765. * @param buttonIdx Which button index changed
  109766. * @param state New state of the button
  109767. * @param changes Which properties on the state changed since last frame
  109768. */
  109769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109770. }
  109771. }
  109772. declare module BABYLON {
  109773. /**
  109774. * Defines the WindowsMotionController object that the state of the windows motion controller
  109775. */
  109776. export class WindowsMotionController extends WebVRController {
  109777. /**
  109778. * The base url used to load the left and right controller models
  109779. */
  109780. static MODEL_BASE_URL: string;
  109781. /**
  109782. * The name of the left controller model file
  109783. */
  109784. static MODEL_LEFT_FILENAME: string;
  109785. /**
  109786. * The name of the right controller model file
  109787. */
  109788. static MODEL_RIGHT_FILENAME: string;
  109789. /**
  109790. * The controller name prefix for this controller type
  109791. */
  109792. static readonly GAMEPAD_ID_PREFIX: string;
  109793. /**
  109794. * The controller id pattern for this controller type
  109795. */
  109796. private static readonly GAMEPAD_ID_PATTERN;
  109797. private _loadedMeshInfo;
  109798. private readonly _mapping;
  109799. /**
  109800. * Fired when the trackpad on this controller is clicked
  109801. */
  109802. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109803. /**
  109804. * Fired when the trackpad on this controller is modified
  109805. */
  109806. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109807. /**
  109808. * The current x and y values of this controller's trackpad
  109809. */
  109810. trackpad: StickValues;
  109811. /**
  109812. * Creates a new WindowsMotionController from a gamepad
  109813. * @param vrGamepad the gamepad that the controller should be created from
  109814. */
  109815. constructor(vrGamepad: any);
  109816. /**
  109817. * Fired when the trigger on this controller is modified
  109818. */
  109819. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109820. /**
  109821. * Fired when the menu button on this controller is modified
  109822. */
  109823. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109824. /**
  109825. * Fired when the grip button on this controller is modified
  109826. */
  109827. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109828. /**
  109829. * Fired when the thumbstick button on this controller is modified
  109830. */
  109831. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109832. /**
  109833. * Fired when the touchpad button on this controller is modified
  109834. */
  109835. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109836. /**
  109837. * Fired when the touchpad values on this controller are modified
  109838. */
  109839. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109840. private _updateTrackpad;
  109841. /**
  109842. * Called once per frame by the engine.
  109843. */
  109844. update(): void;
  109845. /**
  109846. * Called once for each button that changed state since the last frame
  109847. * @param buttonIdx Which button index changed
  109848. * @param state New state of the button
  109849. * @param changes Which properties on the state changed since last frame
  109850. */
  109851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109852. /**
  109853. * Moves the buttons on the controller mesh based on their current state
  109854. * @param buttonName the name of the button to move
  109855. * @param buttonValue the value of the button which determines the buttons new position
  109856. */
  109857. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109858. /**
  109859. * Moves the axis on the controller mesh based on its current state
  109860. * @param axis the index of the axis
  109861. * @param axisValue the value of the axis which determines the meshes new position
  109862. * @hidden
  109863. */
  109864. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109865. /**
  109866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109867. * @param scene scene in which to add meshes
  109868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109869. */
  109870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109871. /**
  109872. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109873. * can be transformed by button presses and axes values, based on this._mapping.
  109874. *
  109875. * @param scene scene in which the meshes exist
  109876. * @param meshes list of meshes that make up the controller model to process
  109877. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109878. */
  109879. private processModel;
  109880. private createMeshInfo;
  109881. /**
  109882. * Gets the ray of the controller in the direction the controller is pointing
  109883. * @param length the length the resulting ray should be
  109884. * @returns a ray in the direction the controller is pointing
  109885. */
  109886. getForwardRay(length?: number): Ray;
  109887. /**
  109888. * Disposes of the controller
  109889. */
  109890. dispose(): void;
  109891. }
  109892. }
  109893. declare module BABYLON {
  109894. /**
  109895. * Oculus Touch Controller
  109896. */
  109897. export class OculusTouchController extends WebVRController {
  109898. /**
  109899. * Base Url for the controller model.
  109900. */
  109901. static MODEL_BASE_URL: string;
  109902. /**
  109903. * File name for the left controller model.
  109904. */
  109905. static MODEL_LEFT_FILENAME: string;
  109906. /**
  109907. * File name for the right controller model.
  109908. */
  109909. static MODEL_RIGHT_FILENAME: string;
  109910. /**
  109911. * Base Url for the Quest controller model.
  109912. */
  109913. static QUEST_MODEL_BASE_URL: string;
  109914. /**
  109915. * @hidden
  109916. * If the controllers are running on a device that needs the updated Quest controller models
  109917. */
  109918. static _IsQuest: boolean;
  109919. /**
  109920. * Fired when the secondary trigger on this controller is modified
  109921. */
  109922. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109923. /**
  109924. * Fired when the thumb rest on this controller is modified
  109925. */
  109926. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109927. /**
  109928. * Creates a new OculusTouchController from a gamepad
  109929. * @param vrGamepad the gamepad that the controller should be created from
  109930. */
  109931. constructor(vrGamepad: any);
  109932. /**
  109933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109934. * @param scene scene in which to add meshes
  109935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109936. */
  109937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109938. /**
  109939. * Fired when the A button on this controller is modified
  109940. */
  109941. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109942. /**
  109943. * Fired when the B button on this controller is modified
  109944. */
  109945. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109946. /**
  109947. * Fired when the X button on this controller is modified
  109948. */
  109949. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109950. /**
  109951. * Fired when the Y button on this controller is modified
  109952. */
  109953. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109954. /**
  109955. * Called once for each button that changed state since the last frame
  109956. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109957. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109958. * 2) secondary trigger (same)
  109959. * 3) A (right) X (left), touch, pressed = value
  109960. * 4) B / Y
  109961. * 5) thumb rest
  109962. * @param buttonIdx Which button index changed
  109963. * @param state New state of the button
  109964. * @param changes Which properties on the state changed since last frame
  109965. */
  109966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109967. }
  109968. }
  109969. declare module BABYLON {
  109970. /**
  109971. * Vive Controller
  109972. */
  109973. export class ViveController extends WebVRController {
  109974. /**
  109975. * Base Url for the controller model.
  109976. */
  109977. static MODEL_BASE_URL: string;
  109978. /**
  109979. * File name for the controller model.
  109980. */
  109981. static MODEL_FILENAME: string;
  109982. /**
  109983. * Creates a new ViveController from a gamepad
  109984. * @param vrGamepad the gamepad that the controller should be created from
  109985. */
  109986. constructor(vrGamepad: any);
  109987. /**
  109988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109989. * @param scene scene in which to add meshes
  109990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109991. */
  109992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109993. /**
  109994. * Fired when the left button on this controller is modified
  109995. */
  109996. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109997. /**
  109998. * Fired when the right button on this controller is modified
  109999. */
  110000. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110001. /**
  110002. * Fired when the menu button on this controller is modified
  110003. */
  110004. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110005. /**
  110006. * Called once for each button that changed state since the last frame
  110007. * Vive mapping:
  110008. * 0: touchpad
  110009. * 1: trigger
  110010. * 2: left AND right buttons
  110011. * 3: menu button
  110012. * @param buttonIdx Which button index changed
  110013. * @param state New state of the button
  110014. * @param changes Which properties on the state changed since last frame
  110015. */
  110016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110017. }
  110018. }
  110019. declare module BABYLON {
  110020. /**
  110021. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110022. */
  110023. export class WebXRControllerModelLoader {
  110024. /**
  110025. * Creates the WebXRControllerModelLoader
  110026. * @param input xr input that creates the controllers
  110027. */
  110028. constructor(input: WebXRInput);
  110029. }
  110030. }
  110031. declare module BABYLON {
  110032. /**
  110033. * Contains an array of blocks representing the octree
  110034. */
  110035. export interface IOctreeContainer<T> {
  110036. /**
  110037. * Blocks within the octree
  110038. */
  110039. blocks: Array<OctreeBlock<T>>;
  110040. }
  110041. /**
  110042. * Class used to store a cell in an octree
  110043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110044. */
  110045. export class OctreeBlock<T> {
  110046. /**
  110047. * Gets the content of the current block
  110048. */
  110049. entries: T[];
  110050. /**
  110051. * Gets the list of block children
  110052. */
  110053. blocks: Array<OctreeBlock<T>>;
  110054. private _depth;
  110055. private _maxDepth;
  110056. private _capacity;
  110057. private _minPoint;
  110058. private _maxPoint;
  110059. private _boundingVectors;
  110060. private _creationFunc;
  110061. /**
  110062. * Creates a new block
  110063. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110064. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110065. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110066. * @param depth defines the current depth of this block in the octree
  110067. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110068. * @param creationFunc defines a callback to call when an element is added to the block
  110069. */
  110070. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110071. /**
  110072. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110073. */
  110074. readonly capacity: number;
  110075. /**
  110076. * Gets the minimum vector (in world space) of the block's bounding box
  110077. */
  110078. readonly minPoint: Vector3;
  110079. /**
  110080. * Gets the maximum vector (in world space) of the block's bounding box
  110081. */
  110082. readonly maxPoint: Vector3;
  110083. /**
  110084. * Add a new element to this block
  110085. * @param entry defines the element to add
  110086. */
  110087. addEntry(entry: T): void;
  110088. /**
  110089. * Remove an element from this block
  110090. * @param entry defines the element to remove
  110091. */
  110092. removeEntry(entry: T): void;
  110093. /**
  110094. * Add an array of elements to this block
  110095. * @param entries defines the array of elements to add
  110096. */
  110097. addEntries(entries: T[]): void;
  110098. /**
  110099. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110100. * @param frustumPlanes defines the frustum planes to test
  110101. * @param selection defines the array to store current content if selection is positive
  110102. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110103. */
  110104. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110105. /**
  110106. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110107. * @param sphereCenter defines the bounding sphere center
  110108. * @param sphereRadius defines the bounding sphere radius
  110109. * @param selection defines the array to store current content if selection is positive
  110110. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110111. */
  110112. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110113. /**
  110114. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110115. * @param ray defines the ray to test with
  110116. * @param selection defines the array to store current content if selection is positive
  110117. */
  110118. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110119. /**
  110120. * Subdivide the content into child blocks (this block will then be empty)
  110121. */
  110122. createInnerBlocks(): void;
  110123. /**
  110124. * @hidden
  110125. */
  110126. 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;
  110127. }
  110128. }
  110129. declare module BABYLON {
  110130. /**
  110131. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110132. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110133. */
  110134. export class Octree<T> {
  110135. /** 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.) */
  110136. maxDepth: number;
  110137. /**
  110138. * Blocks within the octree containing objects
  110139. */
  110140. blocks: Array<OctreeBlock<T>>;
  110141. /**
  110142. * Content stored in the octree
  110143. */
  110144. dynamicContent: T[];
  110145. private _maxBlockCapacity;
  110146. private _selectionContent;
  110147. private _creationFunc;
  110148. /**
  110149. * Creates a octree
  110150. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110151. * @param creationFunc function to be used to instatiate the octree
  110152. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110153. * @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.)
  110154. */
  110155. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110156. /** 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.) */
  110157. maxDepth?: number);
  110158. /**
  110159. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110160. * @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);
  110161. * @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);
  110162. * @param entries meshes to be added to the octree blocks
  110163. */
  110164. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110165. /**
  110166. * Adds a mesh to the octree
  110167. * @param entry Mesh to add to the octree
  110168. */
  110169. addMesh(entry: T): void;
  110170. /**
  110171. * Remove an element from the octree
  110172. * @param entry defines the element to remove
  110173. */
  110174. removeMesh(entry: T): void;
  110175. /**
  110176. * Selects an array of meshes within the frustum
  110177. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110178. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110179. * @returns array of meshes within the frustum
  110180. */
  110181. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110182. /**
  110183. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110184. * @param sphereCenter defines the bounding sphere center
  110185. * @param sphereRadius defines the bounding sphere radius
  110186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110187. * @returns an array of objects that intersect the sphere
  110188. */
  110189. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110190. /**
  110191. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110192. * @param ray defines the ray to test with
  110193. * @returns array of intersected objects
  110194. */
  110195. intersectsRay(ray: Ray): SmartArray<T>;
  110196. /**
  110197. * Adds a mesh into the octree block if it intersects the block
  110198. */
  110199. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110200. /**
  110201. * Adds a submesh into the octree block if it intersects the block
  110202. */
  110203. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110204. }
  110205. }
  110206. declare module BABYLON {
  110207. interface Scene {
  110208. /**
  110209. * @hidden
  110210. * Backing Filed
  110211. */
  110212. _selectionOctree: Octree<AbstractMesh>;
  110213. /**
  110214. * Gets the octree used to boost mesh selection (picking)
  110215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110216. */
  110217. selectionOctree: Octree<AbstractMesh>;
  110218. /**
  110219. * Creates or updates the octree used to boost selection (picking)
  110220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110221. * @param maxCapacity defines the maximum capacity per leaf
  110222. * @param maxDepth defines the maximum depth of the octree
  110223. * @returns an octree of AbstractMesh
  110224. */
  110225. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110226. }
  110227. interface AbstractMesh {
  110228. /**
  110229. * @hidden
  110230. * Backing Field
  110231. */
  110232. _submeshesOctree: Octree<SubMesh>;
  110233. /**
  110234. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110235. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110236. * @param maxCapacity defines the maximum size of each block (64 by default)
  110237. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110238. * @returns the new octree
  110239. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110241. */
  110242. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110243. }
  110244. /**
  110245. * Defines the octree scene component responsible to manage any octrees
  110246. * in a given scene.
  110247. */
  110248. export class OctreeSceneComponent {
  110249. /**
  110250. * The component name help to identify the component in the list of scene components.
  110251. */
  110252. readonly name: string;
  110253. /**
  110254. * The scene the component belongs to.
  110255. */
  110256. scene: Scene;
  110257. /**
  110258. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110259. */
  110260. readonly checksIsEnabled: boolean;
  110261. /**
  110262. * Creates a new instance of the component for the given scene
  110263. * @param scene Defines the scene to register the component in
  110264. */
  110265. constructor(scene: Scene);
  110266. /**
  110267. * Registers the component in a given scene
  110268. */
  110269. register(): void;
  110270. /**
  110271. * Return the list of active meshes
  110272. * @returns the list of active meshes
  110273. */
  110274. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110275. /**
  110276. * Return the list of active sub meshes
  110277. * @param mesh The mesh to get the candidates sub meshes from
  110278. * @returns the list of active sub meshes
  110279. */
  110280. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110281. private _tempRay;
  110282. /**
  110283. * Return the list of sub meshes intersecting with a given local ray
  110284. * @param mesh defines the mesh to find the submesh for
  110285. * @param localRay defines the ray in local space
  110286. * @returns the list of intersecting sub meshes
  110287. */
  110288. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110289. /**
  110290. * Return the list of sub meshes colliding with a collider
  110291. * @param mesh defines the mesh to find the submesh for
  110292. * @param collider defines the collider to evaluate the collision against
  110293. * @returns the list of colliding sub meshes
  110294. */
  110295. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110296. /**
  110297. * Rebuilds the elements related to this component in case of
  110298. * context lost for instance.
  110299. */
  110300. rebuild(): void;
  110301. /**
  110302. * Disposes the component and the associated ressources.
  110303. */
  110304. dispose(): void;
  110305. }
  110306. }
  110307. declare module BABYLON {
  110308. /**
  110309. * Renders a layer on top of an existing scene
  110310. */
  110311. export class UtilityLayerRenderer implements IDisposable {
  110312. /** the original scene that will be rendered on top of */
  110313. originalScene: Scene;
  110314. private _pointerCaptures;
  110315. private _lastPointerEvents;
  110316. private static _DefaultUtilityLayer;
  110317. private static _DefaultKeepDepthUtilityLayer;
  110318. private _sharedGizmoLight;
  110319. private _renderCamera;
  110320. /**
  110321. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110322. * @returns the camera that is used when rendering the utility layer
  110323. */
  110324. getRenderCamera(): Nullable<Camera>;
  110325. /**
  110326. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110327. * @param cam the camera that should be used when rendering the utility layer
  110328. */
  110329. setRenderCamera(cam: Nullable<Camera>): void;
  110330. /**
  110331. * @hidden
  110332. * Light which used by gizmos to get light shading
  110333. */
  110334. _getSharedGizmoLight(): HemisphericLight;
  110335. /**
  110336. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110337. */
  110338. pickUtilitySceneFirst: boolean;
  110339. /**
  110340. * 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)
  110341. */
  110342. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110343. /**
  110344. * 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)
  110345. */
  110346. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110347. /**
  110348. * The scene that is rendered on top of the original scene
  110349. */
  110350. utilityLayerScene: Scene;
  110351. /**
  110352. * If the utility layer should automatically be rendered on top of existing scene
  110353. */
  110354. shouldRender: boolean;
  110355. /**
  110356. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110357. */
  110358. onlyCheckPointerDownEvents: boolean;
  110359. /**
  110360. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110361. */
  110362. processAllEvents: boolean;
  110363. /**
  110364. * Observable raised when the pointer move from the utility layer scene to the main scene
  110365. */
  110366. onPointerOutObservable: Observable<number>;
  110367. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110368. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110369. private _afterRenderObserver;
  110370. private _sceneDisposeObserver;
  110371. private _originalPointerObserver;
  110372. /**
  110373. * Instantiates a UtilityLayerRenderer
  110374. * @param originalScene the original scene that will be rendered on top of
  110375. * @param handleEvents boolean indicating if the utility layer should handle events
  110376. */
  110377. constructor(
  110378. /** the original scene that will be rendered on top of */
  110379. originalScene: Scene, handleEvents?: boolean);
  110380. private _notifyObservers;
  110381. /**
  110382. * Renders the utility layers scene on top of the original scene
  110383. */
  110384. render(): void;
  110385. /**
  110386. * Disposes of the renderer
  110387. */
  110388. dispose(): void;
  110389. private _updateCamera;
  110390. }
  110391. }
  110392. declare module BABYLON {
  110393. /**
  110394. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110395. */
  110396. export class Gizmo implements IDisposable {
  110397. /** The utility layer the gizmo will be added to */
  110398. gizmoLayer: UtilityLayerRenderer;
  110399. /**
  110400. * The root mesh of the gizmo
  110401. */
  110402. _rootMesh: Mesh;
  110403. private _attachedMesh;
  110404. /**
  110405. * Ratio for the scale of the gizmo (Default: 1)
  110406. */
  110407. scaleRatio: number;
  110408. /**
  110409. * If a custom mesh has been set (Default: false)
  110410. */
  110411. protected _customMeshSet: boolean;
  110412. /**
  110413. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110414. * * When set, interactions will be enabled
  110415. */
  110416. attachedMesh: Nullable<AbstractMesh>;
  110417. /**
  110418. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110419. * @param mesh The mesh to replace the default mesh of the gizmo
  110420. */
  110421. setCustomMesh(mesh: Mesh): void;
  110422. /**
  110423. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110424. */
  110425. updateGizmoRotationToMatchAttachedMesh: boolean;
  110426. /**
  110427. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110428. */
  110429. updateGizmoPositionToMatchAttachedMesh: boolean;
  110430. /**
  110431. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110432. */
  110433. updateScale: boolean;
  110434. protected _interactionsEnabled: boolean;
  110435. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110436. private _beforeRenderObserver;
  110437. private _tempVector;
  110438. /**
  110439. * Creates a gizmo
  110440. * @param gizmoLayer The utility layer the gizmo will be added to
  110441. */
  110442. constructor(
  110443. /** The utility layer the gizmo will be added to */
  110444. gizmoLayer?: UtilityLayerRenderer);
  110445. /**
  110446. * Updates the gizmo to match the attached mesh's position/rotation
  110447. */
  110448. protected _update(): void;
  110449. /**
  110450. * Disposes of the gizmo
  110451. */
  110452. dispose(): void;
  110453. }
  110454. }
  110455. declare module BABYLON {
  110456. /**
  110457. * Single plane drag gizmo
  110458. */
  110459. export class PlaneDragGizmo extends Gizmo {
  110460. /**
  110461. * Drag behavior responsible for the gizmos dragging interactions
  110462. */
  110463. dragBehavior: PointerDragBehavior;
  110464. private _pointerObserver;
  110465. /**
  110466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110467. */
  110468. snapDistance: number;
  110469. /**
  110470. * Event that fires each time the gizmo snaps to a new location.
  110471. * * snapDistance is the the change in distance
  110472. */
  110473. onSnapObservable: Observable<{
  110474. snapDistance: number;
  110475. }>;
  110476. private _plane;
  110477. private _coloredMaterial;
  110478. private _hoverMaterial;
  110479. private _isEnabled;
  110480. private _parent;
  110481. /** @hidden */
  110482. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110483. /** @hidden */
  110484. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110485. /**
  110486. * Creates a PlaneDragGizmo
  110487. * @param gizmoLayer The utility layer the gizmo will be added to
  110488. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110489. * @param color The color of the gizmo
  110490. */
  110491. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110492. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110493. /**
  110494. * If the gizmo is enabled
  110495. */
  110496. isEnabled: boolean;
  110497. /**
  110498. * Disposes of the gizmo
  110499. */
  110500. dispose(): void;
  110501. }
  110502. }
  110503. declare module BABYLON {
  110504. /**
  110505. * Gizmo that enables dragging a mesh along 3 axis
  110506. */
  110507. export class PositionGizmo extends Gizmo {
  110508. /**
  110509. * Internal gizmo used for interactions on the x axis
  110510. */
  110511. xGizmo: AxisDragGizmo;
  110512. /**
  110513. * Internal gizmo used for interactions on the y axis
  110514. */
  110515. yGizmo: AxisDragGizmo;
  110516. /**
  110517. * Internal gizmo used for interactions on the z axis
  110518. */
  110519. zGizmo: AxisDragGizmo;
  110520. /**
  110521. * Internal gizmo used for interactions on the yz plane
  110522. */
  110523. xPlaneGizmo: PlaneDragGizmo;
  110524. /**
  110525. * Internal gizmo used for interactions on the xz plane
  110526. */
  110527. yPlaneGizmo: PlaneDragGizmo;
  110528. /**
  110529. * Internal gizmo used for interactions on the xy plane
  110530. */
  110531. zPlaneGizmo: PlaneDragGizmo;
  110532. /**
  110533. * private variables
  110534. */
  110535. private _meshAttached;
  110536. private _updateGizmoRotationToMatchAttachedMesh;
  110537. private _snapDistance;
  110538. private _scaleRatio;
  110539. /** Fires an event when any of it's sub gizmos are dragged */
  110540. onDragStartObservable: Observable<unknown>;
  110541. /** Fires an event when any of it's sub gizmos are released from dragging */
  110542. onDragEndObservable: Observable<unknown>;
  110543. /**
  110544. * If set to true, planar drag is enabled
  110545. */
  110546. private _planarGizmoEnabled;
  110547. attachedMesh: Nullable<AbstractMesh>;
  110548. /**
  110549. * Creates a PositionGizmo
  110550. * @param gizmoLayer The utility layer the gizmo will be added to
  110551. */
  110552. constructor(gizmoLayer?: UtilityLayerRenderer);
  110553. /**
  110554. * If the planar drag gizmo is enabled
  110555. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110556. */
  110557. planarGizmoEnabled: boolean;
  110558. updateGizmoRotationToMatchAttachedMesh: boolean;
  110559. /**
  110560. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110561. */
  110562. snapDistance: number;
  110563. /**
  110564. * Ratio for the scale of the gizmo (Default: 1)
  110565. */
  110566. scaleRatio: number;
  110567. /**
  110568. * Disposes of the gizmo
  110569. */
  110570. dispose(): void;
  110571. /**
  110572. * CustomMeshes are not supported by this gizmo
  110573. * @param mesh The mesh to replace the default mesh of the gizmo
  110574. */
  110575. setCustomMesh(mesh: Mesh): void;
  110576. }
  110577. }
  110578. declare module BABYLON {
  110579. /**
  110580. * Single axis drag gizmo
  110581. */
  110582. export class AxisDragGizmo extends Gizmo {
  110583. /**
  110584. * Drag behavior responsible for the gizmos dragging interactions
  110585. */
  110586. dragBehavior: PointerDragBehavior;
  110587. private _pointerObserver;
  110588. /**
  110589. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110590. */
  110591. snapDistance: number;
  110592. /**
  110593. * Event that fires each time the gizmo snaps to a new location.
  110594. * * snapDistance is the the change in distance
  110595. */
  110596. onSnapObservable: Observable<{
  110597. snapDistance: number;
  110598. }>;
  110599. private _isEnabled;
  110600. private _parent;
  110601. private _arrow;
  110602. private _coloredMaterial;
  110603. private _hoverMaterial;
  110604. /** @hidden */
  110605. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110606. /** @hidden */
  110607. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110608. /**
  110609. * Creates an AxisDragGizmo
  110610. * @param gizmoLayer The utility layer the gizmo will be added to
  110611. * @param dragAxis The axis which the gizmo will be able to drag on
  110612. * @param color The color of the gizmo
  110613. */
  110614. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110615. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110616. /**
  110617. * If the gizmo is enabled
  110618. */
  110619. isEnabled: boolean;
  110620. /**
  110621. * Disposes of the gizmo
  110622. */
  110623. dispose(): void;
  110624. }
  110625. }
  110626. declare module BABYLON.Debug {
  110627. /**
  110628. * The Axes viewer will show 3 axes in a specific point in space
  110629. */
  110630. export class AxesViewer {
  110631. private _xAxis;
  110632. private _yAxis;
  110633. private _zAxis;
  110634. private _scaleLinesFactor;
  110635. private _instanced;
  110636. /**
  110637. * Gets the hosting scene
  110638. */
  110639. scene: Scene;
  110640. /**
  110641. * Gets or sets a number used to scale line length
  110642. */
  110643. scaleLines: number;
  110644. /** Gets the node hierarchy used to render x-axis */
  110645. readonly xAxis: TransformNode;
  110646. /** Gets the node hierarchy used to render y-axis */
  110647. readonly yAxis: TransformNode;
  110648. /** Gets the node hierarchy used to render z-axis */
  110649. readonly zAxis: TransformNode;
  110650. /**
  110651. * Creates a new AxesViewer
  110652. * @param scene defines the hosting scene
  110653. * @param scaleLines defines a number used to scale line length (1 by default)
  110654. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110655. * @param xAxis defines the node hierarchy used to render the x-axis
  110656. * @param yAxis defines the node hierarchy used to render the y-axis
  110657. * @param zAxis defines the node hierarchy used to render the z-axis
  110658. */
  110659. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110660. /**
  110661. * Force the viewer to update
  110662. * @param position defines the position of the viewer
  110663. * @param xaxis defines the x axis of the viewer
  110664. * @param yaxis defines the y axis of the viewer
  110665. * @param zaxis defines the z axis of the viewer
  110666. */
  110667. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110668. /**
  110669. * Creates an instance of this axes viewer.
  110670. * @returns a new axes viewer with instanced meshes
  110671. */
  110672. createInstance(): AxesViewer;
  110673. /** Releases resources */
  110674. dispose(): void;
  110675. private static _SetRenderingGroupId;
  110676. }
  110677. }
  110678. declare module BABYLON.Debug {
  110679. /**
  110680. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110681. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110682. */
  110683. export class BoneAxesViewer extends AxesViewer {
  110684. /**
  110685. * Gets or sets the target mesh where to display the axes viewer
  110686. */
  110687. mesh: Nullable<Mesh>;
  110688. /**
  110689. * Gets or sets the target bone where to display the axes viewer
  110690. */
  110691. bone: Nullable<Bone>;
  110692. /** Gets current position */
  110693. pos: Vector3;
  110694. /** Gets direction of X axis */
  110695. xaxis: Vector3;
  110696. /** Gets direction of Y axis */
  110697. yaxis: Vector3;
  110698. /** Gets direction of Z axis */
  110699. zaxis: Vector3;
  110700. /**
  110701. * Creates a new BoneAxesViewer
  110702. * @param scene defines the hosting scene
  110703. * @param bone defines the target bone
  110704. * @param mesh defines the target mesh
  110705. * @param scaleLines defines a scaling factor for line length (1 by default)
  110706. */
  110707. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110708. /**
  110709. * Force the viewer to update
  110710. */
  110711. update(): void;
  110712. /** Releases resources */
  110713. dispose(): void;
  110714. }
  110715. }
  110716. declare module BABYLON {
  110717. /**
  110718. * Interface used to define scene explorer extensibility option
  110719. */
  110720. export interface IExplorerExtensibilityOption {
  110721. /**
  110722. * Define the option label
  110723. */
  110724. label: string;
  110725. /**
  110726. * Defines the action to execute on click
  110727. */
  110728. action: (entity: any) => void;
  110729. }
  110730. /**
  110731. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110732. */
  110733. export interface IExplorerExtensibilityGroup {
  110734. /**
  110735. * Defines a predicate to test if a given type mut be extended
  110736. */
  110737. predicate: (entity: any) => boolean;
  110738. /**
  110739. * Gets the list of options added to a type
  110740. */
  110741. entries: IExplorerExtensibilityOption[];
  110742. }
  110743. /**
  110744. * Interface used to define the options to use to create the Inspector
  110745. */
  110746. export interface IInspectorOptions {
  110747. /**
  110748. * Display in overlay mode (default: false)
  110749. */
  110750. overlay?: boolean;
  110751. /**
  110752. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110753. */
  110754. globalRoot?: HTMLElement;
  110755. /**
  110756. * Display the Scene explorer
  110757. */
  110758. showExplorer?: boolean;
  110759. /**
  110760. * Display the property inspector
  110761. */
  110762. showInspector?: boolean;
  110763. /**
  110764. * Display in embed mode (both panes on the right)
  110765. */
  110766. embedMode?: boolean;
  110767. /**
  110768. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110769. */
  110770. handleResize?: boolean;
  110771. /**
  110772. * Allow the panes to popup (default: true)
  110773. */
  110774. enablePopup?: boolean;
  110775. /**
  110776. * Allow the panes to be closed by users (default: true)
  110777. */
  110778. enableClose?: boolean;
  110779. /**
  110780. * Optional list of extensibility entries
  110781. */
  110782. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110783. /**
  110784. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110785. */
  110786. inspectorURL?: string;
  110787. }
  110788. interface Scene {
  110789. /**
  110790. * @hidden
  110791. * Backing field
  110792. */
  110793. _debugLayer: DebugLayer;
  110794. /**
  110795. * Gets the debug layer (aka Inspector) associated with the scene
  110796. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110797. */
  110798. debugLayer: DebugLayer;
  110799. }
  110800. /**
  110801. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110802. * what is happening in your scene
  110803. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110804. */
  110805. export class DebugLayer {
  110806. /**
  110807. * Define the url to get the inspector script from.
  110808. * By default it uses the babylonjs CDN.
  110809. * @ignoreNaming
  110810. */
  110811. static InspectorURL: string;
  110812. private _scene;
  110813. private BJSINSPECTOR;
  110814. private _onPropertyChangedObservable?;
  110815. /**
  110816. * Observable triggered when a property is changed through the inspector.
  110817. */
  110818. readonly onPropertyChangedObservable: any;
  110819. /**
  110820. * Instantiates a new debug layer.
  110821. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110822. * what is happening in your scene
  110823. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110824. * @param scene Defines the scene to inspect
  110825. */
  110826. constructor(scene: Scene);
  110827. /** Creates the inspector window. */
  110828. private _createInspector;
  110829. /**
  110830. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110831. * @param entity defines the entity to select
  110832. * @param lineContainerTitle defines the specific block to highlight
  110833. */
  110834. select(entity: any, lineContainerTitle?: string): void;
  110835. /** Get the inspector from bundle or global */
  110836. private _getGlobalInspector;
  110837. /**
  110838. * Get if the inspector is visible or not.
  110839. * @returns true if visible otherwise, false
  110840. */
  110841. isVisible(): boolean;
  110842. /**
  110843. * Hide the inspector and close its window.
  110844. */
  110845. hide(): void;
  110846. /**
  110847. * Launch the debugLayer.
  110848. * @param config Define the configuration of the inspector
  110849. * @return a promise fulfilled when the debug layer is visible
  110850. */
  110851. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110852. }
  110853. }
  110854. declare module BABYLON {
  110855. /**
  110856. * Class containing static functions to help procedurally build meshes
  110857. */
  110858. export class BoxBuilder {
  110859. /**
  110860. * Creates a box mesh
  110861. * * The parameter `size` sets the size (float) of each box side (default 1)
  110862. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110863. * * 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)
  110864. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110868. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110869. * @param name defines the name of the mesh
  110870. * @param options defines the options used to create the mesh
  110871. * @param scene defines the hosting scene
  110872. * @returns the box mesh
  110873. */
  110874. static CreateBox(name: string, options: {
  110875. size?: number;
  110876. width?: number;
  110877. height?: number;
  110878. depth?: number;
  110879. faceUV?: Vector4[];
  110880. faceColors?: Color4[];
  110881. sideOrientation?: number;
  110882. frontUVs?: Vector4;
  110883. backUVs?: Vector4;
  110884. wrap?: boolean;
  110885. topBaseAt?: number;
  110886. bottomBaseAt?: number;
  110887. updatable?: boolean;
  110888. }, scene?: Nullable<Scene>): Mesh;
  110889. }
  110890. }
  110891. declare module BABYLON {
  110892. /**
  110893. * Class containing static functions to help procedurally build meshes
  110894. */
  110895. export class SphereBuilder {
  110896. /**
  110897. * Creates a sphere mesh
  110898. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110899. * * 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`)
  110900. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110901. * * 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
  110902. * * 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)
  110903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110906. * @param name defines the name of the mesh
  110907. * @param options defines the options used to create the mesh
  110908. * @param scene defines the hosting scene
  110909. * @returns the sphere mesh
  110910. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110911. */
  110912. static CreateSphere(name: string, options: {
  110913. segments?: number;
  110914. diameter?: number;
  110915. diameterX?: number;
  110916. diameterY?: number;
  110917. diameterZ?: number;
  110918. arc?: number;
  110919. slice?: number;
  110920. sideOrientation?: number;
  110921. frontUVs?: Vector4;
  110922. backUVs?: Vector4;
  110923. updatable?: boolean;
  110924. }, scene?: Nullable<Scene>): Mesh;
  110925. }
  110926. }
  110927. declare module BABYLON.Debug {
  110928. /**
  110929. * Used to show the physics impostor around the specific mesh
  110930. */
  110931. export class PhysicsViewer {
  110932. /** @hidden */
  110933. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110934. /** @hidden */
  110935. protected _meshes: Array<Nullable<AbstractMesh>>;
  110936. /** @hidden */
  110937. protected _scene: Nullable<Scene>;
  110938. /** @hidden */
  110939. protected _numMeshes: number;
  110940. /** @hidden */
  110941. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110942. private _renderFunction;
  110943. private _utilityLayer;
  110944. private _debugBoxMesh;
  110945. private _debugSphereMesh;
  110946. private _debugCylinderMesh;
  110947. private _debugMaterial;
  110948. private _debugMeshMeshes;
  110949. /**
  110950. * Creates a new PhysicsViewer
  110951. * @param scene defines the hosting scene
  110952. */
  110953. constructor(scene: Scene);
  110954. /** @hidden */
  110955. protected _updateDebugMeshes(): void;
  110956. /**
  110957. * Renders a specified physic impostor
  110958. * @param impostor defines the impostor to render
  110959. * @param targetMesh defines the mesh represented by the impostor
  110960. * @returns the new debug mesh used to render the impostor
  110961. */
  110962. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110963. /**
  110964. * Hides a specified physic impostor
  110965. * @param impostor defines the impostor to hide
  110966. */
  110967. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110968. private _getDebugMaterial;
  110969. private _getDebugBoxMesh;
  110970. private _getDebugSphereMesh;
  110971. private _getDebugCylinderMesh;
  110972. private _getDebugMeshMesh;
  110973. private _getDebugMesh;
  110974. /** Releases all resources */
  110975. dispose(): void;
  110976. }
  110977. }
  110978. declare module BABYLON {
  110979. /**
  110980. * Class containing static functions to help procedurally build meshes
  110981. */
  110982. export class LinesBuilder {
  110983. /**
  110984. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110985. * * 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
  110986. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110987. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110988. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110989. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110990. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110991. * * 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
  110992. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110995. * @param name defines the name of the new line system
  110996. * @param options defines the options used to create the line system
  110997. * @param scene defines the hosting scene
  110998. * @returns a new line system mesh
  110999. */
  111000. static CreateLineSystem(name: string, options: {
  111001. lines: Vector3[][];
  111002. updatable?: boolean;
  111003. instance?: Nullable<LinesMesh>;
  111004. colors?: Nullable<Color4[][]>;
  111005. useVertexAlpha?: boolean;
  111006. }, scene: Nullable<Scene>): LinesMesh;
  111007. /**
  111008. * Creates a line mesh
  111009. * 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
  111010. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111011. * * The parameter `points` is an array successive Vector3
  111012. * * 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
  111013. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111014. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111015. * * When updating an instance, remember that only point positions can change, not the number of points
  111016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111018. * @param name defines the name of the new line system
  111019. * @param options defines the options used to create the line system
  111020. * @param scene defines the hosting scene
  111021. * @returns a new line mesh
  111022. */
  111023. static CreateLines(name: string, options: {
  111024. points: Vector3[];
  111025. updatable?: boolean;
  111026. instance?: Nullable<LinesMesh>;
  111027. colors?: Color4[];
  111028. useVertexAlpha?: boolean;
  111029. }, scene?: Nullable<Scene>): LinesMesh;
  111030. /**
  111031. * Creates a dashed line mesh
  111032. * * 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
  111033. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111034. * * The parameter `points` is an array successive Vector3
  111035. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111036. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111037. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111038. * * 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
  111039. * * When updating an instance, remember that only point positions can change, not the number of points
  111040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111041. * @param name defines the name of the mesh
  111042. * @param options defines the options used to create the mesh
  111043. * @param scene defines the hosting scene
  111044. * @returns the dashed line mesh
  111045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111046. */
  111047. static CreateDashedLines(name: string, options: {
  111048. points: Vector3[];
  111049. dashSize?: number;
  111050. gapSize?: number;
  111051. dashNb?: number;
  111052. updatable?: boolean;
  111053. instance?: LinesMesh;
  111054. }, scene?: Nullable<Scene>): LinesMesh;
  111055. }
  111056. }
  111057. declare module BABYLON {
  111058. /**
  111059. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111060. * in order to better appreciate the issue one might have.
  111061. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111062. */
  111063. export class RayHelper {
  111064. /**
  111065. * Defines the ray we are currently tryin to visualize.
  111066. */
  111067. ray: Nullable<Ray>;
  111068. private _renderPoints;
  111069. private _renderLine;
  111070. private _renderFunction;
  111071. private _scene;
  111072. private _updateToMeshFunction;
  111073. private _attachedToMesh;
  111074. private _meshSpaceDirection;
  111075. private _meshSpaceOrigin;
  111076. /**
  111077. * Helper function to create a colored helper in a scene in one line.
  111078. * @param ray Defines the ray we are currently tryin to visualize
  111079. * @param scene Defines the scene the ray is used in
  111080. * @param color Defines the color we want to see the ray in
  111081. * @returns The newly created ray helper.
  111082. */
  111083. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111084. /**
  111085. * Instantiate a new ray helper.
  111086. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111087. * in order to better appreciate the issue one might have.
  111088. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111089. * @param ray Defines the ray we are currently tryin to visualize
  111090. */
  111091. constructor(ray: Ray);
  111092. /**
  111093. * Shows the ray we are willing to debug.
  111094. * @param scene Defines the scene the ray needs to be rendered in
  111095. * @param color Defines the color the ray needs to be rendered in
  111096. */
  111097. show(scene: Scene, color?: Color3): void;
  111098. /**
  111099. * Hides the ray we are debugging.
  111100. */
  111101. hide(): void;
  111102. private _render;
  111103. /**
  111104. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111105. * @param mesh Defines the mesh we want the helper attached to
  111106. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111107. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111108. * @param length Defines the length of the ray
  111109. */
  111110. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111111. /**
  111112. * Detach the ray helper from the mesh it has previously been attached to.
  111113. */
  111114. detachFromMesh(): void;
  111115. private _updateToMesh;
  111116. /**
  111117. * Dispose the helper and release its associated resources.
  111118. */
  111119. dispose(): void;
  111120. }
  111121. }
  111122. declare module BABYLON.Debug {
  111123. /**
  111124. * Class used to render a debug view of a given skeleton
  111125. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111126. */
  111127. export class SkeletonViewer {
  111128. /** defines the skeleton to render */
  111129. skeleton: Skeleton;
  111130. /** defines the mesh attached to the skeleton */
  111131. mesh: AbstractMesh;
  111132. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111133. autoUpdateBonesMatrices: boolean;
  111134. /** defines the rendering group id to use with the viewer */
  111135. renderingGroupId: number;
  111136. /** Gets or sets the color used to render the skeleton */
  111137. color: Color3;
  111138. private _scene;
  111139. private _debugLines;
  111140. private _debugMesh;
  111141. private _isEnabled;
  111142. private _renderFunction;
  111143. private _utilityLayer;
  111144. /**
  111145. * Returns the mesh used to render the bones
  111146. */
  111147. readonly debugMesh: Nullable<LinesMesh>;
  111148. /**
  111149. * Creates a new SkeletonViewer
  111150. * @param skeleton defines the skeleton to render
  111151. * @param mesh defines the mesh attached to the skeleton
  111152. * @param scene defines the hosting scene
  111153. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111154. * @param renderingGroupId defines the rendering group id to use with the viewer
  111155. */
  111156. constructor(
  111157. /** defines the skeleton to render */
  111158. skeleton: Skeleton,
  111159. /** defines the mesh attached to the skeleton */
  111160. mesh: AbstractMesh, scene: Scene,
  111161. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111162. autoUpdateBonesMatrices?: boolean,
  111163. /** defines the rendering group id to use with the viewer */
  111164. renderingGroupId?: number);
  111165. /** Gets or sets a boolean indicating if the viewer is enabled */
  111166. isEnabled: boolean;
  111167. private _getBonePosition;
  111168. private _getLinesForBonesWithLength;
  111169. private _getLinesForBonesNoLength;
  111170. /** Update the viewer to sync with current skeleton state */
  111171. update(): void;
  111172. /** Release associated resources */
  111173. dispose(): void;
  111174. }
  111175. }
  111176. declare module BABYLON {
  111177. /**
  111178. * Options to create the null engine
  111179. */
  111180. export class NullEngineOptions {
  111181. /**
  111182. * Render width (Default: 512)
  111183. */
  111184. renderWidth: number;
  111185. /**
  111186. * Render height (Default: 256)
  111187. */
  111188. renderHeight: number;
  111189. /**
  111190. * Texture size (Default: 512)
  111191. */
  111192. textureSize: number;
  111193. /**
  111194. * If delta time between frames should be constant
  111195. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111196. */
  111197. deterministicLockstep: boolean;
  111198. /**
  111199. * Maximum about of steps between frames (Default: 4)
  111200. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111201. */
  111202. lockstepMaxSteps: number;
  111203. }
  111204. /**
  111205. * The null engine class provides support for headless version of babylon.js.
  111206. * This can be used in server side scenario or for testing purposes
  111207. */
  111208. export class NullEngine extends Engine {
  111209. private _options;
  111210. /**
  111211. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111212. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111213. * @returns true if engine is in deterministic lock step mode
  111214. */
  111215. isDeterministicLockStep(): boolean;
  111216. /**
  111217. * Gets the max steps when engine is running in deterministic lock step
  111218. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111219. * @returns the max steps
  111220. */
  111221. getLockstepMaxSteps(): number;
  111222. /**
  111223. * Gets the current hardware scaling level.
  111224. * By default the hardware scaling level is computed from the window device ratio.
  111225. * 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.
  111226. * @returns a number indicating the current hardware scaling level
  111227. */
  111228. getHardwareScalingLevel(): number;
  111229. constructor(options?: NullEngineOptions);
  111230. /**
  111231. * Creates a vertex buffer
  111232. * @param vertices the data for the vertex buffer
  111233. * @returns the new WebGL static buffer
  111234. */
  111235. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111236. /**
  111237. * Creates a new index buffer
  111238. * @param indices defines the content of the index buffer
  111239. * @param updatable defines if the index buffer must be updatable
  111240. * @returns a new webGL buffer
  111241. */
  111242. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111243. /**
  111244. * Clear the current render buffer or the current render target (if any is set up)
  111245. * @param color defines the color to use
  111246. * @param backBuffer defines if the back buffer must be cleared
  111247. * @param depth defines if the depth buffer must be cleared
  111248. * @param stencil defines if the stencil buffer must be cleared
  111249. */
  111250. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111251. /**
  111252. * Gets the current render width
  111253. * @param useScreen defines if screen size must be used (or the current render target if any)
  111254. * @returns a number defining the current render width
  111255. */
  111256. getRenderWidth(useScreen?: boolean): number;
  111257. /**
  111258. * Gets the current render height
  111259. * @param useScreen defines if screen size must be used (or the current render target if any)
  111260. * @returns a number defining the current render height
  111261. */
  111262. getRenderHeight(useScreen?: boolean): number;
  111263. /**
  111264. * Set the WebGL's viewport
  111265. * @param viewport defines the viewport element to be used
  111266. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111267. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111268. */
  111269. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111270. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111271. /**
  111272. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111273. * @param pipelineContext defines the pipeline context to use
  111274. * @param uniformsNames defines the list of uniform names
  111275. * @returns an array of webGL uniform locations
  111276. */
  111277. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111278. /**
  111279. * Gets the lsit of active attributes for a given webGL program
  111280. * @param pipelineContext defines the pipeline context to use
  111281. * @param attributesNames defines the list of attribute names to get
  111282. * @returns an array of indices indicating the offset of each attribute
  111283. */
  111284. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111285. /**
  111286. * Binds an effect to the webGL context
  111287. * @param effect defines the effect to bind
  111288. */
  111289. bindSamplers(effect: Effect): void;
  111290. /**
  111291. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111292. * @param effect defines the effect to activate
  111293. */
  111294. enableEffect(effect: Effect): void;
  111295. /**
  111296. * Set various states to the webGL context
  111297. * @param culling defines backface culling state
  111298. * @param zOffset defines the value to apply to zOffset (0 by default)
  111299. * @param force defines if states must be applied even if cache is up to date
  111300. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111301. */
  111302. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111303. /**
  111304. * Set the value of an uniform to an array of int32
  111305. * @param uniform defines the webGL uniform location where to store the value
  111306. * @param array defines the array of int32 to store
  111307. */
  111308. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111309. /**
  111310. * Set the value of an uniform to an array of int32 (stored as vec2)
  111311. * @param uniform defines the webGL uniform location where to store the value
  111312. * @param array defines the array of int32 to store
  111313. */
  111314. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111315. /**
  111316. * Set the value of an uniform to an array of int32 (stored as vec3)
  111317. * @param uniform defines the webGL uniform location where to store the value
  111318. * @param array defines the array of int32 to store
  111319. */
  111320. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111321. /**
  111322. * Set the value of an uniform to an array of int32 (stored as vec4)
  111323. * @param uniform defines the webGL uniform location where to store the value
  111324. * @param array defines the array of int32 to store
  111325. */
  111326. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111327. /**
  111328. * Set the value of an uniform to an array of float32
  111329. * @param uniform defines the webGL uniform location where to store the value
  111330. * @param array defines the array of float32 to store
  111331. */
  111332. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111333. /**
  111334. * Set the value of an uniform to an array of float32 (stored as vec2)
  111335. * @param uniform defines the webGL uniform location where to store the value
  111336. * @param array defines the array of float32 to store
  111337. */
  111338. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111339. /**
  111340. * Set the value of an uniform to an array of float32 (stored as vec3)
  111341. * @param uniform defines the webGL uniform location where to store the value
  111342. * @param array defines the array of float32 to store
  111343. */
  111344. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111345. /**
  111346. * Set the value of an uniform to an array of float32 (stored as vec4)
  111347. * @param uniform defines the webGL uniform location where to store the value
  111348. * @param array defines the array of float32 to store
  111349. */
  111350. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111351. /**
  111352. * Set the value of an uniform to an array of number
  111353. * @param uniform defines the webGL uniform location where to store the value
  111354. * @param array defines the array of number to store
  111355. */
  111356. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111357. /**
  111358. * Set the value of an uniform to an array of number (stored as vec2)
  111359. * @param uniform defines the webGL uniform location where to store the value
  111360. * @param array defines the array of number to store
  111361. */
  111362. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111363. /**
  111364. * Set the value of an uniform to an array of number (stored as vec3)
  111365. * @param uniform defines the webGL uniform location where to store the value
  111366. * @param array defines the array of number to store
  111367. */
  111368. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111369. /**
  111370. * Set the value of an uniform to an array of number (stored as vec4)
  111371. * @param uniform defines the webGL uniform location where to store the value
  111372. * @param array defines the array of number to store
  111373. */
  111374. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111375. /**
  111376. * Set the value of an uniform to an array of float32 (stored as matrices)
  111377. * @param uniform defines the webGL uniform location where to store the value
  111378. * @param matrices defines the array of float32 to store
  111379. */
  111380. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111381. /**
  111382. * Set the value of an uniform to a matrix (3x3)
  111383. * @param uniform defines the webGL uniform location where to store the value
  111384. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111385. */
  111386. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111387. /**
  111388. * Set the value of an uniform to a matrix (2x2)
  111389. * @param uniform defines the webGL uniform location where to store the value
  111390. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111391. */
  111392. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111393. /**
  111394. * Set the value of an uniform to a number (float)
  111395. * @param uniform defines the webGL uniform location where to store the value
  111396. * @param value defines the float number to store
  111397. */
  111398. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111399. /**
  111400. * Set the value of an uniform to a vec2
  111401. * @param uniform defines the webGL uniform location where to store the value
  111402. * @param x defines the 1st component of the value
  111403. * @param y defines the 2nd component of the value
  111404. */
  111405. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111406. /**
  111407. * Set the value of an uniform to a vec3
  111408. * @param uniform defines the webGL uniform location where to store the value
  111409. * @param x defines the 1st component of the value
  111410. * @param y defines the 2nd component of the value
  111411. * @param z defines the 3rd component of the value
  111412. */
  111413. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111414. /**
  111415. * Set the value of an uniform to a boolean
  111416. * @param uniform defines the webGL uniform location where to store the value
  111417. * @param bool defines the boolean to store
  111418. */
  111419. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111420. /**
  111421. * Set the value of an uniform to a vec4
  111422. * @param uniform defines the webGL uniform location where to store the value
  111423. * @param x defines the 1st component of the value
  111424. * @param y defines the 2nd component of the value
  111425. * @param z defines the 3rd component of the value
  111426. * @param w defines the 4th component of the value
  111427. */
  111428. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111429. /**
  111430. * Sets the current alpha mode
  111431. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111432. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111433. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111434. */
  111435. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111436. /**
  111437. * Bind webGl buffers directly to the webGL context
  111438. * @param vertexBuffers defines the vertex buffer to bind
  111439. * @param indexBuffer defines the index buffer to bind
  111440. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111441. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111442. * @param effect defines the effect associated with the vertex buffer
  111443. */
  111444. bindBuffers(vertexBuffers: {
  111445. [key: string]: VertexBuffer;
  111446. }, indexBuffer: DataBuffer, effect: Effect): void;
  111447. /**
  111448. * Force the entire cache to be cleared
  111449. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111450. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111451. */
  111452. wipeCaches(bruteForce?: boolean): void;
  111453. /**
  111454. * Send a draw order
  111455. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111456. * @param indexStart defines the starting index
  111457. * @param indexCount defines the number of index to draw
  111458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111459. */
  111460. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111461. /**
  111462. * Draw a list of indexed primitives
  111463. * @param fillMode defines the primitive to use
  111464. * @param indexStart defines the starting index
  111465. * @param indexCount defines the number of index to draw
  111466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111467. */
  111468. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111469. /**
  111470. * Draw a list of unindexed primitives
  111471. * @param fillMode defines the primitive to use
  111472. * @param verticesStart defines the index of first vertex to draw
  111473. * @param verticesCount defines the count of vertices to draw
  111474. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111475. */
  111476. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111477. /** @hidden */
  111478. _createTexture(): WebGLTexture;
  111479. /** @hidden */
  111480. _releaseTexture(texture: InternalTexture): void;
  111481. /**
  111482. * Usually called from Texture.ts.
  111483. * Passed information to create a WebGLTexture
  111484. * @param urlArg defines a value which contains one of the following:
  111485. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111486. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111487. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111488. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111489. * @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)
  111490. * @param scene needed for loading to the correct scene
  111491. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111492. * @param onLoad optional callback to be called upon successful completion
  111493. * @param onError optional callback to be called upon failure
  111494. * @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
  111495. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111496. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111497. * @param forcedExtension defines the extension to use to pick the right loader
  111498. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111499. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111500. */
  111501. 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;
  111502. /**
  111503. * Creates a new render target texture
  111504. * @param size defines the size of the texture
  111505. * @param options defines the options used to create the texture
  111506. * @returns a new render target texture stored in an InternalTexture
  111507. */
  111508. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111509. /**
  111510. * Update the sampling mode of a given texture
  111511. * @param samplingMode defines the required sampling mode
  111512. * @param texture defines the texture to update
  111513. */
  111514. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111515. /**
  111516. * Binds the frame buffer to the specified texture.
  111517. * @param texture The texture to render to or null for the default canvas
  111518. * @param faceIndex The face of the texture to render to in case of cube texture
  111519. * @param requiredWidth The width of the target to render to
  111520. * @param requiredHeight The height of the target to render to
  111521. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111522. * @param depthStencilTexture The depth stencil texture to use to render
  111523. * @param lodLevel defines le lod level to bind to the frame buffer
  111524. */
  111525. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111526. /**
  111527. * Unbind the current render target texture from the webGL context
  111528. * @param texture defines the render target texture to unbind
  111529. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111530. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111531. */
  111532. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111533. /**
  111534. * Creates a dynamic vertex buffer
  111535. * @param vertices the data for the dynamic vertex buffer
  111536. * @returns the new WebGL dynamic buffer
  111537. */
  111538. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111539. /**
  111540. * Update the content of a dynamic texture
  111541. * @param texture defines the texture to update
  111542. * @param canvas defines the canvas containing the source
  111543. * @param invertY defines if data must be stored with Y axis inverted
  111544. * @param premulAlpha defines if alpha is stored as premultiplied
  111545. * @param format defines the format of the data
  111546. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111547. */
  111548. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111549. /**
  111550. * Gets a boolean indicating if all created effects are ready
  111551. * @returns true if all effects are ready
  111552. */
  111553. areAllEffectsReady(): boolean;
  111554. /**
  111555. * @hidden
  111556. * Get the current error code of the webGL context
  111557. * @returns the error code
  111558. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111559. */
  111560. getError(): number;
  111561. /** @hidden */
  111562. _getUnpackAlignement(): number;
  111563. /** @hidden */
  111564. _unpackFlipY(value: boolean): void;
  111565. /**
  111566. * Update a dynamic index buffer
  111567. * @param indexBuffer defines the target index buffer
  111568. * @param indices defines the data to update
  111569. * @param offset defines the offset in the target index buffer where update should start
  111570. */
  111571. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111572. /**
  111573. * Updates a dynamic vertex buffer.
  111574. * @param vertexBuffer the vertex buffer to update
  111575. * @param vertices the data used to update the vertex buffer
  111576. * @param byteOffset the byte offset of the data (optional)
  111577. * @param byteLength the byte length of the data (optional)
  111578. */
  111579. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111580. /** @hidden */
  111581. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111582. /** @hidden */
  111583. _bindTexture(channel: number, texture: InternalTexture): void;
  111584. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111585. /**
  111586. * 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
  111587. */
  111588. releaseEffects(): void;
  111589. displayLoadingUI(): void;
  111590. hideLoadingUI(): void;
  111591. /** @hidden */
  111592. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111593. /** @hidden */
  111594. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111595. /** @hidden */
  111596. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111597. /** @hidden */
  111598. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111599. }
  111600. }
  111601. declare module BABYLON {
  111602. /** @hidden */
  111603. export class _OcclusionDataStorage {
  111604. /** @hidden */
  111605. occlusionInternalRetryCounter: number;
  111606. /** @hidden */
  111607. isOcclusionQueryInProgress: boolean;
  111608. /** @hidden */
  111609. isOccluded: boolean;
  111610. /** @hidden */
  111611. occlusionRetryCount: number;
  111612. /** @hidden */
  111613. occlusionType: number;
  111614. /** @hidden */
  111615. occlusionQueryAlgorithmType: number;
  111616. }
  111617. interface Engine {
  111618. /**
  111619. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111620. * @return the new query
  111621. */
  111622. createQuery(): WebGLQuery;
  111623. /**
  111624. * Delete and release a webGL query
  111625. * @param query defines the query to delete
  111626. * @return the current engine
  111627. */
  111628. deleteQuery(query: WebGLQuery): Engine;
  111629. /**
  111630. * Check if a given query has resolved and got its value
  111631. * @param query defines the query to check
  111632. * @returns true if the query got its value
  111633. */
  111634. isQueryResultAvailable(query: WebGLQuery): boolean;
  111635. /**
  111636. * Gets the value of a given query
  111637. * @param query defines the query to check
  111638. * @returns the value of the query
  111639. */
  111640. getQueryResult(query: WebGLQuery): number;
  111641. /**
  111642. * Initiates an occlusion query
  111643. * @param algorithmType defines the algorithm to use
  111644. * @param query defines the query to use
  111645. * @returns the current engine
  111646. * @see http://doc.babylonjs.com/features/occlusionquery
  111647. */
  111648. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111649. /**
  111650. * Ends an occlusion query
  111651. * @see http://doc.babylonjs.com/features/occlusionquery
  111652. * @param algorithmType defines the algorithm to use
  111653. * @returns the current engine
  111654. */
  111655. endOcclusionQuery(algorithmType: number): Engine;
  111656. /**
  111657. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111658. * Please note that only one query can be issued at a time
  111659. * @returns a time token used to track the time span
  111660. */
  111661. startTimeQuery(): Nullable<_TimeToken>;
  111662. /**
  111663. * Ends a time query
  111664. * @param token defines the token used to measure the time span
  111665. * @returns the time spent (in ns)
  111666. */
  111667. endTimeQuery(token: _TimeToken): int;
  111668. /** @hidden */
  111669. _currentNonTimestampToken: Nullable<_TimeToken>;
  111670. /** @hidden */
  111671. _createTimeQuery(): WebGLQuery;
  111672. /** @hidden */
  111673. _deleteTimeQuery(query: WebGLQuery): void;
  111674. /** @hidden */
  111675. _getGlAlgorithmType(algorithmType: number): number;
  111676. /** @hidden */
  111677. _getTimeQueryResult(query: WebGLQuery): any;
  111678. /** @hidden */
  111679. _getTimeQueryAvailability(query: WebGLQuery): any;
  111680. }
  111681. interface AbstractMesh {
  111682. /**
  111683. * Backing filed
  111684. * @hidden
  111685. */
  111686. __occlusionDataStorage: _OcclusionDataStorage;
  111687. /**
  111688. * Access property
  111689. * @hidden
  111690. */
  111691. _occlusionDataStorage: _OcclusionDataStorage;
  111692. /**
  111693. * 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.
  111694. * The default value is -1 which means don't break the query and wait till the result
  111695. * @see http://doc.babylonjs.com/features/occlusionquery
  111696. */
  111697. occlusionRetryCount: number;
  111698. /**
  111699. * 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:
  111700. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111701. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111702. * * 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.
  111703. * @see http://doc.babylonjs.com/features/occlusionquery
  111704. */
  111705. occlusionType: number;
  111706. /**
  111707. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111708. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111709. * * 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.
  111710. * @see http://doc.babylonjs.com/features/occlusionquery
  111711. */
  111712. occlusionQueryAlgorithmType: number;
  111713. /**
  111714. * 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
  111715. * @see http://doc.babylonjs.com/features/occlusionquery
  111716. */
  111717. isOccluded: boolean;
  111718. /**
  111719. * Flag to check the progress status of the query
  111720. * @see http://doc.babylonjs.com/features/occlusionquery
  111721. */
  111722. isOcclusionQueryInProgress: boolean;
  111723. }
  111724. }
  111725. declare module BABYLON {
  111726. /** @hidden */
  111727. export var _forceTransformFeedbackToBundle: boolean;
  111728. interface Engine {
  111729. /**
  111730. * Creates a webGL transform feedback object
  111731. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111732. * @returns the webGL transform feedback object
  111733. */
  111734. createTransformFeedback(): WebGLTransformFeedback;
  111735. /**
  111736. * Delete a webGL transform feedback object
  111737. * @param value defines the webGL transform feedback object to delete
  111738. */
  111739. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111740. /**
  111741. * Bind a webGL transform feedback object to the webgl context
  111742. * @param value defines the webGL transform feedback object to bind
  111743. */
  111744. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111745. /**
  111746. * Begins a transform feedback operation
  111747. * @param usePoints defines if points or triangles must be used
  111748. */
  111749. beginTransformFeedback(usePoints: boolean): void;
  111750. /**
  111751. * Ends a transform feedback operation
  111752. */
  111753. endTransformFeedback(): void;
  111754. /**
  111755. * Specify the varyings to use with transform feedback
  111756. * @param program defines the associated webGL program
  111757. * @param value defines the list of strings representing the varying names
  111758. */
  111759. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111760. /**
  111761. * Bind a webGL buffer for a transform feedback operation
  111762. * @param value defines the webGL buffer to bind
  111763. */
  111764. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111765. }
  111766. }
  111767. declare module BABYLON {
  111768. /**
  111769. * Creation options of the multi render target texture.
  111770. */
  111771. export interface IMultiRenderTargetOptions {
  111772. /**
  111773. * Define if the texture needs to create mip maps after render.
  111774. */
  111775. generateMipMaps?: boolean;
  111776. /**
  111777. * Define the types of all the draw buffers we want to create
  111778. */
  111779. types?: number[];
  111780. /**
  111781. * Define the sampling modes of all the draw buffers we want to create
  111782. */
  111783. samplingModes?: number[];
  111784. /**
  111785. * Define if a depth buffer is required
  111786. */
  111787. generateDepthBuffer?: boolean;
  111788. /**
  111789. * Define if a stencil buffer is required
  111790. */
  111791. generateStencilBuffer?: boolean;
  111792. /**
  111793. * Define if a depth texture is required instead of a depth buffer
  111794. */
  111795. generateDepthTexture?: boolean;
  111796. /**
  111797. * Define the number of desired draw buffers
  111798. */
  111799. textureCount?: number;
  111800. /**
  111801. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111802. */
  111803. doNotChangeAspectRatio?: boolean;
  111804. /**
  111805. * Define the default type of the buffers we are creating
  111806. */
  111807. defaultType?: number;
  111808. }
  111809. /**
  111810. * A multi render target, like a render target provides the ability to render to a texture.
  111811. * Unlike the render target, it can render to several draw buffers in one draw.
  111812. * This is specially interesting in deferred rendering or for any effects requiring more than
  111813. * just one color from a single pass.
  111814. */
  111815. export class MultiRenderTarget extends RenderTargetTexture {
  111816. private _internalTextures;
  111817. private _textures;
  111818. private _multiRenderTargetOptions;
  111819. /**
  111820. * Get if draw buffers are currently supported by the used hardware and browser.
  111821. */
  111822. readonly isSupported: boolean;
  111823. /**
  111824. * Get the list of textures generated by the multi render target.
  111825. */
  111826. readonly textures: Texture[];
  111827. /**
  111828. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111829. */
  111830. readonly depthTexture: Texture;
  111831. /**
  111832. * Set the wrapping mode on U of all the textures we are rendering to.
  111833. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111834. */
  111835. wrapU: number;
  111836. /**
  111837. * Set the wrapping mode on V of all the textures we are rendering to.
  111838. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111839. */
  111840. wrapV: number;
  111841. /**
  111842. * Instantiate a new multi render target texture.
  111843. * A multi render target, like a render target provides the ability to render to a texture.
  111844. * Unlike the render target, it can render to several draw buffers in one draw.
  111845. * This is specially interesting in deferred rendering or for any effects requiring more than
  111846. * just one color from a single pass.
  111847. * @param name Define the name of the texture
  111848. * @param size Define the size of the buffers to render to
  111849. * @param count Define the number of target we are rendering into
  111850. * @param scene Define the scene the texture belongs to
  111851. * @param options Define the options used to create the multi render target
  111852. */
  111853. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111854. /** @hidden */
  111855. _rebuild(): void;
  111856. private _createInternalTextures;
  111857. private _createTextures;
  111858. /**
  111859. * Define the number of samples used if MSAA is enabled.
  111860. */
  111861. samples: number;
  111862. /**
  111863. * Resize all the textures in the multi render target.
  111864. * Be carrefull as it will recreate all the data in the new texture.
  111865. * @param size Define the new size
  111866. */
  111867. resize(size: any): void;
  111868. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111869. /**
  111870. * Dispose the render targets and their associated resources
  111871. */
  111872. dispose(): void;
  111873. /**
  111874. * Release all the underlying texture used as draw buffers.
  111875. */
  111876. releaseInternalTextures(): void;
  111877. }
  111878. }
  111879. declare module BABYLON {
  111880. interface ThinEngine {
  111881. /**
  111882. * Unbind a list of render target textures from the webGL context
  111883. * This is used only when drawBuffer extension or webGL2 are active
  111884. * @param textures defines the render target textures to unbind
  111885. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111886. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111887. */
  111888. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111889. /**
  111890. * Create a multi render target texture
  111891. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111892. * @param size defines the size of the texture
  111893. * @param options defines the creation options
  111894. * @returns the cube texture as an InternalTexture
  111895. */
  111896. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111897. /**
  111898. * Update the sample count for a given multiple render target texture
  111899. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111900. * @param textures defines the textures to update
  111901. * @param samples defines the sample count to set
  111902. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111903. */
  111904. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111905. }
  111906. }
  111907. declare module BABYLON {
  111908. /**
  111909. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111910. */
  111911. export interface CubeMapInfo {
  111912. /**
  111913. * The pixel array for the front face.
  111914. * This is stored in format, left to right, up to down format.
  111915. */
  111916. front: Nullable<ArrayBufferView>;
  111917. /**
  111918. * The pixel array for the back face.
  111919. * This is stored in format, left to right, up to down format.
  111920. */
  111921. back: Nullable<ArrayBufferView>;
  111922. /**
  111923. * The pixel array for the left face.
  111924. * This is stored in format, left to right, up to down format.
  111925. */
  111926. left: Nullable<ArrayBufferView>;
  111927. /**
  111928. * The pixel array for the right face.
  111929. * This is stored in format, left to right, up to down format.
  111930. */
  111931. right: Nullable<ArrayBufferView>;
  111932. /**
  111933. * The pixel array for the up face.
  111934. * This is stored in format, left to right, up to down format.
  111935. */
  111936. up: Nullable<ArrayBufferView>;
  111937. /**
  111938. * The pixel array for the down face.
  111939. * This is stored in format, left to right, up to down format.
  111940. */
  111941. down: Nullable<ArrayBufferView>;
  111942. /**
  111943. * The size of the cubemap stored.
  111944. *
  111945. * Each faces will be size * size pixels.
  111946. */
  111947. size: number;
  111948. /**
  111949. * The format of the texture.
  111950. *
  111951. * RGBA, RGB.
  111952. */
  111953. format: number;
  111954. /**
  111955. * The type of the texture data.
  111956. *
  111957. * UNSIGNED_INT, FLOAT.
  111958. */
  111959. type: number;
  111960. /**
  111961. * Specifies whether the texture is in gamma space.
  111962. */
  111963. gammaSpace: boolean;
  111964. }
  111965. /**
  111966. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111967. */
  111968. export class PanoramaToCubeMapTools {
  111969. private static FACE_FRONT;
  111970. private static FACE_BACK;
  111971. private static FACE_RIGHT;
  111972. private static FACE_LEFT;
  111973. private static FACE_DOWN;
  111974. private static FACE_UP;
  111975. /**
  111976. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111977. *
  111978. * @param float32Array The source data.
  111979. * @param inputWidth The width of the input panorama.
  111980. * @param inputHeight The height of the input panorama.
  111981. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111982. * @return The cubemap data
  111983. */
  111984. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111985. private static CreateCubemapTexture;
  111986. private static CalcProjectionSpherical;
  111987. }
  111988. }
  111989. declare module BABYLON {
  111990. /**
  111991. * Helper class dealing with the extraction of spherical polynomial dataArray
  111992. * from a cube map.
  111993. */
  111994. export class CubeMapToSphericalPolynomialTools {
  111995. private static FileFaces;
  111996. /**
  111997. * Converts a texture to the according Spherical Polynomial data.
  111998. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111999. *
  112000. * @param texture The texture to extract the information from.
  112001. * @return The Spherical Polynomial data.
  112002. */
  112003. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112004. /**
  112005. * Converts a cubemap to the according Spherical Polynomial data.
  112006. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112007. *
  112008. * @param cubeInfo The Cube map to extract the information from.
  112009. * @return The Spherical Polynomial data.
  112010. */
  112011. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112012. }
  112013. }
  112014. declare module BABYLON {
  112015. interface BaseTexture {
  112016. /**
  112017. * Get the polynomial representation of the texture data.
  112018. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112019. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112020. */
  112021. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112022. }
  112023. }
  112024. declare module BABYLON {
  112025. /** @hidden */
  112026. export var rgbdEncodePixelShader: {
  112027. name: string;
  112028. shader: string;
  112029. };
  112030. }
  112031. declare module BABYLON {
  112032. /** @hidden */
  112033. export var rgbdDecodePixelShader: {
  112034. name: string;
  112035. shader: string;
  112036. };
  112037. }
  112038. declare module BABYLON {
  112039. /**
  112040. * Raw texture data and descriptor sufficient for WebGL texture upload
  112041. */
  112042. export interface EnvironmentTextureInfo {
  112043. /**
  112044. * Version of the environment map
  112045. */
  112046. version: number;
  112047. /**
  112048. * Width of image
  112049. */
  112050. width: number;
  112051. /**
  112052. * Irradiance information stored in the file.
  112053. */
  112054. irradiance: any;
  112055. /**
  112056. * Specular information stored in the file.
  112057. */
  112058. specular: any;
  112059. }
  112060. /**
  112061. * Defines One Image in the file. It requires only the position in the file
  112062. * as well as the length.
  112063. */
  112064. interface BufferImageData {
  112065. /**
  112066. * Length of the image data.
  112067. */
  112068. length: number;
  112069. /**
  112070. * Position of the data from the null terminator delimiting the end of the JSON.
  112071. */
  112072. position: number;
  112073. }
  112074. /**
  112075. * Defines the specular data enclosed in the file.
  112076. * This corresponds to the version 1 of the data.
  112077. */
  112078. export interface EnvironmentTextureSpecularInfoV1 {
  112079. /**
  112080. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112081. */
  112082. specularDataPosition?: number;
  112083. /**
  112084. * This contains all the images data needed to reconstruct the cubemap.
  112085. */
  112086. mipmaps: Array<BufferImageData>;
  112087. /**
  112088. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112089. */
  112090. lodGenerationScale: number;
  112091. }
  112092. /**
  112093. * Sets of helpers addressing the serialization and deserialization of environment texture
  112094. * stored in a BabylonJS env file.
  112095. * Those files are usually stored as .env files.
  112096. */
  112097. export class EnvironmentTextureTools {
  112098. /**
  112099. * Magic number identifying the env file.
  112100. */
  112101. private static _MagicBytes;
  112102. /**
  112103. * Gets the environment info from an env file.
  112104. * @param data The array buffer containing the .env bytes.
  112105. * @returns the environment file info (the json header) if successfully parsed.
  112106. */
  112107. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112108. /**
  112109. * Creates an environment texture from a loaded cube texture.
  112110. * @param texture defines the cube texture to convert in env file
  112111. * @return a promise containing the environment data if succesfull.
  112112. */
  112113. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112114. /**
  112115. * Creates a JSON representation of the spherical data.
  112116. * @param texture defines the texture containing the polynomials
  112117. * @return the JSON representation of the spherical info
  112118. */
  112119. private static _CreateEnvTextureIrradiance;
  112120. /**
  112121. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112122. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112123. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112124. * @return the views described by info providing access to the underlying buffer
  112125. */
  112126. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112127. /**
  112128. * Uploads the texture info contained in the env file to the GPU.
  112129. * @param texture defines the internal texture to upload to
  112130. * @param arrayBuffer defines the buffer cotaining the data to load
  112131. * @param info defines the texture info retrieved through the GetEnvInfo method
  112132. * @returns a promise
  112133. */
  112134. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112135. private static _OnImageReadyAsync;
  112136. /**
  112137. * Uploads the levels of image data to the GPU.
  112138. * @param texture defines the internal texture to upload to
  112139. * @param imageData defines the array buffer views of image data [mipmap][face]
  112140. * @returns a promise
  112141. */
  112142. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112143. /**
  112144. * Uploads spherical polynomials information to the texture.
  112145. * @param texture defines the texture we are trying to upload the information to
  112146. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112147. */
  112148. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112149. /** @hidden */
  112150. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112151. }
  112152. }
  112153. declare module BABYLON {
  112154. /**
  112155. * Contains position and normal vectors for a vertex
  112156. */
  112157. export class PositionNormalVertex {
  112158. /** the position of the vertex (defaut: 0,0,0) */
  112159. position: Vector3;
  112160. /** the normal of the vertex (defaut: 0,1,0) */
  112161. normal: Vector3;
  112162. /**
  112163. * Creates a PositionNormalVertex
  112164. * @param position the position of the vertex (defaut: 0,0,0)
  112165. * @param normal the normal of the vertex (defaut: 0,1,0)
  112166. */
  112167. constructor(
  112168. /** the position of the vertex (defaut: 0,0,0) */
  112169. position?: Vector3,
  112170. /** the normal of the vertex (defaut: 0,1,0) */
  112171. normal?: Vector3);
  112172. /**
  112173. * Clones the PositionNormalVertex
  112174. * @returns the cloned PositionNormalVertex
  112175. */
  112176. clone(): PositionNormalVertex;
  112177. }
  112178. /**
  112179. * Contains position, normal and uv vectors for a vertex
  112180. */
  112181. export class PositionNormalTextureVertex {
  112182. /** the position of the vertex (defaut: 0,0,0) */
  112183. position: Vector3;
  112184. /** the normal of the vertex (defaut: 0,1,0) */
  112185. normal: Vector3;
  112186. /** the uv of the vertex (default: 0,0) */
  112187. uv: Vector2;
  112188. /**
  112189. * Creates a PositionNormalTextureVertex
  112190. * @param position the position of the vertex (defaut: 0,0,0)
  112191. * @param normal the normal of the vertex (defaut: 0,1,0)
  112192. * @param uv the uv of the vertex (default: 0,0)
  112193. */
  112194. constructor(
  112195. /** the position of the vertex (defaut: 0,0,0) */
  112196. position?: Vector3,
  112197. /** the normal of the vertex (defaut: 0,1,0) */
  112198. normal?: Vector3,
  112199. /** the uv of the vertex (default: 0,0) */
  112200. uv?: Vector2);
  112201. /**
  112202. * Clones the PositionNormalTextureVertex
  112203. * @returns the cloned PositionNormalTextureVertex
  112204. */
  112205. clone(): PositionNormalTextureVertex;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /** @hidden */
  112210. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112211. private _genericAttributeLocation;
  112212. private _varyingLocationCount;
  112213. private _varyingLocationMap;
  112214. private _replacements;
  112215. private _textureCount;
  112216. private _uniforms;
  112217. lineProcessor(line: string): string;
  112218. attributeProcessor(attribute: string): string;
  112219. varyingProcessor(varying: string, isFragment: boolean): string;
  112220. uniformProcessor(uniform: string): string;
  112221. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112222. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112223. }
  112224. }
  112225. declare module BABYLON {
  112226. /**
  112227. * Container for accessors for natively-stored mesh data buffers.
  112228. */
  112229. class NativeDataBuffer extends DataBuffer {
  112230. /**
  112231. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112232. */
  112233. nativeIndexBuffer?: any;
  112234. /**
  112235. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112236. */
  112237. nativeVertexBuffer?: any;
  112238. }
  112239. /** @hidden */
  112240. export class NativeEngine extends Engine {
  112241. private readonly _native;
  112242. getHardwareScalingLevel(): number;
  112243. constructor();
  112244. /**
  112245. * Can be used to override the current requestAnimationFrame requester.
  112246. * @hidden
  112247. */
  112248. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  112249. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112250. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112251. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112252. recordVertexArrayObject(vertexBuffers: {
  112253. [key: string]: VertexBuffer;
  112254. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112255. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112256. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112257. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112258. /**
  112259. * Draw a list of indexed primitives
  112260. * @param fillMode defines the primitive to use
  112261. * @param indexStart defines the starting index
  112262. * @param indexCount defines the number of index to draw
  112263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112264. */
  112265. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112266. /**
  112267. * Draw a list of unindexed primitives
  112268. * @param fillMode defines the primitive to use
  112269. * @param verticesStart defines the index of first vertex to draw
  112270. * @param verticesCount defines the count of vertices to draw
  112271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112272. */
  112273. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112274. createPipelineContext(): IPipelineContext;
  112275. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112276. /** @hidden */
  112277. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112278. /** @hidden */
  112279. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112280. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112281. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112282. protected _setProgram(program: WebGLProgram): void;
  112283. _releaseEffect(effect: Effect): void;
  112284. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112285. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112286. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112287. bindSamplers(effect: Effect): void;
  112288. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112289. getRenderWidth(useScreen?: boolean): number;
  112290. getRenderHeight(useScreen?: boolean): number;
  112291. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112292. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112293. /**
  112294. * Set the z offset to apply to current rendering
  112295. * @param value defines the offset to apply
  112296. */
  112297. setZOffset(value: number): void;
  112298. /**
  112299. * Gets the current value of the zOffset
  112300. * @returns the current zOffset state
  112301. */
  112302. getZOffset(): number;
  112303. /**
  112304. * Enable or disable depth buffering
  112305. * @param enable defines the state to set
  112306. */
  112307. setDepthBuffer(enable: boolean): void;
  112308. /**
  112309. * Gets a boolean indicating if depth writing is enabled
  112310. * @returns the current depth writing state
  112311. */
  112312. getDepthWrite(): boolean;
  112313. /**
  112314. * Enable or disable depth writing
  112315. * @param enable defines the state to set
  112316. */
  112317. setDepthWrite(enable: boolean): void;
  112318. /**
  112319. * Enable or disable color writing
  112320. * @param enable defines the state to set
  112321. */
  112322. setColorWrite(enable: boolean): void;
  112323. /**
  112324. * Gets a boolean indicating if color writing is enabled
  112325. * @returns the current color writing state
  112326. */
  112327. getColorWrite(): boolean;
  112328. /**
  112329. * Sets alpha constants used by some alpha blending modes
  112330. * @param r defines the red component
  112331. * @param g defines the green component
  112332. * @param b defines the blue component
  112333. * @param a defines the alpha component
  112334. */
  112335. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112336. /**
  112337. * Sets the current alpha mode
  112338. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112339. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112341. */
  112342. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112343. /**
  112344. * Gets the current alpha mode
  112345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112346. * @returns the current alpha mode
  112347. */
  112348. getAlphaMode(): number;
  112349. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112350. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112351. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112352. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112353. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112354. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112355. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112356. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112357. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112358. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112359. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112360. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112361. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112362. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112363. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112364. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112365. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112366. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112367. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112368. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112369. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112370. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112371. wipeCaches(bruteForce?: boolean): void;
  112372. _createTexture(): WebGLTexture;
  112373. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112374. /**
  112375. * Usually called from BABYLON.Texture.ts.
  112376. * Passed information to create a WebGLTexture
  112377. * @param urlArg defines a value which contains one of the following:
  112378. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112379. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112380. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112381. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112382. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112383. * @param scene needed for loading to the correct scene
  112384. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112385. * @param onLoad optional callback to be called upon successful completion
  112386. * @param onError optional callback to be called upon failure
  112387. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112388. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112389. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112390. * @param forcedExtension defines the extension to use to pick the right loader
  112391. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112392. */
  112393. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  112394. /**
  112395. * Creates a cube texture
  112396. * @param rootUrl defines the url where the files to load is located
  112397. * @param scene defines the current scene
  112398. * @param files defines the list of files to load (1 per face)
  112399. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112400. * @param onLoad defines an optional callback raised when the texture is loaded
  112401. * @param onError defines an optional callback raised if there is an issue to load the texture
  112402. * @param format defines the format of the data
  112403. * @param forcedExtension defines the extension to use to pick the right loader
  112404. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112405. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112406. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112407. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112408. * @returns the cube texture as an InternalTexture
  112409. */
  112410. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  112411. private _getSamplingFilter;
  112412. private static _GetNativeTextureFormat;
  112413. createRenderTargetTexture(size: number | {
  112414. width: number;
  112415. height: number;
  112416. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112417. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112418. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112419. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112420. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112421. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112422. /**
  112423. * Updates a dynamic vertex buffer.
  112424. * @param vertexBuffer the vertex buffer to update
  112425. * @param data the data used to update the vertex buffer
  112426. * @param byteOffset the byte offset of the data (optional)
  112427. * @param byteLength the byte length of the data (optional)
  112428. */
  112429. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112430. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112431. private _updateAnisotropicLevel;
  112432. private _getAddressMode;
  112433. /** @hidden */
  112434. _bindTexture(channel: number, texture: InternalTexture): void;
  112435. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112436. releaseEffects(): void;
  112437. /** @hidden */
  112438. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112439. /** @hidden */
  112440. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112441. /** @hidden */
  112442. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112443. /** @hidden */
  112444. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112445. }
  112446. }
  112447. declare module BABYLON {
  112448. /**
  112449. * Gather the list of clipboard event types as constants.
  112450. */
  112451. export class ClipboardEventTypes {
  112452. /**
  112453. * The clipboard event is fired when a copy command is active (pressed).
  112454. */
  112455. static readonly COPY: number;
  112456. /**
  112457. * The clipboard event is fired when a cut command is active (pressed).
  112458. */
  112459. static readonly CUT: number;
  112460. /**
  112461. * The clipboard event is fired when a paste command is active (pressed).
  112462. */
  112463. static readonly PASTE: number;
  112464. }
  112465. /**
  112466. * This class is used to store clipboard related info for the onClipboardObservable event.
  112467. */
  112468. export class ClipboardInfo {
  112469. /**
  112470. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112471. */
  112472. type: number;
  112473. /**
  112474. * Defines the related dom event
  112475. */
  112476. event: ClipboardEvent;
  112477. /**
  112478. *Creates an instance of ClipboardInfo.
  112479. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112480. * @param event Defines the related dom event
  112481. */
  112482. constructor(
  112483. /**
  112484. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112485. */
  112486. type: number,
  112487. /**
  112488. * Defines the related dom event
  112489. */
  112490. event: ClipboardEvent);
  112491. /**
  112492. * Get the clipboard event's type from the keycode.
  112493. * @param keyCode Defines the keyCode for the current keyboard event.
  112494. * @return {number}
  112495. */
  112496. static GetTypeFromCharacter(keyCode: number): number;
  112497. }
  112498. }
  112499. declare module BABYLON {
  112500. /**
  112501. * Google Daydream controller
  112502. */
  112503. export class DaydreamController extends WebVRController {
  112504. /**
  112505. * Base Url for the controller model.
  112506. */
  112507. static MODEL_BASE_URL: string;
  112508. /**
  112509. * File name for the controller model.
  112510. */
  112511. static MODEL_FILENAME: string;
  112512. /**
  112513. * Gamepad Id prefix used to identify Daydream Controller.
  112514. */
  112515. static readonly GAMEPAD_ID_PREFIX: string;
  112516. /**
  112517. * Creates a new DaydreamController from a gamepad
  112518. * @param vrGamepad the gamepad that the controller should be created from
  112519. */
  112520. constructor(vrGamepad: any);
  112521. /**
  112522. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112523. * @param scene scene in which to add meshes
  112524. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112525. */
  112526. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112527. /**
  112528. * Called once for each button that changed state since the last frame
  112529. * @param buttonIdx Which button index changed
  112530. * @param state New state of the button
  112531. * @param changes Which properties on the state changed since last frame
  112532. */
  112533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112534. }
  112535. }
  112536. declare module BABYLON {
  112537. /**
  112538. * Gear VR Controller
  112539. */
  112540. export class GearVRController extends WebVRController {
  112541. /**
  112542. * Base Url for the controller model.
  112543. */
  112544. static MODEL_BASE_URL: string;
  112545. /**
  112546. * File name for the controller model.
  112547. */
  112548. static MODEL_FILENAME: string;
  112549. /**
  112550. * Gamepad Id prefix used to identify this controller.
  112551. */
  112552. static readonly GAMEPAD_ID_PREFIX: string;
  112553. private readonly _buttonIndexToObservableNameMap;
  112554. /**
  112555. * Creates a new GearVRController from a gamepad
  112556. * @param vrGamepad the gamepad that the controller should be created from
  112557. */
  112558. constructor(vrGamepad: any);
  112559. /**
  112560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112561. * @param scene scene in which to add meshes
  112562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112563. */
  112564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112565. /**
  112566. * Called once for each button that changed state since the last frame
  112567. * @param buttonIdx Which button index changed
  112568. * @param state New state of the button
  112569. * @param changes Which properties on the state changed since last frame
  112570. */
  112571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112572. }
  112573. }
  112574. declare module BABYLON {
  112575. /**
  112576. * Class containing static functions to help procedurally build meshes
  112577. */
  112578. export class PolyhedronBuilder {
  112579. /**
  112580. * Creates a polyhedron mesh
  112581. * * 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
  112582. * * The parameter `size` (positive float, default 1) sets the polygon size
  112583. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112584. * * 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`
  112585. * * 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
  112586. * * 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)`)
  112587. * * 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
  112588. * * 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
  112589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112592. * @param name defines the name of the mesh
  112593. * @param options defines the options used to create the mesh
  112594. * @param scene defines the hosting scene
  112595. * @returns the polyhedron mesh
  112596. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112597. */
  112598. static CreatePolyhedron(name: string, options: {
  112599. type?: number;
  112600. size?: number;
  112601. sizeX?: number;
  112602. sizeY?: number;
  112603. sizeZ?: number;
  112604. custom?: any;
  112605. faceUV?: Vector4[];
  112606. faceColors?: Color4[];
  112607. flat?: boolean;
  112608. updatable?: boolean;
  112609. sideOrientation?: number;
  112610. frontUVs?: Vector4;
  112611. backUVs?: Vector4;
  112612. }, scene?: Nullable<Scene>): Mesh;
  112613. }
  112614. }
  112615. declare module BABYLON {
  112616. /**
  112617. * Gizmo that enables scaling a mesh along 3 axis
  112618. */
  112619. export class ScaleGizmo extends Gizmo {
  112620. /**
  112621. * Internal gizmo used for interactions on the x axis
  112622. */
  112623. xGizmo: AxisScaleGizmo;
  112624. /**
  112625. * Internal gizmo used for interactions on the y axis
  112626. */
  112627. yGizmo: AxisScaleGizmo;
  112628. /**
  112629. * Internal gizmo used for interactions on the z axis
  112630. */
  112631. zGizmo: AxisScaleGizmo;
  112632. /**
  112633. * Internal gizmo used to scale all axis equally
  112634. */
  112635. uniformScaleGizmo: AxisScaleGizmo;
  112636. private _meshAttached;
  112637. private _updateGizmoRotationToMatchAttachedMesh;
  112638. private _snapDistance;
  112639. private _scaleRatio;
  112640. private _uniformScalingMesh;
  112641. private _octahedron;
  112642. /** Fires an event when any of it's sub gizmos are dragged */
  112643. onDragStartObservable: Observable<unknown>;
  112644. /** Fires an event when any of it's sub gizmos are released from dragging */
  112645. onDragEndObservable: Observable<unknown>;
  112646. attachedMesh: Nullable<AbstractMesh>;
  112647. /**
  112648. * Creates a ScaleGizmo
  112649. * @param gizmoLayer The utility layer the gizmo will be added to
  112650. */
  112651. constructor(gizmoLayer?: UtilityLayerRenderer);
  112652. updateGizmoRotationToMatchAttachedMesh: boolean;
  112653. /**
  112654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112655. */
  112656. snapDistance: number;
  112657. /**
  112658. * Ratio for the scale of the gizmo (Default: 1)
  112659. */
  112660. scaleRatio: number;
  112661. /**
  112662. * Disposes of the gizmo
  112663. */
  112664. dispose(): void;
  112665. }
  112666. }
  112667. declare module BABYLON {
  112668. /**
  112669. * Single axis scale gizmo
  112670. */
  112671. export class AxisScaleGizmo extends Gizmo {
  112672. /**
  112673. * Drag behavior responsible for the gizmos dragging interactions
  112674. */
  112675. dragBehavior: PointerDragBehavior;
  112676. private _pointerObserver;
  112677. /**
  112678. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112679. */
  112680. snapDistance: number;
  112681. /**
  112682. * Event that fires each time the gizmo snaps to a new location.
  112683. * * snapDistance is the the change in distance
  112684. */
  112685. onSnapObservable: Observable<{
  112686. snapDistance: number;
  112687. }>;
  112688. /**
  112689. * If the scaling operation should be done on all axis (default: false)
  112690. */
  112691. uniformScaling: boolean;
  112692. private _isEnabled;
  112693. private _parent;
  112694. private _arrow;
  112695. private _coloredMaterial;
  112696. private _hoverMaterial;
  112697. /**
  112698. * Creates an AxisScaleGizmo
  112699. * @param gizmoLayer The utility layer the gizmo will be added to
  112700. * @param dragAxis The axis which the gizmo will be able to scale on
  112701. * @param color The color of the gizmo
  112702. */
  112703. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112705. /**
  112706. * If the gizmo is enabled
  112707. */
  112708. isEnabled: boolean;
  112709. /**
  112710. * Disposes of the gizmo
  112711. */
  112712. dispose(): void;
  112713. /**
  112714. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112715. * @param mesh The mesh to replace the default mesh of the gizmo
  112716. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112717. */
  112718. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112719. }
  112720. }
  112721. declare module BABYLON {
  112722. /**
  112723. * Bounding box gizmo
  112724. */
  112725. export class BoundingBoxGizmo extends Gizmo {
  112726. private _lineBoundingBox;
  112727. private _rotateSpheresParent;
  112728. private _scaleBoxesParent;
  112729. private _boundingDimensions;
  112730. private _renderObserver;
  112731. private _pointerObserver;
  112732. private _scaleDragSpeed;
  112733. private _tmpQuaternion;
  112734. private _tmpVector;
  112735. private _tmpRotationMatrix;
  112736. /**
  112737. * 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)
  112738. */
  112739. ignoreChildren: boolean;
  112740. /**
  112741. * 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)
  112742. */
  112743. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112744. /**
  112745. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112746. */
  112747. rotationSphereSize: number;
  112748. /**
  112749. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112750. */
  112751. scaleBoxSize: number;
  112752. /**
  112753. * 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)
  112754. */
  112755. fixedDragMeshScreenSize: boolean;
  112756. /**
  112757. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112758. */
  112759. fixedDragMeshScreenSizeDistanceFactor: number;
  112760. /**
  112761. * Fired when a rotation sphere or scale box is dragged
  112762. */
  112763. onDragStartObservable: Observable<{}>;
  112764. /**
  112765. * Fired when a scale box is dragged
  112766. */
  112767. onScaleBoxDragObservable: Observable<{}>;
  112768. /**
  112769. * Fired when a scale box drag is ended
  112770. */
  112771. onScaleBoxDragEndObservable: Observable<{}>;
  112772. /**
  112773. * Fired when a rotation sphere is dragged
  112774. */
  112775. onRotationSphereDragObservable: Observable<{}>;
  112776. /**
  112777. * Fired when a rotation sphere drag is ended
  112778. */
  112779. onRotationSphereDragEndObservable: Observable<{}>;
  112780. /**
  112781. * 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)
  112782. */
  112783. scalePivot: Nullable<Vector3>;
  112784. /**
  112785. * Mesh used as a pivot to rotate the attached mesh
  112786. */
  112787. private _anchorMesh;
  112788. private _existingMeshScale;
  112789. private _dragMesh;
  112790. private pointerDragBehavior;
  112791. private coloredMaterial;
  112792. private hoverColoredMaterial;
  112793. /**
  112794. * Sets the color of the bounding box gizmo
  112795. * @param color the color to set
  112796. */
  112797. setColor(color: Color3): void;
  112798. /**
  112799. * Creates an BoundingBoxGizmo
  112800. * @param gizmoLayer The utility layer the gizmo will be added to
  112801. * @param color The color of the gizmo
  112802. */
  112803. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112804. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112805. private _selectNode;
  112806. /**
  112807. * Updates the bounding box information for the Gizmo
  112808. */
  112809. updateBoundingBox(): void;
  112810. private _updateRotationSpheres;
  112811. private _updateScaleBoxes;
  112812. /**
  112813. * Enables rotation on the specified axis and disables rotation on the others
  112814. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112815. */
  112816. setEnabledRotationAxis(axis: string): void;
  112817. /**
  112818. * Enables/disables scaling
  112819. * @param enable if scaling should be enabled
  112820. */
  112821. setEnabledScaling(enable: boolean): void;
  112822. private _updateDummy;
  112823. /**
  112824. * Enables a pointer drag behavior on the bounding box of the gizmo
  112825. */
  112826. enableDragBehavior(): void;
  112827. /**
  112828. * Disposes of the gizmo
  112829. */
  112830. dispose(): void;
  112831. /**
  112832. * 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)
  112833. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112834. * @returns the bounding box mesh with the passed in mesh as a child
  112835. */
  112836. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112837. /**
  112838. * CustomMeshes are not supported by this gizmo
  112839. * @param mesh The mesh to replace the default mesh of the gizmo
  112840. */
  112841. setCustomMesh(mesh: Mesh): void;
  112842. }
  112843. }
  112844. declare module BABYLON {
  112845. /**
  112846. * Single plane rotation gizmo
  112847. */
  112848. export class PlaneRotationGizmo extends Gizmo {
  112849. /**
  112850. * Drag behavior responsible for the gizmos dragging interactions
  112851. */
  112852. dragBehavior: PointerDragBehavior;
  112853. private _pointerObserver;
  112854. /**
  112855. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112856. */
  112857. snapDistance: number;
  112858. /**
  112859. * Event that fires each time the gizmo snaps to a new location.
  112860. * * snapDistance is the the change in distance
  112861. */
  112862. onSnapObservable: Observable<{
  112863. snapDistance: number;
  112864. }>;
  112865. private _isEnabled;
  112866. private _parent;
  112867. /**
  112868. * Creates a PlaneRotationGizmo
  112869. * @param gizmoLayer The utility layer the gizmo will be added to
  112870. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112871. * @param color The color of the gizmo
  112872. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112873. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112874. */
  112875. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112876. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112877. /**
  112878. * If the gizmo is enabled
  112879. */
  112880. isEnabled: boolean;
  112881. /**
  112882. * Disposes of the gizmo
  112883. */
  112884. dispose(): void;
  112885. }
  112886. }
  112887. declare module BABYLON {
  112888. /**
  112889. * Gizmo that enables rotating a mesh along 3 axis
  112890. */
  112891. export class RotationGizmo extends Gizmo {
  112892. /**
  112893. * Internal gizmo used for interactions on the x axis
  112894. */
  112895. xGizmo: PlaneRotationGizmo;
  112896. /**
  112897. * Internal gizmo used for interactions on the y axis
  112898. */
  112899. yGizmo: PlaneRotationGizmo;
  112900. /**
  112901. * Internal gizmo used for interactions on the z axis
  112902. */
  112903. zGizmo: PlaneRotationGizmo;
  112904. /** Fires an event when any of it's sub gizmos are dragged */
  112905. onDragStartObservable: Observable<unknown>;
  112906. /** Fires an event when any of it's sub gizmos are released from dragging */
  112907. onDragEndObservable: Observable<unknown>;
  112908. private _meshAttached;
  112909. attachedMesh: Nullable<AbstractMesh>;
  112910. /**
  112911. * Creates a RotationGizmo
  112912. * @param gizmoLayer The utility layer the gizmo will be added to
  112913. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112914. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112915. */
  112916. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112917. updateGizmoRotationToMatchAttachedMesh: boolean;
  112918. /**
  112919. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112920. */
  112921. snapDistance: number;
  112922. /**
  112923. * Ratio for the scale of the gizmo (Default: 1)
  112924. */
  112925. scaleRatio: number;
  112926. /**
  112927. * Disposes of the gizmo
  112928. */
  112929. dispose(): void;
  112930. /**
  112931. * CustomMeshes are not supported by this gizmo
  112932. * @param mesh The mesh to replace the default mesh of the gizmo
  112933. */
  112934. setCustomMesh(mesh: Mesh): void;
  112935. }
  112936. }
  112937. declare module BABYLON {
  112938. /**
  112939. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112940. */
  112941. export class GizmoManager implements IDisposable {
  112942. private scene;
  112943. /**
  112944. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112945. */
  112946. gizmos: {
  112947. positionGizmo: Nullable<PositionGizmo>;
  112948. rotationGizmo: Nullable<RotationGizmo>;
  112949. scaleGizmo: Nullable<ScaleGizmo>;
  112950. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112951. };
  112952. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112953. clearGizmoOnEmptyPointerEvent: boolean;
  112954. /** Fires an event when the manager is attached to a mesh */
  112955. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112956. private _gizmosEnabled;
  112957. private _pointerObserver;
  112958. private _attachedMesh;
  112959. private _boundingBoxColor;
  112960. private _defaultUtilityLayer;
  112961. private _defaultKeepDepthUtilityLayer;
  112962. /**
  112963. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112964. */
  112965. boundingBoxDragBehavior: SixDofDragBehavior;
  112966. /**
  112967. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112968. */
  112969. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112970. /**
  112971. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112972. */
  112973. usePointerToAttachGizmos: boolean;
  112974. /**
  112975. * Utility layer that the bounding box gizmo belongs to
  112976. */
  112977. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112978. /**
  112979. * Utility layer that all gizmos besides bounding box belong to
  112980. */
  112981. readonly utilityLayer: UtilityLayerRenderer;
  112982. /**
  112983. * Instatiates a gizmo manager
  112984. * @param scene the scene to overlay the gizmos on top of
  112985. */
  112986. constructor(scene: Scene);
  112987. /**
  112988. * Attaches a set of gizmos to the specified mesh
  112989. * @param mesh The mesh the gizmo's should be attached to
  112990. */
  112991. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112992. /**
  112993. * If the position gizmo is enabled
  112994. */
  112995. positionGizmoEnabled: boolean;
  112996. /**
  112997. * If the rotation gizmo is enabled
  112998. */
  112999. rotationGizmoEnabled: boolean;
  113000. /**
  113001. * If the scale gizmo is enabled
  113002. */
  113003. scaleGizmoEnabled: boolean;
  113004. /**
  113005. * If the boundingBox gizmo is enabled
  113006. */
  113007. boundingBoxGizmoEnabled: boolean;
  113008. /**
  113009. * Disposes of the gizmo manager
  113010. */
  113011. dispose(): void;
  113012. }
  113013. }
  113014. declare module BABYLON {
  113015. /**
  113016. * A directional light is defined by a direction (what a surprise!).
  113017. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113018. * 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.
  113019. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113020. */
  113021. export class DirectionalLight extends ShadowLight {
  113022. private _shadowFrustumSize;
  113023. /**
  113024. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113025. */
  113026. /**
  113027. * Specifies a fix frustum size for the shadow generation.
  113028. */
  113029. shadowFrustumSize: number;
  113030. private _shadowOrthoScale;
  113031. /**
  113032. * Gets the shadow projection scale against the optimal computed one.
  113033. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113034. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113035. */
  113036. /**
  113037. * Sets the shadow projection scale against the optimal computed one.
  113038. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113039. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113040. */
  113041. shadowOrthoScale: number;
  113042. /**
  113043. * Automatically compute the projection matrix to best fit (including all the casters)
  113044. * on each frame.
  113045. */
  113046. autoUpdateExtends: boolean;
  113047. private _orthoLeft;
  113048. private _orthoRight;
  113049. private _orthoTop;
  113050. private _orthoBottom;
  113051. /**
  113052. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113053. * The directional light is emitted from everywhere in the given direction.
  113054. * It can cast shadows.
  113055. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113056. * @param name The friendly name of the light
  113057. * @param direction The direction of the light
  113058. * @param scene The scene the light belongs to
  113059. */
  113060. constructor(name: string, direction: Vector3, scene: Scene);
  113061. /**
  113062. * Returns the string "DirectionalLight".
  113063. * @return The class name
  113064. */
  113065. getClassName(): string;
  113066. /**
  113067. * Returns the integer 1.
  113068. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113069. */
  113070. getTypeID(): number;
  113071. /**
  113072. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113073. * Returns the DirectionalLight Shadow projection matrix.
  113074. */
  113075. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113076. /**
  113077. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113078. * Returns the DirectionalLight Shadow projection matrix.
  113079. */
  113080. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113081. /**
  113082. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113083. * Returns the DirectionalLight Shadow projection matrix.
  113084. */
  113085. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113086. protected _buildUniformLayout(): void;
  113087. /**
  113088. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113089. * @param effect The effect to update
  113090. * @param lightIndex The index of the light in the effect to update
  113091. * @returns The directional light
  113092. */
  113093. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113094. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113095. /**
  113096. * Gets the minZ used for shadow according to both the scene and the light.
  113097. *
  113098. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113099. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113100. * @param activeCamera The camera we are returning the min for
  113101. * @returns the depth min z
  113102. */
  113103. getDepthMinZ(activeCamera: Camera): number;
  113104. /**
  113105. * Gets the maxZ used for shadow according to both the scene and the light.
  113106. *
  113107. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113108. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113109. * @param activeCamera The camera we are returning the max for
  113110. * @returns the depth max z
  113111. */
  113112. getDepthMaxZ(activeCamera: Camera): number;
  113113. /**
  113114. * Prepares the list of defines specific to the light type.
  113115. * @param defines the list of defines
  113116. * @param lightIndex defines the index of the light for the effect
  113117. */
  113118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113119. }
  113120. }
  113121. declare module BABYLON {
  113122. /**
  113123. * Class containing static functions to help procedurally build meshes
  113124. */
  113125. export class HemisphereBuilder {
  113126. /**
  113127. * Creates a hemisphere mesh
  113128. * @param name defines the name of the mesh
  113129. * @param options defines the options used to create the mesh
  113130. * @param scene defines the hosting scene
  113131. * @returns the hemisphere mesh
  113132. */
  113133. static CreateHemisphere(name: string, options: {
  113134. segments?: number;
  113135. diameter?: number;
  113136. sideOrientation?: number;
  113137. }, scene: any): Mesh;
  113138. }
  113139. }
  113140. declare module BABYLON {
  113141. /**
  113142. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113143. * These values define a cone of light starting from the position, emitting toward the direction.
  113144. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113145. * and the exponent defines the speed of the decay of the light with distance (reach).
  113146. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113147. */
  113148. export class SpotLight extends ShadowLight {
  113149. private _angle;
  113150. private _innerAngle;
  113151. private _cosHalfAngle;
  113152. private _lightAngleScale;
  113153. private _lightAngleOffset;
  113154. /**
  113155. * Gets the cone angle of the spot light in Radians.
  113156. */
  113157. /**
  113158. * Sets the cone angle of the spot light in Radians.
  113159. */
  113160. angle: number;
  113161. /**
  113162. * Only used in gltf falloff mode, this defines the angle where
  113163. * the directional falloff will start before cutting at angle which could be seen
  113164. * as outer angle.
  113165. */
  113166. /**
  113167. * Only used in gltf falloff mode, this defines the angle where
  113168. * the directional falloff will start before cutting at angle which could be seen
  113169. * as outer angle.
  113170. */
  113171. innerAngle: number;
  113172. private _shadowAngleScale;
  113173. /**
  113174. * Allows scaling the angle of the light for shadow generation only.
  113175. */
  113176. /**
  113177. * Allows scaling the angle of the light for shadow generation only.
  113178. */
  113179. shadowAngleScale: number;
  113180. /**
  113181. * The light decay speed with the distance from the emission spot.
  113182. */
  113183. exponent: number;
  113184. private _projectionTextureMatrix;
  113185. /**
  113186. * Allows reading the projecton texture
  113187. */
  113188. readonly projectionTextureMatrix: Matrix;
  113189. protected _projectionTextureLightNear: number;
  113190. /**
  113191. * Gets the near clip of the Spotlight for texture projection.
  113192. */
  113193. /**
  113194. * Sets the near clip of the Spotlight for texture projection.
  113195. */
  113196. projectionTextureLightNear: number;
  113197. protected _projectionTextureLightFar: number;
  113198. /**
  113199. * Gets the far clip of the Spotlight for texture projection.
  113200. */
  113201. /**
  113202. * Sets the far clip of the Spotlight for texture projection.
  113203. */
  113204. projectionTextureLightFar: number;
  113205. protected _projectionTextureUpDirection: Vector3;
  113206. /**
  113207. * Gets the Up vector of the Spotlight for texture projection.
  113208. */
  113209. /**
  113210. * Sets the Up vector of the Spotlight for texture projection.
  113211. */
  113212. projectionTextureUpDirection: Vector3;
  113213. private _projectionTexture;
  113214. /**
  113215. * Gets the projection texture of the light.
  113216. */
  113217. /**
  113218. * Sets the projection texture of the light.
  113219. */
  113220. projectionTexture: Nullable<BaseTexture>;
  113221. private _projectionTextureViewLightDirty;
  113222. private _projectionTextureProjectionLightDirty;
  113223. private _projectionTextureDirty;
  113224. private _projectionTextureViewTargetVector;
  113225. private _projectionTextureViewLightMatrix;
  113226. private _projectionTextureProjectionLightMatrix;
  113227. private _projectionTextureScalingMatrix;
  113228. /**
  113229. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113230. * It can cast shadows.
  113231. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113232. * @param name The light friendly name
  113233. * @param position The position of the spot light in the scene
  113234. * @param direction The direction of the light in the scene
  113235. * @param angle The cone angle of the light in Radians
  113236. * @param exponent The light decay speed with the distance from the emission spot
  113237. * @param scene The scene the lights belongs to
  113238. */
  113239. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113240. /**
  113241. * Returns the string "SpotLight".
  113242. * @returns the class name
  113243. */
  113244. getClassName(): string;
  113245. /**
  113246. * Returns the integer 2.
  113247. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113248. */
  113249. getTypeID(): number;
  113250. /**
  113251. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113252. */
  113253. protected _setDirection(value: Vector3): void;
  113254. /**
  113255. * Overrides the position setter to recompute the projection texture view light Matrix.
  113256. */
  113257. protected _setPosition(value: Vector3): void;
  113258. /**
  113259. * 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.
  113260. * Returns the SpotLight.
  113261. */
  113262. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113263. protected _computeProjectionTextureViewLightMatrix(): void;
  113264. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113265. /**
  113266. * Main function for light texture projection matrix computing.
  113267. */
  113268. protected _computeProjectionTextureMatrix(): void;
  113269. protected _buildUniformLayout(): void;
  113270. private _computeAngleValues;
  113271. /**
  113272. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113273. * @param effect The effect to update
  113274. * @param lightIndex The index of the light in the effect to update
  113275. * @returns The spot light
  113276. */
  113277. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113279. /**
  113280. * Disposes the light and the associated resources.
  113281. */
  113282. dispose(): void;
  113283. /**
  113284. * Prepares the list of defines specific to the light type.
  113285. * @param defines the list of defines
  113286. * @param lightIndex defines the index of the light for the effect
  113287. */
  113288. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113289. }
  113290. }
  113291. declare module BABYLON {
  113292. /**
  113293. * Gizmo that enables viewing a light
  113294. */
  113295. export class LightGizmo extends Gizmo {
  113296. private _lightMesh;
  113297. private _material;
  113298. private cachedPosition;
  113299. private cachedForward;
  113300. /**
  113301. * Creates a LightGizmo
  113302. * @param gizmoLayer The utility layer the gizmo will be added to
  113303. */
  113304. constructor(gizmoLayer?: UtilityLayerRenderer);
  113305. private _light;
  113306. /**
  113307. * The light that the gizmo is attached to
  113308. */
  113309. light: Nullable<Light>;
  113310. /**
  113311. * Gets the material used to render the light gizmo
  113312. */
  113313. readonly material: StandardMaterial;
  113314. /**
  113315. * @hidden
  113316. * Updates the gizmo to match the attached mesh's position/rotation
  113317. */
  113318. protected _update(): void;
  113319. private static _Scale;
  113320. /**
  113321. * Creates the lines for a light mesh
  113322. */
  113323. private static _createLightLines;
  113324. /**
  113325. * Disposes of the light gizmo
  113326. */
  113327. dispose(): void;
  113328. private static _CreateHemisphericLightMesh;
  113329. private static _CreatePointLightMesh;
  113330. private static _CreateSpotLightMesh;
  113331. private static _CreateDirectionalLightMesh;
  113332. }
  113333. }
  113334. declare module BABYLON {
  113335. /** @hidden */
  113336. export var backgroundFragmentDeclaration: {
  113337. name: string;
  113338. shader: string;
  113339. };
  113340. }
  113341. declare module BABYLON {
  113342. /** @hidden */
  113343. export var backgroundUboDeclaration: {
  113344. name: string;
  113345. shader: string;
  113346. };
  113347. }
  113348. declare module BABYLON {
  113349. /** @hidden */
  113350. export var backgroundPixelShader: {
  113351. name: string;
  113352. shader: string;
  113353. };
  113354. }
  113355. declare module BABYLON {
  113356. /** @hidden */
  113357. export var backgroundVertexDeclaration: {
  113358. name: string;
  113359. shader: string;
  113360. };
  113361. }
  113362. declare module BABYLON {
  113363. /** @hidden */
  113364. export var backgroundVertexShader: {
  113365. name: string;
  113366. shader: string;
  113367. };
  113368. }
  113369. declare module BABYLON {
  113370. /**
  113371. * Background material used to create an efficient environement around your scene.
  113372. */
  113373. export class BackgroundMaterial extends PushMaterial {
  113374. /**
  113375. * Standard reflectance value at parallel view angle.
  113376. */
  113377. static StandardReflectance0: number;
  113378. /**
  113379. * Standard reflectance value at grazing angle.
  113380. */
  113381. static StandardReflectance90: number;
  113382. protected _primaryColor: Color3;
  113383. /**
  113384. * Key light Color (multiply against the environement texture)
  113385. */
  113386. primaryColor: Color3;
  113387. protected __perceptualColor: Nullable<Color3>;
  113388. /**
  113389. * Experimental Internal Use Only.
  113390. *
  113391. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113392. * This acts as a helper to set the primary color to a more "human friendly" value.
  113393. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113394. * output color as close as possible from the chosen value.
  113395. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113396. * part of lighting setup.)
  113397. */
  113398. _perceptualColor: Nullable<Color3>;
  113399. protected _primaryColorShadowLevel: float;
  113400. /**
  113401. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113402. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113403. */
  113404. primaryColorShadowLevel: float;
  113405. protected _primaryColorHighlightLevel: float;
  113406. /**
  113407. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113408. * The primary color is used at the level chosen to define what the white area would look.
  113409. */
  113410. primaryColorHighlightLevel: float;
  113411. protected _reflectionTexture: Nullable<BaseTexture>;
  113412. /**
  113413. * Reflection Texture used in the material.
  113414. * Should be author in a specific way for the best result (refer to the documentation).
  113415. */
  113416. reflectionTexture: Nullable<BaseTexture>;
  113417. protected _reflectionBlur: float;
  113418. /**
  113419. * Reflection Texture level of blur.
  113420. *
  113421. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113422. * texture twice.
  113423. */
  113424. reflectionBlur: float;
  113425. protected _diffuseTexture: Nullable<BaseTexture>;
  113426. /**
  113427. * Diffuse Texture used in the material.
  113428. * Should be author in a specific way for the best result (refer to the documentation).
  113429. */
  113430. diffuseTexture: Nullable<BaseTexture>;
  113431. protected _shadowLights: Nullable<IShadowLight[]>;
  113432. /**
  113433. * Specify the list of lights casting shadow on the material.
  113434. * All scene shadow lights will be included if null.
  113435. */
  113436. shadowLights: Nullable<IShadowLight[]>;
  113437. protected _shadowLevel: float;
  113438. /**
  113439. * Helps adjusting the shadow to a softer level if required.
  113440. * 0 means black shadows and 1 means no shadows.
  113441. */
  113442. shadowLevel: float;
  113443. protected _sceneCenter: Vector3;
  113444. /**
  113445. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113446. * It is usually zero but might be interesting to modify according to your setup.
  113447. */
  113448. sceneCenter: Vector3;
  113449. protected _opacityFresnel: boolean;
  113450. /**
  113451. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113452. * This helps ensuring a nice transition when the camera goes under the ground.
  113453. */
  113454. opacityFresnel: boolean;
  113455. protected _reflectionFresnel: boolean;
  113456. /**
  113457. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113458. * This helps adding a mirror texture on the ground.
  113459. */
  113460. reflectionFresnel: boolean;
  113461. protected _reflectionFalloffDistance: number;
  113462. /**
  113463. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113464. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113465. */
  113466. reflectionFalloffDistance: number;
  113467. protected _reflectionAmount: number;
  113468. /**
  113469. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113470. */
  113471. reflectionAmount: number;
  113472. protected _reflectionReflectance0: number;
  113473. /**
  113474. * This specifies the weight of the reflection at grazing angle.
  113475. */
  113476. reflectionReflectance0: number;
  113477. protected _reflectionReflectance90: number;
  113478. /**
  113479. * This specifies the weight of the reflection at a perpendicular point of view.
  113480. */
  113481. reflectionReflectance90: number;
  113482. /**
  113483. * Sets the reflection reflectance fresnel values according to the default standard
  113484. * empirically know to work well :-)
  113485. */
  113486. reflectionStandardFresnelWeight: number;
  113487. protected _useRGBColor: boolean;
  113488. /**
  113489. * Helps to directly use the maps channels instead of their level.
  113490. */
  113491. useRGBColor: boolean;
  113492. protected _enableNoise: boolean;
  113493. /**
  113494. * This helps reducing the banding effect that could occur on the background.
  113495. */
  113496. enableNoise: boolean;
  113497. /**
  113498. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113499. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113500. * Recommended to be keep at 1.0 except for special cases.
  113501. */
  113502. fovMultiplier: number;
  113503. private _fovMultiplier;
  113504. /**
  113505. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113506. */
  113507. useEquirectangularFOV: boolean;
  113508. private _maxSimultaneousLights;
  113509. /**
  113510. * Number of Simultaneous lights allowed on the material.
  113511. */
  113512. maxSimultaneousLights: int;
  113513. /**
  113514. * Default configuration related to image processing available in the Background Material.
  113515. */
  113516. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113517. /**
  113518. * Keep track of the image processing observer to allow dispose and replace.
  113519. */
  113520. private _imageProcessingObserver;
  113521. /**
  113522. * Attaches a new image processing configuration to the PBR Material.
  113523. * @param configuration (if null the scene configuration will be use)
  113524. */
  113525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113526. /**
  113527. * Gets the image processing configuration used either in this material.
  113528. */
  113529. /**
  113530. * Sets the Default image processing configuration used either in the this material.
  113531. *
  113532. * If sets to null, the scene one is in use.
  113533. */
  113534. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113535. /**
  113536. * Gets wether the color curves effect is enabled.
  113537. */
  113538. /**
  113539. * Sets wether the color curves effect is enabled.
  113540. */
  113541. cameraColorCurvesEnabled: boolean;
  113542. /**
  113543. * Gets wether the color grading effect is enabled.
  113544. */
  113545. /**
  113546. * Gets wether the color grading effect is enabled.
  113547. */
  113548. cameraColorGradingEnabled: boolean;
  113549. /**
  113550. * Gets wether tonemapping is enabled or not.
  113551. */
  113552. /**
  113553. * Sets wether tonemapping is enabled or not
  113554. */
  113555. cameraToneMappingEnabled: boolean;
  113556. /**
  113557. * The camera exposure used on this material.
  113558. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113559. * This corresponds to a photographic exposure.
  113560. */
  113561. /**
  113562. * The camera exposure used on this material.
  113563. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113564. * This corresponds to a photographic exposure.
  113565. */
  113566. cameraExposure: float;
  113567. /**
  113568. * Gets The camera contrast used on this material.
  113569. */
  113570. /**
  113571. * Sets The camera contrast used on this material.
  113572. */
  113573. cameraContrast: float;
  113574. /**
  113575. * Gets the Color Grading 2D Lookup Texture.
  113576. */
  113577. /**
  113578. * Sets the Color Grading 2D Lookup Texture.
  113579. */
  113580. cameraColorGradingTexture: Nullable<BaseTexture>;
  113581. /**
  113582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113584. * 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;
  113585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113586. */
  113587. /**
  113588. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113589. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113590. * 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;
  113591. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113592. */
  113593. cameraColorCurves: Nullable<ColorCurves>;
  113594. /**
  113595. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113596. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113597. */
  113598. switchToBGR: boolean;
  113599. private _renderTargets;
  113600. private _reflectionControls;
  113601. private _white;
  113602. private _primaryShadowColor;
  113603. private _primaryHighlightColor;
  113604. /**
  113605. * Instantiates a Background Material in the given scene
  113606. * @param name The friendly name of the material
  113607. * @param scene The scene to add the material to
  113608. */
  113609. constructor(name: string, scene: Scene);
  113610. /**
  113611. * Gets a boolean indicating that current material needs to register RTT
  113612. */
  113613. readonly hasRenderTargetTextures: boolean;
  113614. /**
  113615. * The entire material has been created in order to prevent overdraw.
  113616. * @returns false
  113617. */
  113618. needAlphaTesting(): boolean;
  113619. /**
  113620. * The entire material has been created in order to prevent overdraw.
  113621. * @returns true if blending is enable
  113622. */
  113623. needAlphaBlending(): boolean;
  113624. /**
  113625. * Checks wether the material is ready to be rendered for a given mesh.
  113626. * @param mesh The mesh to render
  113627. * @param subMesh The submesh to check against
  113628. * @param useInstances Specify wether or not the material is used with instances
  113629. * @returns true if all the dependencies are ready (Textures, Effects...)
  113630. */
  113631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113632. /**
  113633. * Compute the primary color according to the chosen perceptual color.
  113634. */
  113635. private _computePrimaryColorFromPerceptualColor;
  113636. /**
  113637. * Compute the highlights and shadow colors according to their chosen levels.
  113638. */
  113639. private _computePrimaryColors;
  113640. /**
  113641. * Build the uniform buffer used in the material.
  113642. */
  113643. buildUniformLayout(): void;
  113644. /**
  113645. * Unbind the material.
  113646. */
  113647. unbind(): void;
  113648. /**
  113649. * Bind only the world matrix to the material.
  113650. * @param world The world matrix to bind.
  113651. */
  113652. bindOnlyWorldMatrix(world: Matrix): void;
  113653. /**
  113654. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113655. * @param world The world matrix to bind.
  113656. * @param subMesh The submesh to bind for.
  113657. */
  113658. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113659. /**
  113660. * Checks to see if a texture is used in the material.
  113661. * @param texture - Base texture to use.
  113662. * @returns - Boolean specifying if a texture is used in the material.
  113663. */
  113664. hasTexture(texture: BaseTexture): boolean;
  113665. /**
  113666. * Dispose the material.
  113667. * @param forceDisposeEffect Force disposal of the associated effect.
  113668. * @param forceDisposeTextures Force disposal of the associated textures.
  113669. */
  113670. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113671. /**
  113672. * Clones the material.
  113673. * @param name The cloned name.
  113674. * @returns The cloned material.
  113675. */
  113676. clone(name: string): BackgroundMaterial;
  113677. /**
  113678. * Serializes the current material to its JSON representation.
  113679. * @returns The JSON representation.
  113680. */
  113681. serialize(): any;
  113682. /**
  113683. * Gets the class name of the material
  113684. * @returns "BackgroundMaterial"
  113685. */
  113686. getClassName(): string;
  113687. /**
  113688. * Parse a JSON input to create back a background material.
  113689. * @param source The JSON data to parse
  113690. * @param scene The scene to create the parsed material in
  113691. * @param rootUrl The root url of the assets the material depends upon
  113692. * @returns the instantiated BackgroundMaterial.
  113693. */
  113694. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113695. }
  113696. }
  113697. declare module BABYLON {
  113698. /**
  113699. * Represents the different options available during the creation of
  113700. * a Environment helper.
  113701. *
  113702. * This can control the default ground, skybox and image processing setup of your scene.
  113703. */
  113704. export interface IEnvironmentHelperOptions {
  113705. /**
  113706. * Specifies wether or not to create a ground.
  113707. * True by default.
  113708. */
  113709. createGround: boolean;
  113710. /**
  113711. * Specifies the ground size.
  113712. * 15 by default.
  113713. */
  113714. groundSize: number;
  113715. /**
  113716. * The texture used on the ground for the main color.
  113717. * Comes from the BabylonJS CDN by default.
  113718. *
  113719. * Remarks: Can be either a texture or a url.
  113720. */
  113721. groundTexture: string | BaseTexture;
  113722. /**
  113723. * The color mixed in the ground texture by default.
  113724. * BabylonJS clearColor by default.
  113725. */
  113726. groundColor: Color3;
  113727. /**
  113728. * Specifies the ground opacity.
  113729. * 1 by default.
  113730. */
  113731. groundOpacity: number;
  113732. /**
  113733. * Enables the ground to receive shadows.
  113734. * True by default.
  113735. */
  113736. enableGroundShadow: boolean;
  113737. /**
  113738. * Helps preventing the shadow to be fully black on the ground.
  113739. * 0.5 by default.
  113740. */
  113741. groundShadowLevel: number;
  113742. /**
  113743. * Creates a mirror texture attach to the ground.
  113744. * false by default.
  113745. */
  113746. enableGroundMirror: boolean;
  113747. /**
  113748. * Specifies the ground mirror size ratio.
  113749. * 0.3 by default as the default kernel is 64.
  113750. */
  113751. groundMirrorSizeRatio: number;
  113752. /**
  113753. * Specifies the ground mirror blur kernel size.
  113754. * 64 by default.
  113755. */
  113756. groundMirrorBlurKernel: number;
  113757. /**
  113758. * Specifies the ground mirror visibility amount.
  113759. * 1 by default
  113760. */
  113761. groundMirrorAmount: number;
  113762. /**
  113763. * Specifies the ground mirror reflectance weight.
  113764. * This uses the standard weight of the background material to setup the fresnel effect
  113765. * of the mirror.
  113766. * 1 by default.
  113767. */
  113768. groundMirrorFresnelWeight: number;
  113769. /**
  113770. * Specifies the ground mirror Falloff distance.
  113771. * This can helps reducing the size of the reflection.
  113772. * 0 by Default.
  113773. */
  113774. groundMirrorFallOffDistance: number;
  113775. /**
  113776. * Specifies the ground mirror texture type.
  113777. * Unsigned Int by Default.
  113778. */
  113779. groundMirrorTextureType: number;
  113780. /**
  113781. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113782. * the shown objects.
  113783. */
  113784. groundYBias: number;
  113785. /**
  113786. * Specifies wether or not to create a skybox.
  113787. * True by default.
  113788. */
  113789. createSkybox: boolean;
  113790. /**
  113791. * Specifies the skybox size.
  113792. * 20 by default.
  113793. */
  113794. skyboxSize: number;
  113795. /**
  113796. * The texture used on the skybox for the main color.
  113797. * Comes from the BabylonJS CDN by default.
  113798. *
  113799. * Remarks: Can be either a texture or a url.
  113800. */
  113801. skyboxTexture: string | BaseTexture;
  113802. /**
  113803. * The color mixed in the skybox texture by default.
  113804. * BabylonJS clearColor by default.
  113805. */
  113806. skyboxColor: Color3;
  113807. /**
  113808. * The background rotation around the Y axis of the scene.
  113809. * This helps aligning the key lights of your scene with the background.
  113810. * 0 by default.
  113811. */
  113812. backgroundYRotation: number;
  113813. /**
  113814. * Compute automatically the size of the elements to best fit with the scene.
  113815. */
  113816. sizeAuto: boolean;
  113817. /**
  113818. * Default position of the rootMesh if autoSize is not true.
  113819. */
  113820. rootPosition: Vector3;
  113821. /**
  113822. * Sets up the image processing in the scene.
  113823. * true by default.
  113824. */
  113825. setupImageProcessing: boolean;
  113826. /**
  113827. * The texture used as your environment texture in the scene.
  113828. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113829. *
  113830. * Remarks: Can be either a texture or a url.
  113831. */
  113832. environmentTexture: string | BaseTexture;
  113833. /**
  113834. * The value of the exposure to apply to the scene.
  113835. * 0.6 by default if setupImageProcessing is true.
  113836. */
  113837. cameraExposure: number;
  113838. /**
  113839. * The value of the contrast to apply to the scene.
  113840. * 1.6 by default if setupImageProcessing is true.
  113841. */
  113842. cameraContrast: number;
  113843. /**
  113844. * Specifies wether or not tonemapping should be enabled in the scene.
  113845. * true by default if setupImageProcessing is true.
  113846. */
  113847. toneMappingEnabled: boolean;
  113848. }
  113849. /**
  113850. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113851. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113852. * It also helps with the default setup of your imageProcessing configuration.
  113853. */
  113854. export class EnvironmentHelper {
  113855. /**
  113856. * Default ground texture URL.
  113857. */
  113858. private static _groundTextureCDNUrl;
  113859. /**
  113860. * Default skybox texture URL.
  113861. */
  113862. private static _skyboxTextureCDNUrl;
  113863. /**
  113864. * Default environment texture URL.
  113865. */
  113866. private static _environmentTextureCDNUrl;
  113867. /**
  113868. * Creates the default options for the helper.
  113869. */
  113870. private static _getDefaultOptions;
  113871. private _rootMesh;
  113872. /**
  113873. * Gets the root mesh created by the helper.
  113874. */
  113875. readonly rootMesh: Mesh;
  113876. private _skybox;
  113877. /**
  113878. * Gets the skybox created by the helper.
  113879. */
  113880. readonly skybox: Nullable<Mesh>;
  113881. private _skyboxTexture;
  113882. /**
  113883. * Gets the skybox texture created by the helper.
  113884. */
  113885. readonly skyboxTexture: Nullable<BaseTexture>;
  113886. private _skyboxMaterial;
  113887. /**
  113888. * Gets the skybox material created by the helper.
  113889. */
  113890. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113891. private _ground;
  113892. /**
  113893. * Gets the ground mesh created by the helper.
  113894. */
  113895. readonly ground: Nullable<Mesh>;
  113896. private _groundTexture;
  113897. /**
  113898. * Gets the ground texture created by the helper.
  113899. */
  113900. readonly groundTexture: Nullable<BaseTexture>;
  113901. private _groundMirror;
  113902. /**
  113903. * Gets the ground mirror created by the helper.
  113904. */
  113905. readonly groundMirror: Nullable<MirrorTexture>;
  113906. /**
  113907. * Gets the ground mirror render list to helps pushing the meshes
  113908. * you wish in the ground reflection.
  113909. */
  113910. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113911. private _groundMaterial;
  113912. /**
  113913. * Gets the ground material created by the helper.
  113914. */
  113915. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113916. /**
  113917. * Stores the creation options.
  113918. */
  113919. private readonly _scene;
  113920. private _options;
  113921. /**
  113922. * This observable will be notified with any error during the creation of the environment,
  113923. * mainly texture creation errors.
  113924. */
  113925. onErrorObservable: Observable<{
  113926. message?: string;
  113927. exception?: any;
  113928. }>;
  113929. /**
  113930. * constructor
  113931. * @param options Defines the options we want to customize the helper
  113932. * @param scene The scene to add the material to
  113933. */
  113934. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113935. /**
  113936. * Updates the background according to the new options
  113937. * @param options
  113938. */
  113939. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113940. /**
  113941. * Sets the primary color of all the available elements.
  113942. * @param color the main color to affect to the ground and the background
  113943. */
  113944. setMainColor(color: Color3): void;
  113945. /**
  113946. * Setup the image processing according to the specified options.
  113947. */
  113948. private _setupImageProcessing;
  113949. /**
  113950. * Setup the environment texture according to the specified options.
  113951. */
  113952. private _setupEnvironmentTexture;
  113953. /**
  113954. * Setup the background according to the specified options.
  113955. */
  113956. private _setupBackground;
  113957. /**
  113958. * Get the scene sizes according to the setup.
  113959. */
  113960. private _getSceneSize;
  113961. /**
  113962. * Setup the ground according to the specified options.
  113963. */
  113964. private _setupGround;
  113965. /**
  113966. * Setup the ground material according to the specified options.
  113967. */
  113968. private _setupGroundMaterial;
  113969. /**
  113970. * Setup the ground diffuse texture according to the specified options.
  113971. */
  113972. private _setupGroundDiffuseTexture;
  113973. /**
  113974. * Setup the ground mirror texture according to the specified options.
  113975. */
  113976. private _setupGroundMirrorTexture;
  113977. /**
  113978. * Setup the ground to receive the mirror texture.
  113979. */
  113980. private _setupMirrorInGroundMaterial;
  113981. /**
  113982. * Setup the skybox according to the specified options.
  113983. */
  113984. private _setupSkybox;
  113985. /**
  113986. * Setup the skybox material according to the specified options.
  113987. */
  113988. private _setupSkyboxMaterial;
  113989. /**
  113990. * Setup the skybox reflection texture according to the specified options.
  113991. */
  113992. private _setupSkyboxReflectionTexture;
  113993. private _errorHandler;
  113994. /**
  113995. * Dispose all the elements created by the Helper.
  113996. */
  113997. dispose(): void;
  113998. }
  113999. }
  114000. declare module BABYLON {
  114001. /**
  114002. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114003. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114004. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114005. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114006. */
  114007. export class PhotoDome extends TransformNode {
  114008. /**
  114009. * Define the image as a Monoscopic panoramic 360 image.
  114010. */
  114011. static readonly MODE_MONOSCOPIC: number;
  114012. /**
  114013. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114014. */
  114015. static readonly MODE_TOPBOTTOM: number;
  114016. /**
  114017. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114018. */
  114019. static readonly MODE_SIDEBYSIDE: number;
  114020. private _useDirectMapping;
  114021. /**
  114022. * The texture being displayed on the sphere
  114023. */
  114024. protected _photoTexture: Texture;
  114025. /**
  114026. * Gets or sets the texture being displayed on the sphere
  114027. */
  114028. photoTexture: Texture;
  114029. /**
  114030. * Observable raised when an error occured while loading the 360 image
  114031. */
  114032. onLoadErrorObservable: Observable<string>;
  114033. /**
  114034. * The skybox material
  114035. */
  114036. protected _material: BackgroundMaterial;
  114037. /**
  114038. * The surface used for the skybox
  114039. */
  114040. protected _mesh: Mesh;
  114041. /**
  114042. * Gets the mesh used for the skybox.
  114043. */
  114044. readonly mesh: Mesh;
  114045. /**
  114046. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114047. * Also see the options.resolution property.
  114048. */
  114049. fovMultiplier: number;
  114050. private _imageMode;
  114051. /**
  114052. * Gets or set the current video mode for the video. It can be:
  114053. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114054. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114055. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114056. */
  114057. imageMode: number;
  114058. /**
  114059. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114060. * @param name Element's name, child elements will append suffixes for their own names.
  114061. * @param urlsOfPhoto defines the url of the photo to display
  114062. * @param options defines an object containing optional or exposed sub element properties
  114063. * @param onError defines a callback called when an error occured while loading the texture
  114064. */
  114065. constructor(name: string, urlOfPhoto: string, options: {
  114066. resolution?: number;
  114067. size?: number;
  114068. useDirectMapping?: boolean;
  114069. faceForward?: boolean;
  114070. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114071. private _onBeforeCameraRenderObserver;
  114072. private _changeImageMode;
  114073. /**
  114074. * Releases resources associated with this node.
  114075. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114076. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114077. */
  114078. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114079. }
  114080. }
  114081. declare module BABYLON {
  114082. /**
  114083. * Class used to host RGBD texture specific utilities
  114084. */
  114085. export class RGBDTextureTools {
  114086. /**
  114087. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114088. * @param texture the texture to expand.
  114089. */
  114090. static ExpandRGBDTexture(texture: Texture): void;
  114091. }
  114092. }
  114093. declare module BABYLON {
  114094. /**
  114095. * Class used to host texture specific utilities
  114096. */
  114097. export class BRDFTextureTools {
  114098. /**
  114099. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114100. * @param scene defines the hosting scene
  114101. * @returns the environment BRDF texture
  114102. */
  114103. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114104. private static _environmentBRDFBase64Texture;
  114105. }
  114106. }
  114107. declare module BABYLON {
  114108. /**
  114109. * @hidden
  114110. */
  114111. export interface IMaterialClearCoatDefines {
  114112. CLEARCOAT: boolean;
  114113. CLEARCOAT_DEFAULTIOR: boolean;
  114114. CLEARCOAT_TEXTURE: boolean;
  114115. CLEARCOAT_TEXTUREDIRECTUV: number;
  114116. CLEARCOAT_BUMP: boolean;
  114117. CLEARCOAT_BUMPDIRECTUV: number;
  114118. CLEARCOAT_TINT: boolean;
  114119. CLEARCOAT_TINT_TEXTURE: boolean;
  114120. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114121. /** @hidden */
  114122. _areTexturesDirty: boolean;
  114123. }
  114124. /**
  114125. * Define the code related to the clear coat parameters of the pbr material.
  114126. */
  114127. export class PBRClearCoatConfiguration {
  114128. /**
  114129. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114130. * The default fits with a polyurethane material.
  114131. */
  114132. private static readonly _DefaultIndexOfRefraction;
  114133. private _isEnabled;
  114134. /**
  114135. * Defines if the clear coat is enabled in the material.
  114136. */
  114137. isEnabled: boolean;
  114138. /**
  114139. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114140. */
  114141. intensity: number;
  114142. /**
  114143. * Defines the clear coat layer roughness.
  114144. */
  114145. roughness: number;
  114146. private _indexOfRefraction;
  114147. /**
  114148. * Defines the index of refraction of the clear coat.
  114149. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114150. * The default fits with a polyurethane material.
  114151. * Changing the default value is more performance intensive.
  114152. */
  114153. indexOfRefraction: number;
  114154. private _texture;
  114155. /**
  114156. * Stores the clear coat values in a texture.
  114157. */
  114158. texture: Nullable<BaseTexture>;
  114159. private _bumpTexture;
  114160. /**
  114161. * Define the clear coat specific bump texture.
  114162. */
  114163. bumpTexture: Nullable<BaseTexture>;
  114164. private _isTintEnabled;
  114165. /**
  114166. * Defines if the clear coat tint is enabled in the material.
  114167. */
  114168. isTintEnabled: boolean;
  114169. /**
  114170. * Defines the clear coat tint of the material.
  114171. * This is only use if tint is enabled
  114172. */
  114173. tintColor: Color3;
  114174. /**
  114175. * Defines the distance at which the tint color should be found in the
  114176. * clear coat media.
  114177. * This is only use if tint is enabled
  114178. */
  114179. tintColorAtDistance: number;
  114180. /**
  114181. * Defines the clear coat layer thickness.
  114182. * This is only use if tint is enabled
  114183. */
  114184. tintThickness: number;
  114185. private _tintTexture;
  114186. /**
  114187. * Stores the clear tint values in a texture.
  114188. * rgb is tint
  114189. * a is a thickness factor
  114190. */
  114191. tintTexture: Nullable<BaseTexture>;
  114192. /** @hidden */
  114193. private _internalMarkAllSubMeshesAsTexturesDirty;
  114194. /** @hidden */
  114195. _markAllSubMeshesAsTexturesDirty(): void;
  114196. /**
  114197. * Instantiate a new istance of clear coat configuration.
  114198. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114199. */
  114200. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114201. /**
  114202. * Gets wehter the submesh is ready to be used or not.
  114203. * @param defines the list of "defines" to update.
  114204. * @param scene defines the scene the material belongs to.
  114205. * @param engine defines the engine the material belongs to.
  114206. * @param disableBumpMap defines wether the material disables bump or not.
  114207. * @returns - boolean indicating that the submesh is ready or not.
  114208. */
  114209. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114210. /**
  114211. * Checks to see if a texture is used in the material.
  114212. * @param defines the list of "defines" to update.
  114213. * @param scene defines the scene to the material belongs to.
  114214. */
  114215. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114216. /**
  114217. * Binds the material data.
  114218. * @param uniformBuffer defines the Uniform buffer to fill in.
  114219. * @param scene defines the scene the material belongs to.
  114220. * @param engine defines the engine the material belongs to.
  114221. * @param disableBumpMap defines wether the material disables bump or not.
  114222. * @param isFrozen defines wether the material is frozen or not.
  114223. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114224. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114225. */
  114226. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114227. /**
  114228. * Checks to see if a texture is used in the material.
  114229. * @param texture - Base texture to use.
  114230. * @returns - Boolean specifying if a texture is used in the material.
  114231. */
  114232. hasTexture(texture: BaseTexture): boolean;
  114233. /**
  114234. * Returns an array of the actively used textures.
  114235. * @param activeTextures Array of BaseTextures
  114236. */
  114237. getActiveTextures(activeTextures: BaseTexture[]): void;
  114238. /**
  114239. * Returns the animatable textures.
  114240. * @param animatables Array of animatable textures.
  114241. */
  114242. getAnimatables(animatables: IAnimatable[]): void;
  114243. /**
  114244. * Disposes the resources of the material.
  114245. * @param forceDisposeTextures - Forces the disposal of all textures.
  114246. */
  114247. dispose(forceDisposeTextures?: boolean): void;
  114248. /**
  114249. * Get the current class name of the texture useful for serialization or dynamic coding.
  114250. * @returns "PBRClearCoatConfiguration"
  114251. */
  114252. getClassName(): string;
  114253. /**
  114254. * Add fallbacks to the effect fallbacks list.
  114255. * @param defines defines the Base texture to use.
  114256. * @param fallbacks defines the current fallback list.
  114257. * @param currentRank defines the current fallback rank.
  114258. * @returns the new fallback rank.
  114259. */
  114260. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114261. /**
  114262. * Add the required uniforms to the current list.
  114263. * @param uniforms defines the current uniform list.
  114264. */
  114265. static AddUniforms(uniforms: string[]): void;
  114266. /**
  114267. * Add the required samplers to the current list.
  114268. * @param samplers defines the current sampler list.
  114269. */
  114270. static AddSamplers(samplers: string[]): void;
  114271. /**
  114272. * Add the required uniforms to the current buffer.
  114273. * @param uniformBuffer defines the current uniform buffer.
  114274. */
  114275. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114276. /**
  114277. * Makes a duplicate of the current configuration into another one.
  114278. * @param clearCoatConfiguration define the config where to copy the info
  114279. */
  114280. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114281. /**
  114282. * Serializes this clear coat configuration.
  114283. * @returns - An object with the serialized config.
  114284. */
  114285. serialize(): any;
  114286. /**
  114287. * Parses a anisotropy Configuration from a serialized object.
  114288. * @param source - Serialized object.
  114289. * @param scene Defines the scene we are parsing for
  114290. * @param rootUrl Defines the rootUrl to load from
  114291. */
  114292. parse(source: any, scene: Scene, rootUrl: string): void;
  114293. }
  114294. }
  114295. declare module BABYLON {
  114296. /**
  114297. * @hidden
  114298. */
  114299. export interface IMaterialAnisotropicDefines {
  114300. ANISOTROPIC: boolean;
  114301. ANISOTROPIC_TEXTURE: boolean;
  114302. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114303. MAINUV1: boolean;
  114304. _areTexturesDirty: boolean;
  114305. _needUVs: boolean;
  114306. }
  114307. /**
  114308. * Define the code related to the anisotropic parameters of the pbr material.
  114309. */
  114310. export class PBRAnisotropicConfiguration {
  114311. private _isEnabled;
  114312. /**
  114313. * Defines if the anisotropy is enabled in the material.
  114314. */
  114315. isEnabled: boolean;
  114316. /**
  114317. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114318. */
  114319. intensity: number;
  114320. /**
  114321. * Defines if the effect is along the tangents, bitangents or in between.
  114322. * By default, the effect is "strectching" the highlights along the tangents.
  114323. */
  114324. direction: Vector2;
  114325. private _texture;
  114326. /**
  114327. * Stores the anisotropy values in a texture.
  114328. * rg is direction (like normal from -1 to 1)
  114329. * b is a intensity
  114330. */
  114331. texture: Nullable<BaseTexture>;
  114332. /** @hidden */
  114333. private _internalMarkAllSubMeshesAsTexturesDirty;
  114334. /** @hidden */
  114335. _markAllSubMeshesAsTexturesDirty(): void;
  114336. /**
  114337. * Instantiate a new istance of anisotropy configuration.
  114338. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114339. */
  114340. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114341. /**
  114342. * Specifies that the submesh is ready to be used.
  114343. * @param defines the list of "defines" to update.
  114344. * @param scene defines the scene the material belongs to.
  114345. * @returns - boolean indicating that the submesh is ready or not.
  114346. */
  114347. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114348. /**
  114349. * Checks to see if a texture is used in the material.
  114350. * @param defines the list of "defines" to update.
  114351. * @param mesh the mesh we are preparing the defines for.
  114352. * @param scene defines the scene the material belongs to.
  114353. */
  114354. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114355. /**
  114356. * Binds the material data.
  114357. * @param uniformBuffer defines the Uniform buffer to fill in.
  114358. * @param scene defines the scene the material belongs to.
  114359. * @param isFrozen defines wether the material is frozen or not.
  114360. */
  114361. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114362. /**
  114363. * Checks to see if a texture is used in the material.
  114364. * @param texture - Base texture to use.
  114365. * @returns - Boolean specifying if a texture is used in the material.
  114366. */
  114367. hasTexture(texture: BaseTexture): boolean;
  114368. /**
  114369. * Returns an array of the actively used textures.
  114370. * @param activeTextures Array of BaseTextures
  114371. */
  114372. getActiveTextures(activeTextures: BaseTexture[]): void;
  114373. /**
  114374. * Returns the animatable textures.
  114375. * @param animatables Array of animatable textures.
  114376. */
  114377. getAnimatables(animatables: IAnimatable[]): void;
  114378. /**
  114379. * Disposes the resources of the material.
  114380. * @param forceDisposeTextures - Forces the disposal of all textures.
  114381. */
  114382. dispose(forceDisposeTextures?: boolean): void;
  114383. /**
  114384. * Get the current class name of the texture useful for serialization or dynamic coding.
  114385. * @returns "PBRAnisotropicConfiguration"
  114386. */
  114387. getClassName(): string;
  114388. /**
  114389. * Add fallbacks to the effect fallbacks list.
  114390. * @param defines defines the Base texture to use.
  114391. * @param fallbacks defines the current fallback list.
  114392. * @param currentRank defines the current fallback rank.
  114393. * @returns the new fallback rank.
  114394. */
  114395. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114396. /**
  114397. * Add the required uniforms to the current list.
  114398. * @param uniforms defines the current uniform list.
  114399. */
  114400. static AddUniforms(uniforms: string[]): void;
  114401. /**
  114402. * Add the required uniforms to the current buffer.
  114403. * @param uniformBuffer defines the current uniform buffer.
  114404. */
  114405. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114406. /**
  114407. * Add the required samplers to the current list.
  114408. * @param samplers defines the current sampler list.
  114409. */
  114410. static AddSamplers(samplers: string[]): void;
  114411. /**
  114412. * Makes a duplicate of the current configuration into another one.
  114413. * @param anisotropicConfiguration define the config where to copy the info
  114414. */
  114415. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114416. /**
  114417. * Serializes this anisotropy configuration.
  114418. * @returns - An object with the serialized config.
  114419. */
  114420. serialize(): any;
  114421. /**
  114422. * Parses a anisotropy Configuration from a serialized object.
  114423. * @param source - Serialized object.
  114424. * @param scene Defines the scene we are parsing for
  114425. * @param rootUrl Defines the rootUrl to load from
  114426. */
  114427. parse(source: any, scene: Scene, rootUrl: string): void;
  114428. }
  114429. }
  114430. declare module BABYLON {
  114431. /**
  114432. * @hidden
  114433. */
  114434. export interface IMaterialBRDFDefines {
  114435. BRDF_V_HEIGHT_CORRELATED: boolean;
  114436. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114437. SPHERICAL_HARMONICS: boolean;
  114438. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114439. /** @hidden */
  114440. _areMiscDirty: boolean;
  114441. }
  114442. /**
  114443. * Define the code related to the BRDF parameters of the pbr material.
  114444. */
  114445. export class PBRBRDFConfiguration {
  114446. /**
  114447. * Default value used for the energy conservation.
  114448. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114449. */
  114450. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114451. /**
  114452. * Default value used for the Smith Visibility Height Correlated mode.
  114453. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114454. */
  114455. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114456. /**
  114457. * Default value used for the IBL diffuse part.
  114458. * This can help switching back to the polynomials mode globally which is a tiny bit
  114459. * less GPU intensive at the drawback of a lower quality.
  114460. */
  114461. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114462. /**
  114463. * Default value used for activating energy conservation for the specular workflow.
  114464. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114465. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114466. */
  114467. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114468. private _useEnergyConservation;
  114469. /**
  114470. * Defines if the material uses energy conservation.
  114471. */
  114472. useEnergyConservation: boolean;
  114473. private _useSmithVisibilityHeightCorrelated;
  114474. /**
  114475. * LEGACY Mode set to false
  114476. * Defines if the material uses height smith correlated visibility term.
  114477. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114478. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114479. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114480. * Not relying on height correlated will also disable energy conservation.
  114481. */
  114482. useSmithVisibilityHeightCorrelated: boolean;
  114483. private _useSphericalHarmonics;
  114484. /**
  114485. * LEGACY Mode set to false
  114486. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114487. * diffuse part of the IBL.
  114488. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114489. * to the ground truth.
  114490. */
  114491. useSphericalHarmonics: boolean;
  114492. private _useSpecularGlossinessInputEnergyConservation;
  114493. /**
  114494. * Defines if the material uses energy conservation, when the specular workflow is active.
  114495. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114496. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114497. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114498. */
  114499. useSpecularGlossinessInputEnergyConservation: boolean;
  114500. /** @hidden */
  114501. private _internalMarkAllSubMeshesAsMiscDirty;
  114502. /** @hidden */
  114503. _markAllSubMeshesAsMiscDirty(): void;
  114504. /**
  114505. * Instantiate a new istance of clear coat configuration.
  114506. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114507. */
  114508. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114509. /**
  114510. * Checks to see if a texture is used in the material.
  114511. * @param defines the list of "defines" to update.
  114512. */
  114513. prepareDefines(defines: IMaterialBRDFDefines): void;
  114514. /**
  114515. * Get the current class name of the texture useful for serialization or dynamic coding.
  114516. * @returns "PBRClearCoatConfiguration"
  114517. */
  114518. getClassName(): string;
  114519. /**
  114520. * Makes a duplicate of the current configuration into another one.
  114521. * @param brdfConfiguration define the config where to copy the info
  114522. */
  114523. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114524. /**
  114525. * Serializes this BRDF configuration.
  114526. * @returns - An object with the serialized config.
  114527. */
  114528. serialize(): any;
  114529. /**
  114530. * Parses a anisotropy Configuration from a serialized object.
  114531. * @param source - Serialized object.
  114532. * @param scene Defines the scene we are parsing for
  114533. * @param rootUrl Defines the rootUrl to load from
  114534. */
  114535. parse(source: any, scene: Scene, rootUrl: string): void;
  114536. }
  114537. }
  114538. declare module BABYLON {
  114539. /**
  114540. * @hidden
  114541. */
  114542. export interface IMaterialSheenDefines {
  114543. SHEEN: boolean;
  114544. SHEEN_TEXTURE: boolean;
  114545. SHEEN_TEXTUREDIRECTUV: number;
  114546. SHEEN_LINKWITHALBEDO: boolean;
  114547. /** @hidden */
  114548. _areTexturesDirty: boolean;
  114549. }
  114550. /**
  114551. * Define the code related to the Sheen parameters of the pbr material.
  114552. */
  114553. export class PBRSheenConfiguration {
  114554. private _isEnabled;
  114555. /**
  114556. * Defines if the material uses sheen.
  114557. */
  114558. isEnabled: boolean;
  114559. private _linkSheenWithAlbedo;
  114560. /**
  114561. * Defines if the sheen is linked to the sheen color.
  114562. */
  114563. linkSheenWithAlbedo: boolean;
  114564. /**
  114565. * Defines the sheen intensity.
  114566. */
  114567. intensity: number;
  114568. /**
  114569. * Defines the sheen color.
  114570. */
  114571. color: Color3;
  114572. private _texture;
  114573. /**
  114574. * Stores the sheen tint values in a texture.
  114575. * rgb is tint
  114576. * a is a intensity
  114577. */
  114578. texture: Nullable<BaseTexture>;
  114579. /** @hidden */
  114580. private _internalMarkAllSubMeshesAsTexturesDirty;
  114581. /** @hidden */
  114582. _markAllSubMeshesAsTexturesDirty(): void;
  114583. /**
  114584. * Instantiate a new istance of clear coat configuration.
  114585. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114586. */
  114587. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114588. /**
  114589. * Specifies that the submesh is ready to be used.
  114590. * @param defines the list of "defines" to update.
  114591. * @param scene defines the scene the material belongs to.
  114592. * @returns - boolean indicating that the submesh is ready or not.
  114593. */
  114594. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114595. /**
  114596. * Checks to see if a texture is used in the material.
  114597. * @param defines the list of "defines" to update.
  114598. * @param scene defines the scene the material belongs to.
  114599. */
  114600. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114601. /**
  114602. * Binds the material data.
  114603. * @param uniformBuffer defines the Uniform buffer to fill in.
  114604. * @param scene defines the scene the material belongs to.
  114605. * @param isFrozen defines wether the material is frozen or not.
  114606. */
  114607. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114608. /**
  114609. * Checks to see if a texture is used in the material.
  114610. * @param texture - Base texture to use.
  114611. * @returns - Boolean specifying if a texture is used in the material.
  114612. */
  114613. hasTexture(texture: BaseTexture): boolean;
  114614. /**
  114615. * Returns an array of the actively used textures.
  114616. * @param activeTextures Array of BaseTextures
  114617. */
  114618. getActiveTextures(activeTextures: BaseTexture[]): void;
  114619. /**
  114620. * Returns the animatable textures.
  114621. * @param animatables Array of animatable textures.
  114622. */
  114623. getAnimatables(animatables: IAnimatable[]): void;
  114624. /**
  114625. * Disposes the resources of the material.
  114626. * @param forceDisposeTextures - Forces the disposal of all textures.
  114627. */
  114628. dispose(forceDisposeTextures?: boolean): void;
  114629. /**
  114630. * Get the current class name of the texture useful for serialization or dynamic coding.
  114631. * @returns "PBRSheenConfiguration"
  114632. */
  114633. getClassName(): string;
  114634. /**
  114635. * Add fallbacks to the effect fallbacks list.
  114636. * @param defines defines the Base texture to use.
  114637. * @param fallbacks defines the current fallback list.
  114638. * @param currentRank defines the current fallback rank.
  114639. * @returns the new fallback rank.
  114640. */
  114641. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114642. /**
  114643. * Add the required uniforms to the current list.
  114644. * @param uniforms defines the current uniform list.
  114645. */
  114646. static AddUniforms(uniforms: string[]): void;
  114647. /**
  114648. * Add the required uniforms to the current buffer.
  114649. * @param uniformBuffer defines the current uniform buffer.
  114650. */
  114651. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114652. /**
  114653. * Add the required samplers to the current list.
  114654. * @param samplers defines the current sampler list.
  114655. */
  114656. static AddSamplers(samplers: string[]): void;
  114657. /**
  114658. * Makes a duplicate of the current configuration into another one.
  114659. * @param sheenConfiguration define the config where to copy the info
  114660. */
  114661. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114662. /**
  114663. * Serializes this BRDF configuration.
  114664. * @returns - An object with the serialized config.
  114665. */
  114666. serialize(): any;
  114667. /**
  114668. * Parses a anisotropy Configuration from a serialized object.
  114669. * @param source - Serialized object.
  114670. * @param scene Defines the scene we are parsing for
  114671. * @param rootUrl Defines the rootUrl to load from
  114672. */
  114673. parse(source: any, scene: Scene, rootUrl: string): void;
  114674. }
  114675. }
  114676. declare module BABYLON {
  114677. /**
  114678. * @hidden
  114679. */
  114680. export interface IMaterialSubSurfaceDefines {
  114681. SUBSURFACE: boolean;
  114682. SS_REFRACTION: boolean;
  114683. SS_TRANSLUCENCY: boolean;
  114684. SS_SCATERRING: boolean;
  114685. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114686. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114687. SS_REFRACTIONMAP_3D: boolean;
  114688. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114689. SS_LODINREFRACTIONALPHA: boolean;
  114690. SS_GAMMAREFRACTION: boolean;
  114691. SS_RGBDREFRACTION: boolean;
  114692. SS_LINEARSPECULARREFRACTION: boolean;
  114693. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114694. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114695. /** @hidden */
  114696. _areTexturesDirty: boolean;
  114697. }
  114698. /**
  114699. * Define the code related to the sub surface parameters of the pbr material.
  114700. */
  114701. export class PBRSubSurfaceConfiguration {
  114702. private _isRefractionEnabled;
  114703. /**
  114704. * Defines if the refraction is enabled in the material.
  114705. */
  114706. isRefractionEnabled: boolean;
  114707. private _isTranslucencyEnabled;
  114708. /**
  114709. * Defines if the translucency is enabled in the material.
  114710. */
  114711. isTranslucencyEnabled: boolean;
  114712. private _isScatteringEnabled;
  114713. /**
  114714. * Defines the refraction intensity of the material.
  114715. * The refraction when enabled replaces the Diffuse part of the material.
  114716. * The intensity helps transitionning between diffuse and refraction.
  114717. */
  114718. refractionIntensity: number;
  114719. /**
  114720. * Defines the translucency intensity of the material.
  114721. * When translucency has been enabled, this defines how much of the "translucency"
  114722. * is addded to the diffuse part of the material.
  114723. */
  114724. translucencyIntensity: number;
  114725. /**
  114726. * Defines the scattering intensity of the material.
  114727. * When scattering has been enabled, this defines how much of the "scattered light"
  114728. * is addded to the diffuse part of the material.
  114729. */
  114730. scatteringIntensity: number;
  114731. private _thicknessTexture;
  114732. /**
  114733. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114734. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114735. * 0 would mean minimumThickness
  114736. * 1 would mean maximumThickness
  114737. * The other channels might be use as a mask to vary the different effects intensity.
  114738. */
  114739. thicknessTexture: Nullable<BaseTexture>;
  114740. private _refractionTexture;
  114741. /**
  114742. * Defines the texture to use for refraction.
  114743. */
  114744. refractionTexture: Nullable<BaseTexture>;
  114745. private _indexOfRefraction;
  114746. /**
  114747. * Defines the index of refraction used in the material.
  114748. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114749. */
  114750. indexOfRefraction: number;
  114751. private _invertRefractionY;
  114752. /**
  114753. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114754. */
  114755. invertRefractionY: boolean;
  114756. private _linkRefractionWithTransparency;
  114757. /**
  114758. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114759. * Materials half opaque for instance using refraction could benefit from this control.
  114760. */
  114761. linkRefractionWithTransparency: boolean;
  114762. /**
  114763. * Defines the minimum thickness stored in the thickness map.
  114764. * If no thickness map is defined, this value will be used to simulate thickness.
  114765. */
  114766. minimumThickness: number;
  114767. /**
  114768. * Defines the maximum thickness stored in the thickness map.
  114769. */
  114770. maximumThickness: number;
  114771. /**
  114772. * Defines the volume tint of the material.
  114773. * This is used for both translucency and scattering.
  114774. */
  114775. tintColor: Color3;
  114776. /**
  114777. * Defines the distance at which the tint color should be found in the media.
  114778. * This is used for refraction only.
  114779. */
  114780. tintColorAtDistance: number;
  114781. /**
  114782. * Defines how far each channel transmit through the media.
  114783. * It is defined as a color to simplify it selection.
  114784. */
  114785. diffusionDistance: Color3;
  114786. private _useMaskFromThicknessTexture;
  114787. /**
  114788. * Stores the intensity of the different subsurface effects in the thickness texture.
  114789. * * the green channel is the translucency intensity.
  114790. * * the blue channel is the scattering intensity.
  114791. * * the alpha channel is the refraction intensity.
  114792. */
  114793. useMaskFromThicknessTexture: boolean;
  114794. /** @hidden */
  114795. private _internalMarkAllSubMeshesAsTexturesDirty;
  114796. /** @hidden */
  114797. _markAllSubMeshesAsTexturesDirty(): void;
  114798. /**
  114799. * Instantiate a new istance of sub surface configuration.
  114800. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114801. */
  114802. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114803. /**
  114804. * Gets wehter the submesh is ready to be used or not.
  114805. * @param defines the list of "defines" to update.
  114806. * @param scene defines the scene the material belongs to.
  114807. * @returns - boolean indicating that the submesh is ready or not.
  114808. */
  114809. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114810. /**
  114811. * Checks to see if a texture is used in the material.
  114812. * @param defines the list of "defines" to update.
  114813. * @param scene defines the scene to the material belongs to.
  114814. */
  114815. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114816. /**
  114817. * Binds the material data.
  114818. * @param uniformBuffer defines the Uniform buffer to fill in.
  114819. * @param scene defines the scene the material belongs to.
  114820. * @param engine defines the engine the material belongs to.
  114821. * @param isFrozen defines wether the material is frozen or not.
  114822. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114823. */
  114824. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114825. /**
  114826. * Unbinds the material from the mesh.
  114827. * @param activeEffect defines the effect that should be unbound from.
  114828. * @returns true if unbound, otherwise false
  114829. */
  114830. unbind(activeEffect: Effect): boolean;
  114831. /**
  114832. * Returns the texture used for refraction or null if none is used.
  114833. * @param scene defines the scene the material belongs to.
  114834. * @returns - Refraction texture if present. If no refraction texture and refraction
  114835. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114836. */
  114837. private _getRefractionTexture;
  114838. /**
  114839. * Returns true if alpha blending should be disabled.
  114840. */
  114841. readonly disableAlphaBlending: boolean;
  114842. /**
  114843. * Fills the list of render target textures.
  114844. * @param renderTargets the list of render targets to update
  114845. */
  114846. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114847. /**
  114848. * Checks to see if a texture is used in the material.
  114849. * @param texture - Base texture to use.
  114850. * @returns - Boolean specifying if a texture is used in the material.
  114851. */
  114852. hasTexture(texture: BaseTexture): boolean;
  114853. /**
  114854. * Gets a boolean indicating that current material needs to register RTT
  114855. * @returns true if this uses a render target otherwise false.
  114856. */
  114857. hasRenderTargetTextures(): boolean;
  114858. /**
  114859. * Returns an array of the actively used textures.
  114860. * @param activeTextures Array of BaseTextures
  114861. */
  114862. getActiveTextures(activeTextures: BaseTexture[]): void;
  114863. /**
  114864. * Returns the animatable textures.
  114865. * @param animatables Array of animatable textures.
  114866. */
  114867. getAnimatables(animatables: IAnimatable[]): void;
  114868. /**
  114869. * Disposes the resources of the material.
  114870. * @param forceDisposeTextures - Forces the disposal of all textures.
  114871. */
  114872. dispose(forceDisposeTextures?: boolean): void;
  114873. /**
  114874. * Get the current class name of the texture useful for serialization or dynamic coding.
  114875. * @returns "PBRSubSurfaceConfiguration"
  114876. */
  114877. getClassName(): string;
  114878. /**
  114879. * Add fallbacks to the effect fallbacks list.
  114880. * @param defines defines the Base texture to use.
  114881. * @param fallbacks defines the current fallback list.
  114882. * @param currentRank defines the current fallback rank.
  114883. * @returns the new fallback rank.
  114884. */
  114885. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114886. /**
  114887. * Add the required uniforms to the current list.
  114888. * @param uniforms defines the current uniform list.
  114889. */
  114890. static AddUniforms(uniforms: string[]): void;
  114891. /**
  114892. * Add the required samplers to the current list.
  114893. * @param samplers defines the current sampler list.
  114894. */
  114895. static AddSamplers(samplers: string[]): void;
  114896. /**
  114897. * Add the required uniforms to the current buffer.
  114898. * @param uniformBuffer defines the current uniform buffer.
  114899. */
  114900. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114901. /**
  114902. * Makes a duplicate of the current configuration into another one.
  114903. * @param configuration define the config where to copy the info
  114904. */
  114905. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114906. /**
  114907. * Serializes this Sub Surface configuration.
  114908. * @returns - An object with the serialized config.
  114909. */
  114910. serialize(): any;
  114911. /**
  114912. * Parses a anisotropy Configuration from a serialized object.
  114913. * @param source - Serialized object.
  114914. * @param scene Defines the scene we are parsing for
  114915. * @param rootUrl Defines the rootUrl to load from
  114916. */
  114917. parse(source: any, scene: Scene, rootUrl: string): void;
  114918. }
  114919. }
  114920. declare module BABYLON {
  114921. /** @hidden */
  114922. export var pbrFragmentDeclaration: {
  114923. name: string;
  114924. shader: string;
  114925. };
  114926. }
  114927. declare module BABYLON {
  114928. /** @hidden */
  114929. export var pbrUboDeclaration: {
  114930. name: string;
  114931. shader: string;
  114932. };
  114933. }
  114934. declare module BABYLON {
  114935. /** @hidden */
  114936. export var pbrFragmentExtraDeclaration: {
  114937. name: string;
  114938. shader: string;
  114939. };
  114940. }
  114941. declare module BABYLON {
  114942. /** @hidden */
  114943. export var pbrFragmentSamplersDeclaration: {
  114944. name: string;
  114945. shader: string;
  114946. };
  114947. }
  114948. declare module BABYLON {
  114949. /** @hidden */
  114950. export var pbrHelperFunctions: {
  114951. name: string;
  114952. shader: string;
  114953. };
  114954. }
  114955. declare module BABYLON {
  114956. /** @hidden */
  114957. export var harmonicsFunctions: {
  114958. name: string;
  114959. shader: string;
  114960. };
  114961. }
  114962. declare module BABYLON {
  114963. /** @hidden */
  114964. export var pbrDirectLightingSetupFunctions: {
  114965. name: string;
  114966. shader: string;
  114967. };
  114968. }
  114969. declare module BABYLON {
  114970. /** @hidden */
  114971. export var pbrDirectLightingFalloffFunctions: {
  114972. name: string;
  114973. shader: string;
  114974. };
  114975. }
  114976. declare module BABYLON {
  114977. /** @hidden */
  114978. export var pbrBRDFFunctions: {
  114979. name: string;
  114980. shader: string;
  114981. };
  114982. }
  114983. declare module BABYLON {
  114984. /** @hidden */
  114985. export var pbrDirectLightingFunctions: {
  114986. name: string;
  114987. shader: string;
  114988. };
  114989. }
  114990. declare module BABYLON {
  114991. /** @hidden */
  114992. export var pbrIBLFunctions: {
  114993. name: string;
  114994. shader: string;
  114995. };
  114996. }
  114997. declare module BABYLON {
  114998. /** @hidden */
  114999. export var pbrDebug: {
  115000. name: string;
  115001. shader: string;
  115002. };
  115003. }
  115004. declare module BABYLON {
  115005. /** @hidden */
  115006. export var pbrPixelShader: {
  115007. name: string;
  115008. shader: string;
  115009. };
  115010. }
  115011. declare module BABYLON {
  115012. /** @hidden */
  115013. export var pbrVertexDeclaration: {
  115014. name: string;
  115015. shader: string;
  115016. };
  115017. }
  115018. declare module BABYLON {
  115019. /** @hidden */
  115020. export var pbrVertexShader: {
  115021. name: string;
  115022. shader: string;
  115023. };
  115024. }
  115025. declare module BABYLON {
  115026. /**
  115027. * Manages the defines for the PBR Material.
  115028. * @hidden
  115029. */
  115030. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115031. PBR: boolean;
  115032. MAINUV1: boolean;
  115033. MAINUV2: boolean;
  115034. UV1: boolean;
  115035. UV2: boolean;
  115036. ALBEDO: boolean;
  115037. ALBEDODIRECTUV: number;
  115038. VERTEXCOLOR: boolean;
  115039. AMBIENT: boolean;
  115040. AMBIENTDIRECTUV: number;
  115041. AMBIENTINGRAYSCALE: boolean;
  115042. OPACITY: boolean;
  115043. VERTEXALPHA: boolean;
  115044. OPACITYDIRECTUV: number;
  115045. OPACITYRGB: boolean;
  115046. ALPHATEST: boolean;
  115047. DEPTHPREPASS: boolean;
  115048. ALPHABLEND: boolean;
  115049. ALPHAFROMALBEDO: boolean;
  115050. ALPHATESTVALUE: string;
  115051. SPECULAROVERALPHA: boolean;
  115052. RADIANCEOVERALPHA: boolean;
  115053. ALPHAFRESNEL: boolean;
  115054. LINEARALPHAFRESNEL: boolean;
  115055. PREMULTIPLYALPHA: boolean;
  115056. EMISSIVE: boolean;
  115057. EMISSIVEDIRECTUV: number;
  115058. REFLECTIVITY: boolean;
  115059. REFLECTIVITYDIRECTUV: number;
  115060. SPECULARTERM: boolean;
  115061. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115062. MICROSURFACEAUTOMATIC: boolean;
  115063. LODBASEDMICROSFURACE: boolean;
  115064. MICROSURFACEMAP: boolean;
  115065. MICROSURFACEMAPDIRECTUV: number;
  115066. METALLICWORKFLOW: boolean;
  115067. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115068. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115069. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115070. AOSTOREINMETALMAPRED: boolean;
  115071. ENVIRONMENTBRDF: boolean;
  115072. ENVIRONMENTBRDF_RGBD: boolean;
  115073. NORMAL: boolean;
  115074. TANGENT: boolean;
  115075. BUMP: boolean;
  115076. BUMPDIRECTUV: number;
  115077. OBJECTSPACE_NORMALMAP: boolean;
  115078. PARALLAX: boolean;
  115079. PARALLAXOCCLUSION: boolean;
  115080. NORMALXYSCALE: boolean;
  115081. LIGHTMAP: boolean;
  115082. LIGHTMAPDIRECTUV: number;
  115083. USELIGHTMAPASSHADOWMAP: boolean;
  115084. GAMMALIGHTMAP: boolean;
  115085. RGBDLIGHTMAP: boolean;
  115086. REFLECTION: boolean;
  115087. REFLECTIONMAP_3D: boolean;
  115088. REFLECTIONMAP_SPHERICAL: boolean;
  115089. REFLECTIONMAP_PLANAR: boolean;
  115090. REFLECTIONMAP_CUBIC: boolean;
  115091. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115092. REFLECTIONMAP_PROJECTION: boolean;
  115093. REFLECTIONMAP_SKYBOX: boolean;
  115094. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115095. REFLECTIONMAP_EXPLICIT: boolean;
  115096. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115097. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115098. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115099. INVERTCUBICMAP: boolean;
  115100. USESPHERICALFROMREFLECTIONMAP: boolean;
  115101. USEIRRADIANCEMAP: boolean;
  115102. SPHERICAL_HARMONICS: boolean;
  115103. USESPHERICALINVERTEX: boolean;
  115104. REFLECTIONMAP_OPPOSITEZ: boolean;
  115105. LODINREFLECTIONALPHA: boolean;
  115106. GAMMAREFLECTION: boolean;
  115107. RGBDREFLECTION: boolean;
  115108. LINEARSPECULARREFLECTION: boolean;
  115109. RADIANCEOCCLUSION: boolean;
  115110. HORIZONOCCLUSION: boolean;
  115111. INSTANCES: boolean;
  115112. NUM_BONE_INFLUENCERS: number;
  115113. BonesPerMesh: number;
  115114. BONETEXTURE: boolean;
  115115. NONUNIFORMSCALING: boolean;
  115116. MORPHTARGETS: boolean;
  115117. MORPHTARGETS_NORMAL: boolean;
  115118. MORPHTARGETS_TANGENT: boolean;
  115119. MORPHTARGETS_UV: boolean;
  115120. NUM_MORPH_INFLUENCERS: number;
  115121. IMAGEPROCESSING: boolean;
  115122. VIGNETTE: boolean;
  115123. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115124. VIGNETTEBLENDMODEOPAQUE: boolean;
  115125. TONEMAPPING: boolean;
  115126. TONEMAPPING_ACES: boolean;
  115127. CONTRAST: boolean;
  115128. COLORCURVES: boolean;
  115129. COLORGRADING: boolean;
  115130. COLORGRADING3D: boolean;
  115131. SAMPLER3DGREENDEPTH: boolean;
  115132. SAMPLER3DBGRMAP: boolean;
  115133. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115134. EXPOSURE: boolean;
  115135. MULTIVIEW: boolean;
  115136. USEPHYSICALLIGHTFALLOFF: boolean;
  115137. USEGLTFLIGHTFALLOFF: boolean;
  115138. TWOSIDEDLIGHTING: boolean;
  115139. SHADOWFLOAT: boolean;
  115140. CLIPPLANE: boolean;
  115141. CLIPPLANE2: boolean;
  115142. CLIPPLANE3: boolean;
  115143. CLIPPLANE4: boolean;
  115144. POINTSIZE: boolean;
  115145. FOG: boolean;
  115146. LOGARITHMICDEPTH: boolean;
  115147. FORCENORMALFORWARD: boolean;
  115148. SPECULARAA: boolean;
  115149. CLEARCOAT: boolean;
  115150. CLEARCOAT_DEFAULTIOR: boolean;
  115151. CLEARCOAT_TEXTURE: boolean;
  115152. CLEARCOAT_TEXTUREDIRECTUV: number;
  115153. CLEARCOAT_BUMP: boolean;
  115154. CLEARCOAT_BUMPDIRECTUV: number;
  115155. CLEARCOAT_TINT: boolean;
  115156. CLEARCOAT_TINT_TEXTURE: boolean;
  115157. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115158. ANISOTROPIC: boolean;
  115159. ANISOTROPIC_TEXTURE: boolean;
  115160. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115161. BRDF_V_HEIGHT_CORRELATED: boolean;
  115162. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115163. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115164. SHEEN: boolean;
  115165. SHEEN_TEXTURE: boolean;
  115166. SHEEN_TEXTUREDIRECTUV: number;
  115167. SHEEN_LINKWITHALBEDO: boolean;
  115168. SUBSURFACE: boolean;
  115169. SS_REFRACTION: boolean;
  115170. SS_TRANSLUCENCY: boolean;
  115171. SS_SCATERRING: boolean;
  115172. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115173. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115174. SS_REFRACTIONMAP_3D: boolean;
  115175. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115176. SS_LODINREFRACTIONALPHA: boolean;
  115177. SS_GAMMAREFRACTION: boolean;
  115178. SS_RGBDREFRACTION: boolean;
  115179. SS_LINEARSPECULARREFRACTION: boolean;
  115180. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115181. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115182. UNLIT: boolean;
  115183. DEBUGMODE: number;
  115184. /**
  115185. * Initializes the PBR Material defines.
  115186. */
  115187. constructor();
  115188. /**
  115189. * Resets the PBR Material defines.
  115190. */
  115191. reset(): void;
  115192. }
  115193. /**
  115194. * The Physically based material base class of BJS.
  115195. *
  115196. * This offers the main features of a standard PBR material.
  115197. * For more information, please refer to the documentation :
  115198. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115199. */
  115200. export abstract class PBRBaseMaterial extends PushMaterial {
  115201. /**
  115202. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115203. */
  115204. static readonly PBRMATERIAL_OPAQUE: number;
  115205. /**
  115206. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115207. */
  115208. static readonly PBRMATERIAL_ALPHATEST: number;
  115209. /**
  115210. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115211. */
  115212. static readonly PBRMATERIAL_ALPHABLEND: number;
  115213. /**
  115214. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115215. * They are also discarded below the alpha cutoff threshold to improve performances.
  115216. */
  115217. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115218. /**
  115219. * Defines the default value of how much AO map is occluding the analytical lights
  115220. * (point spot...).
  115221. */
  115222. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115223. /**
  115224. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115225. */
  115226. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115227. /**
  115228. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115229. * to enhance interoperability with other engines.
  115230. */
  115231. static readonly LIGHTFALLOFF_GLTF: number;
  115232. /**
  115233. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115234. * to enhance interoperability with other materials.
  115235. */
  115236. static readonly LIGHTFALLOFF_STANDARD: number;
  115237. /**
  115238. * Intensity of the direct lights e.g. the four lights available in your scene.
  115239. * This impacts both the direct diffuse and specular highlights.
  115240. */
  115241. protected _directIntensity: number;
  115242. /**
  115243. * Intensity of the emissive part of the material.
  115244. * This helps controlling the emissive effect without modifying the emissive color.
  115245. */
  115246. protected _emissiveIntensity: number;
  115247. /**
  115248. * Intensity of the environment e.g. how much the environment will light the object
  115249. * either through harmonics for rough material or through the refelction for shiny ones.
  115250. */
  115251. protected _environmentIntensity: number;
  115252. /**
  115253. * This is a special control allowing the reduction of the specular highlights coming from the
  115254. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115255. */
  115256. protected _specularIntensity: number;
  115257. /**
  115258. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115259. */
  115260. private _lightingInfos;
  115261. /**
  115262. * Debug Control allowing disabling the bump map on this material.
  115263. */
  115264. protected _disableBumpMap: boolean;
  115265. /**
  115266. * AKA Diffuse Texture in standard nomenclature.
  115267. */
  115268. protected _albedoTexture: Nullable<BaseTexture>;
  115269. /**
  115270. * AKA Occlusion Texture in other nomenclature.
  115271. */
  115272. protected _ambientTexture: Nullable<BaseTexture>;
  115273. /**
  115274. * AKA Occlusion Texture Intensity in other nomenclature.
  115275. */
  115276. protected _ambientTextureStrength: number;
  115277. /**
  115278. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115279. * 1 means it completely occludes it
  115280. * 0 mean it has no impact
  115281. */
  115282. protected _ambientTextureImpactOnAnalyticalLights: number;
  115283. /**
  115284. * Stores the alpha values in a texture.
  115285. */
  115286. protected _opacityTexture: Nullable<BaseTexture>;
  115287. /**
  115288. * Stores the reflection values in a texture.
  115289. */
  115290. protected _reflectionTexture: Nullable<BaseTexture>;
  115291. /**
  115292. * Stores the emissive values in a texture.
  115293. */
  115294. protected _emissiveTexture: Nullable<BaseTexture>;
  115295. /**
  115296. * AKA Specular texture in other nomenclature.
  115297. */
  115298. protected _reflectivityTexture: Nullable<BaseTexture>;
  115299. /**
  115300. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115301. */
  115302. protected _metallicTexture: Nullable<BaseTexture>;
  115303. /**
  115304. * Specifies the metallic scalar of the metallic/roughness workflow.
  115305. * Can also be used to scale the metalness values of the metallic texture.
  115306. */
  115307. protected _metallic: Nullable<number>;
  115308. /**
  115309. * Specifies the roughness scalar of the metallic/roughness workflow.
  115310. * Can also be used to scale the roughness values of the metallic texture.
  115311. */
  115312. protected _roughness: Nullable<number>;
  115313. /**
  115314. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115315. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115316. */
  115317. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115318. /**
  115319. * Stores surface normal data used to displace a mesh in a texture.
  115320. */
  115321. protected _bumpTexture: Nullable<BaseTexture>;
  115322. /**
  115323. * Stores the pre-calculated light information of a mesh in a texture.
  115324. */
  115325. protected _lightmapTexture: Nullable<BaseTexture>;
  115326. /**
  115327. * The color of a material in ambient lighting.
  115328. */
  115329. protected _ambientColor: Color3;
  115330. /**
  115331. * AKA Diffuse Color in other nomenclature.
  115332. */
  115333. protected _albedoColor: Color3;
  115334. /**
  115335. * AKA Specular Color in other nomenclature.
  115336. */
  115337. protected _reflectivityColor: Color3;
  115338. /**
  115339. * The color applied when light is reflected from a material.
  115340. */
  115341. protected _reflectionColor: Color3;
  115342. /**
  115343. * The color applied when light is emitted from a material.
  115344. */
  115345. protected _emissiveColor: Color3;
  115346. /**
  115347. * AKA Glossiness in other nomenclature.
  115348. */
  115349. protected _microSurface: number;
  115350. /**
  115351. * Specifies that the material will use the light map as a show map.
  115352. */
  115353. protected _useLightmapAsShadowmap: boolean;
  115354. /**
  115355. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115356. * makes the reflect vector face the model (under horizon).
  115357. */
  115358. protected _useHorizonOcclusion: boolean;
  115359. /**
  115360. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115361. * too much the area relying on ambient texture to define their ambient occlusion.
  115362. */
  115363. protected _useRadianceOcclusion: boolean;
  115364. /**
  115365. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115366. */
  115367. protected _useAlphaFromAlbedoTexture: boolean;
  115368. /**
  115369. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115370. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115371. */
  115372. protected _useSpecularOverAlpha: boolean;
  115373. /**
  115374. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115375. */
  115376. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115377. /**
  115378. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115379. */
  115380. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115381. /**
  115382. * Specifies if the metallic texture contains the roughness information in its green channel.
  115383. */
  115384. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115385. /**
  115386. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115387. */
  115388. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115389. /**
  115390. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115391. */
  115392. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115393. /**
  115394. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115395. */
  115396. protected _useAmbientInGrayScale: boolean;
  115397. /**
  115398. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115399. * The material will try to infer what glossiness each pixel should be.
  115400. */
  115401. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115402. /**
  115403. * Defines the falloff type used in this material.
  115404. * It by default is Physical.
  115405. */
  115406. protected _lightFalloff: number;
  115407. /**
  115408. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115409. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115410. */
  115411. protected _useRadianceOverAlpha: boolean;
  115412. /**
  115413. * Allows using an object space normal map (instead of tangent space).
  115414. */
  115415. protected _useObjectSpaceNormalMap: boolean;
  115416. /**
  115417. * Allows using the bump map in parallax mode.
  115418. */
  115419. protected _useParallax: boolean;
  115420. /**
  115421. * Allows using the bump map in parallax occlusion mode.
  115422. */
  115423. protected _useParallaxOcclusion: boolean;
  115424. /**
  115425. * Controls the scale bias of the parallax mode.
  115426. */
  115427. protected _parallaxScaleBias: number;
  115428. /**
  115429. * If sets to true, disables all the lights affecting the material.
  115430. */
  115431. protected _disableLighting: boolean;
  115432. /**
  115433. * Number of Simultaneous lights allowed on the material.
  115434. */
  115435. protected _maxSimultaneousLights: number;
  115436. /**
  115437. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115438. */
  115439. protected _invertNormalMapX: boolean;
  115440. /**
  115441. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115442. */
  115443. protected _invertNormalMapY: boolean;
  115444. /**
  115445. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115446. */
  115447. protected _twoSidedLighting: boolean;
  115448. /**
  115449. * Defines the alpha limits in alpha test mode.
  115450. */
  115451. protected _alphaCutOff: number;
  115452. /**
  115453. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115454. */
  115455. protected _forceAlphaTest: boolean;
  115456. /**
  115457. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115458. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115459. */
  115460. protected _useAlphaFresnel: boolean;
  115461. /**
  115462. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115463. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115464. */
  115465. protected _useLinearAlphaFresnel: boolean;
  115466. /**
  115467. * The transparency mode of the material.
  115468. */
  115469. protected _transparencyMode: Nullable<number>;
  115470. /**
  115471. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115472. * from cos thetav and roughness:
  115473. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115474. */
  115475. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115476. /**
  115477. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115478. */
  115479. protected _forceIrradianceInFragment: boolean;
  115480. /**
  115481. * Force normal to face away from face.
  115482. */
  115483. protected _forceNormalForward: boolean;
  115484. /**
  115485. * Enables specular anti aliasing in the PBR shader.
  115486. * It will both interacts on the Geometry for analytical and IBL lighting.
  115487. * It also prefilter the roughness map based on the bump values.
  115488. */
  115489. protected _enableSpecularAntiAliasing: boolean;
  115490. /**
  115491. * Default configuration related to image processing available in the PBR Material.
  115492. */
  115493. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115494. /**
  115495. * Keep track of the image processing observer to allow dispose and replace.
  115496. */
  115497. private _imageProcessingObserver;
  115498. /**
  115499. * Attaches a new image processing configuration to the PBR Material.
  115500. * @param configuration
  115501. */
  115502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115503. /**
  115504. * Stores the available render targets.
  115505. */
  115506. private _renderTargets;
  115507. /**
  115508. * Sets the global ambient color for the material used in lighting calculations.
  115509. */
  115510. private _globalAmbientColor;
  115511. /**
  115512. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115513. */
  115514. private _useLogarithmicDepth;
  115515. /**
  115516. * If set to true, no lighting calculations will be applied.
  115517. */
  115518. private _unlit;
  115519. private _debugMode;
  115520. /**
  115521. * @hidden
  115522. * This is reserved for the inspector.
  115523. * Defines the material debug mode.
  115524. * It helps seeing only some components of the material while troubleshooting.
  115525. */
  115526. debugMode: number;
  115527. /**
  115528. * @hidden
  115529. * This is reserved for the inspector.
  115530. * Specify from where on screen the debug mode should start.
  115531. * The value goes from -1 (full screen) to 1 (not visible)
  115532. * It helps with side by side comparison against the final render
  115533. * This defaults to -1
  115534. */
  115535. private debugLimit;
  115536. /**
  115537. * @hidden
  115538. * This is reserved for the inspector.
  115539. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115540. * You can use the factor to better multiply the final value.
  115541. */
  115542. private debugFactor;
  115543. /**
  115544. * Defines the clear coat layer parameters for the material.
  115545. */
  115546. readonly clearCoat: PBRClearCoatConfiguration;
  115547. /**
  115548. * Defines the anisotropic parameters for the material.
  115549. */
  115550. readonly anisotropy: PBRAnisotropicConfiguration;
  115551. /**
  115552. * Defines the BRDF parameters for the material.
  115553. */
  115554. readonly brdf: PBRBRDFConfiguration;
  115555. /**
  115556. * Defines the Sheen parameters for the material.
  115557. */
  115558. readonly sheen: PBRSheenConfiguration;
  115559. /**
  115560. * Defines the SubSurface parameters for the material.
  115561. */
  115562. readonly subSurface: PBRSubSurfaceConfiguration;
  115563. /**
  115564. * Custom callback helping to override the default shader used in the material.
  115565. */
  115566. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115567. protected _rebuildInParallel: boolean;
  115568. /**
  115569. * Instantiates a new PBRMaterial instance.
  115570. *
  115571. * @param name The material name
  115572. * @param scene The scene the material will be use in.
  115573. */
  115574. constructor(name: string, scene: Scene);
  115575. /**
  115576. * Gets a boolean indicating that current material needs to register RTT
  115577. */
  115578. readonly hasRenderTargetTextures: boolean;
  115579. /**
  115580. * Gets the name of the material class.
  115581. */
  115582. getClassName(): string;
  115583. /**
  115584. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115585. */
  115586. /**
  115587. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115588. */
  115589. useLogarithmicDepth: boolean;
  115590. /**
  115591. * Gets the current transparency mode.
  115592. */
  115593. /**
  115594. * Sets the transparency mode of the material.
  115595. *
  115596. * | Value | Type | Description |
  115597. * | ----- | ----------------------------------- | ----------- |
  115598. * | 0 | OPAQUE | |
  115599. * | 1 | ALPHATEST | |
  115600. * | 2 | ALPHABLEND | |
  115601. * | 3 | ALPHATESTANDBLEND | |
  115602. *
  115603. */
  115604. transparencyMode: Nullable<number>;
  115605. /**
  115606. * Returns true if alpha blending should be disabled.
  115607. */
  115608. private readonly _disableAlphaBlending;
  115609. /**
  115610. * Specifies whether or not this material should be rendered in alpha blend mode.
  115611. */
  115612. needAlphaBlending(): boolean;
  115613. /**
  115614. * Specifies if the mesh will require alpha blending.
  115615. * @param mesh - BJS mesh.
  115616. */
  115617. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115618. /**
  115619. * Specifies whether or not this material should be rendered in alpha test mode.
  115620. */
  115621. needAlphaTesting(): boolean;
  115622. /**
  115623. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115624. */
  115625. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115626. /**
  115627. * Gets the texture used for the alpha test.
  115628. */
  115629. getAlphaTestTexture(): Nullable<BaseTexture>;
  115630. /**
  115631. * Specifies that the submesh is ready to be used.
  115632. * @param mesh - BJS mesh.
  115633. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115634. * @param useInstances - Specifies that instances should be used.
  115635. * @returns - boolean indicating that the submesh is ready or not.
  115636. */
  115637. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115638. /**
  115639. * Specifies if the material uses metallic roughness workflow.
  115640. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115641. */
  115642. isMetallicWorkflow(): boolean;
  115643. private _prepareEffect;
  115644. private _prepareDefines;
  115645. /**
  115646. * Force shader compilation
  115647. */
  115648. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  115649. clipPlane: boolean;
  115650. }>): void;
  115651. /**
  115652. * Initializes the uniform buffer layout for the shader.
  115653. */
  115654. buildUniformLayout(): void;
  115655. /**
  115656. * Unbinds the material from the mesh
  115657. */
  115658. unbind(): void;
  115659. /**
  115660. * Binds the submesh data.
  115661. * @param world - The world matrix.
  115662. * @param mesh - The BJS mesh.
  115663. * @param subMesh - A submesh of the BJS mesh.
  115664. */
  115665. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115666. /**
  115667. * Returns the animatable textures.
  115668. * @returns - Array of animatable textures.
  115669. */
  115670. getAnimatables(): IAnimatable[];
  115671. /**
  115672. * Returns the texture used for reflections.
  115673. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115674. */
  115675. private _getReflectionTexture;
  115676. /**
  115677. * Returns an array of the actively used textures.
  115678. * @returns - Array of BaseTextures
  115679. */
  115680. getActiveTextures(): BaseTexture[];
  115681. /**
  115682. * Checks to see if a texture is used in the material.
  115683. * @param texture - Base texture to use.
  115684. * @returns - Boolean specifying if a texture is used in the material.
  115685. */
  115686. hasTexture(texture: BaseTexture): boolean;
  115687. /**
  115688. * Disposes the resources of the material.
  115689. * @param forceDisposeEffect - Forces the disposal of effects.
  115690. * @param forceDisposeTextures - Forces the disposal of all textures.
  115691. */
  115692. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115693. }
  115694. }
  115695. declare module BABYLON {
  115696. /**
  115697. * The Physically based material of BJS.
  115698. *
  115699. * This offers the main features of a standard PBR material.
  115700. * For more information, please refer to the documentation :
  115701. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115702. */
  115703. export class PBRMaterial extends PBRBaseMaterial {
  115704. /**
  115705. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115706. */
  115707. static readonly PBRMATERIAL_OPAQUE: number;
  115708. /**
  115709. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115710. */
  115711. static readonly PBRMATERIAL_ALPHATEST: number;
  115712. /**
  115713. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115714. */
  115715. static readonly PBRMATERIAL_ALPHABLEND: number;
  115716. /**
  115717. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115718. * They are also discarded below the alpha cutoff threshold to improve performances.
  115719. */
  115720. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115721. /**
  115722. * Defines the default value of how much AO map is occluding the analytical lights
  115723. * (point spot...).
  115724. */
  115725. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115726. /**
  115727. * Intensity of the direct lights e.g. the four lights available in your scene.
  115728. * This impacts both the direct diffuse and specular highlights.
  115729. */
  115730. directIntensity: number;
  115731. /**
  115732. * Intensity of the emissive part of the material.
  115733. * This helps controlling the emissive effect without modifying the emissive color.
  115734. */
  115735. emissiveIntensity: number;
  115736. /**
  115737. * Intensity of the environment e.g. how much the environment will light the object
  115738. * either through harmonics for rough material or through the refelction for shiny ones.
  115739. */
  115740. environmentIntensity: number;
  115741. /**
  115742. * This is a special control allowing the reduction of the specular highlights coming from the
  115743. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115744. */
  115745. specularIntensity: number;
  115746. /**
  115747. * Debug Control allowing disabling the bump map on this material.
  115748. */
  115749. disableBumpMap: boolean;
  115750. /**
  115751. * AKA Diffuse Texture in standard nomenclature.
  115752. */
  115753. albedoTexture: BaseTexture;
  115754. /**
  115755. * AKA Occlusion Texture in other nomenclature.
  115756. */
  115757. ambientTexture: BaseTexture;
  115758. /**
  115759. * AKA Occlusion Texture Intensity in other nomenclature.
  115760. */
  115761. ambientTextureStrength: number;
  115762. /**
  115763. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115764. * 1 means it completely occludes it
  115765. * 0 mean it has no impact
  115766. */
  115767. ambientTextureImpactOnAnalyticalLights: number;
  115768. /**
  115769. * Stores the alpha values in a texture.
  115770. */
  115771. opacityTexture: BaseTexture;
  115772. /**
  115773. * Stores the reflection values in a texture.
  115774. */
  115775. reflectionTexture: Nullable<BaseTexture>;
  115776. /**
  115777. * Stores the emissive values in a texture.
  115778. */
  115779. emissiveTexture: BaseTexture;
  115780. /**
  115781. * AKA Specular texture in other nomenclature.
  115782. */
  115783. reflectivityTexture: BaseTexture;
  115784. /**
  115785. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115786. */
  115787. metallicTexture: BaseTexture;
  115788. /**
  115789. * Specifies the metallic scalar of the metallic/roughness workflow.
  115790. * Can also be used to scale the metalness values of the metallic texture.
  115791. */
  115792. metallic: Nullable<number>;
  115793. /**
  115794. * Specifies the roughness scalar of the metallic/roughness workflow.
  115795. * Can also be used to scale the roughness values of the metallic texture.
  115796. */
  115797. roughness: Nullable<number>;
  115798. /**
  115799. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115800. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115801. */
  115802. microSurfaceTexture: BaseTexture;
  115803. /**
  115804. * Stores surface normal data used to displace a mesh in a texture.
  115805. */
  115806. bumpTexture: BaseTexture;
  115807. /**
  115808. * Stores the pre-calculated light information of a mesh in a texture.
  115809. */
  115810. lightmapTexture: BaseTexture;
  115811. /**
  115812. * Stores the refracted light information in a texture.
  115813. */
  115814. refractionTexture: Nullable<BaseTexture>;
  115815. /**
  115816. * The color of a material in ambient lighting.
  115817. */
  115818. ambientColor: Color3;
  115819. /**
  115820. * AKA Diffuse Color in other nomenclature.
  115821. */
  115822. albedoColor: Color3;
  115823. /**
  115824. * AKA Specular Color in other nomenclature.
  115825. */
  115826. reflectivityColor: Color3;
  115827. /**
  115828. * The color reflected from the material.
  115829. */
  115830. reflectionColor: Color3;
  115831. /**
  115832. * The color emitted from the material.
  115833. */
  115834. emissiveColor: Color3;
  115835. /**
  115836. * AKA Glossiness in other nomenclature.
  115837. */
  115838. microSurface: number;
  115839. /**
  115840. * source material index of refraction (IOR)' / 'destination material IOR.
  115841. */
  115842. indexOfRefraction: number;
  115843. /**
  115844. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115845. */
  115846. invertRefractionY: boolean;
  115847. /**
  115848. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115849. * Materials half opaque for instance using refraction could benefit from this control.
  115850. */
  115851. linkRefractionWithTransparency: boolean;
  115852. /**
  115853. * If true, the light map contains occlusion information instead of lighting info.
  115854. */
  115855. useLightmapAsShadowmap: boolean;
  115856. /**
  115857. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115858. */
  115859. useAlphaFromAlbedoTexture: boolean;
  115860. /**
  115861. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115862. */
  115863. forceAlphaTest: boolean;
  115864. /**
  115865. * Defines the alpha limits in alpha test mode.
  115866. */
  115867. alphaCutOff: number;
  115868. /**
  115869. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115870. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115871. */
  115872. useSpecularOverAlpha: boolean;
  115873. /**
  115874. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115875. */
  115876. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115877. /**
  115878. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115879. */
  115880. useRoughnessFromMetallicTextureAlpha: boolean;
  115881. /**
  115882. * Specifies if the metallic texture contains the roughness information in its green channel.
  115883. */
  115884. useRoughnessFromMetallicTextureGreen: boolean;
  115885. /**
  115886. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115887. */
  115888. useMetallnessFromMetallicTextureBlue: boolean;
  115889. /**
  115890. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115891. */
  115892. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115893. /**
  115894. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115895. */
  115896. useAmbientInGrayScale: boolean;
  115897. /**
  115898. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115899. * The material will try to infer what glossiness each pixel should be.
  115900. */
  115901. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115902. /**
  115903. * BJS is using an harcoded light falloff based on a manually sets up range.
  115904. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115905. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115906. */
  115907. /**
  115908. * BJS is using an harcoded light falloff based on a manually sets up range.
  115909. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115910. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115911. */
  115912. usePhysicalLightFalloff: boolean;
  115913. /**
  115914. * In order to support the falloff compatibility with gltf, a special mode has been added
  115915. * to reproduce the gltf light falloff.
  115916. */
  115917. /**
  115918. * In order to support the falloff compatibility with gltf, a special mode has been added
  115919. * to reproduce the gltf light falloff.
  115920. */
  115921. useGLTFLightFalloff: boolean;
  115922. /**
  115923. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115924. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115925. */
  115926. useRadianceOverAlpha: boolean;
  115927. /**
  115928. * Allows using an object space normal map (instead of tangent space).
  115929. */
  115930. useObjectSpaceNormalMap: boolean;
  115931. /**
  115932. * Allows using the bump map in parallax mode.
  115933. */
  115934. useParallax: boolean;
  115935. /**
  115936. * Allows using the bump map in parallax occlusion mode.
  115937. */
  115938. useParallaxOcclusion: boolean;
  115939. /**
  115940. * Controls the scale bias of the parallax mode.
  115941. */
  115942. parallaxScaleBias: number;
  115943. /**
  115944. * If sets to true, disables all the lights affecting the material.
  115945. */
  115946. disableLighting: boolean;
  115947. /**
  115948. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115949. */
  115950. forceIrradianceInFragment: boolean;
  115951. /**
  115952. * Number of Simultaneous lights allowed on the material.
  115953. */
  115954. maxSimultaneousLights: number;
  115955. /**
  115956. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115957. */
  115958. invertNormalMapX: boolean;
  115959. /**
  115960. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115961. */
  115962. invertNormalMapY: boolean;
  115963. /**
  115964. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115965. */
  115966. twoSidedLighting: boolean;
  115967. /**
  115968. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115969. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115970. */
  115971. useAlphaFresnel: boolean;
  115972. /**
  115973. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115974. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115975. */
  115976. useLinearAlphaFresnel: boolean;
  115977. /**
  115978. * Let user defines the brdf lookup texture used for IBL.
  115979. * A default 8bit version is embedded but you could point at :
  115980. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115981. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115982. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115983. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115984. */
  115985. environmentBRDFTexture: Nullable<BaseTexture>;
  115986. /**
  115987. * Force normal to face away from face.
  115988. */
  115989. forceNormalForward: boolean;
  115990. /**
  115991. * Enables specular anti aliasing in the PBR shader.
  115992. * It will both interacts on the Geometry for analytical and IBL lighting.
  115993. * It also prefilter the roughness map based on the bump values.
  115994. */
  115995. enableSpecularAntiAliasing: boolean;
  115996. /**
  115997. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115998. * makes the reflect vector face the model (under horizon).
  115999. */
  116000. useHorizonOcclusion: boolean;
  116001. /**
  116002. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116003. * too much the area relying on ambient texture to define their ambient occlusion.
  116004. */
  116005. useRadianceOcclusion: boolean;
  116006. /**
  116007. * If set to true, no lighting calculations will be applied.
  116008. */
  116009. unlit: boolean;
  116010. /**
  116011. * Gets the image processing configuration used either in this material.
  116012. */
  116013. /**
  116014. * Sets the Default image processing configuration used either in the this material.
  116015. *
  116016. * If sets to null, the scene one is in use.
  116017. */
  116018. imageProcessingConfiguration: ImageProcessingConfiguration;
  116019. /**
  116020. * Gets wether the color curves effect is enabled.
  116021. */
  116022. /**
  116023. * Sets wether the color curves effect is enabled.
  116024. */
  116025. cameraColorCurvesEnabled: boolean;
  116026. /**
  116027. * Gets wether the color grading effect is enabled.
  116028. */
  116029. /**
  116030. * Gets wether the color grading effect is enabled.
  116031. */
  116032. cameraColorGradingEnabled: boolean;
  116033. /**
  116034. * Gets wether tonemapping is enabled or not.
  116035. */
  116036. /**
  116037. * Sets wether tonemapping is enabled or not
  116038. */
  116039. cameraToneMappingEnabled: boolean;
  116040. /**
  116041. * The camera exposure used on this material.
  116042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116043. * This corresponds to a photographic exposure.
  116044. */
  116045. /**
  116046. * The camera exposure used on this material.
  116047. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116048. * This corresponds to a photographic exposure.
  116049. */
  116050. cameraExposure: number;
  116051. /**
  116052. * Gets The camera contrast used on this material.
  116053. */
  116054. /**
  116055. * Sets The camera contrast used on this material.
  116056. */
  116057. cameraContrast: number;
  116058. /**
  116059. * Gets the Color Grading 2D Lookup Texture.
  116060. */
  116061. /**
  116062. * Sets the Color Grading 2D Lookup Texture.
  116063. */
  116064. cameraColorGradingTexture: Nullable<BaseTexture>;
  116065. /**
  116066. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116067. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116068. * 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;
  116069. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116070. */
  116071. /**
  116072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116074. * 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;
  116075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116076. */
  116077. cameraColorCurves: Nullable<ColorCurves>;
  116078. /**
  116079. * Instantiates a new PBRMaterial instance.
  116080. *
  116081. * @param name The material name
  116082. * @param scene The scene the material will be use in.
  116083. */
  116084. constructor(name: string, scene: Scene);
  116085. /**
  116086. * Returns the name of this material class.
  116087. */
  116088. getClassName(): string;
  116089. /**
  116090. * Makes a duplicate of the current material.
  116091. * @param name - name to use for the new material.
  116092. */
  116093. clone(name: string): PBRMaterial;
  116094. /**
  116095. * Serializes this PBR Material.
  116096. * @returns - An object with the serialized material.
  116097. */
  116098. serialize(): any;
  116099. /**
  116100. * Parses a PBR Material from a serialized object.
  116101. * @param source - Serialized object.
  116102. * @param scene - BJS scene instance.
  116103. * @param rootUrl - url for the scene object
  116104. * @returns - PBRMaterial
  116105. */
  116106. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116107. }
  116108. }
  116109. declare module BABYLON {
  116110. /**
  116111. * Direct draw surface info
  116112. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116113. */
  116114. export interface DDSInfo {
  116115. /**
  116116. * Width of the texture
  116117. */
  116118. width: number;
  116119. /**
  116120. * Width of the texture
  116121. */
  116122. height: number;
  116123. /**
  116124. * Number of Mipmaps for the texture
  116125. * @see https://en.wikipedia.org/wiki/Mipmap
  116126. */
  116127. mipmapCount: number;
  116128. /**
  116129. * If the textures format is a known fourCC format
  116130. * @see https://www.fourcc.org/
  116131. */
  116132. isFourCC: boolean;
  116133. /**
  116134. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116135. */
  116136. isRGB: boolean;
  116137. /**
  116138. * If the texture is a lumincance format
  116139. */
  116140. isLuminance: boolean;
  116141. /**
  116142. * If this is a cube texture
  116143. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116144. */
  116145. isCube: boolean;
  116146. /**
  116147. * If the texture is a compressed format eg. FOURCC_DXT1
  116148. */
  116149. isCompressed: boolean;
  116150. /**
  116151. * The dxgiFormat of the texture
  116152. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116153. */
  116154. dxgiFormat: number;
  116155. /**
  116156. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116157. */
  116158. textureType: number;
  116159. /**
  116160. * Sphericle polynomial created for the dds texture
  116161. */
  116162. sphericalPolynomial?: SphericalPolynomial;
  116163. }
  116164. /**
  116165. * Class used to provide DDS decompression tools
  116166. */
  116167. export class DDSTools {
  116168. /**
  116169. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116170. */
  116171. static StoreLODInAlphaChannel: boolean;
  116172. /**
  116173. * Gets DDS information from an array buffer
  116174. * @param arrayBuffer defines the array buffer to read data from
  116175. * @returns the DDS information
  116176. */
  116177. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116178. private static _FloatView;
  116179. private static _Int32View;
  116180. private static _ToHalfFloat;
  116181. private static _FromHalfFloat;
  116182. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116183. private static _GetHalfFloatRGBAArrayBuffer;
  116184. private static _GetFloatRGBAArrayBuffer;
  116185. private static _GetFloatAsUIntRGBAArrayBuffer;
  116186. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116187. private static _GetRGBAArrayBuffer;
  116188. private static _ExtractLongWordOrder;
  116189. private static _GetRGBArrayBuffer;
  116190. private static _GetLuminanceArrayBuffer;
  116191. /**
  116192. * Uploads DDS Levels to a Babylon Texture
  116193. * @hidden
  116194. */
  116195. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116196. }
  116197. interface ThinEngine {
  116198. /**
  116199. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116200. * @param rootUrl defines the url where the file to load is located
  116201. * @param scene defines the current scene
  116202. * @param lodScale defines scale to apply to the mip map selection
  116203. * @param lodOffset defines offset to apply to the mip map selection
  116204. * @param onLoad defines an optional callback raised when the texture is loaded
  116205. * @param onError defines an optional callback raised if there is an issue to load the texture
  116206. * @param format defines the format of the data
  116207. * @param forcedExtension defines the extension to use to pick the right loader
  116208. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116209. * @returns the cube texture as an InternalTexture
  116210. */
  116211. 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;
  116212. }
  116213. }
  116214. declare module BABYLON {
  116215. /**
  116216. * Implementation of the DDS Texture Loader.
  116217. * @hidden
  116218. */
  116219. export class _DDSTextureLoader implements IInternalTextureLoader {
  116220. /**
  116221. * Defines wether the loader supports cascade loading the different faces.
  116222. */
  116223. readonly supportCascades: boolean;
  116224. /**
  116225. * This returns if the loader support the current file information.
  116226. * @param extension defines the file extension of the file being loaded
  116227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116228. * @param fallback defines the fallback internal texture if any
  116229. * @param isBase64 defines whether the texture is encoded as a base64
  116230. * @param isBuffer defines whether the texture data are stored as a buffer
  116231. * @returns true if the loader can load the specified file
  116232. */
  116233. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116234. /**
  116235. * Transform the url before loading if required.
  116236. * @param rootUrl the url of the texture
  116237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116238. * @returns the transformed texture
  116239. */
  116240. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116241. /**
  116242. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116243. * @param rootUrl the url of the texture
  116244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116245. * @returns the fallback texture
  116246. */
  116247. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116248. /**
  116249. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116250. * @param data contains the texture data
  116251. * @param texture defines the BabylonJS internal texture
  116252. * @param createPolynomials will be true if polynomials have been requested
  116253. * @param onLoad defines the callback to trigger once the texture is ready
  116254. * @param onError defines the callback to trigger in case of error
  116255. */
  116256. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116257. /**
  116258. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116259. * @param data contains the texture data
  116260. * @param texture defines the BabylonJS internal texture
  116261. * @param callback defines the method to call once ready to upload
  116262. */
  116263. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116264. }
  116265. }
  116266. declare module BABYLON {
  116267. /**
  116268. * Implementation of the ENV Texture Loader.
  116269. * @hidden
  116270. */
  116271. export class _ENVTextureLoader implements IInternalTextureLoader {
  116272. /**
  116273. * Defines wether the loader supports cascade loading the different faces.
  116274. */
  116275. readonly supportCascades: boolean;
  116276. /**
  116277. * This returns if the loader support the current file information.
  116278. * @param extension defines the file extension of the file being loaded
  116279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116280. * @param fallback defines the fallback internal texture if any
  116281. * @param isBase64 defines whether the texture is encoded as a base64
  116282. * @param isBuffer defines whether the texture data are stored as a buffer
  116283. * @returns true if the loader can load the specified file
  116284. */
  116285. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116286. /**
  116287. * Transform the url before loading if required.
  116288. * @param rootUrl the url of the texture
  116289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116290. * @returns the transformed texture
  116291. */
  116292. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116293. /**
  116294. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116295. * @param rootUrl the url of the texture
  116296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116297. * @returns the fallback texture
  116298. */
  116299. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116300. /**
  116301. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116302. * @param data contains the texture data
  116303. * @param texture defines the BabylonJS internal texture
  116304. * @param createPolynomials will be true if polynomials have been requested
  116305. * @param onLoad defines the callback to trigger once the texture is ready
  116306. * @param onError defines the callback to trigger in case of error
  116307. */
  116308. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116309. /**
  116310. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116311. * @param data contains the texture data
  116312. * @param texture defines the BabylonJS internal texture
  116313. * @param callback defines the method to call once ready to upload
  116314. */
  116315. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116316. }
  116317. }
  116318. declare module BABYLON {
  116319. /**
  116320. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116321. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116322. */
  116323. export class KhronosTextureContainer {
  116324. /** contents of the KTX container file */
  116325. arrayBuffer: any;
  116326. private static HEADER_LEN;
  116327. private static COMPRESSED_2D;
  116328. private static COMPRESSED_3D;
  116329. private static TEX_2D;
  116330. private static TEX_3D;
  116331. /**
  116332. * Gets the openGL type
  116333. */
  116334. glType: number;
  116335. /**
  116336. * Gets the openGL type size
  116337. */
  116338. glTypeSize: number;
  116339. /**
  116340. * Gets the openGL format
  116341. */
  116342. glFormat: number;
  116343. /**
  116344. * Gets the openGL internal format
  116345. */
  116346. glInternalFormat: number;
  116347. /**
  116348. * Gets the base internal format
  116349. */
  116350. glBaseInternalFormat: number;
  116351. /**
  116352. * Gets image width in pixel
  116353. */
  116354. pixelWidth: number;
  116355. /**
  116356. * Gets image height in pixel
  116357. */
  116358. pixelHeight: number;
  116359. /**
  116360. * Gets image depth in pixels
  116361. */
  116362. pixelDepth: number;
  116363. /**
  116364. * Gets the number of array elements
  116365. */
  116366. numberOfArrayElements: number;
  116367. /**
  116368. * Gets the number of faces
  116369. */
  116370. numberOfFaces: number;
  116371. /**
  116372. * Gets the number of mipmap levels
  116373. */
  116374. numberOfMipmapLevels: number;
  116375. /**
  116376. * Gets the bytes of key value data
  116377. */
  116378. bytesOfKeyValueData: number;
  116379. /**
  116380. * Gets the load type
  116381. */
  116382. loadType: number;
  116383. /**
  116384. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116385. */
  116386. isInvalid: boolean;
  116387. /**
  116388. * Creates a new KhronosTextureContainer
  116389. * @param arrayBuffer contents of the KTX container file
  116390. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116391. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116392. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116393. */
  116394. constructor(
  116395. /** contents of the KTX container file */
  116396. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116397. /**
  116398. * Uploads KTX content to a Babylon Texture.
  116399. * It is assumed that the texture has already been created & is currently bound
  116400. * @hidden
  116401. */
  116402. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116403. private _upload2DCompressedLevels;
  116404. }
  116405. }
  116406. declare module BABYLON {
  116407. /**
  116408. * Implementation of the KTX Texture Loader.
  116409. * @hidden
  116410. */
  116411. export class _KTXTextureLoader implements IInternalTextureLoader {
  116412. /**
  116413. * Defines wether the loader supports cascade loading the different faces.
  116414. */
  116415. readonly supportCascades: boolean;
  116416. /**
  116417. * This returns if the loader support the current file information.
  116418. * @param extension defines the file extension of the file being loaded
  116419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116420. * @param fallback defines the fallback internal texture if any
  116421. * @param isBase64 defines whether the texture is encoded as a base64
  116422. * @param isBuffer defines whether the texture data are stored as a buffer
  116423. * @returns true if the loader can load the specified file
  116424. */
  116425. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116426. /**
  116427. * Transform the url before loading if required.
  116428. * @param rootUrl the url of the texture
  116429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116430. * @returns the transformed texture
  116431. */
  116432. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116433. /**
  116434. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116435. * @param rootUrl the url of the texture
  116436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116437. * @returns the fallback texture
  116438. */
  116439. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116440. /**
  116441. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116442. * @param data contains the texture data
  116443. * @param texture defines the BabylonJS internal texture
  116444. * @param createPolynomials will be true if polynomials have been requested
  116445. * @param onLoad defines the callback to trigger once the texture is ready
  116446. * @param onError defines the callback to trigger in case of error
  116447. */
  116448. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116449. /**
  116450. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116451. * @param data contains the texture data
  116452. * @param texture defines the BabylonJS internal texture
  116453. * @param callback defines the method to call once ready to upload
  116454. */
  116455. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116456. }
  116457. }
  116458. declare module BABYLON {
  116459. /**
  116460. * Options for the default xr helper
  116461. */
  116462. export class WebXRDefaultExperienceOptions {
  116463. /**
  116464. * Floor meshes that should be used for teleporting
  116465. */
  116466. floorMeshes: Array<AbstractMesh>;
  116467. }
  116468. /**
  116469. * Default experience which provides a similar setup to the previous webVRExperience
  116470. */
  116471. export class WebXRDefaultExperience {
  116472. /**
  116473. * Base experience
  116474. */
  116475. baseExperience: WebXRExperienceHelper;
  116476. /**
  116477. * Input experience extension
  116478. */
  116479. input: WebXRInput;
  116480. /**
  116481. * Loads the controller models
  116482. */
  116483. controllerModelLoader: WebXRControllerModelLoader;
  116484. /**
  116485. * Enables laser pointer and selection
  116486. */
  116487. pointerSelection: WebXRControllerPointerSelection;
  116488. /**
  116489. * Enables teleportation
  116490. */
  116491. teleportation: WebXRControllerTeleportation;
  116492. /**
  116493. * Enables ui for enetering/exiting xr
  116494. */
  116495. enterExitUI: WebXREnterExitUI;
  116496. /**
  116497. * Default output canvas xr should render to
  116498. */
  116499. outputCanvas: WebXRManagedOutputCanvas;
  116500. /**
  116501. * Creates the default xr experience
  116502. * @param scene scene
  116503. * @param options options for basic configuration
  116504. * @returns resulting WebXRDefaultExperience
  116505. */
  116506. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116507. private constructor();
  116508. /**
  116509. * DIsposes of the experience helper
  116510. */
  116511. dispose(): void;
  116512. }
  116513. }
  116514. declare module BABYLON {
  116515. /** @hidden */
  116516. export var _forceSceneHelpersToBundle: boolean;
  116517. interface Scene {
  116518. /**
  116519. * Creates a default light for the scene.
  116520. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116521. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116522. */
  116523. createDefaultLight(replace?: boolean): void;
  116524. /**
  116525. * Creates a default camera for the scene.
  116526. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116527. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116528. * @param replace has default false, when true replaces the active camera in the scene
  116529. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116530. */
  116531. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116532. /**
  116533. * Creates a default camera and a default light.
  116534. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116535. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116536. * @param replace has the default false, when true replaces the active camera/light in the scene
  116537. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116538. */
  116539. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116540. /**
  116541. * Creates a new sky box
  116542. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116543. * @param environmentTexture defines the texture to use as environment texture
  116544. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116545. * @param scale defines the overall scale of the skybox
  116546. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116547. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116548. * @returns a new mesh holding the sky box
  116549. */
  116550. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116551. /**
  116552. * Creates a new environment
  116553. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116554. * @param options defines the options you can use to configure the environment
  116555. * @returns the new EnvironmentHelper
  116556. */
  116557. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116558. /**
  116559. * Creates a new VREXperienceHelper
  116560. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116561. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116562. * @returns a new VREXperienceHelper
  116563. */
  116564. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116565. /**
  116566. * Creates a new WebXRDefaultExperience
  116567. * @see http://doc.babylonjs.com/how_to/webxr
  116568. * @param options experience options
  116569. * @returns a promise for a new WebXRDefaultExperience
  116570. */
  116571. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116572. }
  116573. }
  116574. declare module BABYLON {
  116575. /**
  116576. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116577. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116578. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116579. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116580. */
  116581. export class VideoDome extends TransformNode {
  116582. /**
  116583. * Define the video source as a Monoscopic panoramic 360 video.
  116584. */
  116585. static readonly MODE_MONOSCOPIC: number;
  116586. /**
  116587. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116588. */
  116589. static readonly MODE_TOPBOTTOM: number;
  116590. /**
  116591. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116592. */
  116593. static readonly MODE_SIDEBYSIDE: number;
  116594. private _halfDome;
  116595. private _useDirectMapping;
  116596. /**
  116597. * The video texture being displayed on the sphere
  116598. */
  116599. protected _videoTexture: VideoTexture;
  116600. /**
  116601. * Gets the video texture being displayed on the sphere
  116602. */
  116603. readonly videoTexture: VideoTexture;
  116604. /**
  116605. * The skybox material
  116606. */
  116607. protected _material: BackgroundMaterial;
  116608. /**
  116609. * The surface used for the skybox
  116610. */
  116611. protected _mesh: Mesh;
  116612. /**
  116613. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116614. */
  116615. private _halfDomeMask;
  116616. /**
  116617. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116618. * Also see the options.resolution property.
  116619. */
  116620. fovMultiplier: number;
  116621. private _videoMode;
  116622. /**
  116623. * Gets or set the current video mode for the video. It can be:
  116624. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116625. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116626. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116627. */
  116628. videoMode: number;
  116629. /**
  116630. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116631. *
  116632. */
  116633. /**
  116634. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116635. */
  116636. halfDome: boolean;
  116637. /**
  116638. * Oberserver used in Stereoscopic VR Mode.
  116639. */
  116640. private _onBeforeCameraRenderObserver;
  116641. /**
  116642. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116643. * @param name Element's name, child elements will append suffixes for their own names.
  116644. * @param urlsOrVideo defines the url(s) or the video element to use
  116645. * @param options An object containing optional or exposed sub element properties
  116646. */
  116647. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116648. resolution?: number;
  116649. clickToPlay?: boolean;
  116650. autoPlay?: boolean;
  116651. loop?: boolean;
  116652. size?: number;
  116653. poster?: string;
  116654. faceForward?: boolean;
  116655. useDirectMapping?: boolean;
  116656. halfDomeMode?: boolean;
  116657. }, scene: Scene);
  116658. private _changeVideoMode;
  116659. /**
  116660. * Releases resources associated with this node.
  116661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116663. */
  116664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116665. }
  116666. }
  116667. declare module BABYLON {
  116668. /**
  116669. * This class can be used to get instrumentation data from a Babylon engine
  116670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116671. */
  116672. export class EngineInstrumentation implements IDisposable {
  116673. /**
  116674. * Define the instrumented engine.
  116675. */
  116676. engine: Engine;
  116677. private _captureGPUFrameTime;
  116678. private _gpuFrameTimeToken;
  116679. private _gpuFrameTime;
  116680. private _captureShaderCompilationTime;
  116681. private _shaderCompilationTime;
  116682. private _onBeginFrameObserver;
  116683. private _onEndFrameObserver;
  116684. private _onBeforeShaderCompilationObserver;
  116685. private _onAfterShaderCompilationObserver;
  116686. /**
  116687. * Gets the perf counter used for GPU frame time
  116688. */
  116689. readonly gpuFrameTimeCounter: PerfCounter;
  116690. /**
  116691. * Gets the GPU frame time capture status
  116692. */
  116693. /**
  116694. * Enable or disable the GPU frame time capture
  116695. */
  116696. captureGPUFrameTime: boolean;
  116697. /**
  116698. * Gets the perf counter used for shader compilation time
  116699. */
  116700. readonly shaderCompilationTimeCounter: PerfCounter;
  116701. /**
  116702. * Gets the shader compilation time capture status
  116703. */
  116704. /**
  116705. * Enable or disable the shader compilation time capture
  116706. */
  116707. captureShaderCompilationTime: boolean;
  116708. /**
  116709. * Instantiates a new engine instrumentation.
  116710. * This class can be used to get instrumentation data from a Babylon engine
  116711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116712. * @param engine Defines the engine to instrument
  116713. */
  116714. constructor(
  116715. /**
  116716. * Define the instrumented engine.
  116717. */
  116718. engine: Engine);
  116719. /**
  116720. * Dispose and release associated resources.
  116721. */
  116722. dispose(): void;
  116723. }
  116724. }
  116725. declare module BABYLON {
  116726. /**
  116727. * This class can be used to get instrumentation data from a Babylon engine
  116728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116729. */
  116730. export class SceneInstrumentation implements IDisposable {
  116731. /**
  116732. * Defines the scene to instrument
  116733. */
  116734. scene: Scene;
  116735. private _captureActiveMeshesEvaluationTime;
  116736. private _activeMeshesEvaluationTime;
  116737. private _captureRenderTargetsRenderTime;
  116738. private _renderTargetsRenderTime;
  116739. private _captureFrameTime;
  116740. private _frameTime;
  116741. private _captureRenderTime;
  116742. private _renderTime;
  116743. private _captureInterFrameTime;
  116744. private _interFrameTime;
  116745. private _captureParticlesRenderTime;
  116746. private _particlesRenderTime;
  116747. private _captureSpritesRenderTime;
  116748. private _spritesRenderTime;
  116749. private _capturePhysicsTime;
  116750. private _physicsTime;
  116751. private _captureAnimationsTime;
  116752. private _animationsTime;
  116753. private _captureCameraRenderTime;
  116754. private _cameraRenderTime;
  116755. private _onBeforeActiveMeshesEvaluationObserver;
  116756. private _onAfterActiveMeshesEvaluationObserver;
  116757. private _onBeforeRenderTargetsRenderObserver;
  116758. private _onAfterRenderTargetsRenderObserver;
  116759. private _onAfterRenderObserver;
  116760. private _onBeforeDrawPhaseObserver;
  116761. private _onAfterDrawPhaseObserver;
  116762. private _onBeforeAnimationsObserver;
  116763. private _onBeforeParticlesRenderingObserver;
  116764. private _onAfterParticlesRenderingObserver;
  116765. private _onBeforeSpritesRenderingObserver;
  116766. private _onAfterSpritesRenderingObserver;
  116767. private _onBeforePhysicsObserver;
  116768. private _onAfterPhysicsObserver;
  116769. private _onAfterAnimationsObserver;
  116770. private _onBeforeCameraRenderObserver;
  116771. private _onAfterCameraRenderObserver;
  116772. /**
  116773. * Gets the perf counter used for active meshes evaluation time
  116774. */
  116775. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116776. /**
  116777. * Gets the active meshes evaluation time capture status
  116778. */
  116779. /**
  116780. * Enable or disable the active meshes evaluation time capture
  116781. */
  116782. captureActiveMeshesEvaluationTime: boolean;
  116783. /**
  116784. * Gets the perf counter used for render targets render time
  116785. */
  116786. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116787. /**
  116788. * Gets the render targets render time capture status
  116789. */
  116790. /**
  116791. * Enable or disable the render targets render time capture
  116792. */
  116793. captureRenderTargetsRenderTime: boolean;
  116794. /**
  116795. * Gets the perf counter used for particles render time
  116796. */
  116797. readonly particlesRenderTimeCounter: PerfCounter;
  116798. /**
  116799. * Gets the particles render time capture status
  116800. */
  116801. /**
  116802. * Enable or disable the particles render time capture
  116803. */
  116804. captureParticlesRenderTime: boolean;
  116805. /**
  116806. * Gets the perf counter used for sprites render time
  116807. */
  116808. readonly spritesRenderTimeCounter: PerfCounter;
  116809. /**
  116810. * Gets the sprites render time capture status
  116811. */
  116812. /**
  116813. * Enable or disable the sprites render time capture
  116814. */
  116815. captureSpritesRenderTime: boolean;
  116816. /**
  116817. * Gets the perf counter used for physics time
  116818. */
  116819. readonly physicsTimeCounter: PerfCounter;
  116820. /**
  116821. * Gets the physics time capture status
  116822. */
  116823. /**
  116824. * Enable or disable the physics time capture
  116825. */
  116826. capturePhysicsTime: boolean;
  116827. /**
  116828. * Gets the perf counter used for animations time
  116829. */
  116830. readonly animationsTimeCounter: PerfCounter;
  116831. /**
  116832. * Gets the animations time capture status
  116833. */
  116834. /**
  116835. * Enable or disable the animations time capture
  116836. */
  116837. captureAnimationsTime: boolean;
  116838. /**
  116839. * Gets the perf counter used for frame time capture
  116840. */
  116841. readonly frameTimeCounter: PerfCounter;
  116842. /**
  116843. * Gets the frame time capture status
  116844. */
  116845. /**
  116846. * Enable or disable the frame time capture
  116847. */
  116848. captureFrameTime: boolean;
  116849. /**
  116850. * Gets the perf counter used for inter-frames time capture
  116851. */
  116852. readonly interFrameTimeCounter: PerfCounter;
  116853. /**
  116854. * Gets the inter-frames time capture status
  116855. */
  116856. /**
  116857. * Enable or disable the inter-frames time capture
  116858. */
  116859. captureInterFrameTime: boolean;
  116860. /**
  116861. * Gets the perf counter used for render time capture
  116862. */
  116863. readonly renderTimeCounter: PerfCounter;
  116864. /**
  116865. * Gets the render time capture status
  116866. */
  116867. /**
  116868. * Enable or disable the render time capture
  116869. */
  116870. captureRenderTime: boolean;
  116871. /**
  116872. * Gets the perf counter used for camera render time capture
  116873. */
  116874. readonly cameraRenderTimeCounter: PerfCounter;
  116875. /**
  116876. * Gets the camera render time capture status
  116877. */
  116878. /**
  116879. * Enable or disable the camera render time capture
  116880. */
  116881. captureCameraRenderTime: boolean;
  116882. /**
  116883. * Gets the perf counter used for draw calls
  116884. */
  116885. readonly drawCallsCounter: PerfCounter;
  116886. /**
  116887. * Instantiates a new scene instrumentation.
  116888. * This class can be used to get instrumentation data from a Babylon engine
  116889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116890. * @param scene Defines the scene to instrument
  116891. */
  116892. constructor(
  116893. /**
  116894. * Defines the scene to instrument
  116895. */
  116896. scene: Scene);
  116897. /**
  116898. * Dispose and release associated resources.
  116899. */
  116900. dispose(): void;
  116901. }
  116902. }
  116903. declare module BABYLON {
  116904. /** @hidden */
  116905. export var glowMapGenerationPixelShader: {
  116906. name: string;
  116907. shader: string;
  116908. };
  116909. }
  116910. declare module BABYLON {
  116911. /** @hidden */
  116912. export var glowMapGenerationVertexShader: {
  116913. name: string;
  116914. shader: string;
  116915. };
  116916. }
  116917. declare module BABYLON {
  116918. /**
  116919. * Effect layer options. This helps customizing the behaviour
  116920. * of the effect layer.
  116921. */
  116922. export interface IEffectLayerOptions {
  116923. /**
  116924. * Multiplication factor apply to the canvas size to compute the render target size
  116925. * used to generated the objects (the smaller the faster).
  116926. */
  116927. mainTextureRatio: number;
  116928. /**
  116929. * Enforces a fixed size texture to ensure effect stability across devices.
  116930. */
  116931. mainTextureFixedSize?: number;
  116932. /**
  116933. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116934. */
  116935. alphaBlendingMode: number;
  116936. /**
  116937. * The camera attached to the layer.
  116938. */
  116939. camera: Nullable<Camera>;
  116940. /**
  116941. * The rendering group to draw the layer in.
  116942. */
  116943. renderingGroupId: number;
  116944. }
  116945. /**
  116946. * The effect layer Helps adding post process effect blended with the main pass.
  116947. *
  116948. * This can be for instance use to generate glow or higlight effects on the scene.
  116949. *
  116950. * The effect layer class can not be used directly and is intented to inherited from to be
  116951. * customized per effects.
  116952. */
  116953. export abstract class EffectLayer {
  116954. private _vertexBuffers;
  116955. private _indexBuffer;
  116956. private _cachedDefines;
  116957. private _effectLayerMapGenerationEffect;
  116958. private _effectLayerOptions;
  116959. private _mergeEffect;
  116960. protected _scene: Scene;
  116961. protected _engine: Engine;
  116962. protected _maxSize: number;
  116963. protected _mainTextureDesiredSize: ISize;
  116964. protected _mainTexture: RenderTargetTexture;
  116965. protected _shouldRender: boolean;
  116966. protected _postProcesses: PostProcess[];
  116967. protected _textures: BaseTexture[];
  116968. protected _emissiveTextureAndColor: {
  116969. texture: Nullable<BaseTexture>;
  116970. color: Color4;
  116971. };
  116972. /**
  116973. * The name of the layer
  116974. */
  116975. name: string;
  116976. /**
  116977. * The clear color of the texture used to generate the glow map.
  116978. */
  116979. neutralColor: Color4;
  116980. /**
  116981. * Specifies wether the highlight layer is enabled or not.
  116982. */
  116983. isEnabled: boolean;
  116984. /**
  116985. * Gets the camera attached to the layer.
  116986. */
  116987. readonly camera: Nullable<Camera>;
  116988. /**
  116989. * Gets the rendering group id the layer should render in.
  116990. */
  116991. renderingGroupId: number;
  116992. /**
  116993. * An event triggered when the effect layer has been disposed.
  116994. */
  116995. onDisposeObservable: Observable<EffectLayer>;
  116996. /**
  116997. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116998. */
  116999. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117000. /**
  117001. * An event triggered when the generated texture is being merged in the scene.
  117002. */
  117003. onBeforeComposeObservable: Observable<EffectLayer>;
  117004. /**
  117005. * An event triggered when the generated texture has been merged in the scene.
  117006. */
  117007. onAfterComposeObservable: Observable<EffectLayer>;
  117008. /**
  117009. * An event triggered when the efffect layer changes its size.
  117010. */
  117011. onSizeChangedObservable: Observable<EffectLayer>;
  117012. /** @hidden */
  117013. static _SceneComponentInitialization: (scene: Scene) => void;
  117014. /**
  117015. * Instantiates a new effect Layer and references it in the scene.
  117016. * @param name The name of the layer
  117017. * @param scene The scene to use the layer in
  117018. */
  117019. constructor(
  117020. /** The Friendly of the effect in the scene */
  117021. name: string, scene: Scene);
  117022. /**
  117023. * Get the effect name of the layer.
  117024. * @return The effect name
  117025. */
  117026. abstract getEffectName(): string;
  117027. /**
  117028. * Checks for the readiness of the element composing the layer.
  117029. * @param subMesh the mesh to check for
  117030. * @param useInstances specify wether or not to use instances to render the mesh
  117031. * @return true if ready otherwise, false
  117032. */
  117033. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117034. /**
  117035. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117036. * @returns true if the effect requires stencil during the main canvas render pass.
  117037. */
  117038. abstract needStencil(): boolean;
  117039. /**
  117040. * Create the merge effect. This is the shader use to blit the information back
  117041. * to the main canvas at the end of the scene rendering.
  117042. * @returns The effect containing the shader used to merge the effect on the main canvas
  117043. */
  117044. protected abstract _createMergeEffect(): Effect;
  117045. /**
  117046. * Creates the render target textures and post processes used in the effect layer.
  117047. */
  117048. protected abstract _createTextureAndPostProcesses(): void;
  117049. /**
  117050. * Implementation specific of rendering the generating effect on the main canvas.
  117051. * @param effect The effect used to render through
  117052. */
  117053. protected abstract _internalRender(effect: Effect): void;
  117054. /**
  117055. * Sets the required values for both the emissive texture and and the main color.
  117056. */
  117057. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117058. /**
  117059. * Free any resources and references associated to a mesh.
  117060. * Internal use
  117061. * @param mesh The mesh to free.
  117062. */
  117063. abstract _disposeMesh(mesh: Mesh): void;
  117064. /**
  117065. * Serializes this layer (Glow or Highlight for example)
  117066. * @returns a serialized layer object
  117067. */
  117068. abstract serialize?(): any;
  117069. /**
  117070. * Initializes the effect layer with the required options.
  117071. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  117072. */
  117073. protected _init(options: Partial<IEffectLayerOptions>): void;
  117074. /**
  117075. * Generates the index buffer of the full screen quad blending to the main canvas.
  117076. */
  117077. private _generateIndexBuffer;
  117078. /**
  117079. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  117080. */
  117081. private _generateVertexBuffer;
  117082. /**
  117083. * Sets the main texture desired size which is the closest power of two
  117084. * of the engine canvas size.
  117085. */
  117086. private _setMainTextureSize;
  117087. /**
  117088. * Creates the main texture for the effect layer.
  117089. */
  117090. protected _createMainTexture(): void;
  117091. /**
  117092. * Adds specific effects defines.
  117093. * @param defines The defines to add specifics to.
  117094. */
  117095. protected _addCustomEffectDefines(defines: string[]): void;
  117096. /**
  117097. * Checks for the readiness of the element composing the layer.
  117098. * @param subMesh the mesh to check for
  117099. * @param useInstances specify wether or not to use instances to render the mesh
  117100. * @param emissiveTexture the associated emissive texture used to generate the glow
  117101. * @return true if ready otherwise, false
  117102. */
  117103. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117104. /**
  117105. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117106. */
  117107. render(): void;
  117108. /**
  117109. * Determine if a given mesh will be used in the current effect.
  117110. * @param mesh mesh to test
  117111. * @returns true if the mesh will be used
  117112. */
  117113. hasMesh(mesh: AbstractMesh): boolean;
  117114. /**
  117115. * Returns true if the layer contains information to display, otherwise false.
  117116. * @returns true if the glow layer should be rendered
  117117. */
  117118. shouldRender(): boolean;
  117119. /**
  117120. * Returns true if the mesh should render, otherwise false.
  117121. * @param mesh The mesh to render
  117122. * @returns true if it should render otherwise false
  117123. */
  117124. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117125. /**
  117126. * Returns true if the mesh can be rendered, otherwise false.
  117127. * @param mesh The mesh to render
  117128. * @param material The material used on the mesh
  117129. * @returns true if it can be rendered otherwise false
  117130. */
  117131. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117132. /**
  117133. * Returns true if the mesh should render, otherwise false.
  117134. * @param mesh The mesh to render
  117135. * @returns true if it should render otherwise false
  117136. */
  117137. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117138. /**
  117139. * Renders the submesh passed in parameter to the generation map.
  117140. */
  117141. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117142. /**
  117143. * Rebuild the required buffers.
  117144. * @hidden Internal use only.
  117145. */
  117146. _rebuild(): void;
  117147. /**
  117148. * Dispose only the render target textures and post process.
  117149. */
  117150. private _disposeTextureAndPostProcesses;
  117151. /**
  117152. * Dispose the highlight layer and free resources.
  117153. */
  117154. dispose(): void;
  117155. /**
  117156. * Gets the class name of the effect layer
  117157. * @returns the string with the class name of the effect layer
  117158. */
  117159. getClassName(): string;
  117160. /**
  117161. * Creates an effect layer from parsed effect layer data
  117162. * @param parsedEffectLayer defines effect layer data
  117163. * @param scene defines the current scene
  117164. * @param rootUrl defines the root URL containing the effect layer information
  117165. * @returns a parsed effect Layer
  117166. */
  117167. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117168. }
  117169. }
  117170. declare module BABYLON {
  117171. interface AbstractScene {
  117172. /**
  117173. * The list of effect layers (highlights/glow) added to the scene
  117174. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117175. * @see http://doc.babylonjs.com/how_to/glow_layer
  117176. */
  117177. effectLayers: Array<EffectLayer>;
  117178. /**
  117179. * Removes the given effect layer from this scene.
  117180. * @param toRemove defines the effect layer to remove
  117181. * @returns the index of the removed effect layer
  117182. */
  117183. removeEffectLayer(toRemove: EffectLayer): number;
  117184. /**
  117185. * Adds the given effect layer to this scene
  117186. * @param newEffectLayer defines the effect layer to add
  117187. */
  117188. addEffectLayer(newEffectLayer: EffectLayer): void;
  117189. }
  117190. /**
  117191. * Defines the layer scene component responsible to manage any effect layers
  117192. * in a given scene.
  117193. */
  117194. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117195. /**
  117196. * The component name helpfull to identify the component in the list of scene components.
  117197. */
  117198. readonly name: string;
  117199. /**
  117200. * The scene the component belongs to.
  117201. */
  117202. scene: Scene;
  117203. private _engine;
  117204. private _renderEffects;
  117205. private _needStencil;
  117206. private _previousStencilState;
  117207. /**
  117208. * Creates a new instance of the component for the given scene
  117209. * @param scene Defines the scene to register the component in
  117210. */
  117211. constructor(scene: Scene);
  117212. /**
  117213. * Registers the component in a given scene
  117214. */
  117215. register(): void;
  117216. /**
  117217. * Rebuilds the elements related to this component in case of
  117218. * context lost for instance.
  117219. */
  117220. rebuild(): void;
  117221. /**
  117222. * Serializes the component data to the specified json object
  117223. * @param serializationObject The object to serialize to
  117224. */
  117225. serialize(serializationObject: any): void;
  117226. /**
  117227. * Adds all the elements from the container to the scene
  117228. * @param container the container holding the elements
  117229. */
  117230. addFromContainer(container: AbstractScene): void;
  117231. /**
  117232. * Removes all the elements in the container from the scene
  117233. * @param container contains the elements to remove
  117234. * @param dispose if the removed element should be disposed (default: false)
  117235. */
  117236. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117237. /**
  117238. * Disposes the component and the associated ressources.
  117239. */
  117240. dispose(): void;
  117241. private _isReadyForMesh;
  117242. private _renderMainTexture;
  117243. private _setStencil;
  117244. private _setStencilBack;
  117245. private _draw;
  117246. private _drawCamera;
  117247. private _drawRenderingGroup;
  117248. }
  117249. }
  117250. declare module BABYLON {
  117251. /** @hidden */
  117252. export var glowMapMergePixelShader: {
  117253. name: string;
  117254. shader: string;
  117255. };
  117256. }
  117257. declare module BABYLON {
  117258. /** @hidden */
  117259. export var glowMapMergeVertexShader: {
  117260. name: string;
  117261. shader: string;
  117262. };
  117263. }
  117264. declare module BABYLON {
  117265. interface AbstractScene {
  117266. /**
  117267. * Return a the first highlight layer of the scene with a given name.
  117268. * @param name The name of the highlight layer to look for.
  117269. * @return The highlight layer if found otherwise null.
  117270. */
  117271. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117272. }
  117273. /**
  117274. * Glow layer options. This helps customizing the behaviour
  117275. * of the glow layer.
  117276. */
  117277. export interface IGlowLayerOptions {
  117278. /**
  117279. * Multiplication factor apply to the canvas size to compute the render target size
  117280. * used to generated the glowing objects (the smaller the faster).
  117281. */
  117282. mainTextureRatio: number;
  117283. /**
  117284. * Enforces a fixed size texture to ensure resize independant blur.
  117285. */
  117286. mainTextureFixedSize?: number;
  117287. /**
  117288. * How big is the kernel of the blur texture.
  117289. */
  117290. blurKernelSize: number;
  117291. /**
  117292. * The camera attached to the layer.
  117293. */
  117294. camera: Nullable<Camera>;
  117295. /**
  117296. * Enable MSAA by chosing the number of samples.
  117297. */
  117298. mainTextureSamples?: number;
  117299. /**
  117300. * The rendering group to draw the layer in.
  117301. */
  117302. renderingGroupId: number;
  117303. }
  117304. /**
  117305. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117306. *
  117307. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  117308. * glowy meshes to your scene.
  117309. *
  117310. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117311. */
  117312. export class GlowLayer extends EffectLayer {
  117313. /**
  117314. * Effect Name of the layer.
  117315. */
  117316. static readonly EffectName: string;
  117317. /**
  117318. * The default blur kernel size used for the glow.
  117319. */
  117320. static DefaultBlurKernelSize: number;
  117321. /**
  117322. * The default texture size ratio used for the glow.
  117323. */
  117324. static DefaultTextureRatio: number;
  117325. /**
  117326. * Sets the kernel size of the blur.
  117327. */
  117328. /**
  117329. * Gets the kernel size of the blur.
  117330. */
  117331. blurKernelSize: number;
  117332. /**
  117333. * Sets the glow intensity.
  117334. */
  117335. /**
  117336. * Gets the glow intensity.
  117337. */
  117338. intensity: number;
  117339. private _options;
  117340. private _intensity;
  117341. private _horizontalBlurPostprocess1;
  117342. private _verticalBlurPostprocess1;
  117343. private _horizontalBlurPostprocess2;
  117344. private _verticalBlurPostprocess2;
  117345. private _blurTexture1;
  117346. private _blurTexture2;
  117347. private _postProcesses1;
  117348. private _postProcesses2;
  117349. private _includedOnlyMeshes;
  117350. private _excludedMeshes;
  117351. /**
  117352. * Callback used to let the user override the color selection on a per mesh basis
  117353. */
  117354. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117355. /**
  117356. * Callback used to let the user override the texture selection on a per mesh basis
  117357. */
  117358. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117359. /**
  117360. * Instantiates a new glow Layer and references it to the scene.
  117361. * @param name The name of the layer
  117362. * @param scene The scene to use the layer in
  117363. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117364. */
  117365. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117366. /**
  117367. * Get the effect name of the layer.
  117368. * @return The effect name
  117369. */
  117370. getEffectName(): string;
  117371. /**
  117372. * Create the merge effect. This is the shader use to blit the information back
  117373. * to the main canvas at the end of the scene rendering.
  117374. */
  117375. protected _createMergeEffect(): Effect;
  117376. /**
  117377. * Creates the render target textures and post processes used in the glow layer.
  117378. */
  117379. protected _createTextureAndPostProcesses(): void;
  117380. /**
  117381. * Checks for the readiness of the element composing the layer.
  117382. * @param subMesh the mesh to check for
  117383. * @param useInstances specify wether or not to use instances to render the mesh
  117384. * @param emissiveTexture the associated emissive texture used to generate the glow
  117385. * @return true if ready otherwise, false
  117386. */
  117387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117388. /**
  117389. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117390. */
  117391. needStencil(): boolean;
  117392. /**
  117393. * Returns true if the mesh can be rendered, otherwise false.
  117394. * @param mesh The mesh to render
  117395. * @param material The material used on the mesh
  117396. * @returns true if it can be rendered otherwise false
  117397. */
  117398. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117399. /**
  117400. * Implementation specific of rendering the generating effect on the main canvas.
  117401. * @param effect The effect used to render through
  117402. */
  117403. protected _internalRender(effect: Effect): void;
  117404. /**
  117405. * Sets the required values for both the emissive texture and and the main color.
  117406. */
  117407. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117408. /**
  117409. * Returns true if the mesh should render, otherwise false.
  117410. * @param mesh The mesh to render
  117411. * @returns true if it should render otherwise false
  117412. */
  117413. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117414. /**
  117415. * Adds specific effects defines.
  117416. * @param defines The defines to add specifics to.
  117417. */
  117418. protected _addCustomEffectDefines(defines: string[]): void;
  117419. /**
  117420. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117421. * @param mesh The mesh to exclude from the glow layer
  117422. */
  117423. addExcludedMesh(mesh: Mesh): void;
  117424. /**
  117425. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117426. * @param mesh The mesh to remove
  117427. */
  117428. removeExcludedMesh(mesh: Mesh): void;
  117429. /**
  117430. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117431. * @param mesh The mesh to include in the glow layer
  117432. */
  117433. addIncludedOnlyMesh(mesh: Mesh): void;
  117434. /**
  117435. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117436. * @param mesh The mesh to remove
  117437. */
  117438. removeIncludedOnlyMesh(mesh: Mesh): void;
  117439. /**
  117440. * Determine if a given mesh will be used in the glow layer
  117441. * @param mesh The mesh to test
  117442. * @returns true if the mesh will be highlighted by the current glow layer
  117443. */
  117444. hasMesh(mesh: AbstractMesh): boolean;
  117445. /**
  117446. * Free any resources and references associated to a mesh.
  117447. * Internal use
  117448. * @param mesh The mesh to free.
  117449. * @hidden
  117450. */
  117451. _disposeMesh(mesh: Mesh): void;
  117452. /**
  117453. * Gets the class name of the effect layer
  117454. * @returns the string with the class name of the effect layer
  117455. */
  117456. getClassName(): string;
  117457. /**
  117458. * Serializes this glow layer
  117459. * @returns a serialized glow layer object
  117460. */
  117461. serialize(): any;
  117462. /**
  117463. * Creates a Glow Layer from parsed glow layer data
  117464. * @param parsedGlowLayer defines glow layer data
  117465. * @param scene defines the current scene
  117466. * @param rootUrl defines the root URL containing the glow layer information
  117467. * @returns a parsed Glow Layer
  117468. */
  117469. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117470. }
  117471. }
  117472. declare module BABYLON {
  117473. /** @hidden */
  117474. export var glowBlurPostProcessPixelShader: {
  117475. name: string;
  117476. shader: string;
  117477. };
  117478. }
  117479. declare module BABYLON {
  117480. interface AbstractScene {
  117481. /**
  117482. * Return a the first highlight layer of the scene with a given name.
  117483. * @param name The name of the highlight layer to look for.
  117484. * @return The highlight layer if found otherwise null.
  117485. */
  117486. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117487. }
  117488. /**
  117489. * Highlight layer options. This helps customizing the behaviour
  117490. * of the highlight layer.
  117491. */
  117492. export interface IHighlightLayerOptions {
  117493. /**
  117494. * Multiplication factor apply to the canvas size to compute the render target size
  117495. * used to generated the glowing objects (the smaller the faster).
  117496. */
  117497. mainTextureRatio: number;
  117498. /**
  117499. * Enforces a fixed size texture to ensure resize independant blur.
  117500. */
  117501. mainTextureFixedSize?: number;
  117502. /**
  117503. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117504. * of the picture to blur (the smaller the faster).
  117505. */
  117506. blurTextureSizeRatio: number;
  117507. /**
  117508. * How big in texel of the blur texture is the vertical blur.
  117509. */
  117510. blurVerticalSize: number;
  117511. /**
  117512. * How big in texel of the blur texture is the horizontal blur.
  117513. */
  117514. blurHorizontalSize: number;
  117515. /**
  117516. * Alpha blending mode used to apply the blur. Default is combine.
  117517. */
  117518. alphaBlendingMode: number;
  117519. /**
  117520. * The camera attached to the layer.
  117521. */
  117522. camera: Nullable<Camera>;
  117523. /**
  117524. * Should we display highlight as a solid stroke?
  117525. */
  117526. isStroke?: boolean;
  117527. /**
  117528. * The rendering group to draw the layer in.
  117529. */
  117530. renderingGroupId: number;
  117531. }
  117532. /**
  117533. * The highlight layer Helps adding a glow effect around a mesh.
  117534. *
  117535. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  117536. * glowy meshes to your scene.
  117537. *
  117538. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117539. */
  117540. export class HighlightLayer extends EffectLayer {
  117541. name: string;
  117542. /**
  117543. * Effect Name of the highlight layer.
  117544. */
  117545. static readonly EffectName: string;
  117546. /**
  117547. * The neutral color used during the preparation of the glow effect.
  117548. * This is black by default as the blend operation is a blend operation.
  117549. */
  117550. static NeutralColor: Color4;
  117551. /**
  117552. * Stencil value used for glowing meshes.
  117553. */
  117554. static GlowingMeshStencilReference: number;
  117555. /**
  117556. * Stencil value used for the other meshes in the scene.
  117557. */
  117558. static NormalMeshStencilReference: number;
  117559. /**
  117560. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117561. */
  117562. innerGlow: boolean;
  117563. /**
  117564. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117565. */
  117566. outerGlow: boolean;
  117567. /**
  117568. * Specifies the horizontal size of the blur.
  117569. */
  117570. /**
  117571. * Gets the horizontal size of the blur.
  117572. */
  117573. blurHorizontalSize: number;
  117574. /**
  117575. * Specifies the vertical size of the blur.
  117576. */
  117577. /**
  117578. * Gets the vertical size of the blur.
  117579. */
  117580. blurVerticalSize: number;
  117581. /**
  117582. * An event triggered when the highlight layer is being blurred.
  117583. */
  117584. onBeforeBlurObservable: Observable<HighlightLayer>;
  117585. /**
  117586. * An event triggered when the highlight layer has been blurred.
  117587. */
  117588. onAfterBlurObservable: Observable<HighlightLayer>;
  117589. private _instanceGlowingMeshStencilReference;
  117590. private _options;
  117591. private _downSamplePostprocess;
  117592. private _horizontalBlurPostprocess;
  117593. private _verticalBlurPostprocess;
  117594. private _blurTexture;
  117595. private _meshes;
  117596. private _excludedMeshes;
  117597. /**
  117598. * Instantiates a new highlight Layer and references it to the scene..
  117599. * @param name The name of the layer
  117600. * @param scene The scene to use the layer in
  117601. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117602. */
  117603. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117604. /**
  117605. * Get the effect name of the layer.
  117606. * @return The effect name
  117607. */
  117608. getEffectName(): string;
  117609. /**
  117610. * Create the merge effect. This is the shader use to blit the information back
  117611. * to the main canvas at the end of the scene rendering.
  117612. */
  117613. protected _createMergeEffect(): Effect;
  117614. /**
  117615. * Creates the render target textures and post processes used in the highlight layer.
  117616. */
  117617. protected _createTextureAndPostProcesses(): void;
  117618. /**
  117619. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117620. */
  117621. needStencil(): boolean;
  117622. /**
  117623. * Checks for the readiness of the element composing the layer.
  117624. * @param subMesh the mesh to check for
  117625. * @param useInstances specify wether or not to use instances to render the mesh
  117626. * @param emissiveTexture the associated emissive texture used to generate the glow
  117627. * @return true if ready otherwise, false
  117628. */
  117629. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117630. /**
  117631. * Implementation specific of rendering the generating effect on the main canvas.
  117632. * @param effect The effect used to render through
  117633. */
  117634. protected _internalRender(effect: Effect): void;
  117635. /**
  117636. * Returns true if the layer contains information to display, otherwise false.
  117637. */
  117638. shouldRender(): boolean;
  117639. /**
  117640. * Returns true if the mesh should render, otherwise false.
  117641. * @param mesh The mesh to render
  117642. * @returns true if it should render otherwise false
  117643. */
  117644. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117645. /**
  117646. * Sets the required values for both the emissive texture and and the main color.
  117647. */
  117648. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117649. /**
  117650. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117651. * @param mesh The mesh to exclude from the highlight layer
  117652. */
  117653. addExcludedMesh(mesh: Mesh): void;
  117654. /**
  117655. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117656. * @param mesh The mesh to highlight
  117657. */
  117658. removeExcludedMesh(mesh: Mesh): void;
  117659. /**
  117660. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117661. * @param mesh mesh to test
  117662. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117663. */
  117664. hasMesh(mesh: AbstractMesh): boolean;
  117665. /**
  117666. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117667. * @param mesh The mesh to highlight
  117668. * @param color The color of the highlight
  117669. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117670. */
  117671. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117672. /**
  117673. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117674. * @param mesh The mesh to highlight
  117675. */
  117676. removeMesh(mesh: Mesh): void;
  117677. /**
  117678. * Force the stencil to the normal expected value for none glowing parts
  117679. */
  117680. private _defaultStencilReference;
  117681. /**
  117682. * Free any resources and references associated to a mesh.
  117683. * Internal use
  117684. * @param mesh The mesh to free.
  117685. * @hidden
  117686. */
  117687. _disposeMesh(mesh: Mesh): void;
  117688. /**
  117689. * Dispose the highlight layer and free resources.
  117690. */
  117691. dispose(): void;
  117692. /**
  117693. * Gets the class name of the effect layer
  117694. * @returns the string with the class name of the effect layer
  117695. */
  117696. getClassName(): string;
  117697. /**
  117698. * Serializes this Highlight layer
  117699. * @returns a serialized Highlight layer object
  117700. */
  117701. serialize(): any;
  117702. /**
  117703. * Creates a Highlight layer from parsed Highlight layer data
  117704. * @param parsedHightlightLayer defines the Highlight layer data
  117705. * @param scene defines the current scene
  117706. * @param rootUrl defines the root URL containing the Highlight layer information
  117707. * @returns a parsed Highlight layer
  117708. */
  117709. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117710. }
  117711. }
  117712. declare module BABYLON {
  117713. interface AbstractScene {
  117714. /**
  117715. * The list of layers (background and foreground) of the scene
  117716. */
  117717. layers: Array<Layer>;
  117718. }
  117719. /**
  117720. * Defines the layer scene component responsible to manage any layers
  117721. * in a given scene.
  117722. */
  117723. export class LayerSceneComponent implements ISceneComponent {
  117724. /**
  117725. * The component name helpfull to identify the component in the list of scene components.
  117726. */
  117727. readonly name: string;
  117728. /**
  117729. * The scene the component belongs to.
  117730. */
  117731. scene: Scene;
  117732. private _engine;
  117733. /**
  117734. * Creates a new instance of the component for the given scene
  117735. * @param scene Defines the scene to register the component in
  117736. */
  117737. constructor(scene: Scene);
  117738. /**
  117739. * Registers the component in a given scene
  117740. */
  117741. register(): void;
  117742. /**
  117743. * Rebuilds the elements related to this component in case of
  117744. * context lost for instance.
  117745. */
  117746. rebuild(): void;
  117747. /**
  117748. * Disposes the component and the associated ressources.
  117749. */
  117750. dispose(): void;
  117751. private _draw;
  117752. private _drawCameraPredicate;
  117753. private _drawCameraBackground;
  117754. private _drawCameraForeground;
  117755. private _drawRenderTargetPredicate;
  117756. private _drawRenderTargetBackground;
  117757. private _drawRenderTargetForeground;
  117758. /**
  117759. * Adds all the elements from the container to the scene
  117760. * @param container the container holding the elements
  117761. */
  117762. addFromContainer(container: AbstractScene): void;
  117763. /**
  117764. * Removes all the elements in the container from the scene
  117765. * @param container contains the elements to remove
  117766. * @param dispose if the removed element should be disposed (default: false)
  117767. */
  117768. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117769. }
  117770. }
  117771. declare module BABYLON {
  117772. /** @hidden */
  117773. export var layerPixelShader: {
  117774. name: string;
  117775. shader: string;
  117776. };
  117777. }
  117778. declare module BABYLON {
  117779. /** @hidden */
  117780. export var layerVertexShader: {
  117781. name: string;
  117782. shader: string;
  117783. };
  117784. }
  117785. declare module BABYLON {
  117786. /**
  117787. * This represents a full screen 2d layer.
  117788. * This can be useful to display a picture in the background of your scene for instance.
  117789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117790. */
  117791. export class Layer {
  117792. /**
  117793. * Define the name of the layer.
  117794. */
  117795. name: string;
  117796. /**
  117797. * Define the texture the layer should display.
  117798. */
  117799. texture: Nullable<Texture>;
  117800. /**
  117801. * Is the layer in background or foreground.
  117802. */
  117803. isBackground: boolean;
  117804. /**
  117805. * Define the color of the layer (instead of texture).
  117806. */
  117807. color: Color4;
  117808. /**
  117809. * Define the scale of the layer in order to zoom in out of the texture.
  117810. */
  117811. scale: Vector2;
  117812. /**
  117813. * Define an offset for the layer in order to shift the texture.
  117814. */
  117815. offset: Vector2;
  117816. /**
  117817. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117818. */
  117819. alphaBlendingMode: number;
  117820. /**
  117821. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117822. * Alpha test will not mix with the background color in case of transparency.
  117823. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117824. */
  117825. alphaTest: boolean;
  117826. /**
  117827. * Define a mask to restrict the layer to only some of the scene cameras.
  117828. */
  117829. layerMask: number;
  117830. /**
  117831. * Define the list of render target the layer is visible into.
  117832. */
  117833. renderTargetTextures: RenderTargetTexture[];
  117834. /**
  117835. * Define if the layer is only used in renderTarget or if it also
  117836. * renders in the main frame buffer of the canvas.
  117837. */
  117838. renderOnlyInRenderTargetTextures: boolean;
  117839. private _scene;
  117840. private _vertexBuffers;
  117841. private _indexBuffer;
  117842. private _effect;
  117843. private _alphaTestEffect;
  117844. /**
  117845. * An event triggered when the layer is disposed.
  117846. */
  117847. onDisposeObservable: Observable<Layer>;
  117848. private _onDisposeObserver;
  117849. /**
  117850. * Back compatibility with callback before the onDisposeObservable existed.
  117851. * The set callback will be triggered when the layer has been disposed.
  117852. */
  117853. onDispose: () => void;
  117854. /**
  117855. * An event triggered before rendering the scene
  117856. */
  117857. onBeforeRenderObservable: Observable<Layer>;
  117858. private _onBeforeRenderObserver;
  117859. /**
  117860. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117861. * The set callback will be triggered just before rendering the layer.
  117862. */
  117863. onBeforeRender: () => void;
  117864. /**
  117865. * An event triggered after rendering the scene
  117866. */
  117867. onAfterRenderObservable: Observable<Layer>;
  117868. private _onAfterRenderObserver;
  117869. /**
  117870. * Back compatibility with callback before the onAfterRenderObservable existed.
  117871. * The set callback will be triggered just after rendering the layer.
  117872. */
  117873. onAfterRender: () => void;
  117874. /**
  117875. * Instantiates a new layer.
  117876. * This represents a full screen 2d layer.
  117877. * This can be useful to display a picture in the background of your scene for instance.
  117878. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117879. * @param name Define the name of the layer in the scene
  117880. * @param imgUrl Define the url of the texture to display in the layer
  117881. * @param scene Define the scene the layer belongs to
  117882. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117883. * @param color Defines a color for the layer
  117884. */
  117885. constructor(
  117886. /**
  117887. * Define the name of the layer.
  117888. */
  117889. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117890. private _createIndexBuffer;
  117891. /** @hidden */
  117892. _rebuild(): void;
  117893. /**
  117894. * Renders the layer in the scene.
  117895. */
  117896. render(): void;
  117897. /**
  117898. * Disposes and releases the associated ressources.
  117899. */
  117900. dispose(): void;
  117901. }
  117902. }
  117903. declare module BABYLON {
  117904. /** @hidden */
  117905. export var lensFlarePixelShader: {
  117906. name: string;
  117907. shader: string;
  117908. };
  117909. }
  117910. declare module BABYLON {
  117911. /** @hidden */
  117912. export var lensFlareVertexShader: {
  117913. name: string;
  117914. shader: string;
  117915. };
  117916. }
  117917. declare module BABYLON {
  117918. /**
  117919. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117920. * It is usually composed of several `lensFlare`.
  117921. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117922. */
  117923. export class LensFlareSystem {
  117924. /**
  117925. * Define the name of the lens flare system
  117926. */
  117927. name: string;
  117928. /**
  117929. * List of lens flares used in this system.
  117930. */
  117931. lensFlares: LensFlare[];
  117932. /**
  117933. * Define a limit from the border the lens flare can be visible.
  117934. */
  117935. borderLimit: number;
  117936. /**
  117937. * Define a viewport border we do not want to see the lens flare in.
  117938. */
  117939. viewportBorder: number;
  117940. /**
  117941. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117942. */
  117943. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117944. /**
  117945. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117946. */
  117947. layerMask: number;
  117948. /**
  117949. * Define the id of the lens flare system in the scene.
  117950. * (equal to name by default)
  117951. */
  117952. id: string;
  117953. private _scene;
  117954. private _emitter;
  117955. private _vertexBuffers;
  117956. private _indexBuffer;
  117957. private _effect;
  117958. private _positionX;
  117959. private _positionY;
  117960. private _isEnabled;
  117961. /** @hidden */
  117962. static _SceneComponentInitialization: (scene: Scene) => void;
  117963. /**
  117964. * Instantiates a lens flare system.
  117965. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117966. * It is usually composed of several `lensFlare`.
  117967. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117968. * @param name Define the name of the lens flare system in the scene
  117969. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117970. * @param scene Define the scene the lens flare system belongs to
  117971. */
  117972. constructor(
  117973. /**
  117974. * Define the name of the lens flare system
  117975. */
  117976. name: string, emitter: any, scene: Scene);
  117977. /**
  117978. * Define if the lens flare system is enabled.
  117979. */
  117980. isEnabled: boolean;
  117981. /**
  117982. * Get the scene the effects belongs to.
  117983. * @returns the scene holding the lens flare system
  117984. */
  117985. getScene(): Scene;
  117986. /**
  117987. * Get the emitter of the lens flare system.
  117988. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117989. * @returns the emitter of the lens flare system
  117990. */
  117991. getEmitter(): any;
  117992. /**
  117993. * Set the emitter of the lens flare system.
  117994. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117995. * @param newEmitter Define the new emitter of the system
  117996. */
  117997. setEmitter(newEmitter: any): void;
  117998. /**
  117999. * Get the lens flare system emitter position.
  118000. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118001. * @returns the position
  118002. */
  118003. getEmitterPosition(): Vector3;
  118004. /**
  118005. * @hidden
  118006. */
  118007. computeEffectivePosition(globalViewport: Viewport): boolean;
  118008. /** @hidden */
  118009. _isVisible(): boolean;
  118010. /**
  118011. * @hidden
  118012. */
  118013. render(): boolean;
  118014. /**
  118015. * Dispose and release the lens flare with its associated resources.
  118016. */
  118017. dispose(): void;
  118018. /**
  118019. * Parse a lens flare system from a JSON repressentation
  118020. * @param parsedLensFlareSystem Define the JSON to parse
  118021. * @param scene Define the scene the parsed system should be instantiated in
  118022. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118023. * @returns the parsed system
  118024. */
  118025. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118026. /**
  118027. * Serialize the current Lens Flare System into a JSON representation.
  118028. * @returns the serialized JSON
  118029. */
  118030. serialize(): any;
  118031. }
  118032. }
  118033. declare module BABYLON {
  118034. /**
  118035. * This represents one of the lens effect in a `lensFlareSystem`.
  118036. * It controls one of the indiviual texture used in the effect.
  118037. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118038. */
  118039. export class LensFlare {
  118040. /**
  118041. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118042. */
  118043. size: number;
  118044. /**
  118045. * 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.
  118046. */
  118047. position: number;
  118048. /**
  118049. * Define the lens color.
  118050. */
  118051. color: Color3;
  118052. /**
  118053. * Define the lens texture.
  118054. */
  118055. texture: Nullable<Texture>;
  118056. /**
  118057. * Define the alpha mode to render this particular lens.
  118058. */
  118059. alphaMode: number;
  118060. private _system;
  118061. /**
  118062. * Creates a new Lens Flare.
  118063. * This represents one of the lens effect in a `lensFlareSystem`.
  118064. * It controls one of the indiviual texture used in the effect.
  118065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118066. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  118067. * @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.
  118068. * @param color Define the lens color
  118069. * @param imgUrl Define the lens texture url
  118070. * @param system Define the `lensFlareSystem` this flare is part of
  118071. * @returns The newly created Lens Flare
  118072. */
  118073. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  118074. /**
  118075. * Instantiates a new Lens Flare.
  118076. * This represents one of the lens effect in a `lensFlareSystem`.
  118077. * It controls one of the indiviual texture used in the effect.
  118078. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118079. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  118080. * @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.
  118081. * @param color Define the lens color
  118082. * @param imgUrl Define the lens texture url
  118083. * @param system Define the `lensFlareSystem` this flare is part of
  118084. */
  118085. constructor(
  118086. /**
  118087. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118088. */
  118089. size: number,
  118090. /**
  118091. * 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.
  118092. */
  118093. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118094. /**
  118095. * Dispose and release the lens flare with its associated resources.
  118096. */
  118097. dispose(): void;
  118098. }
  118099. }
  118100. declare module BABYLON {
  118101. interface AbstractScene {
  118102. /**
  118103. * The list of lens flare system added to the scene
  118104. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118105. */
  118106. lensFlareSystems: Array<LensFlareSystem>;
  118107. /**
  118108. * Removes the given lens flare system from this scene.
  118109. * @param toRemove The lens flare system to remove
  118110. * @returns The index of the removed lens flare system
  118111. */
  118112. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118113. /**
  118114. * Adds the given lens flare system to this scene
  118115. * @param newLensFlareSystem The lens flare system to add
  118116. */
  118117. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118118. /**
  118119. * Gets a lens flare system using its name
  118120. * @param name defines the name to look for
  118121. * @returns the lens flare system or null if not found
  118122. */
  118123. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118124. /**
  118125. * Gets a lens flare system using its id
  118126. * @param id defines the id to look for
  118127. * @returns the lens flare system or null if not found
  118128. */
  118129. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118130. }
  118131. /**
  118132. * Defines the lens flare scene component responsible to manage any lens flares
  118133. * in a given scene.
  118134. */
  118135. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118136. /**
  118137. * The component name helpfull to identify the component in the list of scene components.
  118138. */
  118139. readonly name: string;
  118140. /**
  118141. * The scene the component belongs to.
  118142. */
  118143. scene: Scene;
  118144. /**
  118145. * Creates a new instance of the component for the given scene
  118146. * @param scene Defines the scene to register the component in
  118147. */
  118148. constructor(scene: Scene);
  118149. /**
  118150. * Registers the component in a given scene
  118151. */
  118152. register(): void;
  118153. /**
  118154. * Rebuilds the elements related to this component in case of
  118155. * context lost for instance.
  118156. */
  118157. rebuild(): void;
  118158. /**
  118159. * Adds all the elements from the container to the scene
  118160. * @param container the container holding the elements
  118161. */
  118162. addFromContainer(container: AbstractScene): void;
  118163. /**
  118164. * Removes all the elements in the container from the scene
  118165. * @param container contains the elements to remove
  118166. * @param dispose if the removed element should be disposed (default: false)
  118167. */
  118168. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118169. /**
  118170. * Serializes the component data to the specified json object
  118171. * @param serializationObject The object to serialize to
  118172. */
  118173. serialize(serializationObject: any): void;
  118174. /**
  118175. * Disposes the component and the associated ressources.
  118176. */
  118177. dispose(): void;
  118178. private _draw;
  118179. }
  118180. }
  118181. declare module BABYLON {
  118182. /**
  118183. * Defines the shadow generator component responsible to manage any shadow generators
  118184. * in a given scene.
  118185. */
  118186. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118187. /**
  118188. * The component name helpfull to identify the component in the list of scene components.
  118189. */
  118190. readonly name: string;
  118191. /**
  118192. * The scene the component belongs to.
  118193. */
  118194. scene: Scene;
  118195. /**
  118196. * Creates a new instance of the component for the given scene
  118197. * @param scene Defines the scene to register the component in
  118198. */
  118199. constructor(scene: Scene);
  118200. /**
  118201. * Registers the component in a given scene
  118202. */
  118203. register(): void;
  118204. /**
  118205. * Rebuilds the elements related to this component in case of
  118206. * context lost for instance.
  118207. */
  118208. rebuild(): void;
  118209. /**
  118210. * Serializes the component data to the specified json object
  118211. * @param serializationObject The object to serialize to
  118212. */
  118213. serialize(serializationObject: any): void;
  118214. /**
  118215. * Adds all the elements from the container to the scene
  118216. * @param container the container holding the elements
  118217. */
  118218. addFromContainer(container: AbstractScene): void;
  118219. /**
  118220. * Removes all the elements in the container from the scene
  118221. * @param container contains the elements to remove
  118222. * @param dispose if the removed element should be disposed (default: false)
  118223. */
  118224. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118225. /**
  118226. * Rebuilds the elements related to this component in case of
  118227. * context lost for instance.
  118228. */
  118229. dispose(): void;
  118230. private _gatherRenderTargets;
  118231. }
  118232. }
  118233. declare module BABYLON {
  118234. /**
  118235. * A point light is a light defined by an unique point in world space.
  118236. * The light is emitted in every direction from this point.
  118237. * A good example of a point light is a standard light bulb.
  118238. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118239. */
  118240. export class PointLight extends ShadowLight {
  118241. private _shadowAngle;
  118242. /**
  118243. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118244. * This specifies what angle the shadow will use to be created.
  118245. *
  118246. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118247. */
  118248. /**
  118249. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118250. * This specifies what angle the shadow will use to be created.
  118251. *
  118252. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118253. */
  118254. shadowAngle: number;
  118255. /**
  118256. * Gets the direction if it has been set.
  118257. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118258. */
  118259. /**
  118260. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118261. */
  118262. direction: Vector3;
  118263. /**
  118264. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118265. * A PointLight emits the light in every direction.
  118266. * It can cast shadows.
  118267. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118268. * ```javascript
  118269. * var pointLight = new PointLight("pl", camera.position, scene);
  118270. * ```
  118271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118272. * @param name The light friendly name
  118273. * @param position The position of the point light in the scene
  118274. * @param scene The scene the lights belongs to
  118275. */
  118276. constructor(name: string, position: Vector3, scene: Scene);
  118277. /**
  118278. * Returns the string "PointLight"
  118279. * @returns the class name
  118280. */
  118281. getClassName(): string;
  118282. /**
  118283. * Returns the integer 0.
  118284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118285. */
  118286. getTypeID(): number;
  118287. /**
  118288. * Specifies wether or not the shadowmap should be a cube texture.
  118289. * @returns true if the shadowmap needs to be a cube texture.
  118290. */
  118291. needCube(): boolean;
  118292. /**
  118293. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118294. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118295. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118296. */
  118297. getShadowDirection(faceIndex?: number): Vector3;
  118298. /**
  118299. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118300. * - fov = PI / 2
  118301. * - aspect ratio : 1.0
  118302. * - z-near and far equal to the active camera minZ and maxZ.
  118303. * Returns the PointLight.
  118304. */
  118305. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118306. protected _buildUniformLayout(): void;
  118307. /**
  118308. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118309. * @param effect The effect to update
  118310. * @param lightIndex The index of the light in the effect to update
  118311. * @returns The point light
  118312. */
  118313. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118315. /**
  118316. * Prepares the list of defines specific to the light type.
  118317. * @param defines the list of defines
  118318. * @param lightIndex defines the index of the light for the effect
  118319. */
  118320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118321. }
  118322. }
  118323. declare module BABYLON {
  118324. /**
  118325. * Header information of HDR texture files.
  118326. */
  118327. export interface HDRInfo {
  118328. /**
  118329. * The height of the texture in pixels.
  118330. */
  118331. height: number;
  118332. /**
  118333. * The width of the texture in pixels.
  118334. */
  118335. width: number;
  118336. /**
  118337. * The index of the beginning of the data in the binary file.
  118338. */
  118339. dataPosition: number;
  118340. }
  118341. /**
  118342. * This groups tools to convert HDR texture to native colors array.
  118343. */
  118344. export class HDRTools {
  118345. private static Ldexp;
  118346. private static Rgbe2float;
  118347. private static readStringLine;
  118348. /**
  118349. * Reads header information from an RGBE texture stored in a native array.
  118350. * More information on this format are available here:
  118351. * https://en.wikipedia.org/wiki/RGBE_image_format
  118352. *
  118353. * @param uint8array The binary file stored in native array.
  118354. * @return The header information.
  118355. */
  118356. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118357. /**
  118358. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118359. * This RGBE texture needs to store the information as a panorama.
  118360. *
  118361. * More information on this format are available here:
  118362. * https://en.wikipedia.org/wiki/RGBE_image_format
  118363. *
  118364. * @param buffer The binary file stored in an array buffer.
  118365. * @param size The expected size of the extracted cubemap.
  118366. * @return The Cube Map information.
  118367. */
  118368. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118369. /**
  118370. * Returns the pixels data extracted from an RGBE texture.
  118371. * This pixels will be stored left to right up to down in the R G B order in one array.
  118372. *
  118373. * More information on this format are available here:
  118374. * https://en.wikipedia.org/wiki/RGBE_image_format
  118375. *
  118376. * @param uint8array The binary file stored in an array buffer.
  118377. * @param hdrInfo The header information of the file.
  118378. * @return The pixels data in RGB right to left up to down order.
  118379. */
  118380. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118381. private static RGBE_ReadPixels_RLE;
  118382. }
  118383. }
  118384. declare module BABYLON {
  118385. /**
  118386. * This represents a texture coming from an HDR input.
  118387. *
  118388. * The only supported format is currently panorama picture stored in RGBE format.
  118389. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118390. */
  118391. export class HDRCubeTexture extends BaseTexture {
  118392. private static _facesMapping;
  118393. private _generateHarmonics;
  118394. private _noMipmap;
  118395. private _textureMatrix;
  118396. private _size;
  118397. private _onLoad;
  118398. private _onError;
  118399. /**
  118400. * The texture URL.
  118401. */
  118402. url: string;
  118403. /**
  118404. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118405. */
  118406. coordinatesMode: number;
  118407. protected _isBlocking: boolean;
  118408. /**
  118409. * Sets wether or not the texture is blocking during loading.
  118410. */
  118411. /**
  118412. * Gets wether or not the texture is blocking during loading.
  118413. */
  118414. isBlocking: boolean;
  118415. protected _rotationY: number;
  118416. /**
  118417. * Sets texture matrix rotation angle around Y axis in radians.
  118418. */
  118419. /**
  118420. * Gets texture matrix rotation angle around Y axis radians.
  118421. */
  118422. rotationY: number;
  118423. /**
  118424. * Gets or sets the center of the bounding box associated with the cube texture
  118425. * It must define where the camera used to render the texture was set
  118426. */
  118427. boundingBoxPosition: Vector3;
  118428. private _boundingBoxSize;
  118429. /**
  118430. * Gets or sets the size of the bounding box associated with the cube texture
  118431. * When defined, the cubemap will switch to local mode
  118432. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118433. * @example https://www.babylonjs-playground.com/#RNASML
  118434. */
  118435. boundingBoxSize: Vector3;
  118436. /**
  118437. * Instantiates an HDRTexture from the following parameters.
  118438. *
  118439. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118440. * @param scene The scene the texture will be used in
  118441. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118442. * @param noMipmap Forces to not generate the mipmap if true
  118443. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118444. * @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)
  118445. * @param reserved Reserved flag for internal use.
  118446. */
  118447. 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>);
  118448. /**
  118449. * Get the current class name of the texture useful for serialization or dynamic coding.
  118450. * @returns "HDRCubeTexture"
  118451. */
  118452. getClassName(): string;
  118453. /**
  118454. * Occurs when the file is raw .hdr file.
  118455. */
  118456. private loadTexture;
  118457. clone(): HDRCubeTexture;
  118458. delayLoad(): void;
  118459. /**
  118460. * Get the texture reflection matrix used to rotate/transform the reflection.
  118461. * @returns the reflection matrix
  118462. */
  118463. getReflectionTextureMatrix(): Matrix;
  118464. /**
  118465. * Set the texture reflection matrix used to rotate/transform the reflection.
  118466. * @param value Define the reflection matrix to set
  118467. */
  118468. setReflectionTextureMatrix(value: Matrix): void;
  118469. /**
  118470. * Parses a JSON representation of an HDR Texture in order to create the texture
  118471. * @param parsedTexture Define the JSON representation
  118472. * @param scene Define the scene the texture should be created in
  118473. * @param rootUrl Define the root url in case we need to load relative dependencies
  118474. * @returns the newly created texture after parsing
  118475. */
  118476. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118477. serialize(): any;
  118478. }
  118479. }
  118480. declare module BABYLON {
  118481. /**
  118482. * Class used to control physics engine
  118483. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118484. */
  118485. export class PhysicsEngine implements IPhysicsEngine {
  118486. private _physicsPlugin;
  118487. /**
  118488. * Global value used to control the smallest number supported by the simulation
  118489. */
  118490. static Epsilon: number;
  118491. private _impostors;
  118492. private _joints;
  118493. /**
  118494. * Gets the gravity vector used by the simulation
  118495. */
  118496. gravity: Vector3;
  118497. /**
  118498. * Factory used to create the default physics plugin.
  118499. * @returns The default physics plugin
  118500. */
  118501. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118502. /**
  118503. * Creates a new Physics Engine
  118504. * @param gravity defines the gravity vector used by the simulation
  118505. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118506. */
  118507. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118508. /**
  118509. * Sets the gravity vector used by the simulation
  118510. * @param gravity defines the gravity vector to use
  118511. */
  118512. setGravity(gravity: Vector3): void;
  118513. /**
  118514. * Set the time step of the physics engine.
  118515. * Default is 1/60.
  118516. * To slow it down, enter 1/600 for example.
  118517. * To speed it up, 1/30
  118518. * @param newTimeStep defines the new timestep to apply to this world.
  118519. */
  118520. setTimeStep(newTimeStep?: number): void;
  118521. /**
  118522. * Get the time step of the physics engine.
  118523. * @returns the current time step
  118524. */
  118525. getTimeStep(): number;
  118526. /**
  118527. * Release all resources
  118528. */
  118529. dispose(): void;
  118530. /**
  118531. * Gets the name of the current physics plugin
  118532. * @returns the name of the plugin
  118533. */
  118534. getPhysicsPluginName(): string;
  118535. /**
  118536. * Adding a new impostor for the impostor tracking.
  118537. * This will be done by the impostor itself.
  118538. * @param impostor the impostor to add
  118539. */
  118540. addImpostor(impostor: PhysicsImpostor): void;
  118541. /**
  118542. * Remove an impostor from the engine.
  118543. * This impostor and its mesh will not longer be updated by the physics engine.
  118544. * @param impostor the impostor to remove
  118545. */
  118546. removeImpostor(impostor: PhysicsImpostor): void;
  118547. /**
  118548. * Add a joint to the physics engine
  118549. * @param mainImpostor defines the main impostor to which the joint is added.
  118550. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118551. * @param joint defines the joint that will connect both impostors.
  118552. */
  118553. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118554. /**
  118555. * Removes a joint from the simulation
  118556. * @param mainImpostor defines the impostor used with the joint
  118557. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118558. * @param joint defines the joint to remove
  118559. */
  118560. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118561. /**
  118562. * Called by the scene. No need to call it.
  118563. * @param delta defines the timespam between frames
  118564. */
  118565. _step(delta: number): void;
  118566. /**
  118567. * Gets the current plugin used to run the simulation
  118568. * @returns current plugin
  118569. */
  118570. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118571. /**
  118572. * Gets the list of physic impostors
  118573. * @returns an array of PhysicsImpostor
  118574. */
  118575. getImpostors(): Array<PhysicsImpostor>;
  118576. /**
  118577. * Gets the impostor for a physics enabled object
  118578. * @param object defines the object impersonated by the impostor
  118579. * @returns the PhysicsImpostor or null if not found
  118580. */
  118581. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118582. /**
  118583. * Gets the impostor for a physics body object
  118584. * @param body defines physics body used by the impostor
  118585. * @returns the PhysicsImpostor or null if not found
  118586. */
  118587. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118588. /**
  118589. * Does a raycast in the physics world
  118590. * @param from when should the ray start?
  118591. * @param to when should the ray end?
  118592. * @returns PhysicsRaycastResult
  118593. */
  118594. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118595. }
  118596. }
  118597. declare module BABYLON {
  118598. /** @hidden */
  118599. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118600. private _useDeltaForWorldStep;
  118601. world: any;
  118602. name: string;
  118603. private _physicsMaterials;
  118604. private _fixedTimeStep;
  118605. private _cannonRaycastResult;
  118606. private _raycastResult;
  118607. private _physicsBodysToRemoveAfterStep;
  118608. BJSCANNON: any;
  118609. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118610. setGravity(gravity: Vector3): void;
  118611. setTimeStep(timeStep: number): void;
  118612. getTimeStep(): number;
  118613. executeStep(delta: number): void;
  118614. private _removeMarkedPhysicsBodiesFromWorld;
  118615. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118616. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118617. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118618. private _processChildMeshes;
  118619. removePhysicsBody(impostor: PhysicsImpostor): void;
  118620. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118621. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118622. private _addMaterial;
  118623. private _checkWithEpsilon;
  118624. private _createShape;
  118625. private _createHeightmap;
  118626. private _minus90X;
  118627. private _plus90X;
  118628. private _tmpPosition;
  118629. private _tmpDeltaPosition;
  118630. private _tmpUnityRotation;
  118631. private _updatePhysicsBodyTransformation;
  118632. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118633. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118634. isSupported(): boolean;
  118635. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118636. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118637. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118638. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118639. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118640. getBodyMass(impostor: PhysicsImpostor): number;
  118641. getBodyFriction(impostor: PhysicsImpostor): number;
  118642. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118643. getBodyRestitution(impostor: PhysicsImpostor): number;
  118644. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118645. sleepBody(impostor: PhysicsImpostor): void;
  118646. wakeUpBody(impostor: PhysicsImpostor): void;
  118647. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118648. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118649. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118650. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118651. getRadius(impostor: PhysicsImpostor): number;
  118652. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118653. dispose(): void;
  118654. private _extendNamespace;
  118655. /**
  118656. * Does a raycast in the physics world
  118657. * @param from when should the ray start?
  118658. * @param to when should the ray end?
  118659. * @returns PhysicsRaycastResult
  118660. */
  118661. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118662. }
  118663. }
  118664. declare module BABYLON {
  118665. /** @hidden */
  118666. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118667. world: any;
  118668. name: string;
  118669. BJSOIMO: any;
  118670. private _raycastResult;
  118671. constructor(iterations?: number, oimoInjection?: any);
  118672. setGravity(gravity: Vector3): void;
  118673. setTimeStep(timeStep: number): void;
  118674. getTimeStep(): number;
  118675. private _tmpImpostorsArray;
  118676. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118677. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118678. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118679. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118680. private _tmpPositionVector;
  118681. removePhysicsBody(impostor: PhysicsImpostor): void;
  118682. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118683. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118684. isSupported(): boolean;
  118685. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118686. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118687. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118688. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118689. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118690. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118691. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118692. getBodyMass(impostor: PhysicsImpostor): number;
  118693. getBodyFriction(impostor: PhysicsImpostor): number;
  118694. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118695. getBodyRestitution(impostor: PhysicsImpostor): number;
  118696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118697. sleepBody(impostor: PhysicsImpostor): void;
  118698. wakeUpBody(impostor: PhysicsImpostor): void;
  118699. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118700. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118701. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118702. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118703. getRadius(impostor: PhysicsImpostor): number;
  118704. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118705. dispose(): void;
  118706. /**
  118707. * Does a raycast in the physics world
  118708. * @param from when should the ray start?
  118709. * @param to when should the ray end?
  118710. * @returns PhysicsRaycastResult
  118711. */
  118712. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118713. }
  118714. }
  118715. declare module BABYLON {
  118716. /**
  118717. * Class containing static functions to help procedurally build meshes
  118718. */
  118719. export class RibbonBuilder {
  118720. /**
  118721. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118722. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118723. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118724. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118725. * * 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
  118726. * * 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
  118727. * * 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
  118728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118731. * * 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
  118732. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118733. * * 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
  118734. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118736. * @param name defines the name of the mesh
  118737. * @param options defines the options used to create the mesh
  118738. * @param scene defines the hosting scene
  118739. * @returns the ribbon mesh
  118740. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118742. */
  118743. static CreateRibbon(name: string, options: {
  118744. pathArray: Vector3[][];
  118745. closeArray?: boolean;
  118746. closePath?: boolean;
  118747. offset?: number;
  118748. updatable?: boolean;
  118749. sideOrientation?: number;
  118750. frontUVs?: Vector4;
  118751. backUVs?: Vector4;
  118752. instance?: Mesh;
  118753. invertUV?: boolean;
  118754. uvs?: Vector2[];
  118755. colors?: Color4[];
  118756. }, scene?: Nullable<Scene>): Mesh;
  118757. }
  118758. }
  118759. declare module BABYLON {
  118760. /**
  118761. * Class containing static functions to help procedurally build meshes
  118762. */
  118763. export class ShapeBuilder {
  118764. /**
  118765. * 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.
  118766. * * 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.
  118767. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118768. * * 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.
  118769. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118770. * * 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
  118771. * * 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
  118772. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118777. * @param name defines the name of the mesh
  118778. * @param options defines the options used to create the mesh
  118779. * @param scene defines the hosting scene
  118780. * @returns the extruded shape mesh
  118781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118783. */
  118784. static ExtrudeShape(name: string, options: {
  118785. shape: Vector3[];
  118786. path: Vector3[];
  118787. scale?: number;
  118788. rotation?: number;
  118789. cap?: number;
  118790. updatable?: boolean;
  118791. sideOrientation?: number;
  118792. frontUVs?: Vector4;
  118793. backUVs?: Vector4;
  118794. instance?: Mesh;
  118795. invertUV?: boolean;
  118796. }, scene?: Nullable<Scene>): Mesh;
  118797. /**
  118798. * Creates an custom extruded shape mesh.
  118799. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118800. * * 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.
  118801. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118802. * * 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
  118803. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118804. * * 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
  118805. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118806. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118807. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118808. * * 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
  118809. * * 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
  118810. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118815. * @param name defines the name of the mesh
  118816. * @param options defines the options used to create the mesh
  118817. * @param scene defines the hosting scene
  118818. * @returns the custom extruded shape mesh
  118819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118820. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118822. */
  118823. static ExtrudeShapeCustom(name: string, options: {
  118824. shape: Vector3[];
  118825. path: Vector3[];
  118826. scaleFunction?: any;
  118827. rotationFunction?: any;
  118828. ribbonCloseArray?: boolean;
  118829. ribbonClosePath?: boolean;
  118830. cap?: number;
  118831. updatable?: boolean;
  118832. sideOrientation?: number;
  118833. frontUVs?: Vector4;
  118834. backUVs?: Vector4;
  118835. instance?: Mesh;
  118836. invertUV?: boolean;
  118837. }, scene?: Nullable<Scene>): Mesh;
  118838. private static _ExtrudeShapeGeneric;
  118839. }
  118840. }
  118841. declare module BABYLON {
  118842. /**
  118843. * AmmoJS Physics plugin
  118844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118845. * @see https://github.com/kripken/ammo.js/
  118846. */
  118847. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118848. private _useDeltaForWorldStep;
  118849. /**
  118850. * Reference to the Ammo library
  118851. */
  118852. bjsAMMO: any;
  118853. /**
  118854. * Created ammoJS world which physics bodies are added to
  118855. */
  118856. world: any;
  118857. /**
  118858. * Name of the plugin
  118859. */
  118860. name: string;
  118861. private _timeStep;
  118862. private _fixedTimeStep;
  118863. private _maxSteps;
  118864. private _tmpQuaternion;
  118865. private _tmpAmmoTransform;
  118866. private _tmpAmmoQuaternion;
  118867. private _tmpAmmoConcreteContactResultCallback;
  118868. private _collisionConfiguration;
  118869. private _dispatcher;
  118870. private _overlappingPairCache;
  118871. private _solver;
  118872. private _softBodySolver;
  118873. private _tmpAmmoVectorA;
  118874. private _tmpAmmoVectorB;
  118875. private _tmpAmmoVectorC;
  118876. private _tmpAmmoVectorD;
  118877. private _tmpContactCallbackResult;
  118878. private _tmpAmmoVectorRCA;
  118879. private _tmpAmmoVectorRCB;
  118880. private _raycastResult;
  118881. private static readonly DISABLE_COLLISION_FLAG;
  118882. private static readonly KINEMATIC_FLAG;
  118883. private static readonly DISABLE_DEACTIVATION_FLAG;
  118884. /**
  118885. * Initializes the ammoJS plugin
  118886. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118887. * @param ammoInjection can be used to inject your own ammo reference
  118888. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118889. */
  118890. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118891. /**
  118892. * Sets the gravity of the physics world (m/(s^2))
  118893. * @param gravity Gravity to set
  118894. */
  118895. setGravity(gravity: Vector3): void;
  118896. /**
  118897. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118898. * @param timeStep timestep to use in seconds
  118899. */
  118900. setTimeStep(timeStep: number): void;
  118901. /**
  118902. * 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)
  118903. * @param fixedTimeStep fixedTimeStep to use in seconds
  118904. */
  118905. setFixedTimeStep(fixedTimeStep: number): void;
  118906. /**
  118907. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118908. * @param maxSteps the maximum number of steps by the physics engine per frame
  118909. */
  118910. setMaxSteps(maxSteps: number): void;
  118911. /**
  118912. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118913. * @returns the current timestep in seconds
  118914. */
  118915. getTimeStep(): number;
  118916. private _isImpostorInContact;
  118917. private _isImpostorPairInContact;
  118918. private _stepSimulation;
  118919. /**
  118920. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118921. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118922. * After the step the babylon meshes are set to the position of the physics imposters
  118923. * @param delta amount of time to step forward
  118924. * @param impostors array of imposters to update before/after the step
  118925. */
  118926. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118927. /**
  118928. * Update babylon mesh to match physics world object
  118929. * @param impostor imposter to match
  118930. */
  118931. private _afterSoftStep;
  118932. /**
  118933. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118934. * @param impostor imposter to match
  118935. */
  118936. private _ropeStep;
  118937. /**
  118938. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118939. * @param impostor imposter to match
  118940. */
  118941. private _softbodyOrClothStep;
  118942. private _tmpVector;
  118943. private _tmpMatrix;
  118944. /**
  118945. * Applies an impulse on the imposter
  118946. * @param impostor imposter to apply impulse to
  118947. * @param force amount of force to be applied to the imposter
  118948. * @param contactPoint the location to apply the impulse on the imposter
  118949. */
  118950. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118951. /**
  118952. * Applies a force on the imposter
  118953. * @param impostor imposter to apply force
  118954. * @param force amount of force to be applied to the imposter
  118955. * @param contactPoint the location to apply the force on the imposter
  118956. */
  118957. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118958. /**
  118959. * Creates a physics body using the plugin
  118960. * @param impostor the imposter to create the physics body on
  118961. */
  118962. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118963. /**
  118964. * Removes the physics body from the imposter and disposes of the body's memory
  118965. * @param impostor imposter to remove the physics body from
  118966. */
  118967. removePhysicsBody(impostor: PhysicsImpostor): void;
  118968. /**
  118969. * Generates a joint
  118970. * @param impostorJoint the imposter joint to create the joint with
  118971. */
  118972. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118973. /**
  118974. * Removes a joint
  118975. * @param impostorJoint the imposter joint to remove the joint from
  118976. */
  118977. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118978. private _addMeshVerts;
  118979. /**
  118980. * Initialise the soft body vertices to match its object's (mesh) vertices
  118981. * Softbody vertices (nodes) are in world space and to match this
  118982. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118983. * @param impostor to create the softbody for
  118984. */
  118985. private _softVertexData;
  118986. /**
  118987. * Create an impostor's soft body
  118988. * @param impostor to create the softbody for
  118989. */
  118990. private _createSoftbody;
  118991. /**
  118992. * Create cloth for an impostor
  118993. * @param impostor to create the softbody for
  118994. */
  118995. private _createCloth;
  118996. /**
  118997. * Create rope for an impostor
  118998. * @param impostor to create the softbody for
  118999. */
  119000. private _createRope;
  119001. private _addHullVerts;
  119002. private _createShape;
  119003. /**
  119004. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119005. * @param impostor imposter containing the physics body and babylon object
  119006. */
  119007. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119008. /**
  119009. * Sets the babylon object's position/rotation from the physics body's position/rotation
  119010. * @param impostor imposter containing the physics body and babylon object
  119011. * @param newPosition new position
  119012. * @param newRotation new rotation
  119013. */
  119014. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119015. /**
  119016. * If this plugin is supported
  119017. * @returns true if its supported
  119018. */
  119019. isSupported(): boolean;
  119020. /**
  119021. * Sets the linear velocity of the physics body
  119022. * @param impostor imposter to set the velocity on
  119023. * @param velocity velocity to set
  119024. */
  119025. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119026. /**
  119027. * Sets the angular velocity of the physics body
  119028. * @param impostor imposter to set the velocity on
  119029. * @param velocity velocity to set
  119030. */
  119031. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119032. /**
  119033. * gets the linear velocity
  119034. * @param impostor imposter to get linear velocity from
  119035. * @returns linear velocity
  119036. */
  119037. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119038. /**
  119039. * gets the angular velocity
  119040. * @param impostor imposter to get angular velocity from
  119041. * @returns angular velocity
  119042. */
  119043. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119044. /**
  119045. * Sets the mass of physics body
  119046. * @param impostor imposter to set the mass on
  119047. * @param mass mass to set
  119048. */
  119049. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119050. /**
  119051. * Gets the mass of the physics body
  119052. * @param impostor imposter to get the mass from
  119053. * @returns mass
  119054. */
  119055. getBodyMass(impostor: PhysicsImpostor): number;
  119056. /**
  119057. * Gets friction of the impostor
  119058. * @param impostor impostor to get friction from
  119059. * @returns friction value
  119060. */
  119061. getBodyFriction(impostor: PhysicsImpostor): number;
  119062. /**
  119063. * Sets friction of the impostor
  119064. * @param impostor impostor to set friction on
  119065. * @param friction friction value
  119066. */
  119067. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119068. /**
  119069. * Gets restitution of the impostor
  119070. * @param impostor impostor to get restitution from
  119071. * @returns restitution value
  119072. */
  119073. getBodyRestitution(impostor: PhysicsImpostor): number;
  119074. /**
  119075. * Sets resitution of the impostor
  119076. * @param impostor impostor to set resitution on
  119077. * @param restitution resitution value
  119078. */
  119079. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119080. /**
  119081. * Gets pressure inside the impostor
  119082. * @param impostor impostor to get pressure from
  119083. * @returns pressure value
  119084. */
  119085. getBodyPressure(impostor: PhysicsImpostor): number;
  119086. /**
  119087. * Sets pressure inside a soft body impostor
  119088. * Cloth and rope must remain 0 pressure
  119089. * @param impostor impostor to set pressure on
  119090. * @param pressure pressure value
  119091. */
  119092. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119093. /**
  119094. * Gets stiffness of the impostor
  119095. * @param impostor impostor to get stiffness from
  119096. * @returns pressure value
  119097. */
  119098. getBodyStiffness(impostor: PhysicsImpostor): number;
  119099. /**
  119100. * Sets stiffness of the impostor
  119101. * @param impostor impostor to set stiffness on
  119102. * @param stiffness stiffness value from 0 to 1
  119103. */
  119104. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119105. /**
  119106. * Gets velocityIterations of the impostor
  119107. * @param impostor impostor to get velocity iterations from
  119108. * @returns velocityIterations value
  119109. */
  119110. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119111. /**
  119112. * Sets velocityIterations of the impostor
  119113. * @param impostor impostor to set velocity iterations on
  119114. * @param velocityIterations velocityIterations value
  119115. */
  119116. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119117. /**
  119118. * Gets positionIterations of the impostor
  119119. * @param impostor impostor to get position iterations from
  119120. * @returns positionIterations value
  119121. */
  119122. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119123. /**
  119124. * Sets positionIterations of the impostor
  119125. * @param impostor impostor to set position on
  119126. * @param positionIterations positionIterations value
  119127. */
  119128. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119129. /**
  119130. * Append an anchor to a cloth object
  119131. * @param impostor is the cloth impostor to add anchor to
  119132. * @param otherImpostor is the rigid impostor to anchor to
  119133. * @param width ratio across width from 0 to 1
  119134. * @param height ratio up height from 0 to 1
  119135. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119136. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119137. */
  119138. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119139. /**
  119140. * Append an hook to a rope object
  119141. * @param impostor is the rope impostor to add hook to
  119142. * @param otherImpostor is the rigid impostor to hook to
  119143. * @param length ratio along the rope from 0 to 1
  119144. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119145. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119146. */
  119147. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119148. /**
  119149. * Sleeps the physics body and stops it from being active
  119150. * @param impostor impostor to sleep
  119151. */
  119152. sleepBody(impostor: PhysicsImpostor): void;
  119153. /**
  119154. * Activates the physics body
  119155. * @param impostor impostor to activate
  119156. */
  119157. wakeUpBody(impostor: PhysicsImpostor): void;
  119158. /**
  119159. * Updates the distance parameters of the joint
  119160. * @param joint joint to update
  119161. * @param maxDistance maximum distance of the joint
  119162. * @param minDistance minimum distance of the joint
  119163. */
  119164. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119165. /**
  119166. * Sets a motor on the joint
  119167. * @param joint joint to set motor on
  119168. * @param speed speed of the motor
  119169. * @param maxForce maximum force of the motor
  119170. * @param motorIndex index of the motor
  119171. */
  119172. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119173. /**
  119174. * Sets the motors limit
  119175. * @param joint joint to set limit on
  119176. * @param upperLimit upper limit
  119177. * @param lowerLimit lower limit
  119178. */
  119179. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119180. /**
  119181. * Syncs the position and rotation of a mesh with the impostor
  119182. * @param mesh mesh to sync
  119183. * @param impostor impostor to update the mesh with
  119184. */
  119185. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119186. /**
  119187. * Gets the radius of the impostor
  119188. * @param impostor impostor to get radius from
  119189. * @returns the radius
  119190. */
  119191. getRadius(impostor: PhysicsImpostor): number;
  119192. /**
  119193. * Gets the box size of the impostor
  119194. * @param impostor impostor to get box size from
  119195. * @param result the resulting box size
  119196. */
  119197. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119198. /**
  119199. * Disposes of the impostor
  119200. */
  119201. dispose(): void;
  119202. /**
  119203. * Does a raycast in the physics world
  119204. * @param from when should the ray start?
  119205. * @param to when should the ray end?
  119206. * @returns PhysicsRaycastResult
  119207. */
  119208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119209. }
  119210. }
  119211. declare module BABYLON {
  119212. interface AbstractScene {
  119213. /**
  119214. * The list of reflection probes added to the scene
  119215. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119216. */
  119217. reflectionProbes: Array<ReflectionProbe>;
  119218. /**
  119219. * Removes the given reflection probe from this scene.
  119220. * @param toRemove The reflection probe to remove
  119221. * @returns The index of the removed reflection probe
  119222. */
  119223. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119224. /**
  119225. * Adds the given reflection probe to this scene.
  119226. * @param newReflectionProbe The reflection probe to add
  119227. */
  119228. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119229. }
  119230. /**
  119231. * Class used to generate realtime reflection / refraction cube textures
  119232. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119233. */
  119234. export class ReflectionProbe {
  119235. /** defines the name of the probe */
  119236. name: string;
  119237. private _scene;
  119238. private _renderTargetTexture;
  119239. private _projectionMatrix;
  119240. private _viewMatrix;
  119241. private _target;
  119242. private _add;
  119243. private _attachedMesh;
  119244. private _invertYAxis;
  119245. /** Gets or sets probe position (center of the cube map) */
  119246. position: Vector3;
  119247. /**
  119248. * Creates a new reflection probe
  119249. * @param name defines the name of the probe
  119250. * @param size defines the texture resolution (for each face)
  119251. * @param scene defines the hosting scene
  119252. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119253. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119254. */
  119255. constructor(
  119256. /** defines the name of the probe */
  119257. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119258. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119259. samples: number;
  119260. /** Gets or sets the refresh rate to use (on every frame by default) */
  119261. refreshRate: number;
  119262. /**
  119263. * Gets the hosting scene
  119264. * @returns a Scene
  119265. */
  119266. getScene(): Scene;
  119267. /** Gets the internal CubeTexture used to render to */
  119268. readonly cubeTexture: RenderTargetTexture;
  119269. /** Gets the list of meshes to render */
  119270. readonly renderList: Nullable<AbstractMesh[]>;
  119271. /**
  119272. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119273. * @param mesh defines the mesh to attach to
  119274. */
  119275. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119276. /**
  119277. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119278. * @param renderingGroupId The rendering group id corresponding to its index
  119279. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119280. */
  119281. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119282. /**
  119283. * Clean all associated resources
  119284. */
  119285. dispose(): void;
  119286. /**
  119287. * Converts the reflection probe information to a readable string for debug purpose.
  119288. * @param fullDetails Supports for multiple levels of logging within scene loading
  119289. * @returns the human readable reflection probe info
  119290. */
  119291. toString(fullDetails?: boolean): string;
  119292. /**
  119293. * Get the class name of the relfection probe.
  119294. * @returns "ReflectionProbe"
  119295. */
  119296. getClassName(): string;
  119297. /**
  119298. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119299. * @returns The JSON representation of the texture
  119300. */
  119301. serialize(): any;
  119302. /**
  119303. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119304. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119305. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119306. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119307. * @returns The parsed reflection probe if successful
  119308. */
  119309. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119310. }
  119311. }
  119312. declare module BABYLON {
  119313. /** @hidden */
  119314. export var _BabylonLoaderRegistered: boolean;
  119315. }
  119316. declare module BABYLON {
  119317. /**
  119318. * The Physically based simple base material of BJS.
  119319. *
  119320. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119321. * It is used as the base class for both the specGloss and metalRough conventions.
  119322. */
  119323. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119324. /**
  119325. * Number of Simultaneous lights allowed on the material.
  119326. */
  119327. maxSimultaneousLights: number;
  119328. /**
  119329. * If sets to true, disables all the lights affecting the material.
  119330. */
  119331. disableLighting: boolean;
  119332. /**
  119333. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119334. */
  119335. environmentTexture: BaseTexture;
  119336. /**
  119337. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119338. */
  119339. invertNormalMapX: boolean;
  119340. /**
  119341. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119342. */
  119343. invertNormalMapY: boolean;
  119344. /**
  119345. * Normal map used in the model.
  119346. */
  119347. normalTexture: BaseTexture;
  119348. /**
  119349. * Emissivie color used to self-illuminate the model.
  119350. */
  119351. emissiveColor: Color3;
  119352. /**
  119353. * Emissivie texture used to self-illuminate the model.
  119354. */
  119355. emissiveTexture: BaseTexture;
  119356. /**
  119357. * Occlusion Channel Strenght.
  119358. */
  119359. occlusionStrength: number;
  119360. /**
  119361. * Occlusion Texture of the material (adding extra occlusion effects).
  119362. */
  119363. occlusionTexture: BaseTexture;
  119364. /**
  119365. * Defines the alpha limits in alpha test mode.
  119366. */
  119367. alphaCutOff: number;
  119368. /**
  119369. * Gets the current double sided mode.
  119370. */
  119371. /**
  119372. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119373. */
  119374. doubleSided: boolean;
  119375. /**
  119376. * Stores the pre-calculated light information of a mesh in a texture.
  119377. */
  119378. lightmapTexture: BaseTexture;
  119379. /**
  119380. * If true, the light map contains occlusion information instead of lighting info.
  119381. */
  119382. useLightmapAsShadowmap: boolean;
  119383. /**
  119384. * Instantiates a new PBRMaterial instance.
  119385. *
  119386. * @param name The material name
  119387. * @param scene The scene the material will be use in.
  119388. */
  119389. constructor(name: string, scene: Scene);
  119390. getClassName(): string;
  119391. }
  119392. }
  119393. declare module BABYLON {
  119394. /**
  119395. * The PBR material of BJS following the metal roughness convention.
  119396. *
  119397. * This fits to the PBR convention in the GLTF definition:
  119398. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119399. */
  119400. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119401. /**
  119402. * The base color has two different interpretations depending on the value of metalness.
  119403. * When the material is a metal, the base color is the specific measured reflectance value
  119404. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119405. * of the material.
  119406. */
  119407. baseColor: Color3;
  119408. /**
  119409. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119410. * well as opacity information in the alpha channel.
  119411. */
  119412. baseTexture: BaseTexture;
  119413. /**
  119414. * Specifies the metallic scalar value of the material.
  119415. * Can also be used to scale the metalness values of the metallic texture.
  119416. */
  119417. metallic: number;
  119418. /**
  119419. * Specifies the roughness scalar value of the material.
  119420. * Can also be used to scale the roughness values of the metallic texture.
  119421. */
  119422. roughness: number;
  119423. /**
  119424. * Texture containing both the metallic value in the B channel and the
  119425. * roughness value in the G channel to keep better precision.
  119426. */
  119427. metallicRoughnessTexture: BaseTexture;
  119428. /**
  119429. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119430. *
  119431. * @param name The material name
  119432. * @param scene The scene the material will be use in.
  119433. */
  119434. constructor(name: string, scene: Scene);
  119435. /**
  119436. * Return the currrent class name of the material.
  119437. */
  119438. getClassName(): string;
  119439. /**
  119440. * Makes a duplicate of the current material.
  119441. * @param name - name to use for the new material.
  119442. */
  119443. clone(name: string): PBRMetallicRoughnessMaterial;
  119444. /**
  119445. * Serialize the material to a parsable JSON object.
  119446. */
  119447. serialize(): any;
  119448. /**
  119449. * Parses a JSON object correponding to the serialize function.
  119450. */
  119451. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119452. }
  119453. }
  119454. declare module BABYLON {
  119455. /**
  119456. * The PBR material of BJS following the specular glossiness convention.
  119457. *
  119458. * This fits to the PBR convention in the GLTF definition:
  119459. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119460. */
  119461. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119462. /**
  119463. * Specifies the diffuse color of the material.
  119464. */
  119465. diffuseColor: Color3;
  119466. /**
  119467. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119468. * channel.
  119469. */
  119470. diffuseTexture: BaseTexture;
  119471. /**
  119472. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119473. */
  119474. specularColor: Color3;
  119475. /**
  119476. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119477. */
  119478. glossiness: number;
  119479. /**
  119480. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119481. */
  119482. specularGlossinessTexture: BaseTexture;
  119483. /**
  119484. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119485. *
  119486. * @param name The material name
  119487. * @param scene The scene the material will be use in.
  119488. */
  119489. constructor(name: string, scene: Scene);
  119490. /**
  119491. * Return the currrent class name of the material.
  119492. */
  119493. getClassName(): string;
  119494. /**
  119495. * Makes a duplicate of the current material.
  119496. * @param name - name to use for the new material.
  119497. */
  119498. clone(name: string): PBRSpecularGlossinessMaterial;
  119499. /**
  119500. * Serialize the material to a parsable JSON object.
  119501. */
  119502. serialize(): any;
  119503. /**
  119504. * Parses a JSON object correponding to the serialize function.
  119505. */
  119506. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119507. }
  119508. }
  119509. declare module BABYLON {
  119510. /**
  119511. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119512. * It can help converting any input color in a desired output one. This can then be used to create effects
  119513. * from sepia, black and white to sixties or futuristic rendering...
  119514. *
  119515. * The only supported format is currently 3dl.
  119516. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119517. */
  119518. export class ColorGradingTexture extends BaseTexture {
  119519. /**
  119520. * The current texture matrix. (will always be identity in color grading texture)
  119521. */
  119522. private _textureMatrix;
  119523. /**
  119524. * The texture URL.
  119525. */
  119526. url: string;
  119527. /**
  119528. * Empty line regex stored for GC.
  119529. */
  119530. private static _noneEmptyLineRegex;
  119531. private _engine;
  119532. /**
  119533. * Instantiates a ColorGradingTexture from the following parameters.
  119534. *
  119535. * @param url The location of the color gradind data (currently only supporting 3dl)
  119536. * @param scene The scene the texture will be used in
  119537. */
  119538. constructor(url: string, scene: Scene);
  119539. /**
  119540. * Returns the texture matrix used in most of the material.
  119541. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119542. */
  119543. getTextureMatrix(): Matrix;
  119544. /**
  119545. * Occurs when the file being loaded is a .3dl LUT file.
  119546. */
  119547. private load3dlTexture;
  119548. /**
  119549. * Starts the loading process of the texture.
  119550. */
  119551. private loadTexture;
  119552. /**
  119553. * Clones the color gradind texture.
  119554. */
  119555. clone(): ColorGradingTexture;
  119556. /**
  119557. * Called during delayed load for textures.
  119558. */
  119559. delayLoad(): void;
  119560. /**
  119561. * Parses a color grading texture serialized by Babylon.
  119562. * @param parsedTexture The texture information being parsedTexture
  119563. * @param scene The scene to load the texture in
  119564. * @param rootUrl The root url of the data assets to load
  119565. * @return A color gradind texture
  119566. */
  119567. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119568. /**
  119569. * Serializes the LUT texture to json format.
  119570. */
  119571. serialize(): any;
  119572. }
  119573. }
  119574. declare module BABYLON {
  119575. /**
  119576. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119577. */
  119578. export class EquiRectangularCubeTexture extends BaseTexture {
  119579. /** The six faces of the cube. */
  119580. private static _FacesMapping;
  119581. private _noMipmap;
  119582. private _onLoad;
  119583. private _onError;
  119584. /** The size of the cubemap. */
  119585. private _size;
  119586. /** The buffer of the image. */
  119587. private _buffer;
  119588. /** The width of the input image. */
  119589. private _width;
  119590. /** The height of the input image. */
  119591. private _height;
  119592. /** The URL to the image. */
  119593. url: string;
  119594. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119595. coordinatesMode: number;
  119596. /**
  119597. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119598. * @param url The location of the image
  119599. * @param scene The scene the texture will be used in
  119600. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119601. * @param noMipmap Forces to not generate the mipmap if true
  119602. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119603. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119604. * @param onLoad — defines a callback called when texture is loaded
  119605. * @param onError — defines a callback called if there is an error
  119606. */
  119607. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119608. /**
  119609. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119610. */
  119611. private loadImage;
  119612. /**
  119613. * Convert the image buffer into a cubemap and create a CubeTexture.
  119614. */
  119615. private loadTexture;
  119616. /**
  119617. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119618. * @param buffer The ArrayBuffer that should be converted.
  119619. * @returns The buffer as Float32Array.
  119620. */
  119621. private getFloat32ArrayFromArrayBuffer;
  119622. /**
  119623. * Get the current class name of the texture useful for serialization or dynamic coding.
  119624. * @returns "EquiRectangularCubeTexture"
  119625. */
  119626. getClassName(): string;
  119627. /**
  119628. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119629. * @returns A clone of the current EquiRectangularCubeTexture.
  119630. */
  119631. clone(): EquiRectangularCubeTexture;
  119632. }
  119633. }
  119634. declare module BABYLON {
  119635. /**
  119636. * Based on jsTGALoader - Javascript loader for TGA file
  119637. * By Vincent Thibault
  119638. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119639. */
  119640. export class TGATools {
  119641. private static _TYPE_INDEXED;
  119642. private static _TYPE_RGB;
  119643. private static _TYPE_GREY;
  119644. private static _TYPE_RLE_INDEXED;
  119645. private static _TYPE_RLE_RGB;
  119646. private static _TYPE_RLE_GREY;
  119647. private static _ORIGIN_MASK;
  119648. private static _ORIGIN_SHIFT;
  119649. private static _ORIGIN_BL;
  119650. private static _ORIGIN_BR;
  119651. private static _ORIGIN_UL;
  119652. private static _ORIGIN_UR;
  119653. /**
  119654. * Gets the header of a TGA file
  119655. * @param data defines the TGA data
  119656. * @returns the header
  119657. */
  119658. static GetTGAHeader(data: Uint8Array): any;
  119659. /**
  119660. * Uploads TGA content to a Babylon Texture
  119661. * @hidden
  119662. */
  119663. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119664. /** @hidden */
  119665. 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;
  119666. /** @hidden */
  119667. 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;
  119668. /** @hidden */
  119669. 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;
  119670. /** @hidden */
  119671. 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;
  119672. /** @hidden */
  119673. 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;
  119674. /** @hidden */
  119675. 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;
  119676. }
  119677. }
  119678. declare module BABYLON {
  119679. /**
  119680. * Implementation of the TGA Texture Loader.
  119681. * @hidden
  119682. */
  119683. export class _TGATextureLoader implements IInternalTextureLoader {
  119684. /**
  119685. * Defines wether the loader supports cascade loading the different faces.
  119686. */
  119687. readonly supportCascades: boolean;
  119688. /**
  119689. * This returns if the loader support the current file information.
  119690. * @param extension defines the file extension of the file being loaded
  119691. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119692. * @param fallback defines the fallback internal texture if any
  119693. * @param isBase64 defines whether the texture is encoded as a base64
  119694. * @param isBuffer defines whether the texture data are stored as a buffer
  119695. * @returns true if the loader can load the specified file
  119696. */
  119697. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119698. /**
  119699. * Transform the url before loading if required.
  119700. * @param rootUrl the url of the texture
  119701. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119702. * @returns the transformed texture
  119703. */
  119704. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119705. /**
  119706. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119707. * @param rootUrl the url of the texture
  119708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119709. * @returns the fallback texture
  119710. */
  119711. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119712. /**
  119713. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119714. * @param data contains the texture data
  119715. * @param texture defines the BabylonJS internal texture
  119716. * @param createPolynomials will be true if polynomials have been requested
  119717. * @param onLoad defines the callback to trigger once the texture is ready
  119718. * @param onError defines the callback to trigger in case of error
  119719. */
  119720. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119721. /**
  119722. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119723. * @param data contains the texture data
  119724. * @param texture defines the BabylonJS internal texture
  119725. * @param callback defines the method to call once ready to upload
  119726. */
  119727. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119728. }
  119729. }
  119730. declare module BABYLON {
  119731. /**
  119732. * Info about the .basis files
  119733. */
  119734. class BasisFileInfo {
  119735. /**
  119736. * If the file has alpha
  119737. */
  119738. hasAlpha: boolean;
  119739. /**
  119740. * Info about each image of the basis file
  119741. */
  119742. images: Array<{
  119743. levels: Array<{
  119744. width: number;
  119745. height: number;
  119746. transcodedPixels: ArrayBufferView;
  119747. }>;
  119748. }>;
  119749. }
  119750. /**
  119751. * Result of transcoding a basis file
  119752. */
  119753. class TranscodeResult {
  119754. /**
  119755. * Info about the .basis file
  119756. */
  119757. fileInfo: BasisFileInfo;
  119758. /**
  119759. * Format to use when loading the file
  119760. */
  119761. format: number;
  119762. }
  119763. /**
  119764. * Configuration options for the Basis transcoder
  119765. */
  119766. export class BasisTranscodeConfiguration {
  119767. /**
  119768. * Supported compression formats used to determine the supported output format of the transcoder
  119769. */
  119770. supportedCompressionFormats?: {
  119771. /**
  119772. * etc1 compression format
  119773. */
  119774. etc1?: boolean;
  119775. /**
  119776. * s3tc compression format
  119777. */
  119778. s3tc?: boolean;
  119779. /**
  119780. * pvrtc compression format
  119781. */
  119782. pvrtc?: boolean;
  119783. /**
  119784. * etc2 compression format
  119785. */
  119786. etc2?: boolean;
  119787. };
  119788. /**
  119789. * If mipmap levels should be loaded for transcoded images (Default: true)
  119790. */
  119791. loadMipmapLevels?: boolean;
  119792. /**
  119793. * Index of a single image to load (Default: all images)
  119794. */
  119795. loadSingleImage?: number;
  119796. }
  119797. /**
  119798. * Used to load .Basis files
  119799. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119800. */
  119801. export class BasisTools {
  119802. private static _IgnoreSupportedFormats;
  119803. /**
  119804. * URL to use when loading the basis transcoder
  119805. */
  119806. static JSModuleURL: string;
  119807. /**
  119808. * URL to use when loading the wasm module for the transcoder
  119809. */
  119810. static WasmModuleURL: string;
  119811. /**
  119812. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119813. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119814. * @returns internal format corresponding to the Basis format
  119815. */
  119816. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119817. private static _WorkerPromise;
  119818. private static _Worker;
  119819. private static _actionId;
  119820. private static _CreateWorkerAsync;
  119821. /**
  119822. * Transcodes a loaded image file to compressed pixel data
  119823. * @param imageData image data to transcode
  119824. * @param config configuration options for the transcoding
  119825. * @returns a promise resulting in the transcoded image
  119826. */
  119827. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119828. /**
  119829. * Loads a texture from the transcode result
  119830. * @param texture texture load to
  119831. * @param transcodeResult the result of transcoding the basis file to load from
  119832. */
  119833. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119834. }
  119835. }
  119836. declare module BABYLON {
  119837. /**
  119838. * Loader for .basis file format
  119839. */
  119840. export class _BasisTextureLoader implements IInternalTextureLoader {
  119841. /**
  119842. * Defines whether the loader supports cascade loading the different faces.
  119843. */
  119844. readonly supportCascades: boolean;
  119845. /**
  119846. * This returns if the loader support the current file information.
  119847. * @param extension defines the file extension of the file being loaded
  119848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119849. * @param fallback defines the fallback internal texture if any
  119850. * @param isBase64 defines whether the texture is encoded as a base64
  119851. * @param isBuffer defines whether the texture data are stored as a buffer
  119852. * @returns true if the loader can load the specified file
  119853. */
  119854. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119855. /**
  119856. * Transform the url before loading if required.
  119857. * @param rootUrl the url of the texture
  119858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119859. * @returns the transformed texture
  119860. */
  119861. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119862. /**
  119863. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119864. * @param rootUrl the url of the texture
  119865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119866. * @returns the fallback texture
  119867. */
  119868. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119869. /**
  119870. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119871. * @param data contains the texture data
  119872. * @param texture defines the BabylonJS internal texture
  119873. * @param createPolynomials will be true if polynomials have been requested
  119874. * @param onLoad defines the callback to trigger once the texture is ready
  119875. * @param onError defines the callback to trigger in case of error
  119876. */
  119877. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119878. /**
  119879. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119880. * @param data contains the texture data
  119881. * @param texture defines the BabylonJS internal texture
  119882. * @param callback defines the method to call once ready to upload
  119883. */
  119884. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119885. }
  119886. }
  119887. declare module BABYLON {
  119888. /**
  119889. * 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.
  119890. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119891. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119892. */
  119893. export class CustomProceduralTexture extends ProceduralTexture {
  119894. private _animate;
  119895. private _time;
  119896. private _config;
  119897. private _texturePath;
  119898. /**
  119899. * Instantiates a new Custom Procedural Texture.
  119900. * 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.
  119901. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119902. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119903. * @param name Define the name of the texture
  119904. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119905. * @param size Define the size of the texture to create
  119906. * @param scene Define the scene the texture belongs to
  119907. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119908. * @param generateMipMaps Define if the texture should creates mip maps or not
  119909. */
  119910. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119911. private _loadJson;
  119912. /**
  119913. * Is the texture ready to be used ? (rendered at least once)
  119914. * @returns true if ready, otherwise, false.
  119915. */
  119916. isReady(): boolean;
  119917. /**
  119918. * Render the texture to its associated render target.
  119919. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119920. */
  119921. render(useCameraPostProcess?: boolean): void;
  119922. /**
  119923. * Update the list of dependant textures samplers in the shader.
  119924. */
  119925. updateTextures(): void;
  119926. /**
  119927. * Update the uniform values of the procedural texture in the shader.
  119928. */
  119929. updateShaderUniforms(): void;
  119930. /**
  119931. * Define if the texture animates or not.
  119932. */
  119933. animate: boolean;
  119934. }
  119935. }
  119936. declare module BABYLON {
  119937. /** @hidden */
  119938. export var noisePixelShader: {
  119939. name: string;
  119940. shader: string;
  119941. };
  119942. }
  119943. declare module BABYLON {
  119944. /**
  119945. * Class used to generate noise procedural textures
  119946. */
  119947. export class NoiseProceduralTexture extends ProceduralTexture {
  119948. private _time;
  119949. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119950. brightness: number;
  119951. /** Defines the number of octaves to process */
  119952. octaves: number;
  119953. /** Defines the level of persistence (0.8 by default) */
  119954. persistence: number;
  119955. /** Gets or sets animation speed factor (default is 1) */
  119956. animationSpeedFactor: number;
  119957. /**
  119958. * Creates a new NoiseProceduralTexture
  119959. * @param name defines the name fo the texture
  119960. * @param size defines the size of the texture (default is 256)
  119961. * @param scene defines the hosting scene
  119962. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119963. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119964. */
  119965. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119966. private _updateShaderUniforms;
  119967. protected _getDefines(): string;
  119968. /** Generate the current state of the procedural texture */
  119969. render(useCameraPostProcess?: boolean): void;
  119970. /**
  119971. * Serializes this noise procedural texture
  119972. * @returns a serialized noise procedural texture object
  119973. */
  119974. serialize(): any;
  119975. /**
  119976. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119977. * @param parsedTexture defines parsed texture data
  119978. * @param scene defines the current scene
  119979. * @param rootUrl defines the root URL containing noise procedural texture information
  119980. * @returns a parsed NoiseProceduralTexture
  119981. */
  119982. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119983. }
  119984. }
  119985. declare module BABYLON {
  119986. /**
  119987. * Raw cube texture where the raw buffers are passed in
  119988. */
  119989. export class RawCubeTexture extends CubeTexture {
  119990. /**
  119991. * Creates a cube texture where the raw buffers are passed in.
  119992. * @param scene defines the scene the texture is attached to
  119993. * @param data defines the array of data to use to create each face
  119994. * @param size defines the size of the textures
  119995. * @param format defines the format of the data
  119996. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119997. * @param generateMipMaps defines if the engine should generate the mip levels
  119998. * @param invertY defines if data must be stored with Y axis inverted
  119999. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  120000. * @param compression defines the compression used (null by default)
  120001. */
  120002. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  120003. /**
  120004. * Updates the raw cube texture.
  120005. * @param data defines the data to store
  120006. * @param format defines the data format
  120007. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120008. * @param invertY defines if data must be stored with Y axis inverted
  120009. * @param compression defines the compression used (null by default)
  120010. * @param level defines which level of the texture to update
  120011. */
  120012. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  120013. /**
  120014. * Updates a raw cube texture with RGBD encoded data.
  120015. * @param data defines the array of data [mipmap][face] to use to create each face
  120016. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  120017. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120018. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120019. * @returns a promsie that resolves when the operation is complete
  120020. */
  120021. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120022. /**
  120023. * Clones the raw cube texture.
  120024. * @return a new cube texture
  120025. */
  120026. clone(): CubeTexture;
  120027. /** @hidden */
  120028. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120029. }
  120030. }
  120031. declare module BABYLON {
  120032. /**
  120033. * Class used to store 3D textures containing user data
  120034. */
  120035. export class RawTexture3D extends Texture {
  120036. /** Gets or sets the texture format to use */
  120037. format: number;
  120038. private _engine;
  120039. /**
  120040. * Create a new RawTexture3D
  120041. * @param data defines the data of the texture
  120042. * @param width defines the width of the texture
  120043. * @param height defines the height of the texture
  120044. * @param depth defines the depth of the texture
  120045. * @param format defines the texture format to use
  120046. * @param scene defines the hosting scene
  120047. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120048. * @param invertY defines if texture must be stored with Y axis inverted
  120049. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120050. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120051. */
  120052. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120053. /** Gets or sets the texture format to use */
  120054. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120055. /**
  120056. * Update the texture with new data
  120057. * @param data defines the data to store in the texture
  120058. */
  120059. update(data: ArrayBufferView): void;
  120060. }
  120061. }
  120062. declare module BABYLON {
  120063. /**
  120064. * Creates a refraction texture used by refraction channel of the standard material.
  120065. * It is like a mirror but to see through a material.
  120066. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120067. */
  120068. export class RefractionTexture extends RenderTargetTexture {
  120069. /**
  120070. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  120071. * 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.
  120072. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120073. */
  120074. refractionPlane: Plane;
  120075. /**
  120076. * Define how deep under the surface we should see.
  120077. */
  120078. depth: number;
  120079. /**
  120080. * Creates a refraction texture used by refraction channel of the standard material.
  120081. * It is like a mirror but to see through a material.
  120082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120083. * @param name Define the texture name
  120084. * @param size Define the size of the underlying texture
  120085. * @param scene Define the scene the refraction belongs to
  120086. * @param generateMipMaps Define if we need to generate mips level for the refraction
  120087. */
  120088. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  120089. /**
  120090. * Clone the refraction texture.
  120091. * @returns the cloned texture
  120092. */
  120093. clone(): RefractionTexture;
  120094. /**
  120095. * Serialize the texture to a JSON representation you could use in Parse later on
  120096. * @returns the serialized JSON representation
  120097. */
  120098. serialize(): any;
  120099. }
  120100. }
  120101. declare module BABYLON {
  120102. /**
  120103. * Defines the options related to the creation of an HtmlElementTexture
  120104. */
  120105. export interface IHtmlElementTextureOptions {
  120106. /**
  120107. * Defines wether mip maps should be created or not.
  120108. */
  120109. generateMipMaps?: boolean;
  120110. /**
  120111. * Defines the sampling mode of the texture.
  120112. */
  120113. samplingMode?: number;
  120114. /**
  120115. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120116. */
  120117. engine: Nullable<ThinEngine>;
  120118. /**
  120119. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120120. */
  120121. scene: Nullable<Scene>;
  120122. }
  120123. /**
  120124. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120125. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120126. * is automatically managed.
  120127. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120128. * in your application.
  120129. *
  120130. * As the update is not automatic, you need to call them manually.
  120131. */
  120132. export class HtmlElementTexture extends BaseTexture {
  120133. /**
  120134. * The texture URL.
  120135. */
  120136. element: HTMLVideoElement | HTMLCanvasElement;
  120137. private static readonly DefaultOptions;
  120138. private _textureMatrix;
  120139. private _engine;
  120140. private _isVideo;
  120141. private _generateMipMaps;
  120142. private _samplingMode;
  120143. /**
  120144. * Instantiates a HtmlElementTexture from the following parameters.
  120145. *
  120146. * @param name Defines the name of the texture
  120147. * @param element Defines the video or canvas the texture is filled with
  120148. * @param options Defines the other none mandatory texture creation options
  120149. */
  120150. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120151. private _createInternalTexture;
  120152. /**
  120153. * Returns the texture matrix used in most of the material.
  120154. */
  120155. getTextureMatrix(): Matrix;
  120156. /**
  120157. * Updates the content of the texture.
  120158. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120159. */
  120160. update(invertY?: Nullable<boolean>): void;
  120161. }
  120162. }
  120163. declare module BABYLON {
  120164. /**
  120165. * Enum used to define the target of a block
  120166. */
  120167. export enum NodeMaterialBlockTargets {
  120168. /** Vertex shader */
  120169. Vertex = 1,
  120170. /** Fragment shader */
  120171. Fragment = 2,
  120172. /** Neutral */
  120173. Neutral = 4,
  120174. /** Vertex and Fragment */
  120175. VertexAndFragment = 3
  120176. }
  120177. }
  120178. declare module BABYLON {
  120179. /**
  120180. * Defines the kind of connection point for node based material
  120181. */
  120182. export enum NodeMaterialBlockConnectionPointTypes {
  120183. /** Float */
  120184. Float = 1,
  120185. /** Int */
  120186. Int = 2,
  120187. /** Vector2 */
  120188. Vector2 = 4,
  120189. /** Vector3 */
  120190. Vector3 = 8,
  120191. /** Vector4 */
  120192. Vector4 = 16,
  120193. /** Color3 */
  120194. Color3 = 32,
  120195. /** Color4 */
  120196. Color4 = 64,
  120197. /** Matrix */
  120198. Matrix = 128,
  120199. /** Detect type based on connection */
  120200. AutoDetect = 1024,
  120201. /** Output type that will be defined by input type */
  120202. BasedOnInput = 2048
  120203. }
  120204. }
  120205. declare module BABYLON {
  120206. /**
  120207. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120208. */
  120209. export enum NodeMaterialBlockConnectionPointMode {
  120210. /** Value is an uniform */
  120211. Uniform = 0,
  120212. /** Value is a mesh attribute */
  120213. Attribute = 1,
  120214. /** Value is a varying between vertex and fragment shaders */
  120215. Varying = 2,
  120216. /** Mode is undefined */
  120217. Undefined = 3
  120218. }
  120219. }
  120220. declare module BABYLON {
  120221. /**
  120222. * Enum used to define system values e.g. values automatically provided by the system
  120223. */
  120224. export enum NodeMaterialSystemValues {
  120225. /** World */
  120226. World = 1,
  120227. /** View */
  120228. View = 2,
  120229. /** Projection */
  120230. Projection = 3,
  120231. /** ViewProjection */
  120232. ViewProjection = 4,
  120233. /** WorldView */
  120234. WorldView = 5,
  120235. /** WorldViewProjection */
  120236. WorldViewProjection = 6,
  120237. /** CameraPosition */
  120238. CameraPosition = 7,
  120239. /** Fog Color */
  120240. FogColor = 8,
  120241. /** Delta time */
  120242. DeltaTime = 9
  120243. }
  120244. }
  120245. declare module BABYLON {
  120246. /**
  120247. * Root class for all node material optimizers
  120248. */
  120249. export class NodeMaterialOptimizer {
  120250. /**
  120251. * Function used to optimize a NodeMaterial graph
  120252. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120253. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120254. */
  120255. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120256. }
  120257. }
  120258. declare module BABYLON {
  120259. /**
  120260. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120261. */
  120262. export class TransformBlock extends NodeMaterialBlock {
  120263. /**
  120264. * Defines the value to use to complement W value to transform it to a Vector4
  120265. */
  120266. complementW: number;
  120267. /**
  120268. * Defines the value to use to complement z value to transform it to a Vector4
  120269. */
  120270. complementZ: number;
  120271. /**
  120272. * Creates a new TransformBlock
  120273. * @param name defines the block name
  120274. */
  120275. constructor(name: string);
  120276. /**
  120277. * Gets the current class name
  120278. * @returns the class name
  120279. */
  120280. getClassName(): string;
  120281. /**
  120282. * Gets the vector input
  120283. */
  120284. readonly vector: NodeMaterialConnectionPoint;
  120285. /**
  120286. * Gets the output component
  120287. */
  120288. readonly output: NodeMaterialConnectionPoint;
  120289. /**
  120290. * Gets the matrix transform input
  120291. */
  120292. readonly transform: NodeMaterialConnectionPoint;
  120293. protected _buildBlock(state: NodeMaterialBuildState): this;
  120294. serialize(): any;
  120295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120296. protected _dumpPropertiesCode(): string;
  120297. }
  120298. }
  120299. declare module BABYLON {
  120300. /**
  120301. * Block used to output the vertex position
  120302. */
  120303. export class VertexOutputBlock extends NodeMaterialBlock {
  120304. /**
  120305. * Creates a new VertexOutputBlock
  120306. * @param name defines the block name
  120307. */
  120308. constructor(name: string);
  120309. /**
  120310. * Gets the current class name
  120311. * @returns the class name
  120312. */
  120313. getClassName(): string;
  120314. /**
  120315. * Gets the vector input component
  120316. */
  120317. readonly vector: NodeMaterialConnectionPoint;
  120318. protected _buildBlock(state: NodeMaterialBuildState): this;
  120319. }
  120320. }
  120321. declare module BABYLON {
  120322. /**
  120323. * Block used to output the final color
  120324. */
  120325. export class FragmentOutputBlock extends NodeMaterialBlock {
  120326. /**
  120327. * Create a new FragmentOutputBlock
  120328. * @param name defines the block name
  120329. */
  120330. constructor(name: string);
  120331. /**
  120332. * Gets the current class name
  120333. * @returns the class name
  120334. */
  120335. getClassName(): string;
  120336. /**
  120337. * Gets the rgba input component
  120338. */
  120339. readonly rgba: NodeMaterialConnectionPoint;
  120340. /**
  120341. * Gets the rgb input component
  120342. */
  120343. readonly rgb: NodeMaterialConnectionPoint;
  120344. /**
  120345. * Gets the a input component
  120346. */
  120347. readonly a: NodeMaterialConnectionPoint;
  120348. protected _buildBlock(state: NodeMaterialBuildState): this;
  120349. }
  120350. }
  120351. declare module BABYLON {
  120352. /**
  120353. * Block used to read a reflection texture from a sampler
  120354. */
  120355. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120356. private _define3DName;
  120357. private _defineCubicName;
  120358. private _defineExplicitName;
  120359. private _defineProjectionName;
  120360. private _defineLocalCubicName;
  120361. private _defineSphericalName;
  120362. private _definePlanarName;
  120363. private _defineEquirectangularName;
  120364. private _defineMirroredEquirectangularFixedName;
  120365. private _defineEquirectangularFixedName;
  120366. private _defineSkyboxName;
  120367. private _cubeSamplerName;
  120368. private _2DSamplerName;
  120369. private _positionUVWName;
  120370. private _directionWName;
  120371. private _reflectionCoordsName;
  120372. private _reflection2DCoordsName;
  120373. private _reflectionColorName;
  120374. private _reflectionMatrixName;
  120375. /**
  120376. * Gets or sets the texture associated with the node
  120377. */
  120378. texture: Nullable<BaseTexture>;
  120379. /**
  120380. * Create a new TextureBlock
  120381. * @param name defines the block name
  120382. */
  120383. constructor(name: string);
  120384. /**
  120385. * Gets the current class name
  120386. * @returns the class name
  120387. */
  120388. getClassName(): string;
  120389. /**
  120390. * Gets the world position input component
  120391. */
  120392. readonly position: NodeMaterialConnectionPoint;
  120393. /**
  120394. * Gets the world position input component
  120395. */
  120396. readonly worldPosition: NodeMaterialConnectionPoint;
  120397. /**
  120398. * Gets the world normal input component
  120399. */
  120400. readonly worldNormal: NodeMaterialConnectionPoint;
  120401. /**
  120402. * Gets the world input component
  120403. */
  120404. readonly world: NodeMaterialConnectionPoint;
  120405. /**
  120406. * Gets the camera (or eye) position component
  120407. */
  120408. readonly cameraPosition: NodeMaterialConnectionPoint;
  120409. /**
  120410. * Gets the view input component
  120411. */
  120412. readonly view: NodeMaterialConnectionPoint;
  120413. /**
  120414. * Gets the rgb output component
  120415. */
  120416. readonly rgb: NodeMaterialConnectionPoint;
  120417. /**
  120418. * Gets the r output component
  120419. */
  120420. readonly r: NodeMaterialConnectionPoint;
  120421. /**
  120422. * Gets the g output component
  120423. */
  120424. readonly g: NodeMaterialConnectionPoint;
  120425. /**
  120426. * Gets the b output component
  120427. */
  120428. readonly b: NodeMaterialConnectionPoint;
  120429. autoConfigure(material: NodeMaterial): void;
  120430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120431. isReady(): boolean;
  120432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120433. private _injectVertexCode;
  120434. private _writeOutput;
  120435. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120436. serialize(): any;
  120437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120438. }
  120439. }
  120440. declare module BABYLON {
  120441. /**
  120442. * Interface used to configure the node material editor
  120443. */
  120444. export interface INodeMaterialEditorOptions {
  120445. /** Define the URl to load node editor script */
  120446. editorURL?: string;
  120447. }
  120448. /** @hidden */
  120449. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120450. /** BONES */
  120451. NUM_BONE_INFLUENCERS: number;
  120452. BonesPerMesh: number;
  120453. BONETEXTURE: boolean;
  120454. /** MORPH TARGETS */
  120455. MORPHTARGETS: boolean;
  120456. MORPHTARGETS_NORMAL: boolean;
  120457. MORPHTARGETS_TANGENT: boolean;
  120458. MORPHTARGETS_UV: boolean;
  120459. NUM_MORPH_INFLUENCERS: number;
  120460. /** IMAGE PROCESSING */
  120461. IMAGEPROCESSING: boolean;
  120462. VIGNETTE: boolean;
  120463. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120464. VIGNETTEBLENDMODEOPAQUE: boolean;
  120465. TONEMAPPING: boolean;
  120466. TONEMAPPING_ACES: boolean;
  120467. CONTRAST: boolean;
  120468. EXPOSURE: boolean;
  120469. COLORCURVES: boolean;
  120470. COLORGRADING: boolean;
  120471. COLORGRADING3D: boolean;
  120472. SAMPLER3DGREENDEPTH: boolean;
  120473. SAMPLER3DBGRMAP: boolean;
  120474. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120475. /** MISC. */
  120476. BUMPDIRECTUV: number;
  120477. constructor();
  120478. setValue(name: string, value: boolean): void;
  120479. }
  120480. /**
  120481. * Class used to configure NodeMaterial
  120482. */
  120483. export interface INodeMaterialOptions {
  120484. /**
  120485. * Defines if blocks should emit comments
  120486. */
  120487. emitComments: boolean;
  120488. }
  120489. /**
  120490. * Class used to create a node based material built by assembling shader blocks
  120491. */
  120492. export class NodeMaterial extends PushMaterial {
  120493. private static _BuildIdGenerator;
  120494. private _options;
  120495. private _vertexCompilationState;
  120496. private _fragmentCompilationState;
  120497. private _sharedData;
  120498. private _buildId;
  120499. private _buildWasSuccessful;
  120500. private _cachedWorldViewMatrix;
  120501. private _cachedWorldViewProjectionMatrix;
  120502. private _optimizers;
  120503. private _animationFrame;
  120504. /** Define the URl to load node editor script */
  120505. static EditorURL: string;
  120506. private BJSNODEMATERIALEDITOR;
  120507. /** Get the inspector from bundle or global */
  120508. private _getGlobalNodeMaterialEditor;
  120509. /**
  120510. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  120511. */
  120512. ignoreAlpha: boolean;
  120513. /**
  120514. * Defines the maximum number of lights that can be used in the material
  120515. */
  120516. maxSimultaneousLights: number;
  120517. /**
  120518. * Observable raised when the material is built
  120519. */
  120520. onBuildObservable: Observable<NodeMaterial>;
  120521. /**
  120522. * Gets or sets the root nodes of the material vertex shader
  120523. */
  120524. _vertexOutputNodes: NodeMaterialBlock[];
  120525. /**
  120526. * Gets or sets the root nodes of the material fragment (pixel) shader
  120527. */
  120528. _fragmentOutputNodes: NodeMaterialBlock[];
  120529. /** Gets or sets options to control the node material overall behavior */
  120530. options: INodeMaterialOptions;
  120531. /**
  120532. * Default configuration related to image processing available in the standard Material.
  120533. */
  120534. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120535. /**
  120536. * Gets the image processing configuration used either in this material.
  120537. */
  120538. /**
  120539. * Sets the Default image processing configuration used either in the this material.
  120540. *
  120541. * If sets to null, the scene one is in use.
  120542. */
  120543. imageProcessingConfiguration: ImageProcessingConfiguration;
  120544. /**
  120545. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120546. */
  120547. attachedBlocks: NodeMaterialBlock[];
  120548. /**
  120549. * Create a new node based material
  120550. * @param name defines the material name
  120551. * @param scene defines the hosting scene
  120552. * @param options defines creation option
  120553. */
  120554. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120555. /**
  120556. * Gets the current class name of the material e.g. "NodeMaterial"
  120557. * @returns the class name
  120558. */
  120559. getClassName(): string;
  120560. /**
  120561. * Keep track of the image processing observer to allow dispose and replace.
  120562. */
  120563. private _imageProcessingObserver;
  120564. /**
  120565. * Attaches a new image processing configuration to the Standard Material.
  120566. * @param configuration
  120567. */
  120568. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120569. /**
  120570. * Get a block by its name
  120571. * @param name defines the name of the block to retrieve
  120572. * @returns the required block or null if not found
  120573. */
  120574. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120575. /**
  120576. * Get a block by its name
  120577. * @param predicate defines the predicate used to find the good candidate
  120578. * @returns the required block or null if not found
  120579. */
  120580. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120581. /**
  120582. * Get an input block by its name
  120583. * @param predicate defines the predicate used to find the good candidate
  120584. * @returns the required input block or null if not found
  120585. */
  120586. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120587. /**
  120588. * Gets the list of input blocks attached to this material
  120589. * @returns an array of InputBlocks
  120590. */
  120591. getInputBlocks(): InputBlock[];
  120592. /**
  120593. * Adds a new optimizer to the list of optimizers
  120594. * @param optimizer defines the optimizers to add
  120595. * @returns the current material
  120596. */
  120597. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120598. /**
  120599. * Remove an optimizer from the list of optimizers
  120600. * @param optimizer defines the optimizers to remove
  120601. * @returns the current material
  120602. */
  120603. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120604. /**
  120605. * Add a new block to the list of output nodes
  120606. * @param node defines the node to add
  120607. * @returns the current material
  120608. */
  120609. addOutputNode(node: NodeMaterialBlock): this;
  120610. /**
  120611. * Remove a block from the list of root nodes
  120612. * @param node defines the node to remove
  120613. * @returns the current material
  120614. */
  120615. removeOutputNode(node: NodeMaterialBlock): this;
  120616. private _addVertexOutputNode;
  120617. private _removeVertexOutputNode;
  120618. private _addFragmentOutputNode;
  120619. private _removeFragmentOutputNode;
  120620. /**
  120621. * Specifies if the material will require alpha blending
  120622. * @returns a boolean specifying if alpha blending is needed
  120623. */
  120624. needAlphaBlending(): boolean;
  120625. /**
  120626. * Specifies if this material should be rendered in alpha test mode
  120627. * @returns a boolean specifying if an alpha test is needed.
  120628. */
  120629. needAlphaTesting(): boolean;
  120630. private _initializeBlock;
  120631. private _resetDualBlocks;
  120632. /**
  120633. * Build the material and generates the inner effect
  120634. * @param verbose defines if the build should log activity
  120635. */
  120636. build(verbose?: boolean): void;
  120637. /**
  120638. * Runs an otpimization phase to try to improve the shader code
  120639. */
  120640. optimize(): void;
  120641. private _prepareDefinesForAttributes;
  120642. /**
  120643. * Get if the submesh is ready to be used and all its information available.
  120644. * Child classes can use it to update shaders
  120645. * @param mesh defines the mesh to check
  120646. * @param subMesh defines which submesh to check
  120647. * @param useInstances specifies that instances should be used
  120648. * @returns a boolean indicating that the submesh is ready or not
  120649. */
  120650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120651. /**
  120652. * Get a string representing the shaders built by the current node graph
  120653. */
  120654. readonly compiledShaders: string;
  120655. /**
  120656. * Binds the world matrix to the material
  120657. * @param world defines the world transformation matrix
  120658. */
  120659. bindOnlyWorldMatrix(world: Matrix): void;
  120660. /**
  120661. * Binds the submesh to this material by preparing the effect and shader to draw
  120662. * @param world defines the world transformation matrix
  120663. * @param mesh defines the mesh containing the submesh
  120664. * @param subMesh defines the submesh to bind the material to
  120665. */
  120666. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120667. /**
  120668. * Gets the active textures from the material
  120669. * @returns an array of textures
  120670. */
  120671. getActiveTextures(): BaseTexture[];
  120672. /**
  120673. * Gets the list of texture blocks
  120674. * @returns an array of texture blocks
  120675. */
  120676. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120677. /**
  120678. * Specifies if the material uses a texture
  120679. * @param texture defines the texture to check against the material
  120680. * @returns a boolean specifying if the material uses the texture
  120681. */
  120682. hasTexture(texture: BaseTexture): boolean;
  120683. /**
  120684. * Disposes the material
  120685. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120686. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120687. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120688. */
  120689. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120690. /** Creates the node editor window. */
  120691. private _createNodeEditor;
  120692. /**
  120693. * Launch the node material editor
  120694. * @param config Define the configuration of the editor
  120695. * @return a promise fulfilled when the node editor is visible
  120696. */
  120697. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120698. /**
  120699. * Clear the current material
  120700. */
  120701. clear(): void;
  120702. /**
  120703. * Clear the current material and set it to a default state
  120704. */
  120705. setToDefault(): void;
  120706. /**
  120707. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120708. * @param url defines the url to load from
  120709. * @returns a promise that will fullfil when the material is fully loaded
  120710. */
  120711. loadAsync(url: string): Promise<void>;
  120712. private _gatherBlocks;
  120713. /**
  120714. * Generate a string containing the code declaration required to create an equivalent of this material
  120715. * @returns a string
  120716. */
  120717. generateCode(): string;
  120718. /**
  120719. * Serializes this material in a JSON representation
  120720. * @returns the serialized material object
  120721. */
  120722. serialize(): any;
  120723. private _restoreConnections;
  120724. /**
  120725. * Clear the current graph and load a new one from a serialization object
  120726. * @param source defines the JSON representation of the material
  120727. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120728. */
  120729. loadFromSerialization(source: any, rootUrl?: string): void;
  120730. /**
  120731. * Creates a node material from parsed material data
  120732. * @param source defines the JSON representation of the material
  120733. * @param scene defines the hosting scene
  120734. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120735. * @returns a new node material
  120736. */
  120737. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120738. /**
  120739. * Creates a new node material set to default basic configuration
  120740. * @param name defines the name of the material
  120741. * @param scene defines the hosting scene
  120742. * @returns a new NodeMaterial
  120743. */
  120744. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120745. }
  120746. }
  120747. declare module BABYLON {
  120748. /**
  120749. * Block used to read a texture from a sampler
  120750. */
  120751. export class TextureBlock extends NodeMaterialBlock {
  120752. private _defineName;
  120753. private _linearDefineName;
  120754. private _samplerName;
  120755. private _transformedUVName;
  120756. private _textureTransformName;
  120757. private _textureInfoName;
  120758. private _mainUVName;
  120759. private _mainUVDefineName;
  120760. /**
  120761. * Gets or sets the texture associated with the node
  120762. */
  120763. texture: Nullable<Texture>;
  120764. /**
  120765. * Create a new TextureBlock
  120766. * @param name defines the block name
  120767. */
  120768. constructor(name: string);
  120769. /**
  120770. * Gets the current class name
  120771. * @returns the class name
  120772. */
  120773. getClassName(): string;
  120774. /**
  120775. * Gets the uv input component
  120776. */
  120777. readonly uv: NodeMaterialConnectionPoint;
  120778. /**
  120779. * Gets the rgba output component
  120780. */
  120781. readonly rgba: NodeMaterialConnectionPoint;
  120782. /**
  120783. * Gets the rgb output component
  120784. */
  120785. readonly rgb: NodeMaterialConnectionPoint;
  120786. /**
  120787. * Gets the r output component
  120788. */
  120789. readonly r: NodeMaterialConnectionPoint;
  120790. /**
  120791. * Gets the g output component
  120792. */
  120793. readonly g: NodeMaterialConnectionPoint;
  120794. /**
  120795. * Gets the b output component
  120796. */
  120797. readonly b: NodeMaterialConnectionPoint;
  120798. /**
  120799. * Gets the a output component
  120800. */
  120801. readonly a: NodeMaterialConnectionPoint;
  120802. readonly target: NodeMaterialBlockTargets;
  120803. autoConfigure(material: NodeMaterial): void;
  120804. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120806. isReady(): boolean;
  120807. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120808. private readonly _isMixed;
  120809. private _injectVertexCode;
  120810. private _writeOutput;
  120811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120812. protected _dumpPropertiesCode(): string;
  120813. serialize(): any;
  120814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120815. }
  120816. }
  120817. declare module BABYLON {
  120818. /**
  120819. * Class used to store shared data between 2 NodeMaterialBuildState
  120820. */
  120821. export class NodeMaterialBuildStateSharedData {
  120822. /**
  120823. * Gets the list of emitted varyings
  120824. */
  120825. temps: string[];
  120826. /**
  120827. * Gets the list of emitted varyings
  120828. */
  120829. varyings: string[];
  120830. /**
  120831. * Gets the varying declaration string
  120832. */
  120833. varyingDeclaration: string;
  120834. /**
  120835. * Input blocks
  120836. */
  120837. inputBlocks: InputBlock[];
  120838. /**
  120839. * Input blocks
  120840. */
  120841. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120842. /**
  120843. * Bindable blocks (Blocks that need to set data to the effect)
  120844. */
  120845. bindableBlocks: NodeMaterialBlock[];
  120846. /**
  120847. * List of blocks that can provide a compilation fallback
  120848. */
  120849. blocksWithFallbacks: NodeMaterialBlock[];
  120850. /**
  120851. * List of blocks that can provide a define update
  120852. */
  120853. blocksWithDefines: NodeMaterialBlock[];
  120854. /**
  120855. * List of blocks that can provide a repeatable content
  120856. */
  120857. repeatableContentBlocks: NodeMaterialBlock[];
  120858. /**
  120859. * List of blocks that can provide a dynamic list of uniforms
  120860. */
  120861. dynamicUniformBlocks: NodeMaterialBlock[];
  120862. /**
  120863. * List of blocks that can block the isReady function for the material
  120864. */
  120865. blockingBlocks: NodeMaterialBlock[];
  120866. /**
  120867. * Gets the list of animated inputs
  120868. */
  120869. animatedInputs: InputBlock[];
  120870. /**
  120871. * Build Id used to avoid multiple recompilations
  120872. */
  120873. buildId: number;
  120874. /** List of emitted variables */
  120875. variableNames: {
  120876. [key: string]: number;
  120877. };
  120878. /** List of emitted defines */
  120879. defineNames: {
  120880. [key: string]: number;
  120881. };
  120882. /** Should emit comments? */
  120883. emitComments: boolean;
  120884. /** Emit build activity */
  120885. verbose: boolean;
  120886. /** Gets or sets the hosting scene */
  120887. scene: Scene;
  120888. /**
  120889. * Gets the compilation hints emitted at compilation time
  120890. */
  120891. hints: {
  120892. needWorldViewMatrix: boolean;
  120893. needWorldViewProjectionMatrix: boolean;
  120894. needAlphaBlending: boolean;
  120895. needAlphaTesting: boolean;
  120896. };
  120897. /**
  120898. * List of compilation checks
  120899. */
  120900. checks: {
  120901. emitVertex: boolean;
  120902. emitFragment: boolean;
  120903. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120904. };
  120905. /** Creates a new shared data */
  120906. constructor();
  120907. /**
  120908. * Emits console errors and exceptions if there is a failing check
  120909. */
  120910. emitErrors(): void;
  120911. }
  120912. }
  120913. declare module BABYLON {
  120914. /**
  120915. * Class used to store node based material build state
  120916. */
  120917. export class NodeMaterialBuildState {
  120918. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120919. supportUniformBuffers: boolean;
  120920. /**
  120921. * Gets the list of emitted attributes
  120922. */
  120923. attributes: string[];
  120924. /**
  120925. * Gets the list of emitted uniforms
  120926. */
  120927. uniforms: string[];
  120928. /**
  120929. * Gets the list of emitted constants
  120930. */
  120931. constants: string[];
  120932. /**
  120933. * Gets the list of emitted samplers
  120934. */
  120935. samplers: string[];
  120936. /**
  120937. * Gets the list of emitted functions
  120938. */
  120939. functions: {
  120940. [key: string]: string;
  120941. };
  120942. /**
  120943. * Gets the list of emitted extensions
  120944. */
  120945. extensions: {
  120946. [key: string]: string;
  120947. };
  120948. /**
  120949. * Gets the target of the compilation state
  120950. */
  120951. target: NodeMaterialBlockTargets;
  120952. /**
  120953. * Gets the list of emitted counters
  120954. */
  120955. counters: {
  120956. [key: string]: number;
  120957. };
  120958. /**
  120959. * Shared data between multiple NodeMaterialBuildState instances
  120960. */
  120961. sharedData: NodeMaterialBuildStateSharedData;
  120962. /** @hidden */
  120963. _vertexState: NodeMaterialBuildState;
  120964. /** @hidden */
  120965. _attributeDeclaration: string;
  120966. /** @hidden */
  120967. _uniformDeclaration: string;
  120968. /** @hidden */
  120969. _constantDeclaration: string;
  120970. /** @hidden */
  120971. _samplerDeclaration: string;
  120972. /** @hidden */
  120973. _varyingTransfer: string;
  120974. private _repeatableContentAnchorIndex;
  120975. /** @hidden */
  120976. _builtCompilationString: string;
  120977. /**
  120978. * Gets the emitted compilation strings
  120979. */
  120980. compilationString: string;
  120981. /**
  120982. * Finalize the compilation strings
  120983. * @param state defines the current compilation state
  120984. */
  120985. finalize(state: NodeMaterialBuildState): void;
  120986. /** @hidden */
  120987. readonly _repeatableContentAnchor: string;
  120988. /** @hidden */
  120989. _getFreeVariableName(prefix: string): string;
  120990. /** @hidden */
  120991. _getFreeDefineName(prefix: string): string;
  120992. /** @hidden */
  120993. _excludeVariableName(name: string): void;
  120994. /** @hidden */
  120995. _emit2DSampler(name: string): void;
  120996. /** @hidden */
  120997. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120998. /** @hidden */
  120999. _emitExtension(name: string, extension: string): void;
  121000. /** @hidden */
  121001. _emitFunction(name: string, code: string, comments: string): void;
  121002. /** @hidden */
  121003. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  121004. replaceStrings?: {
  121005. search: RegExp;
  121006. replace: string;
  121007. }[];
  121008. repeatKey?: string;
  121009. }): string;
  121010. /** @hidden */
  121011. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  121012. repeatKey?: string;
  121013. removeAttributes?: boolean;
  121014. removeUniforms?: boolean;
  121015. removeVaryings?: boolean;
  121016. removeIfDef?: boolean;
  121017. replaceStrings?: {
  121018. search: RegExp;
  121019. replace: string;
  121020. }[];
  121021. }, storeKey?: string): void;
  121022. /** @hidden */
  121023. _registerTempVariable(name: string): boolean;
  121024. /** @hidden */
  121025. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  121026. /** @hidden */
  121027. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  121028. /** @hidden */
  121029. _emitFloat(value: number): string;
  121030. }
  121031. }
  121032. declare module BABYLON {
  121033. /**
  121034. * Defines a block that can be used inside a node based material
  121035. */
  121036. export class NodeMaterialBlock {
  121037. private _buildId;
  121038. private _buildTarget;
  121039. private _target;
  121040. private _isFinalMerger;
  121041. private _isInput;
  121042. /** @hidden */
  121043. _codeVariableName: string;
  121044. /** @hidden */
  121045. _inputs: NodeMaterialConnectionPoint[];
  121046. /** @hidden */
  121047. _outputs: NodeMaterialConnectionPoint[];
  121048. /** @hidden */
  121049. _preparationId: number;
  121050. /**
  121051. * Gets or sets the name of the block
  121052. */
  121053. name: string;
  121054. /**
  121055. * Gets or sets the unique id of the node
  121056. */
  121057. uniqueId: number;
  121058. /**
  121059. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  121060. */
  121061. readonly isFinalMerger: boolean;
  121062. /**
  121063. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  121064. */
  121065. readonly isInput: boolean;
  121066. /**
  121067. * Gets or sets the build Id
  121068. */
  121069. buildId: number;
  121070. /**
  121071. * Gets or sets the target of the block
  121072. */
  121073. target: NodeMaterialBlockTargets;
  121074. /**
  121075. * Gets the list of input points
  121076. */
  121077. readonly inputs: NodeMaterialConnectionPoint[];
  121078. /** Gets the list of output points */
  121079. readonly outputs: NodeMaterialConnectionPoint[];
  121080. /**
  121081. * Find an input by its name
  121082. * @param name defines the name of the input to look for
  121083. * @returns the input or null if not found
  121084. */
  121085. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121086. /**
  121087. * Find an output by its name
  121088. * @param name defines the name of the outputto look for
  121089. * @returns the output or null if not found
  121090. */
  121091. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121092. /**
  121093. * Creates a new NodeMaterialBlock
  121094. * @param name defines the block name
  121095. * @param target defines the target of that block (Vertex by default)
  121096. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121097. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121098. */
  121099. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121100. /**
  121101. * Initialize the block and prepare the context for build
  121102. * @param state defines the state that will be used for the build
  121103. */
  121104. initialize(state: NodeMaterialBuildState): void;
  121105. /**
  121106. * Bind data to effect. Will only be called for blocks with isBindable === true
  121107. * @param effect defines the effect to bind data to
  121108. * @param nodeMaterial defines the hosting NodeMaterial
  121109. * @param mesh defines the mesh that will be rendered
  121110. */
  121111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121112. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121113. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121114. protected _writeFloat(value: number): string;
  121115. /**
  121116. * Gets the current class name e.g. "NodeMaterialBlock"
  121117. * @returns the class name
  121118. */
  121119. getClassName(): string;
  121120. /**
  121121. * Register a new input. Must be called inside a block constructor
  121122. * @param name defines the connection point name
  121123. * @param type defines the connection point type
  121124. * @param isOptional defines a boolean indicating that this input can be omitted
  121125. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121126. * @returns the current block
  121127. */
  121128. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121129. /**
  121130. * Register a new output. Must be called inside a block constructor
  121131. * @param name defines the connection point name
  121132. * @param type defines the connection point type
  121133. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121134. * @returns the current block
  121135. */
  121136. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121137. /**
  121138. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121139. * @param forOutput defines an optional connection point to check compatibility with
  121140. * @returns the first available input or null
  121141. */
  121142. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121143. /**
  121144. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121145. * @param forBlock defines an optional block to check compatibility with
  121146. * @returns the first available input or null
  121147. */
  121148. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121149. /**
  121150. * Gets the sibling of the given output
  121151. * @param current defines the current output
  121152. * @returns the next output in the list or null
  121153. */
  121154. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121155. /**
  121156. * Connect current block with another block
  121157. * @param other defines the block to connect with
  121158. * @param options define the various options to help pick the right connections
  121159. * @returns the current block
  121160. */
  121161. connectTo(other: NodeMaterialBlock, options?: {
  121162. input?: string;
  121163. output?: string;
  121164. outputSwizzle?: string;
  121165. }): this | undefined;
  121166. protected _buildBlock(state: NodeMaterialBuildState): void;
  121167. /**
  121168. * Add uniforms, samplers and uniform buffers at compilation time
  121169. * @param state defines the state to update
  121170. * @param nodeMaterial defines the node material requesting the update
  121171. * @param defines defines the material defines to update
  121172. * @param uniformBuffers defines the list of uniform buffer names
  121173. */
  121174. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121175. /**
  121176. * Add potential fallbacks if shader compilation fails
  121177. * @param mesh defines the mesh to be rendered
  121178. * @param fallbacks defines the current prioritized list of fallbacks
  121179. */
  121180. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121181. /**
  121182. * Initialize defines for shader compilation
  121183. * @param mesh defines the mesh to be rendered
  121184. * @param nodeMaterial defines the node material requesting the update
  121185. * @param defines defines the material defines to update
  121186. * @param useInstances specifies that instances should be used
  121187. */
  121188. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121189. /**
  121190. * Update defines for shader compilation
  121191. * @param mesh defines the mesh to be rendered
  121192. * @param nodeMaterial defines the node material requesting the update
  121193. * @param defines defines the material defines to update
  121194. * @param useInstances specifies that instances should be used
  121195. */
  121196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121197. /**
  121198. * Lets the block try to connect some inputs automatically
  121199. * @param material defines the hosting NodeMaterial
  121200. */
  121201. autoConfigure(material: NodeMaterial): void;
  121202. /**
  121203. * Function called when a block is declared as repeatable content generator
  121204. * @param vertexShaderState defines the current compilation state for the vertex shader
  121205. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121206. * @param mesh defines the mesh to be rendered
  121207. * @param defines defines the material defines to update
  121208. */
  121209. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121210. /**
  121211. * Checks if the block is ready
  121212. * @param mesh defines the mesh to be rendered
  121213. * @param nodeMaterial defines the node material requesting the update
  121214. * @param defines defines the material defines to update
  121215. * @param useInstances specifies that instances should be used
  121216. * @returns true if the block is ready
  121217. */
  121218. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121219. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121220. private _processBuild;
  121221. /**
  121222. * Compile the current node and generate the shader code
  121223. * @param state defines the current compilation state (uniforms, samplers, current string)
  121224. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121225. * @returns true if already built
  121226. */
  121227. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121228. protected _inputRename(name: string): string;
  121229. protected _outputRename(name: string): string;
  121230. protected _dumpPropertiesCode(): string;
  121231. /** @hidden */
  121232. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121233. /**
  121234. * Clone the current block to a new identical block
  121235. * @param scene defines the hosting scene
  121236. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121237. * @returns a copy of the current block
  121238. */
  121239. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121240. /**
  121241. * Serializes this block in a JSON representation
  121242. * @returns the serialized block object
  121243. */
  121244. serialize(): any;
  121245. /** @hidden */
  121246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121247. }
  121248. }
  121249. declare module BABYLON {
  121250. /**
  121251. * Enum defining the type of animations supported by InputBlock
  121252. */
  121253. export enum AnimatedInputBlockTypes {
  121254. /** No animation */
  121255. None = 0,
  121256. /** Time based animation. Will only work for floats */
  121257. Time = 1
  121258. }
  121259. }
  121260. declare module BABYLON {
  121261. /**
  121262. * Block used to expose an input value
  121263. */
  121264. export class InputBlock extends NodeMaterialBlock {
  121265. private _mode;
  121266. private _associatedVariableName;
  121267. private _storedValue;
  121268. private _valueCallback;
  121269. private _type;
  121270. private _animationType;
  121271. /** Gets or set a value used to limit the range of float values */
  121272. min: number;
  121273. /** Gets or set a value used to limit the range of float values */
  121274. max: number;
  121275. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121276. matrixMode: number;
  121277. /** @hidden */
  121278. _systemValue: Nullable<NodeMaterialSystemValues>;
  121279. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121280. visibleInInspector: boolean;
  121281. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121282. isConstant: boolean;
  121283. /**
  121284. * Gets or sets the connection point type (default is float)
  121285. */
  121286. readonly type: NodeMaterialBlockConnectionPointTypes;
  121287. /**
  121288. * Creates a new InputBlock
  121289. * @param name defines the block name
  121290. * @param target defines the target of that block (Vertex by default)
  121291. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121292. */
  121293. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121294. /**
  121295. * Gets the output component
  121296. */
  121297. readonly output: NodeMaterialConnectionPoint;
  121298. /**
  121299. * Set the source of this connection point to a vertex attribute
  121300. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121301. * @returns the current connection point
  121302. */
  121303. setAsAttribute(attributeName?: string): InputBlock;
  121304. /**
  121305. * Set the source of this connection point to a system value
  121306. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121307. * @returns the current connection point
  121308. */
  121309. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121310. /**
  121311. * Gets or sets the value of that point.
  121312. * Please note that this value will be ignored if valueCallback is defined
  121313. */
  121314. value: any;
  121315. /**
  121316. * Gets or sets a callback used to get the value of that point.
  121317. * Please note that setting this value will force the connection point to ignore the value property
  121318. */
  121319. valueCallback: () => any;
  121320. /**
  121321. * Gets or sets the associated variable name in the shader
  121322. */
  121323. associatedVariableName: string;
  121324. /** Gets or sets the type of animation applied to the input */
  121325. animationType: AnimatedInputBlockTypes;
  121326. /**
  121327. * Gets a boolean indicating that this connection point not defined yet
  121328. */
  121329. readonly isUndefined: boolean;
  121330. /**
  121331. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121332. * In this case the connection point name must be the name of the uniform to use.
  121333. * Can only be set on inputs
  121334. */
  121335. isUniform: boolean;
  121336. /**
  121337. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121338. * In this case the connection point name must be the name of the attribute to use
  121339. * Can only be set on inputs
  121340. */
  121341. isAttribute: boolean;
  121342. /**
  121343. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121344. * Can only be set on exit points
  121345. */
  121346. isVarying: boolean;
  121347. /**
  121348. * Gets a boolean indicating that the current connection point is a system value
  121349. */
  121350. readonly isSystemValue: boolean;
  121351. /**
  121352. * Gets or sets the current well known value or null if not defined as a system value
  121353. */
  121354. systemValue: Nullable<NodeMaterialSystemValues>;
  121355. /**
  121356. * Gets the current class name
  121357. * @returns the class name
  121358. */
  121359. getClassName(): string;
  121360. /**
  121361. * Animate the input if animationType !== None
  121362. * @param scene defines the rendering scene
  121363. */
  121364. animate(scene: Scene): void;
  121365. private _emitDefine;
  121366. initialize(state: NodeMaterialBuildState): void;
  121367. /**
  121368. * Set the input block to its default value (based on its type)
  121369. */
  121370. setDefaultValue(): void;
  121371. private _emitConstant;
  121372. private _emit;
  121373. /** @hidden */
  121374. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121375. /** @hidden */
  121376. _transmit(effect: Effect, scene: Scene): void;
  121377. protected _buildBlock(state: NodeMaterialBuildState): void;
  121378. protected _dumpPropertiesCode(): string;
  121379. serialize(): any;
  121380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121381. }
  121382. }
  121383. declare module BABYLON {
  121384. /**
  121385. * Defines a connection point for a block
  121386. */
  121387. export class NodeMaterialConnectionPoint {
  121388. /** @hidden */
  121389. _ownerBlock: NodeMaterialBlock;
  121390. /** @hidden */
  121391. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121392. private _endpoints;
  121393. private _associatedVariableName;
  121394. /** @hidden */
  121395. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121396. /** @hidden */
  121397. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121398. private _type;
  121399. /** @hidden */
  121400. _enforceAssociatedVariableName: boolean;
  121401. /**
  121402. * Gets or sets the additional types supported by this connection point
  121403. */
  121404. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121405. /**
  121406. * Gets or sets the additional types excluded by this connection point
  121407. */
  121408. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121409. /**
  121410. * Gets or sets the associated variable name in the shader
  121411. */
  121412. associatedVariableName: string;
  121413. /**
  121414. * Gets or sets the connection point type (default is float)
  121415. */
  121416. type: NodeMaterialBlockConnectionPointTypes;
  121417. /**
  121418. * Gets or sets the connection point name
  121419. */
  121420. name: string;
  121421. /**
  121422. * Gets or sets a boolean indicating that this connection point can be omitted
  121423. */
  121424. isOptional: boolean;
  121425. /**
  121426. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121427. */
  121428. define: string;
  121429. /** Gets or sets the target of that connection point */
  121430. target: NodeMaterialBlockTargets;
  121431. /**
  121432. * Gets a boolean indicating that the current point is connected
  121433. */
  121434. readonly isConnected: boolean;
  121435. /**
  121436. * Gets a boolean indicating that the current point is connected to an input block
  121437. */
  121438. readonly isConnectedToInputBlock: boolean;
  121439. /**
  121440. * Gets a the connected input block (if any)
  121441. */
  121442. readonly connectInputBlock: Nullable<InputBlock>;
  121443. /** Get the other side of the connection (if any) */
  121444. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121445. /** Get the block that owns this connection point */
  121446. readonly ownerBlock: NodeMaterialBlock;
  121447. /** Get the block connected on the other side of this connection (if any) */
  121448. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121449. /** Get the block connected on the endpoints of this connection (if any) */
  121450. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121451. /** Gets the list of connected endpoints */
  121452. readonly endpoints: NodeMaterialConnectionPoint[];
  121453. /** Gets a boolean indicating if that output point is connected to at least one input */
  121454. readonly hasEndpoints: boolean;
  121455. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121456. readonly isConnectedInVertexShader: boolean;
  121457. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121458. readonly isConnectedInFragmentShader: boolean;
  121459. /**
  121460. * Creates a new connection point
  121461. * @param name defines the connection point name
  121462. * @param ownerBlock defines the block hosting this connection point
  121463. */
  121464. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121465. /**
  121466. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121467. * @returns the class name
  121468. */
  121469. getClassName(): string;
  121470. /**
  121471. * Gets an boolean indicating if the current point can be connected to another point
  121472. * @param connectionPoint defines the other connection point
  121473. * @returns true if the connection is possible
  121474. */
  121475. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121476. /**
  121477. * Connect this point to another connection point
  121478. * @param connectionPoint defines the other connection point
  121479. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121480. * @returns the current connection point
  121481. */
  121482. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121483. /**
  121484. * Disconnect this point from one of his endpoint
  121485. * @param endpoint defines the other connection point
  121486. * @returns the current connection point
  121487. */
  121488. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121489. /**
  121490. * Serializes this point in a JSON representation
  121491. * @returns the serialized point object
  121492. */
  121493. serialize(): any;
  121494. }
  121495. }
  121496. declare module BABYLON {
  121497. /**
  121498. * Block used to add support for vertex skinning (bones)
  121499. */
  121500. export class BonesBlock extends NodeMaterialBlock {
  121501. /**
  121502. * Creates a new BonesBlock
  121503. * @param name defines the block name
  121504. */
  121505. constructor(name: string);
  121506. /**
  121507. * Initialize the block and prepare the context for build
  121508. * @param state defines the state that will be used for the build
  121509. */
  121510. initialize(state: NodeMaterialBuildState): void;
  121511. /**
  121512. * Gets the current class name
  121513. * @returns the class name
  121514. */
  121515. getClassName(): string;
  121516. /**
  121517. * Gets the matrix indices input component
  121518. */
  121519. readonly matricesIndices: NodeMaterialConnectionPoint;
  121520. /**
  121521. * Gets the matrix weights input component
  121522. */
  121523. readonly matricesWeights: NodeMaterialConnectionPoint;
  121524. /**
  121525. * Gets the extra matrix indices input component
  121526. */
  121527. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121528. /**
  121529. * Gets the extra matrix weights input component
  121530. */
  121531. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121532. /**
  121533. * Gets the world input component
  121534. */
  121535. readonly world: NodeMaterialConnectionPoint;
  121536. /**
  121537. * Gets the output component
  121538. */
  121539. readonly output: NodeMaterialConnectionPoint;
  121540. autoConfigure(material: NodeMaterial): void;
  121541. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121544. protected _buildBlock(state: NodeMaterialBuildState): this;
  121545. }
  121546. }
  121547. declare module BABYLON {
  121548. /**
  121549. * Block used to add support for instances
  121550. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121551. */
  121552. export class InstancesBlock extends NodeMaterialBlock {
  121553. /**
  121554. * Creates a new InstancesBlock
  121555. * @param name defines the block name
  121556. */
  121557. constructor(name: string);
  121558. /**
  121559. * Gets the current class name
  121560. * @returns the class name
  121561. */
  121562. getClassName(): string;
  121563. /**
  121564. * Gets the first world row input component
  121565. */
  121566. readonly world0: NodeMaterialConnectionPoint;
  121567. /**
  121568. * Gets the second world row input component
  121569. */
  121570. readonly world1: NodeMaterialConnectionPoint;
  121571. /**
  121572. * Gets the third world row input component
  121573. */
  121574. readonly world2: NodeMaterialConnectionPoint;
  121575. /**
  121576. * Gets the forth world row input component
  121577. */
  121578. readonly world3: NodeMaterialConnectionPoint;
  121579. /**
  121580. * Gets the world input component
  121581. */
  121582. readonly world: NodeMaterialConnectionPoint;
  121583. /**
  121584. * Gets the output component
  121585. */
  121586. readonly output: NodeMaterialConnectionPoint;
  121587. autoConfigure(material: NodeMaterial): void;
  121588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121589. protected _buildBlock(state: NodeMaterialBuildState): this;
  121590. }
  121591. }
  121592. declare module BABYLON {
  121593. /**
  121594. * Block used to add morph targets support to vertex shader
  121595. */
  121596. export class MorphTargetsBlock extends NodeMaterialBlock {
  121597. private _repeatableContentAnchor;
  121598. private _repeatebleContentGenerated;
  121599. /**
  121600. * Create a new MorphTargetsBlock
  121601. * @param name defines the block name
  121602. */
  121603. constructor(name: string);
  121604. /**
  121605. * Gets the current class name
  121606. * @returns the class name
  121607. */
  121608. getClassName(): string;
  121609. /**
  121610. * Gets the position input component
  121611. */
  121612. readonly position: NodeMaterialConnectionPoint;
  121613. /**
  121614. * Gets the normal input component
  121615. */
  121616. readonly normal: NodeMaterialConnectionPoint;
  121617. /**
  121618. * Gets the tangent input component
  121619. */
  121620. readonly tangent: NodeMaterialConnectionPoint;
  121621. /**
  121622. * Gets the tangent input component
  121623. */
  121624. readonly uv: NodeMaterialConnectionPoint;
  121625. /**
  121626. * Gets the position output component
  121627. */
  121628. readonly positionOutput: NodeMaterialConnectionPoint;
  121629. /**
  121630. * Gets the normal output component
  121631. */
  121632. readonly normalOutput: NodeMaterialConnectionPoint;
  121633. /**
  121634. * Gets the tangent output component
  121635. */
  121636. readonly tangentOutput: NodeMaterialConnectionPoint;
  121637. /**
  121638. * Gets the tangent output component
  121639. */
  121640. readonly uvOutput: NodeMaterialConnectionPoint;
  121641. initialize(state: NodeMaterialBuildState): void;
  121642. autoConfigure(material: NodeMaterial): void;
  121643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121644. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121645. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121646. protected _buildBlock(state: NodeMaterialBuildState): this;
  121647. }
  121648. }
  121649. declare module BABYLON {
  121650. /**
  121651. * Block used to get data information from a light
  121652. */
  121653. export class LightInformationBlock extends NodeMaterialBlock {
  121654. private _lightDataUniformName;
  121655. private _lightColorUniformName;
  121656. private _lightTypeDefineName;
  121657. /**
  121658. * Gets or sets the light associated with this block
  121659. */
  121660. light: Nullable<Light>;
  121661. /**
  121662. * Creates a new LightInformationBlock
  121663. * @param name defines the block name
  121664. */
  121665. constructor(name: string);
  121666. /**
  121667. * Gets the current class name
  121668. * @returns the class name
  121669. */
  121670. getClassName(): string;
  121671. /**
  121672. * Gets the world position input component
  121673. */
  121674. readonly worldPosition: NodeMaterialConnectionPoint;
  121675. /**
  121676. * Gets the direction output component
  121677. */
  121678. readonly direction: NodeMaterialConnectionPoint;
  121679. /**
  121680. * Gets the direction output component
  121681. */
  121682. readonly color: NodeMaterialConnectionPoint;
  121683. /**
  121684. * Gets the direction output component
  121685. */
  121686. readonly intensity: NodeMaterialConnectionPoint;
  121687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121689. protected _buildBlock(state: NodeMaterialBuildState): this;
  121690. serialize(): any;
  121691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121692. }
  121693. }
  121694. declare module BABYLON {
  121695. /**
  121696. * Block used to add image processing support to fragment shader
  121697. */
  121698. export class ImageProcessingBlock extends NodeMaterialBlock {
  121699. /**
  121700. * Create a new ImageProcessingBlock
  121701. * @param name defines the block name
  121702. */
  121703. constructor(name: string);
  121704. /**
  121705. * Gets the current class name
  121706. * @returns the class name
  121707. */
  121708. getClassName(): string;
  121709. /**
  121710. * Gets the color input component
  121711. */
  121712. readonly color: NodeMaterialConnectionPoint;
  121713. /**
  121714. * Gets the output component
  121715. */
  121716. readonly output: NodeMaterialConnectionPoint;
  121717. /**
  121718. * Initialize the block and prepare the context for build
  121719. * @param state defines the state that will be used for the build
  121720. */
  121721. initialize(state: NodeMaterialBuildState): void;
  121722. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121724. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121725. protected _buildBlock(state: NodeMaterialBuildState): this;
  121726. }
  121727. }
  121728. declare module BABYLON {
  121729. /**
  121730. * Block used to pertub normals based on a normal map
  121731. */
  121732. export class PerturbNormalBlock extends NodeMaterialBlock {
  121733. private _tangentSpaceParameterName;
  121734. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121735. invertX: boolean;
  121736. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121737. invertY: boolean;
  121738. /**
  121739. * Create a new PerturbNormalBlock
  121740. * @param name defines the block name
  121741. */
  121742. constructor(name: string);
  121743. /**
  121744. * Gets the current class name
  121745. * @returns the class name
  121746. */
  121747. getClassName(): string;
  121748. /**
  121749. * Gets the world position input component
  121750. */
  121751. readonly worldPosition: NodeMaterialConnectionPoint;
  121752. /**
  121753. * Gets the world normal input component
  121754. */
  121755. readonly worldNormal: NodeMaterialConnectionPoint;
  121756. /**
  121757. * Gets the uv input component
  121758. */
  121759. readonly uv: NodeMaterialConnectionPoint;
  121760. /**
  121761. * Gets the normal map color input component
  121762. */
  121763. readonly normalMapColor: NodeMaterialConnectionPoint;
  121764. /**
  121765. * Gets the strength input component
  121766. */
  121767. readonly strength: NodeMaterialConnectionPoint;
  121768. /**
  121769. * Gets the output component
  121770. */
  121771. readonly output: NodeMaterialConnectionPoint;
  121772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121773. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121774. autoConfigure(material: NodeMaterial): void;
  121775. protected _buildBlock(state: NodeMaterialBuildState): this;
  121776. protected _dumpPropertiesCode(): string;
  121777. serialize(): any;
  121778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121779. }
  121780. }
  121781. declare module BABYLON {
  121782. /**
  121783. * Block used to discard a pixel if a value is smaller than a cutoff
  121784. */
  121785. export class DiscardBlock extends NodeMaterialBlock {
  121786. /**
  121787. * Create a new DiscardBlock
  121788. * @param name defines the block name
  121789. */
  121790. constructor(name: string);
  121791. /**
  121792. * Gets the current class name
  121793. * @returns the class name
  121794. */
  121795. getClassName(): string;
  121796. /**
  121797. * Gets the color input component
  121798. */
  121799. readonly value: NodeMaterialConnectionPoint;
  121800. /**
  121801. * Gets the cutoff input component
  121802. */
  121803. readonly cutoff: NodeMaterialConnectionPoint;
  121804. protected _buildBlock(state: NodeMaterialBuildState): this;
  121805. }
  121806. }
  121807. declare module BABYLON {
  121808. /**
  121809. * Block used to add support for scene fog
  121810. */
  121811. export class FogBlock extends NodeMaterialBlock {
  121812. private _fogDistanceName;
  121813. private _fogParameters;
  121814. /**
  121815. * Create a new FogBlock
  121816. * @param name defines the block name
  121817. */
  121818. constructor(name: string);
  121819. /**
  121820. * Gets the current class name
  121821. * @returns the class name
  121822. */
  121823. getClassName(): string;
  121824. /**
  121825. * Gets the world position input component
  121826. */
  121827. readonly worldPosition: NodeMaterialConnectionPoint;
  121828. /**
  121829. * Gets the view input component
  121830. */
  121831. readonly view: NodeMaterialConnectionPoint;
  121832. /**
  121833. * Gets the color input component
  121834. */
  121835. readonly input: NodeMaterialConnectionPoint;
  121836. /**
  121837. * Gets the fog color input component
  121838. */
  121839. readonly fogColor: NodeMaterialConnectionPoint;
  121840. /**
  121841. * Gets the output component
  121842. */
  121843. readonly output: NodeMaterialConnectionPoint;
  121844. autoConfigure(material: NodeMaterial): void;
  121845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121847. protected _buildBlock(state: NodeMaterialBuildState): this;
  121848. }
  121849. }
  121850. declare module BABYLON {
  121851. /**
  121852. * Block used to add light in the fragment shader
  121853. */
  121854. export class LightBlock extends NodeMaterialBlock {
  121855. private _lightId;
  121856. /**
  121857. * Gets or sets the light associated with this block
  121858. */
  121859. light: Nullable<Light>;
  121860. /**
  121861. * Create a new LightBlock
  121862. * @param name defines the block name
  121863. */
  121864. constructor(name: string);
  121865. /**
  121866. * Gets the current class name
  121867. * @returns the class name
  121868. */
  121869. getClassName(): string;
  121870. /**
  121871. * Gets the world position input component
  121872. */
  121873. readonly worldPosition: NodeMaterialConnectionPoint;
  121874. /**
  121875. * Gets the world normal input component
  121876. */
  121877. readonly worldNormal: NodeMaterialConnectionPoint;
  121878. /**
  121879. * Gets the camera (or eye) position component
  121880. */
  121881. readonly cameraPosition: NodeMaterialConnectionPoint;
  121882. /**
  121883. * Gets the glossiness component
  121884. */
  121885. readonly glossiness: NodeMaterialConnectionPoint;
  121886. /**
  121887. * Gets the glossinness power component
  121888. */
  121889. readonly glossPower: NodeMaterialConnectionPoint;
  121890. /**
  121891. * Gets the diffuse color component
  121892. */
  121893. readonly diffuseColor: NodeMaterialConnectionPoint;
  121894. /**
  121895. * Gets the specular color component
  121896. */
  121897. readonly specularColor: NodeMaterialConnectionPoint;
  121898. /**
  121899. * Gets the diffuse output component
  121900. */
  121901. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121902. /**
  121903. * Gets the specular output component
  121904. */
  121905. readonly specularOutput: NodeMaterialConnectionPoint;
  121906. autoConfigure(material: NodeMaterial): void;
  121907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121908. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121910. private _injectVertexCode;
  121911. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121912. serialize(): any;
  121913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121914. }
  121915. }
  121916. declare module BABYLON {
  121917. /**
  121918. * Block used to multiply 2 values
  121919. */
  121920. export class MultiplyBlock extends NodeMaterialBlock {
  121921. /**
  121922. * Creates a new MultiplyBlock
  121923. * @param name defines the block name
  121924. */
  121925. constructor(name: string);
  121926. /**
  121927. * Gets the current class name
  121928. * @returns the class name
  121929. */
  121930. getClassName(): string;
  121931. /**
  121932. * Gets the left operand input component
  121933. */
  121934. readonly left: NodeMaterialConnectionPoint;
  121935. /**
  121936. * Gets the right operand input component
  121937. */
  121938. readonly right: NodeMaterialConnectionPoint;
  121939. /**
  121940. * Gets the output component
  121941. */
  121942. readonly output: NodeMaterialConnectionPoint;
  121943. protected _buildBlock(state: NodeMaterialBuildState): this;
  121944. }
  121945. }
  121946. declare module BABYLON {
  121947. /**
  121948. * Block used to add 2 vectors
  121949. */
  121950. export class AddBlock extends NodeMaterialBlock {
  121951. /**
  121952. * Creates a new AddBlock
  121953. * @param name defines the block name
  121954. */
  121955. constructor(name: string);
  121956. /**
  121957. * Gets the current class name
  121958. * @returns the class name
  121959. */
  121960. getClassName(): string;
  121961. /**
  121962. * Gets the left operand input component
  121963. */
  121964. readonly left: NodeMaterialConnectionPoint;
  121965. /**
  121966. * Gets the right operand input component
  121967. */
  121968. readonly right: NodeMaterialConnectionPoint;
  121969. /**
  121970. * Gets the output component
  121971. */
  121972. readonly output: NodeMaterialConnectionPoint;
  121973. protected _buildBlock(state: NodeMaterialBuildState): this;
  121974. }
  121975. }
  121976. declare module BABYLON {
  121977. /**
  121978. * Block used to scale a vector by a float
  121979. */
  121980. export class ScaleBlock extends NodeMaterialBlock {
  121981. /**
  121982. * Creates a new ScaleBlock
  121983. * @param name defines the block name
  121984. */
  121985. constructor(name: string);
  121986. /**
  121987. * Gets the current class name
  121988. * @returns the class name
  121989. */
  121990. getClassName(): string;
  121991. /**
  121992. * Gets the input component
  121993. */
  121994. readonly input: NodeMaterialConnectionPoint;
  121995. /**
  121996. * Gets the factor input component
  121997. */
  121998. readonly factor: NodeMaterialConnectionPoint;
  121999. /**
  122000. * Gets the output component
  122001. */
  122002. readonly output: NodeMaterialConnectionPoint;
  122003. protected _buildBlock(state: NodeMaterialBuildState): this;
  122004. }
  122005. }
  122006. declare module BABYLON {
  122007. /**
  122008. * Block used to clamp a float
  122009. */
  122010. export class ClampBlock extends NodeMaterialBlock {
  122011. /** Gets or sets the minimum range */
  122012. minimum: number;
  122013. /** Gets or sets the maximum range */
  122014. maximum: number;
  122015. /**
  122016. * Creates a new ClampBlock
  122017. * @param name defines the block name
  122018. */
  122019. constructor(name: string);
  122020. /**
  122021. * Gets the current class name
  122022. * @returns the class name
  122023. */
  122024. getClassName(): string;
  122025. /**
  122026. * Gets the value input component
  122027. */
  122028. readonly value: NodeMaterialConnectionPoint;
  122029. /**
  122030. * Gets the output component
  122031. */
  122032. readonly output: NodeMaterialConnectionPoint;
  122033. protected _buildBlock(state: NodeMaterialBuildState): this;
  122034. protected _dumpPropertiesCode(): string;
  122035. serialize(): any;
  122036. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122037. }
  122038. }
  122039. declare module BABYLON {
  122040. /**
  122041. * Block used to apply a cross product between 2 vectors
  122042. */
  122043. export class CrossBlock extends NodeMaterialBlock {
  122044. /**
  122045. * Creates a new CrossBlock
  122046. * @param name defines the block name
  122047. */
  122048. constructor(name: string);
  122049. /**
  122050. * Gets the current class name
  122051. * @returns the class name
  122052. */
  122053. getClassName(): string;
  122054. /**
  122055. * Gets the left operand input component
  122056. */
  122057. readonly left: NodeMaterialConnectionPoint;
  122058. /**
  122059. * Gets the right operand input component
  122060. */
  122061. readonly right: NodeMaterialConnectionPoint;
  122062. /**
  122063. * Gets the output component
  122064. */
  122065. readonly output: NodeMaterialConnectionPoint;
  122066. protected _buildBlock(state: NodeMaterialBuildState): this;
  122067. }
  122068. }
  122069. declare module BABYLON {
  122070. /**
  122071. * Block used to apply a dot product between 2 vectors
  122072. */
  122073. export class DotBlock extends NodeMaterialBlock {
  122074. /**
  122075. * Creates a new DotBlock
  122076. * @param name defines the block name
  122077. */
  122078. constructor(name: string);
  122079. /**
  122080. * Gets the current class name
  122081. * @returns the class name
  122082. */
  122083. getClassName(): string;
  122084. /**
  122085. * Gets the left operand input component
  122086. */
  122087. readonly left: NodeMaterialConnectionPoint;
  122088. /**
  122089. * Gets the right operand input component
  122090. */
  122091. readonly right: NodeMaterialConnectionPoint;
  122092. /**
  122093. * Gets the output component
  122094. */
  122095. readonly output: NodeMaterialConnectionPoint;
  122096. protected _buildBlock(state: NodeMaterialBuildState): this;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * Block used to remap a float from a range to a new one
  122102. */
  122103. export class RemapBlock extends NodeMaterialBlock {
  122104. /**
  122105. * Gets or sets the source range
  122106. */
  122107. sourceRange: Vector2;
  122108. /**
  122109. * Gets or sets the target range
  122110. */
  122111. targetRange: Vector2;
  122112. /**
  122113. * Creates a new RemapBlock
  122114. * @param name defines the block name
  122115. */
  122116. constructor(name: string);
  122117. /**
  122118. * Gets the current class name
  122119. * @returns the class name
  122120. */
  122121. getClassName(): string;
  122122. /**
  122123. * Gets the input component
  122124. */
  122125. readonly input: NodeMaterialConnectionPoint;
  122126. /**
  122127. * Gets the source min input component
  122128. */
  122129. readonly sourceMin: NodeMaterialConnectionPoint;
  122130. /**
  122131. * Gets the source max input component
  122132. */
  122133. readonly sourceMax: NodeMaterialConnectionPoint;
  122134. /**
  122135. * Gets the target min input component
  122136. */
  122137. readonly targetMin: NodeMaterialConnectionPoint;
  122138. /**
  122139. * Gets the target max input component
  122140. */
  122141. readonly targetMax: NodeMaterialConnectionPoint;
  122142. /**
  122143. * Gets the output component
  122144. */
  122145. readonly output: NodeMaterialConnectionPoint;
  122146. protected _buildBlock(state: NodeMaterialBuildState): this;
  122147. protected _dumpPropertiesCode(): string;
  122148. serialize(): any;
  122149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122150. }
  122151. }
  122152. declare module BABYLON {
  122153. /**
  122154. * Block used to normalize a vector
  122155. */
  122156. export class NormalizeBlock extends NodeMaterialBlock {
  122157. /**
  122158. * Creates a new NormalizeBlock
  122159. * @param name defines the block name
  122160. */
  122161. constructor(name: string);
  122162. /**
  122163. * Gets the current class name
  122164. * @returns the class name
  122165. */
  122166. getClassName(): string;
  122167. /**
  122168. * Gets the input component
  122169. */
  122170. readonly input: NodeMaterialConnectionPoint;
  122171. /**
  122172. * Gets the output component
  122173. */
  122174. readonly output: NodeMaterialConnectionPoint;
  122175. protected _buildBlock(state: NodeMaterialBuildState): this;
  122176. }
  122177. }
  122178. declare module BABYLON {
  122179. /**
  122180. * Operations supported by the Trigonometry block
  122181. */
  122182. export enum TrigonometryBlockOperations {
  122183. /** Cos */
  122184. Cos = 0,
  122185. /** Sin */
  122186. Sin = 1,
  122187. /** Abs */
  122188. Abs = 2,
  122189. /** Exp */
  122190. Exp = 3,
  122191. /** Exp2 */
  122192. Exp2 = 4,
  122193. /** Round */
  122194. Round = 5,
  122195. /** Floor */
  122196. Floor = 6,
  122197. /** Ceiling */
  122198. Ceiling = 7,
  122199. /** Square root */
  122200. Sqrt = 8,
  122201. /** Log */
  122202. Log = 9,
  122203. /** Tangent */
  122204. Tan = 10,
  122205. /** Arc tangent */
  122206. ArcTan = 11,
  122207. /** Arc cosinus */
  122208. ArcCos = 12,
  122209. /** Arc sinus */
  122210. ArcSin = 13,
  122211. /** Fraction */
  122212. Fract = 14,
  122213. /** Sign */
  122214. Sign = 15,
  122215. /** To radians (from degrees) */
  122216. Radians = 16,
  122217. /** To degrees (from radians) */
  122218. Degrees = 17
  122219. }
  122220. /**
  122221. * Block used to apply trigonometry operation to floats
  122222. */
  122223. export class TrigonometryBlock extends NodeMaterialBlock {
  122224. /**
  122225. * Gets or sets the operation applied by the block
  122226. */
  122227. operation: TrigonometryBlockOperations;
  122228. /**
  122229. * Creates a new TrigonometryBlock
  122230. * @param name defines the block name
  122231. */
  122232. constructor(name: string);
  122233. /**
  122234. * Gets the current class name
  122235. * @returns the class name
  122236. */
  122237. getClassName(): string;
  122238. /**
  122239. * Gets the input component
  122240. */
  122241. readonly input: NodeMaterialConnectionPoint;
  122242. /**
  122243. * Gets the output component
  122244. */
  122245. readonly output: NodeMaterialConnectionPoint;
  122246. protected _buildBlock(state: NodeMaterialBuildState): this;
  122247. serialize(): any;
  122248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122249. }
  122250. }
  122251. declare module BABYLON {
  122252. /**
  122253. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122254. */
  122255. export class ColorMergerBlock extends NodeMaterialBlock {
  122256. /**
  122257. * Create a new ColorMergerBlock
  122258. * @param name defines the block name
  122259. */
  122260. constructor(name: string);
  122261. /**
  122262. * Gets the current class name
  122263. * @returns the class name
  122264. */
  122265. getClassName(): string;
  122266. /**
  122267. * Gets the r component (input)
  122268. */
  122269. readonly r: NodeMaterialConnectionPoint;
  122270. /**
  122271. * Gets the g component (input)
  122272. */
  122273. readonly g: NodeMaterialConnectionPoint;
  122274. /**
  122275. * Gets the b component (input)
  122276. */
  122277. readonly b: NodeMaterialConnectionPoint;
  122278. /**
  122279. * Gets the a component (input)
  122280. */
  122281. readonly a: NodeMaterialConnectionPoint;
  122282. /**
  122283. * Gets the rgba component (output)
  122284. */
  122285. readonly rgba: NodeMaterialConnectionPoint;
  122286. /**
  122287. * Gets the rgb component (output)
  122288. */
  122289. readonly rgb: NodeMaterialConnectionPoint;
  122290. protected _buildBlock(state: NodeMaterialBuildState): this;
  122291. }
  122292. }
  122293. declare module BABYLON {
  122294. /**
  122295. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122296. */
  122297. export class VectorMergerBlock extends NodeMaterialBlock {
  122298. /**
  122299. * Create a new VectorMergerBlock
  122300. * @param name defines the block name
  122301. */
  122302. constructor(name: string);
  122303. /**
  122304. * Gets the current class name
  122305. * @returns the class name
  122306. */
  122307. getClassName(): string;
  122308. /**
  122309. * Gets the x component (input)
  122310. */
  122311. readonly x: NodeMaterialConnectionPoint;
  122312. /**
  122313. * Gets the y component (input)
  122314. */
  122315. readonly y: NodeMaterialConnectionPoint;
  122316. /**
  122317. * Gets the z component (input)
  122318. */
  122319. readonly z: NodeMaterialConnectionPoint;
  122320. /**
  122321. * Gets the w component (input)
  122322. */
  122323. readonly w: NodeMaterialConnectionPoint;
  122324. /**
  122325. * Gets the xyzw component (output)
  122326. */
  122327. readonly xyzw: NodeMaterialConnectionPoint;
  122328. /**
  122329. * Gets the xyz component (output)
  122330. */
  122331. readonly xyz: NodeMaterialConnectionPoint;
  122332. /**
  122333. * Gets the xy component (output)
  122334. */
  122335. readonly xy: NodeMaterialConnectionPoint;
  122336. protected _buildBlock(state: NodeMaterialBuildState): this;
  122337. }
  122338. }
  122339. declare module BABYLON {
  122340. /**
  122341. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122342. */
  122343. export class ColorSplitterBlock extends NodeMaterialBlock {
  122344. /**
  122345. * Create a new ColorSplitterBlock
  122346. * @param name defines the block name
  122347. */
  122348. constructor(name: string);
  122349. /**
  122350. * Gets the current class name
  122351. * @returns the class name
  122352. */
  122353. getClassName(): string;
  122354. /**
  122355. * Gets the rgba component (input)
  122356. */
  122357. readonly rgba: NodeMaterialConnectionPoint;
  122358. /**
  122359. * Gets the rgb component (input)
  122360. */
  122361. readonly rgbIn: NodeMaterialConnectionPoint;
  122362. /**
  122363. * Gets the rgb component (output)
  122364. */
  122365. readonly rgbOut: NodeMaterialConnectionPoint;
  122366. /**
  122367. * Gets the r component (output)
  122368. */
  122369. readonly r: NodeMaterialConnectionPoint;
  122370. /**
  122371. * Gets the g component (output)
  122372. */
  122373. readonly g: NodeMaterialConnectionPoint;
  122374. /**
  122375. * Gets the b component (output)
  122376. */
  122377. readonly b: NodeMaterialConnectionPoint;
  122378. /**
  122379. * Gets the a component (output)
  122380. */
  122381. readonly a: NodeMaterialConnectionPoint;
  122382. protected _inputRename(name: string): string;
  122383. protected _outputRename(name: string): string;
  122384. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122385. }
  122386. }
  122387. declare module BABYLON {
  122388. /**
  122389. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122390. */
  122391. export class VectorSplitterBlock extends NodeMaterialBlock {
  122392. /**
  122393. * Create a new VectorSplitterBlock
  122394. * @param name defines the block name
  122395. */
  122396. constructor(name: string);
  122397. /**
  122398. * Gets the current class name
  122399. * @returns the class name
  122400. */
  122401. getClassName(): string;
  122402. /**
  122403. * Gets the xyzw component (input)
  122404. */
  122405. readonly xyzw: NodeMaterialConnectionPoint;
  122406. /**
  122407. * Gets the xyz component (input)
  122408. */
  122409. readonly xyzIn: NodeMaterialConnectionPoint;
  122410. /**
  122411. * Gets the xy component (input)
  122412. */
  122413. readonly xyIn: NodeMaterialConnectionPoint;
  122414. /**
  122415. * Gets the xyz component (output)
  122416. */
  122417. readonly xyzOut: NodeMaterialConnectionPoint;
  122418. /**
  122419. * Gets the xy component (output)
  122420. */
  122421. readonly xyOut: NodeMaterialConnectionPoint;
  122422. /**
  122423. * Gets the x component (output)
  122424. */
  122425. readonly x: NodeMaterialConnectionPoint;
  122426. /**
  122427. * Gets the y component (output)
  122428. */
  122429. readonly y: NodeMaterialConnectionPoint;
  122430. /**
  122431. * Gets the z component (output)
  122432. */
  122433. readonly z: NodeMaterialConnectionPoint;
  122434. /**
  122435. * Gets the w component (output)
  122436. */
  122437. readonly w: NodeMaterialConnectionPoint;
  122438. protected _inputRename(name: string): string;
  122439. protected _outputRename(name: string): string;
  122440. protected _buildBlock(state: NodeMaterialBuildState): this;
  122441. }
  122442. }
  122443. declare module BABYLON {
  122444. /**
  122445. * Block used to lerp between 2 values
  122446. */
  122447. export class LerpBlock extends NodeMaterialBlock {
  122448. /**
  122449. * Creates a new LerpBlock
  122450. * @param name defines the block name
  122451. */
  122452. constructor(name: string);
  122453. /**
  122454. * Gets the current class name
  122455. * @returns the class name
  122456. */
  122457. getClassName(): string;
  122458. /**
  122459. * Gets the left operand input component
  122460. */
  122461. readonly left: NodeMaterialConnectionPoint;
  122462. /**
  122463. * Gets the right operand input component
  122464. */
  122465. readonly right: NodeMaterialConnectionPoint;
  122466. /**
  122467. * Gets the gradient operand input component
  122468. */
  122469. readonly gradient: NodeMaterialConnectionPoint;
  122470. /**
  122471. * Gets the output component
  122472. */
  122473. readonly output: NodeMaterialConnectionPoint;
  122474. protected _buildBlock(state: NodeMaterialBuildState): this;
  122475. }
  122476. }
  122477. declare module BABYLON {
  122478. /**
  122479. * Block used to divide 2 vectors
  122480. */
  122481. export class DivideBlock extends NodeMaterialBlock {
  122482. /**
  122483. * Creates a new DivideBlock
  122484. * @param name defines the block name
  122485. */
  122486. constructor(name: string);
  122487. /**
  122488. * Gets the current class name
  122489. * @returns the class name
  122490. */
  122491. getClassName(): string;
  122492. /**
  122493. * Gets the left operand input component
  122494. */
  122495. readonly left: NodeMaterialConnectionPoint;
  122496. /**
  122497. * Gets the right operand input component
  122498. */
  122499. readonly right: NodeMaterialConnectionPoint;
  122500. /**
  122501. * Gets the output component
  122502. */
  122503. readonly output: NodeMaterialConnectionPoint;
  122504. protected _buildBlock(state: NodeMaterialBuildState): this;
  122505. }
  122506. }
  122507. declare module BABYLON {
  122508. /**
  122509. * Block used to subtract 2 vectors
  122510. */
  122511. export class SubtractBlock extends NodeMaterialBlock {
  122512. /**
  122513. * Creates a new SubtractBlock
  122514. * @param name defines the block name
  122515. */
  122516. constructor(name: string);
  122517. /**
  122518. * Gets the current class name
  122519. * @returns the class name
  122520. */
  122521. getClassName(): string;
  122522. /**
  122523. * Gets the left operand input component
  122524. */
  122525. readonly left: NodeMaterialConnectionPoint;
  122526. /**
  122527. * Gets the right operand input component
  122528. */
  122529. readonly right: NodeMaterialConnectionPoint;
  122530. /**
  122531. * Gets the output component
  122532. */
  122533. readonly output: NodeMaterialConnectionPoint;
  122534. protected _buildBlock(state: NodeMaterialBuildState): this;
  122535. }
  122536. }
  122537. declare module BABYLON {
  122538. /**
  122539. * Block used to step a value
  122540. */
  122541. export class StepBlock extends NodeMaterialBlock {
  122542. /**
  122543. * Creates a new StepBlock
  122544. * @param name defines the block name
  122545. */
  122546. constructor(name: string);
  122547. /**
  122548. * Gets the current class name
  122549. * @returns the class name
  122550. */
  122551. getClassName(): string;
  122552. /**
  122553. * Gets the value operand input component
  122554. */
  122555. readonly value: NodeMaterialConnectionPoint;
  122556. /**
  122557. * Gets the edge operand input component
  122558. */
  122559. readonly edge: NodeMaterialConnectionPoint;
  122560. /**
  122561. * Gets the output component
  122562. */
  122563. readonly output: NodeMaterialConnectionPoint;
  122564. protected _buildBlock(state: NodeMaterialBuildState): this;
  122565. }
  122566. }
  122567. declare module BABYLON {
  122568. /**
  122569. * Block used to get the opposite (1 - x) of a value
  122570. */
  122571. export class OneMinusBlock extends NodeMaterialBlock {
  122572. /**
  122573. * Creates a new OneMinusBlock
  122574. * @param name defines the block name
  122575. */
  122576. constructor(name: string);
  122577. /**
  122578. * Gets the current class name
  122579. * @returns the class name
  122580. */
  122581. getClassName(): string;
  122582. /**
  122583. * Gets the input component
  122584. */
  122585. readonly input: NodeMaterialConnectionPoint;
  122586. /**
  122587. * Gets the output component
  122588. */
  122589. readonly output: NodeMaterialConnectionPoint;
  122590. protected _buildBlock(state: NodeMaterialBuildState): this;
  122591. }
  122592. }
  122593. declare module BABYLON {
  122594. /**
  122595. * Block used to get the view direction
  122596. */
  122597. export class ViewDirectionBlock extends NodeMaterialBlock {
  122598. /**
  122599. * Creates a new ViewDirectionBlock
  122600. * @param name defines the block name
  122601. */
  122602. constructor(name: string);
  122603. /**
  122604. * Gets the current class name
  122605. * @returns the class name
  122606. */
  122607. getClassName(): string;
  122608. /**
  122609. * Gets the world position component
  122610. */
  122611. readonly worldPosition: NodeMaterialConnectionPoint;
  122612. /**
  122613. * Gets the camera position component
  122614. */
  122615. readonly cameraPosition: NodeMaterialConnectionPoint;
  122616. /**
  122617. * Gets the output component
  122618. */
  122619. readonly output: NodeMaterialConnectionPoint;
  122620. autoConfigure(material: NodeMaterial): void;
  122621. protected _buildBlock(state: NodeMaterialBuildState): this;
  122622. }
  122623. }
  122624. declare module BABYLON {
  122625. /**
  122626. * Block used to compute fresnel value
  122627. */
  122628. export class FresnelBlock extends NodeMaterialBlock {
  122629. /**
  122630. * Create a new FresnelBlock
  122631. * @param name defines the block name
  122632. */
  122633. constructor(name: string);
  122634. /**
  122635. * Gets the current class name
  122636. * @returns the class name
  122637. */
  122638. getClassName(): string;
  122639. /**
  122640. * Gets the world normal input component
  122641. */
  122642. readonly worldNormal: NodeMaterialConnectionPoint;
  122643. /**
  122644. * Gets the view direction input component
  122645. */
  122646. readonly viewDirection: NodeMaterialConnectionPoint;
  122647. /**
  122648. * Gets the bias input component
  122649. */
  122650. readonly bias: NodeMaterialConnectionPoint;
  122651. /**
  122652. * Gets the camera (or eye) position component
  122653. */
  122654. readonly power: NodeMaterialConnectionPoint;
  122655. /**
  122656. * Gets the fresnel output component
  122657. */
  122658. readonly fresnel: NodeMaterialConnectionPoint;
  122659. autoConfigure(material: NodeMaterial): void;
  122660. protected _buildBlock(state: NodeMaterialBuildState): this;
  122661. }
  122662. }
  122663. declare module BABYLON {
  122664. /**
  122665. * Block used to get the max of 2 values
  122666. */
  122667. export class MaxBlock extends NodeMaterialBlock {
  122668. /**
  122669. * Creates a new MaxBlock
  122670. * @param name defines the block name
  122671. */
  122672. constructor(name: string);
  122673. /**
  122674. * Gets the current class name
  122675. * @returns the class name
  122676. */
  122677. getClassName(): string;
  122678. /**
  122679. * Gets the left operand input component
  122680. */
  122681. readonly left: NodeMaterialConnectionPoint;
  122682. /**
  122683. * Gets the right operand input component
  122684. */
  122685. readonly right: NodeMaterialConnectionPoint;
  122686. /**
  122687. * Gets the output component
  122688. */
  122689. readonly output: NodeMaterialConnectionPoint;
  122690. protected _buildBlock(state: NodeMaterialBuildState): this;
  122691. }
  122692. }
  122693. declare module BABYLON {
  122694. /**
  122695. * Block used to get the min of 2 values
  122696. */
  122697. export class MinBlock extends NodeMaterialBlock {
  122698. /**
  122699. * Creates a new MinBlock
  122700. * @param name defines the block name
  122701. */
  122702. constructor(name: string);
  122703. /**
  122704. * Gets the current class name
  122705. * @returns the class name
  122706. */
  122707. getClassName(): string;
  122708. /**
  122709. * Gets the left operand input component
  122710. */
  122711. readonly left: NodeMaterialConnectionPoint;
  122712. /**
  122713. * Gets the right operand input component
  122714. */
  122715. readonly right: NodeMaterialConnectionPoint;
  122716. /**
  122717. * Gets the output component
  122718. */
  122719. readonly output: NodeMaterialConnectionPoint;
  122720. protected _buildBlock(state: NodeMaterialBuildState): this;
  122721. }
  122722. }
  122723. declare module BABYLON {
  122724. /**
  122725. * Block used to get the distance between 2 values
  122726. */
  122727. export class DistanceBlock extends NodeMaterialBlock {
  122728. /**
  122729. * Creates a new DistanceBlock
  122730. * @param name defines the block name
  122731. */
  122732. constructor(name: string);
  122733. /**
  122734. * Gets the current class name
  122735. * @returns the class name
  122736. */
  122737. getClassName(): string;
  122738. /**
  122739. * Gets the left operand input component
  122740. */
  122741. readonly left: NodeMaterialConnectionPoint;
  122742. /**
  122743. * Gets the right operand input component
  122744. */
  122745. readonly right: NodeMaterialConnectionPoint;
  122746. /**
  122747. * Gets the output component
  122748. */
  122749. readonly output: NodeMaterialConnectionPoint;
  122750. protected _buildBlock(state: NodeMaterialBuildState): this;
  122751. }
  122752. }
  122753. declare module BABYLON {
  122754. /**
  122755. * Block used to get the length of a vector
  122756. */
  122757. export class LengthBlock extends NodeMaterialBlock {
  122758. /**
  122759. * Creates a new LengthBlock
  122760. * @param name defines the block name
  122761. */
  122762. constructor(name: string);
  122763. /**
  122764. * Gets the current class name
  122765. * @returns the class name
  122766. */
  122767. getClassName(): string;
  122768. /**
  122769. * Gets the value input component
  122770. */
  122771. readonly value: NodeMaterialConnectionPoint;
  122772. /**
  122773. * Gets the output component
  122774. */
  122775. readonly output: NodeMaterialConnectionPoint;
  122776. protected _buildBlock(state: NodeMaterialBuildState): this;
  122777. }
  122778. }
  122779. declare module BABYLON {
  122780. /**
  122781. * Block used to get negative version of a value (i.e. x * -1)
  122782. */
  122783. export class NegateBlock extends NodeMaterialBlock {
  122784. /**
  122785. * Creates a new NegateBlock
  122786. * @param name defines the block name
  122787. */
  122788. constructor(name: string);
  122789. /**
  122790. * Gets the current class name
  122791. * @returns the class name
  122792. */
  122793. getClassName(): string;
  122794. /**
  122795. * Gets the value input component
  122796. */
  122797. readonly value: NodeMaterialConnectionPoint;
  122798. /**
  122799. * Gets the output component
  122800. */
  122801. readonly output: NodeMaterialConnectionPoint;
  122802. protected _buildBlock(state: NodeMaterialBuildState): this;
  122803. }
  122804. }
  122805. declare module BABYLON {
  122806. /**
  122807. * Block used to get the value of the first parameter raised to the power of the second
  122808. */
  122809. export class PowBlock extends NodeMaterialBlock {
  122810. /**
  122811. * Creates a new PowBlock
  122812. * @param name defines the block name
  122813. */
  122814. constructor(name: string);
  122815. /**
  122816. * Gets the current class name
  122817. * @returns the class name
  122818. */
  122819. getClassName(): string;
  122820. /**
  122821. * Gets the value operand input component
  122822. */
  122823. readonly value: NodeMaterialConnectionPoint;
  122824. /**
  122825. * Gets the power operand input component
  122826. */
  122827. readonly power: NodeMaterialConnectionPoint;
  122828. /**
  122829. * Gets the output component
  122830. */
  122831. readonly output: NodeMaterialConnectionPoint;
  122832. protected _buildBlock(state: NodeMaterialBuildState): this;
  122833. }
  122834. }
  122835. declare module BABYLON {
  122836. /**
  122837. * Block used to get a random number
  122838. */
  122839. export class RandomNumberBlock extends NodeMaterialBlock {
  122840. /**
  122841. * Creates a new RandomNumberBlock
  122842. * @param name defines the block name
  122843. */
  122844. constructor(name: string);
  122845. /**
  122846. * Gets the current class name
  122847. * @returns the class name
  122848. */
  122849. getClassName(): string;
  122850. /**
  122851. * Gets the seed input component
  122852. */
  122853. readonly seed: NodeMaterialConnectionPoint;
  122854. /**
  122855. * Gets the output component
  122856. */
  122857. readonly output: NodeMaterialConnectionPoint;
  122858. protected _buildBlock(state: NodeMaterialBuildState): this;
  122859. }
  122860. }
  122861. declare module BABYLON {
  122862. /**
  122863. * Block used to compute arc tangent of 2 values
  122864. */
  122865. export class ArcTan2Block extends NodeMaterialBlock {
  122866. /**
  122867. * Creates a new ArcTan2Block
  122868. * @param name defines the block name
  122869. */
  122870. constructor(name: string);
  122871. /**
  122872. * Gets the current class name
  122873. * @returns the class name
  122874. */
  122875. getClassName(): string;
  122876. /**
  122877. * Gets the x operand input component
  122878. */
  122879. readonly x: NodeMaterialConnectionPoint;
  122880. /**
  122881. * Gets the y operand input component
  122882. */
  122883. readonly y: NodeMaterialConnectionPoint;
  122884. /**
  122885. * Gets the output component
  122886. */
  122887. readonly output: NodeMaterialConnectionPoint;
  122888. protected _buildBlock(state: NodeMaterialBuildState): this;
  122889. }
  122890. }
  122891. declare module BABYLON {
  122892. /**
  122893. * Block used to smooth step a value
  122894. */
  122895. export class SmoothStepBlock extends NodeMaterialBlock {
  122896. /**
  122897. * Creates a new SmoothStepBlock
  122898. * @param name defines the block name
  122899. */
  122900. constructor(name: string);
  122901. /**
  122902. * Gets the current class name
  122903. * @returns the class name
  122904. */
  122905. getClassName(): string;
  122906. /**
  122907. * Gets the value operand input component
  122908. */
  122909. readonly value: NodeMaterialConnectionPoint;
  122910. /**
  122911. * Gets the first edge operand input component
  122912. */
  122913. readonly edge0: NodeMaterialConnectionPoint;
  122914. /**
  122915. * Gets the second edge operand input component
  122916. */
  122917. readonly edge1: NodeMaterialConnectionPoint;
  122918. /**
  122919. * Gets the output component
  122920. */
  122921. readonly output: NodeMaterialConnectionPoint;
  122922. protected _buildBlock(state: NodeMaterialBuildState): this;
  122923. }
  122924. }
  122925. declare module BABYLON {
  122926. /**
  122927. * Block used to get the reciprocal (1 / x) of a value
  122928. */
  122929. export class ReciprocalBlock extends NodeMaterialBlock {
  122930. /**
  122931. * Creates a new ReciprocalBlock
  122932. * @param name defines the block name
  122933. */
  122934. constructor(name: string);
  122935. /**
  122936. * Gets the current class name
  122937. * @returns the class name
  122938. */
  122939. getClassName(): string;
  122940. /**
  122941. * Gets the input component
  122942. */
  122943. readonly input: NodeMaterialConnectionPoint;
  122944. /**
  122945. * Gets the output component
  122946. */
  122947. readonly output: NodeMaterialConnectionPoint;
  122948. protected _buildBlock(state: NodeMaterialBuildState): this;
  122949. }
  122950. }
  122951. declare module BABYLON {
  122952. /**
  122953. * Block used to replace a color by another one
  122954. */
  122955. export class ReplaceColorBlock extends NodeMaterialBlock {
  122956. /**
  122957. * Creates a new ReplaceColorBlock
  122958. * @param name defines the block name
  122959. */
  122960. constructor(name: string);
  122961. /**
  122962. * Gets the current class name
  122963. * @returns the class name
  122964. */
  122965. getClassName(): string;
  122966. /**
  122967. * Gets the value input component
  122968. */
  122969. readonly value: NodeMaterialConnectionPoint;
  122970. /**
  122971. * Gets the reference input component
  122972. */
  122973. readonly reference: NodeMaterialConnectionPoint;
  122974. /**
  122975. * Gets the distance input component
  122976. */
  122977. readonly distance: NodeMaterialConnectionPoint;
  122978. /**
  122979. * Gets the replacement input component
  122980. */
  122981. readonly replacement: NodeMaterialConnectionPoint;
  122982. /**
  122983. * Gets the output component
  122984. */
  122985. readonly output: NodeMaterialConnectionPoint;
  122986. protected _buildBlock(state: NodeMaterialBuildState): this;
  122987. }
  122988. }
  122989. declare module BABYLON {
  122990. /**
  122991. * Block used to posterize a value
  122992. * @see https://en.wikipedia.org/wiki/Posterization
  122993. */
  122994. export class PosterizeBlock extends NodeMaterialBlock {
  122995. /**
  122996. * Creates a new PosterizeBlock
  122997. * @param name defines the block name
  122998. */
  122999. constructor(name: string);
  123000. /**
  123001. * Gets the current class name
  123002. * @returns the class name
  123003. */
  123004. getClassName(): string;
  123005. /**
  123006. * Gets the value input component
  123007. */
  123008. readonly value: NodeMaterialConnectionPoint;
  123009. /**
  123010. * Gets the steps input component
  123011. */
  123012. readonly steps: NodeMaterialConnectionPoint;
  123013. /**
  123014. * Gets the output component
  123015. */
  123016. readonly output: NodeMaterialConnectionPoint;
  123017. protected _buildBlock(state: NodeMaterialBuildState): this;
  123018. }
  123019. }
  123020. declare module BABYLON {
  123021. /**
  123022. * Operations supported by the Wave block
  123023. */
  123024. export enum WaveBlockKind {
  123025. /** SawTooth */
  123026. SawTooth = 0,
  123027. /** Square */
  123028. Square = 1,
  123029. /** Triangle */
  123030. Triangle = 2
  123031. }
  123032. /**
  123033. * Block used to apply wave operation to floats
  123034. */
  123035. export class WaveBlock extends NodeMaterialBlock {
  123036. /**
  123037. * Gets or sets the kibnd of wave to be applied by the block
  123038. */
  123039. kind: WaveBlockKind;
  123040. /**
  123041. * Creates a new WaveBlock
  123042. * @param name defines the block name
  123043. */
  123044. constructor(name: string);
  123045. /**
  123046. * Gets the current class name
  123047. * @returns the class name
  123048. */
  123049. getClassName(): string;
  123050. /**
  123051. * Gets the input component
  123052. */
  123053. readonly input: NodeMaterialConnectionPoint;
  123054. /**
  123055. * Gets the output component
  123056. */
  123057. readonly output: NodeMaterialConnectionPoint;
  123058. protected _buildBlock(state: NodeMaterialBuildState): this;
  123059. serialize(): any;
  123060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123061. }
  123062. }
  123063. declare module BABYLON {
  123064. /**
  123065. * Class used to store a color step for the GradientBlock
  123066. */
  123067. export class GradientBlockColorStep {
  123068. /**
  123069. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123070. */
  123071. step: number;
  123072. /**
  123073. * Gets or sets the color associated with this step
  123074. */
  123075. color: Color3;
  123076. /**
  123077. * Creates a new GradientBlockColorStep
  123078. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  123079. * @param color defines the color associated with this step
  123080. */
  123081. constructor(
  123082. /**
  123083. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123084. */
  123085. step: number,
  123086. /**
  123087. * Gets or sets the color associated with this step
  123088. */
  123089. color: Color3);
  123090. }
  123091. /**
  123092. * Block used to return a color from a gradient based on an input value between 0 and 1
  123093. */
  123094. export class GradientBlock extends NodeMaterialBlock {
  123095. /**
  123096. * Gets or sets the list of color steps
  123097. */
  123098. colorSteps: GradientBlockColorStep[];
  123099. /**
  123100. * Creates a new GradientBlock
  123101. * @param name defines the block name
  123102. */
  123103. constructor(name: string);
  123104. /**
  123105. * Gets the current class name
  123106. * @returns the class name
  123107. */
  123108. getClassName(): string;
  123109. /**
  123110. * Gets the gradient input component
  123111. */
  123112. readonly gradient: NodeMaterialConnectionPoint;
  123113. /**
  123114. * Gets the output component
  123115. */
  123116. readonly output: NodeMaterialConnectionPoint;
  123117. private _writeColorConstant;
  123118. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123119. serialize(): any;
  123120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123121. protected _dumpPropertiesCode(): string;
  123122. }
  123123. }
  123124. declare module BABYLON {
  123125. /**
  123126. * Block used to normalize lerp between 2 values
  123127. */
  123128. export class NLerpBlock extends NodeMaterialBlock {
  123129. /**
  123130. * Creates a new NLerpBlock
  123131. * @param name defines the block name
  123132. */
  123133. constructor(name: string);
  123134. /**
  123135. * Gets the current class name
  123136. * @returns the class name
  123137. */
  123138. getClassName(): string;
  123139. /**
  123140. * Gets the left operand input component
  123141. */
  123142. readonly left: NodeMaterialConnectionPoint;
  123143. /**
  123144. * Gets the right operand input component
  123145. */
  123146. readonly right: NodeMaterialConnectionPoint;
  123147. /**
  123148. * Gets the gradient operand input component
  123149. */
  123150. readonly gradient: NodeMaterialConnectionPoint;
  123151. /**
  123152. * Gets the output component
  123153. */
  123154. readonly output: NodeMaterialConnectionPoint;
  123155. protected _buildBlock(state: NodeMaterialBuildState): this;
  123156. }
  123157. }
  123158. declare module BABYLON {
  123159. /**
  123160. * Effect Render Options
  123161. */
  123162. export interface IEffectRendererOptions {
  123163. /**
  123164. * Defines the vertices positions.
  123165. */
  123166. positions?: number[];
  123167. /**
  123168. * Defines the indices.
  123169. */
  123170. indices?: number[];
  123171. }
  123172. /**
  123173. * Helper class to render one or more effects
  123174. */
  123175. export class EffectRenderer {
  123176. private engine;
  123177. private static _DefaultOptions;
  123178. private _vertexBuffers;
  123179. private _indexBuffer;
  123180. private _ringBufferIndex;
  123181. private _ringScreenBuffer;
  123182. private _fullscreenViewport;
  123183. private _getNextFrameBuffer;
  123184. /**
  123185. * Creates an effect renderer
  123186. * @param engine the engine to use for rendering
  123187. * @param options defines the options of the effect renderer
  123188. */
  123189. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123190. /**
  123191. * Sets the current viewport in normalized coordinates 0-1
  123192. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123193. */
  123194. setViewport(viewport?: Viewport): void;
  123195. /**
  123196. * Binds the embedded attributes buffer to the effect.
  123197. * @param effect Defines the effect to bind the attributes for
  123198. */
  123199. bindBuffers(effect: Effect): void;
  123200. /**
  123201. * Sets the current effect wrapper to use during draw.
  123202. * The effect needs to be ready before calling this api.
  123203. * This also sets the default full screen position attribute.
  123204. * @param effectWrapper Defines the effect to draw with
  123205. */
  123206. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123207. /**
  123208. * Draws a full screen quad.
  123209. */
  123210. draw(): void;
  123211. /**
  123212. * renders one or more effects to a specified texture
  123213. * @param effectWrappers list of effects to renderer
  123214. * @param outputTexture texture to draw to, if null it will render to the screen
  123215. */
  123216. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123217. /**
  123218. * Disposes of the effect renderer
  123219. */
  123220. dispose(): void;
  123221. }
  123222. /**
  123223. * Options to create an EffectWrapper
  123224. */
  123225. interface EffectWrapperCreationOptions {
  123226. /**
  123227. * Engine to use to create the effect
  123228. */
  123229. engine: ThinEngine;
  123230. /**
  123231. * Fragment shader for the effect
  123232. */
  123233. fragmentShader: string;
  123234. /**
  123235. * Vertex shader for the effect
  123236. */
  123237. vertexShader?: string;
  123238. /**
  123239. * Attributes to use in the shader
  123240. */
  123241. attributeNames?: Array<string>;
  123242. /**
  123243. * Uniforms to use in the shader
  123244. */
  123245. uniformNames?: Array<string>;
  123246. /**
  123247. * Texture sampler names to use in the shader
  123248. */
  123249. samplerNames?: Array<string>;
  123250. /**
  123251. * The friendly name of the effect displayed in Spector.
  123252. */
  123253. name?: string;
  123254. }
  123255. /**
  123256. * Wraps an effect to be used for rendering
  123257. */
  123258. export class EffectWrapper {
  123259. /**
  123260. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123261. */
  123262. onApplyObservable: Observable<{}>;
  123263. /**
  123264. * The underlying effect
  123265. */
  123266. effect: Effect;
  123267. /**
  123268. * Creates an effect to be renderer
  123269. * @param creationOptions options to create the effect
  123270. */
  123271. constructor(creationOptions: EffectWrapperCreationOptions);
  123272. /**
  123273. * Disposes of the effect wrapper
  123274. */
  123275. dispose(): void;
  123276. }
  123277. }
  123278. declare module BABYLON {
  123279. /**
  123280. * Helper class to push actions to a pool of workers.
  123281. */
  123282. export class WorkerPool implements IDisposable {
  123283. private _workerInfos;
  123284. private _pendingActions;
  123285. /**
  123286. * Constructor
  123287. * @param workers Array of workers to use for actions
  123288. */
  123289. constructor(workers: Array<Worker>);
  123290. /**
  123291. * Terminates all workers and clears any pending actions.
  123292. */
  123293. dispose(): void;
  123294. /**
  123295. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123296. * pended until a worker has completed its action.
  123297. * @param action The action to perform. Call onComplete when the action is complete.
  123298. */
  123299. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123300. private _execute;
  123301. }
  123302. }
  123303. declare module BABYLON {
  123304. /**
  123305. * Configuration for Draco compression
  123306. */
  123307. export interface IDracoCompressionConfiguration {
  123308. /**
  123309. * Configuration for the decoder.
  123310. */
  123311. decoder: {
  123312. /**
  123313. * The url to the WebAssembly module.
  123314. */
  123315. wasmUrl?: string;
  123316. /**
  123317. * The url to the WebAssembly binary.
  123318. */
  123319. wasmBinaryUrl?: string;
  123320. /**
  123321. * The url to the fallback JavaScript module.
  123322. */
  123323. fallbackUrl?: string;
  123324. };
  123325. }
  123326. /**
  123327. * Draco compression (https://google.github.io/draco/)
  123328. *
  123329. * This class wraps the Draco module.
  123330. *
  123331. * **Encoder**
  123332. *
  123333. * The encoder is not currently implemented.
  123334. *
  123335. * **Decoder**
  123336. *
  123337. * 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.
  123338. *
  123339. * To update the configuration, use the following code:
  123340. * ```javascript
  123341. * DracoCompression.Configuration = {
  123342. * decoder: {
  123343. * wasmUrl: "<url to the WebAssembly library>",
  123344. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123345. * fallbackUrl: "<url to the fallback JavaScript library>",
  123346. * }
  123347. * };
  123348. * ```
  123349. *
  123350. * 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.
  123351. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123352. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123353. *
  123354. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123355. * ```javascript
  123356. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123357. * ```
  123358. *
  123359. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123360. */
  123361. export class DracoCompression implements IDisposable {
  123362. private _workerPoolPromise?;
  123363. private _decoderModulePromise?;
  123364. /**
  123365. * The configuration. Defaults to the following urls:
  123366. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123367. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123368. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123369. */
  123370. static Configuration: IDracoCompressionConfiguration;
  123371. /**
  123372. * Returns true if the decoder configuration is available.
  123373. */
  123374. static readonly DecoderAvailable: boolean;
  123375. /**
  123376. * Default number of workers to create when creating the draco compression object.
  123377. */
  123378. static DefaultNumWorkers: number;
  123379. private static GetDefaultNumWorkers;
  123380. private static _Default;
  123381. /**
  123382. * Default instance for the draco compression object.
  123383. */
  123384. static readonly Default: DracoCompression;
  123385. /**
  123386. * Constructor
  123387. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123388. */
  123389. constructor(numWorkers?: number);
  123390. /**
  123391. * Stop all async operations and release resources.
  123392. */
  123393. dispose(): void;
  123394. /**
  123395. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123396. * @returns a promise that resolves when ready
  123397. */
  123398. whenReadyAsync(): Promise<void>;
  123399. /**
  123400. * Decode Draco compressed mesh data to vertex data.
  123401. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123402. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123403. * @returns A promise that resolves with the decoded vertex data
  123404. */
  123405. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123406. [kind: string]: number;
  123407. }): Promise<VertexData>;
  123408. }
  123409. }
  123410. declare module BABYLON {
  123411. /**
  123412. * Class for building Constructive Solid Geometry
  123413. */
  123414. export class CSG {
  123415. private polygons;
  123416. /**
  123417. * The world matrix
  123418. */
  123419. matrix: Matrix;
  123420. /**
  123421. * Stores the position
  123422. */
  123423. position: Vector3;
  123424. /**
  123425. * Stores the rotation
  123426. */
  123427. rotation: Vector3;
  123428. /**
  123429. * Stores the rotation quaternion
  123430. */
  123431. rotationQuaternion: Nullable<Quaternion>;
  123432. /**
  123433. * Stores the scaling vector
  123434. */
  123435. scaling: Vector3;
  123436. /**
  123437. * Convert the Mesh to CSG
  123438. * @param mesh The Mesh to convert to CSG
  123439. * @returns A new CSG from the Mesh
  123440. */
  123441. static FromMesh(mesh: Mesh): CSG;
  123442. /**
  123443. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123444. * @param polygons Polygons used to construct a CSG solid
  123445. */
  123446. private static FromPolygons;
  123447. /**
  123448. * Clones, or makes a deep copy, of the CSG
  123449. * @returns A new CSG
  123450. */
  123451. clone(): CSG;
  123452. /**
  123453. * Unions this CSG with another CSG
  123454. * @param csg The CSG to union against this CSG
  123455. * @returns The unioned CSG
  123456. */
  123457. union(csg: CSG): CSG;
  123458. /**
  123459. * Unions this CSG with another CSG in place
  123460. * @param csg The CSG to union against this CSG
  123461. */
  123462. unionInPlace(csg: CSG): void;
  123463. /**
  123464. * Subtracts this CSG with another CSG
  123465. * @param csg The CSG to subtract against this CSG
  123466. * @returns A new CSG
  123467. */
  123468. subtract(csg: CSG): CSG;
  123469. /**
  123470. * Subtracts this CSG with another CSG in place
  123471. * @param csg The CSG to subtact against this CSG
  123472. */
  123473. subtractInPlace(csg: CSG): void;
  123474. /**
  123475. * Intersect this CSG with another CSG
  123476. * @param csg The CSG to intersect against this CSG
  123477. * @returns A new CSG
  123478. */
  123479. intersect(csg: CSG): CSG;
  123480. /**
  123481. * Intersects this CSG with another CSG in place
  123482. * @param csg The CSG to intersect against this CSG
  123483. */
  123484. intersectInPlace(csg: CSG): void;
  123485. /**
  123486. * Return a new CSG solid with solid and empty space switched. This solid is
  123487. * not modified.
  123488. * @returns A new CSG solid with solid and empty space switched
  123489. */
  123490. inverse(): CSG;
  123491. /**
  123492. * Inverses the CSG in place
  123493. */
  123494. inverseInPlace(): void;
  123495. /**
  123496. * This is used to keep meshes transformations so they can be restored
  123497. * when we build back a Babylon Mesh
  123498. * NB : All CSG operations are performed in world coordinates
  123499. * @param csg The CSG to copy the transform attributes from
  123500. * @returns This CSG
  123501. */
  123502. copyTransformAttributes(csg: CSG): CSG;
  123503. /**
  123504. * Build Raw mesh from CSG
  123505. * Coordinates here are in world space
  123506. * @param name The name of the mesh geometry
  123507. * @param scene The Scene
  123508. * @param keepSubMeshes Specifies if the submeshes should be kept
  123509. * @returns A new Mesh
  123510. */
  123511. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123512. /**
  123513. * Build Mesh from CSG taking material and transforms into account
  123514. * @param name The name of the Mesh
  123515. * @param material The material of the Mesh
  123516. * @param scene The Scene
  123517. * @param keepSubMeshes Specifies if submeshes should be kept
  123518. * @returns The new Mesh
  123519. */
  123520. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123521. }
  123522. }
  123523. declare module BABYLON {
  123524. /**
  123525. * Class used to create a trail following a mesh
  123526. */
  123527. export class TrailMesh extends Mesh {
  123528. private _generator;
  123529. private _autoStart;
  123530. private _running;
  123531. private _diameter;
  123532. private _length;
  123533. private _sectionPolygonPointsCount;
  123534. private _sectionVectors;
  123535. private _sectionNormalVectors;
  123536. private _beforeRenderObserver;
  123537. /**
  123538. * @constructor
  123539. * @param name The value used by scene.getMeshByName() to do a lookup.
  123540. * @param generator The mesh to generate a trail.
  123541. * @param scene The scene to add this mesh to.
  123542. * @param diameter Diameter of trailing mesh. Default is 1.
  123543. * @param length Length of trailing mesh. Default is 60.
  123544. * @param autoStart Automatically start trailing mesh. Default true.
  123545. */
  123546. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123547. /**
  123548. * "TrailMesh"
  123549. * @returns "TrailMesh"
  123550. */
  123551. getClassName(): string;
  123552. private _createMesh;
  123553. /**
  123554. * Start trailing mesh.
  123555. */
  123556. start(): void;
  123557. /**
  123558. * Stop trailing mesh.
  123559. */
  123560. stop(): void;
  123561. /**
  123562. * Update trailing mesh geometry.
  123563. */
  123564. update(): void;
  123565. /**
  123566. * Returns a new TrailMesh object.
  123567. * @param name is a string, the name given to the new mesh
  123568. * @param newGenerator use new generator object for cloned trail mesh
  123569. * @returns a new mesh
  123570. */
  123571. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123572. /**
  123573. * Serializes this trail mesh
  123574. * @param serializationObject object to write serialization to
  123575. */
  123576. serialize(serializationObject: any): void;
  123577. /**
  123578. * Parses a serialized trail mesh
  123579. * @param parsedMesh the serialized mesh
  123580. * @param scene the scene to create the trail mesh in
  123581. * @returns the created trail mesh
  123582. */
  123583. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123584. }
  123585. }
  123586. declare module BABYLON {
  123587. /**
  123588. * Class containing static functions to help procedurally build meshes
  123589. */
  123590. export class TiledBoxBuilder {
  123591. /**
  123592. * Creates a box mesh
  123593. * 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)
  123594. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123598. * @param name defines the name of the mesh
  123599. * @param options defines the options used to create the mesh
  123600. * @param scene defines the hosting scene
  123601. * @returns the box mesh
  123602. */
  123603. static CreateTiledBox(name: string, options: {
  123604. pattern?: number;
  123605. width?: number;
  123606. height?: number;
  123607. depth?: number;
  123608. tileSize?: number;
  123609. tileWidth?: number;
  123610. tileHeight?: number;
  123611. alignHorizontal?: number;
  123612. alignVertical?: number;
  123613. faceUV?: Vector4[];
  123614. faceColors?: Color4[];
  123615. sideOrientation?: number;
  123616. updatable?: boolean;
  123617. }, scene?: Nullable<Scene>): Mesh;
  123618. }
  123619. }
  123620. declare module BABYLON {
  123621. /**
  123622. * Class containing static functions to help procedurally build meshes
  123623. */
  123624. export class TorusKnotBuilder {
  123625. /**
  123626. * Creates a torus knot mesh
  123627. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123628. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123629. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123630. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123634. * @param name defines the name of the mesh
  123635. * @param options defines the options used to create the mesh
  123636. * @param scene defines the hosting scene
  123637. * @returns the torus knot mesh
  123638. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123639. */
  123640. static CreateTorusKnot(name: string, options: {
  123641. radius?: number;
  123642. tube?: number;
  123643. radialSegments?: number;
  123644. tubularSegments?: number;
  123645. p?: number;
  123646. q?: number;
  123647. updatable?: boolean;
  123648. sideOrientation?: number;
  123649. frontUVs?: Vector4;
  123650. backUVs?: Vector4;
  123651. }, scene: any): Mesh;
  123652. }
  123653. }
  123654. declare module BABYLON {
  123655. /**
  123656. * Polygon
  123657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123658. */
  123659. export class Polygon {
  123660. /**
  123661. * Creates a rectangle
  123662. * @param xmin bottom X coord
  123663. * @param ymin bottom Y coord
  123664. * @param xmax top X coord
  123665. * @param ymax top Y coord
  123666. * @returns points that make the resulting rectation
  123667. */
  123668. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123669. /**
  123670. * Creates a circle
  123671. * @param radius radius of circle
  123672. * @param cx scale in x
  123673. * @param cy scale in y
  123674. * @param numberOfSides number of sides that make up the circle
  123675. * @returns points that make the resulting circle
  123676. */
  123677. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123678. /**
  123679. * Creates a polygon from input string
  123680. * @param input Input polygon data
  123681. * @returns the parsed points
  123682. */
  123683. static Parse(input: string): Vector2[];
  123684. /**
  123685. * Starts building a polygon from x and y coordinates
  123686. * @param x x coordinate
  123687. * @param y y coordinate
  123688. * @returns the started path2
  123689. */
  123690. static StartingAt(x: number, y: number): Path2;
  123691. }
  123692. /**
  123693. * Builds a polygon
  123694. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123695. */
  123696. export class PolygonMeshBuilder {
  123697. private _points;
  123698. private _outlinepoints;
  123699. private _holes;
  123700. private _name;
  123701. private _scene;
  123702. private _epoints;
  123703. private _eholes;
  123704. private _addToepoint;
  123705. /**
  123706. * Babylon reference to the earcut plugin.
  123707. */
  123708. bjsEarcut: any;
  123709. /**
  123710. * Creates a PolygonMeshBuilder
  123711. * @param name name of the builder
  123712. * @param contours Path of the polygon
  123713. * @param scene scene to add to when creating the mesh
  123714. * @param earcutInjection can be used to inject your own earcut reference
  123715. */
  123716. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123717. /**
  123718. * Adds a whole within the polygon
  123719. * @param hole Array of points defining the hole
  123720. * @returns this
  123721. */
  123722. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123723. /**
  123724. * Creates the polygon
  123725. * @param updatable If the mesh should be updatable
  123726. * @param depth The depth of the mesh created
  123727. * @returns the created mesh
  123728. */
  123729. build(updatable?: boolean, depth?: number): Mesh;
  123730. /**
  123731. * Creates the polygon
  123732. * @param depth The depth of the mesh created
  123733. * @returns the created VertexData
  123734. */
  123735. buildVertexData(depth?: number): VertexData;
  123736. /**
  123737. * Adds a side to the polygon
  123738. * @param positions points that make the polygon
  123739. * @param normals normals of the polygon
  123740. * @param uvs uvs of the polygon
  123741. * @param indices indices of the polygon
  123742. * @param bounds bounds of the polygon
  123743. * @param points points of the polygon
  123744. * @param depth depth of the polygon
  123745. * @param flip flip of the polygon
  123746. */
  123747. private addSide;
  123748. }
  123749. }
  123750. declare module BABYLON {
  123751. /**
  123752. * Class containing static functions to help procedurally build meshes
  123753. */
  123754. export class PolygonBuilder {
  123755. /**
  123756. * Creates a polygon mesh
  123757. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123758. * * 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
  123759. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123762. * * Remember you can only change the shape positions, not their number when updating a polygon
  123763. * @param name defines the name of the mesh
  123764. * @param options defines the options used to create the mesh
  123765. * @param scene defines the hosting scene
  123766. * @param earcutInjection can be used to inject your own earcut reference
  123767. * @returns the polygon mesh
  123768. */
  123769. static CreatePolygon(name: string, options: {
  123770. shape: Vector3[];
  123771. holes?: Vector3[][];
  123772. depth?: number;
  123773. faceUV?: Vector4[];
  123774. faceColors?: Color4[];
  123775. updatable?: boolean;
  123776. sideOrientation?: number;
  123777. frontUVs?: Vector4;
  123778. backUVs?: Vector4;
  123779. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123780. /**
  123781. * Creates an extruded polygon mesh, with depth in the Y direction.
  123782. * * 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)
  123783. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123784. * @param name defines the name of the mesh
  123785. * @param options defines the options used to create the mesh
  123786. * @param scene defines the hosting scene
  123787. * @param earcutInjection can be used to inject your own earcut reference
  123788. * @returns the polygon mesh
  123789. */
  123790. static ExtrudePolygon(name: string, options: {
  123791. shape: Vector3[];
  123792. holes?: Vector3[][];
  123793. depth?: number;
  123794. faceUV?: Vector4[];
  123795. faceColors?: Color4[];
  123796. updatable?: boolean;
  123797. sideOrientation?: number;
  123798. frontUVs?: Vector4;
  123799. backUVs?: Vector4;
  123800. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123801. }
  123802. }
  123803. declare module BABYLON {
  123804. /**
  123805. * Class containing static functions to help procedurally build meshes
  123806. */
  123807. export class LatheBuilder {
  123808. /**
  123809. * Creates lathe mesh.
  123810. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123811. * * 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
  123812. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123813. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123814. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123815. * * 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
  123816. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123817. * * 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
  123818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123822. * @param name defines the name of the mesh
  123823. * @param options defines the options used to create the mesh
  123824. * @param scene defines the hosting scene
  123825. * @returns the lathe mesh
  123826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123827. */
  123828. static CreateLathe(name: string, options: {
  123829. shape: Vector3[];
  123830. radius?: number;
  123831. tessellation?: number;
  123832. clip?: number;
  123833. arc?: number;
  123834. closed?: boolean;
  123835. updatable?: boolean;
  123836. sideOrientation?: number;
  123837. frontUVs?: Vector4;
  123838. backUVs?: Vector4;
  123839. cap?: number;
  123840. invertUV?: boolean;
  123841. }, scene?: Nullable<Scene>): Mesh;
  123842. }
  123843. }
  123844. declare module BABYLON {
  123845. /**
  123846. * Class containing static functions to help procedurally build meshes
  123847. */
  123848. export class TiledPlaneBuilder {
  123849. /**
  123850. * Creates a tiled plane mesh
  123851. * * The parameter `pattern` will, depending on value, do nothing or
  123852. * * * flip (reflect about central vertical) alternate tiles across and up
  123853. * * * flip every tile on alternate rows
  123854. * * * rotate (180 degs) alternate tiles across and up
  123855. * * * rotate every tile on alternate rows
  123856. * * * flip and rotate alternate tiles across and up
  123857. * * * flip and rotate every tile on alternate rows
  123858. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123859. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123862. * * 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)
  123863. * * 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)
  123864. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123865. * @param name defines the name of the mesh
  123866. * @param options defines the options used to create the mesh
  123867. * @param scene defines the hosting scene
  123868. * @returns the box mesh
  123869. */
  123870. static CreateTiledPlane(name: string, options: {
  123871. pattern?: number;
  123872. tileSize?: number;
  123873. tileWidth?: number;
  123874. tileHeight?: number;
  123875. size?: number;
  123876. width?: number;
  123877. height?: number;
  123878. alignHorizontal?: number;
  123879. alignVertical?: number;
  123880. sideOrientation?: number;
  123881. frontUVs?: Vector4;
  123882. backUVs?: Vector4;
  123883. updatable?: boolean;
  123884. }, scene?: Nullable<Scene>): Mesh;
  123885. }
  123886. }
  123887. declare module BABYLON {
  123888. /**
  123889. * Class containing static functions to help procedurally build meshes
  123890. */
  123891. export class TubeBuilder {
  123892. /**
  123893. * Creates a tube mesh.
  123894. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123895. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123896. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123897. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123898. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123899. * * 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)
  123900. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123901. * * 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
  123902. * * 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
  123903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123907. * @param name defines the name of the mesh
  123908. * @param options defines the options used to create the mesh
  123909. * @param scene defines the hosting scene
  123910. * @returns the tube mesh
  123911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123912. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123913. */
  123914. static CreateTube(name: string, options: {
  123915. path: Vector3[];
  123916. radius?: number;
  123917. tessellation?: number;
  123918. radiusFunction?: {
  123919. (i: number, distance: number): number;
  123920. };
  123921. cap?: number;
  123922. arc?: number;
  123923. updatable?: boolean;
  123924. sideOrientation?: number;
  123925. frontUVs?: Vector4;
  123926. backUVs?: Vector4;
  123927. instance?: Mesh;
  123928. invertUV?: boolean;
  123929. }, scene?: Nullable<Scene>): Mesh;
  123930. }
  123931. }
  123932. declare module BABYLON {
  123933. /**
  123934. * Class containing static functions to help procedurally build meshes
  123935. */
  123936. export class IcoSphereBuilder {
  123937. /**
  123938. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123939. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123940. * * 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`)
  123941. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123942. * * 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
  123943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123946. * @param name defines the name of the mesh
  123947. * @param options defines the options used to create the mesh
  123948. * @param scene defines the hosting scene
  123949. * @returns the icosahedron mesh
  123950. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123951. */
  123952. static CreateIcoSphere(name: string, options: {
  123953. radius?: number;
  123954. radiusX?: number;
  123955. radiusY?: number;
  123956. radiusZ?: number;
  123957. flat?: boolean;
  123958. subdivisions?: number;
  123959. sideOrientation?: number;
  123960. frontUVs?: Vector4;
  123961. backUVs?: Vector4;
  123962. updatable?: boolean;
  123963. }, scene?: Nullable<Scene>): Mesh;
  123964. }
  123965. }
  123966. declare module BABYLON {
  123967. /**
  123968. * Class containing static functions to help procedurally build meshes
  123969. */
  123970. export class DecalBuilder {
  123971. /**
  123972. * Creates a decal mesh.
  123973. * 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
  123974. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123975. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123976. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123977. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123978. * @param name defines the name of the mesh
  123979. * @param sourceMesh defines the mesh where the decal must be applied
  123980. * @param options defines the options used to create the mesh
  123981. * @param scene defines the hosting scene
  123982. * @returns the decal mesh
  123983. * @see https://doc.babylonjs.com/how_to/decals
  123984. */
  123985. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123986. position?: Vector3;
  123987. normal?: Vector3;
  123988. size?: Vector3;
  123989. angle?: number;
  123990. }): Mesh;
  123991. }
  123992. }
  123993. declare module BABYLON {
  123994. /**
  123995. * Class containing static functions to help procedurally build meshes
  123996. */
  123997. export class MeshBuilder {
  123998. /**
  123999. * Creates a box mesh
  124000. * * The parameter `size` sets the size (float) of each box side (default 1)
  124001. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  124002. * * 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)
  124003. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124007. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124008. * @param name defines the name of the mesh
  124009. * @param options defines the options used to create the mesh
  124010. * @param scene defines the hosting scene
  124011. * @returns the box mesh
  124012. */
  124013. static CreateBox(name: string, options: {
  124014. size?: number;
  124015. width?: number;
  124016. height?: number;
  124017. depth?: number;
  124018. faceUV?: Vector4[];
  124019. faceColors?: Color4[];
  124020. sideOrientation?: number;
  124021. frontUVs?: Vector4;
  124022. backUVs?: Vector4;
  124023. updatable?: boolean;
  124024. }, scene?: Nullable<Scene>): Mesh;
  124025. /**
  124026. * Creates a tiled box mesh
  124027. * * faceTiles sets the pattern, tile size and number of tiles for a face
  124028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124029. * @param name defines the name of the mesh
  124030. * @param options defines the options used to create the mesh
  124031. * @param scene defines the hosting scene
  124032. * @returns the tiled box mesh
  124033. */
  124034. static CreateTiledBox(name: string, options: {
  124035. pattern?: number;
  124036. size?: number;
  124037. width?: number;
  124038. height?: number;
  124039. depth: number;
  124040. tileSize?: number;
  124041. tileWidth?: number;
  124042. tileHeight?: number;
  124043. faceUV?: Vector4[];
  124044. faceColors?: Color4[];
  124045. alignHorizontal?: number;
  124046. alignVertical?: number;
  124047. sideOrientation?: number;
  124048. updatable?: boolean;
  124049. }, scene?: Nullable<Scene>): Mesh;
  124050. /**
  124051. * Creates a sphere mesh
  124052. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124053. * * 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`)
  124054. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124055. * * 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
  124056. * * 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)
  124057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124060. * @param name defines the name of the mesh
  124061. * @param options defines the options used to create the mesh
  124062. * @param scene defines the hosting scene
  124063. * @returns the sphere mesh
  124064. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124065. */
  124066. static CreateSphere(name: string, options: {
  124067. segments?: number;
  124068. diameter?: number;
  124069. diameterX?: number;
  124070. diameterY?: number;
  124071. diameterZ?: number;
  124072. arc?: number;
  124073. slice?: number;
  124074. sideOrientation?: number;
  124075. frontUVs?: Vector4;
  124076. backUVs?: Vector4;
  124077. updatable?: boolean;
  124078. }, scene?: Nullable<Scene>): Mesh;
  124079. /**
  124080. * Creates a plane polygonal mesh. By default, this is a disc
  124081. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  124082. * * 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
  124083. * * 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
  124084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124087. * @param name defines the name of the mesh
  124088. * @param options defines the options used to create the mesh
  124089. * @param scene defines the hosting scene
  124090. * @returns the plane polygonal mesh
  124091. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124092. */
  124093. static CreateDisc(name: string, options: {
  124094. radius?: number;
  124095. tessellation?: number;
  124096. arc?: number;
  124097. updatable?: boolean;
  124098. sideOrientation?: number;
  124099. frontUVs?: Vector4;
  124100. backUVs?: Vector4;
  124101. }, scene?: Nullable<Scene>): Mesh;
  124102. /**
  124103. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124104. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124105. * * 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`)
  124106. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124107. * * 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
  124108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124111. * @param name defines the name of the mesh
  124112. * @param options defines the options used to create the mesh
  124113. * @param scene defines the hosting scene
  124114. * @returns the icosahedron mesh
  124115. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124116. */
  124117. static CreateIcoSphere(name: string, options: {
  124118. radius?: number;
  124119. radiusX?: number;
  124120. radiusY?: number;
  124121. radiusZ?: number;
  124122. flat?: boolean;
  124123. subdivisions?: number;
  124124. sideOrientation?: number;
  124125. frontUVs?: Vector4;
  124126. backUVs?: Vector4;
  124127. updatable?: boolean;
  124128. }, scene?: Nullable<Scene>): Mesh;
  124129. /**
  124130. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124131. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124132. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124133. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124134. * * 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
  124135. * * 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
  124136. * * 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
  124137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124140. * * 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
  124141. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124142. * * 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
  124143. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124145. * @param name defines the name of the mesh
  124146. * @param options defines the options used to create the mesh
  124147. * @param scene defines the hosting scene
  124148. * @returns the ribbon mesh
  124149. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124151. */
  124152. static CreateRibbon(name: string, options: {
  124153. pathArray: Vector3[][];
  124154. closeArray?: boolean;
  124155. closePath?: boolean;
  124156. offset?: number;
  124157. updatable?: boolean;
  124158. sideOrientation?: number;
  124159. frontUVs?: Vector4;
  124160. backUVs?: Vector4;
  124161. instance?: Mesh;
  124162. invertUV?: boolean;
  124163. uvs?: Vector2[];
  124164. colors?: Color4[];
  124165. }, scene?: Nullable<Scene>): Mesh;
  124166. /**
  124167. * Creates a cylinder or a cone mesh
  124168. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124169. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124170. * * 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.
  124171. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124172. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124173. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124174. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124175. * * 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).
  124176. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124177. * * 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).
  124178. * * 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
  124179. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124180. * * 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
  124181. * * 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.
  124182. * * If `enclose` is false, a ring surface is one element.
  124183. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124184. * * 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
  124185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124188. * @param name defines the name of the mesh
  124189. * @param options defines the options used to create the mesh
  124190. * @param scene defines the hosting scene
  124191. * @returns the cylinder mesh
  124192. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124193. */
  124194. static CreateCylinder(name: string, options: {
  124195. height?: number;
  124196. diameterTop?: number;
  124197. diameterBottom?: number;
  124198. diameter?: number;
  124199. tessellation?: number;
  124200. subdivisions?: number;
  124201. arc?: number;
  124202. faceColors?: Color4[];
  124203. faceUV?: Vector4[];
  124204. updatable?: boolean;
  124205. hasRings?: boolean;
  124206. enclose?: boolean;
  124207. cap?: number;
  124208. sideOrientation?: number;
  124209. frontUVs?: Vector4;
  124210. backUVs?: Vector4;
  124211. }, scene?: Nullable<Scene>): Mesh;
  124212. /**
  124213. * Creates a torus mesh
  124214. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124215. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124216. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124220. * @param name defines the name of the mesh
  124221. * @param options defines the options used to create the mesh
  124222. * @param scene defines the hosting scene
  124223. * @returns the torus mesh
  124224. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124225. */
  124226. static CreateTorus(name: string, options: {
  124227. diameter?: number;
  124228. thickness?: number;
  124229. tessellation?: number;
  124230. updatable?: boolean;
  124231. sideOrientation?: number;
  124232. frontUVs?: Vector4;
  124233. backUVs?: Vector4;
  124234. }, scene?: Nullable<Scene>): Mesh;
  124235. /**
  124236. * Creates a torus knot mesh
  124237. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124238. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124239. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124240. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124244. * @param name defines the name of the mesh
  124245. * @param options defines the options used to create the mesh
  124246. * @param scene defines the hosting scene
  124247. * @returns the torus knot mesh
  124248. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124249. */
  124250. static CreateTorusKnot(name: string, options: {
  124251. radius?: number;
  124252. tube?: number;
  124253. radialSegments?: number;
  124254. tubularSegments?: number;
  124255. p?: number;
  124256. q?: number;
  124257. updatable?: boolean;
  124258. sideOrientation?: number;
  124259. frontUVs?: Vector4;
  124260. backUVs?: Vector4;
  124261. }, scene?: Nullable<Scene>): Mesh;
  124262. /**
  124263. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124264. * * 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
  124265. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124266. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124267. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124268. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124269. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124270. * * 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
  124271. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124274. * @param name defines the name of the new line system
  124275. * @param options defines the options used to create the line system
  124276. * @param scene defines the hosting scene
  124277. * @returns a new line system mesh
  124278. */
  124279. static CreateLineSystem(name: string, options: {
  124280. lines: Vector3[][];
  124281. updatable?: boolean;
  124282. instance?: Nullable<LinesMesh>;
  124283. colors?: Nullable<Color4[][]>;
  124284. useVertexAlpha?: boolean;
  124285. }, scene: Nullable<Scene>): LinesMesh;
  124286. /**
  124287. * Creates a line mesh
  124288. * 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
  124289. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124290. * * The parameter `points` is an array successive Vector3
  124291. * * 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
  124292. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124293. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124294. * * When updating an instance, remember that only point positions can change, not the number of points
  124295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124297. * @param name defines the name of the new line system
  124298. * @param options defines the options used to create the line system
  124299. * @param scene defines the hosting scene
  124300. * @returns a new line mesh
  124301. */
  124302. static CreateLines(name: string, options: {
  124303. points: Vector3[];
  124304. updatable?: boolean;
  124305. instance?: Nullable<LinesMesh>;
  124306. colors?: Color4[];
  124307. useVertexAlpha?: boolean;
  124308. }, scene?: Nullable<Scene>): LinesMesh;
  124309. /**
  124310. * Creates a dashed line mesh
  124311. * * 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
  124312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124313. * * The parameter `points` is an array successive Vector3
  124314. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124315. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124316. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124317. * * 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
  124318. * * When updating an instance, remember that only point positions can change, not the number of points
  124319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124320. * @param name defines the name of the mesh
  124321. * @param options defines the options used to create the mesh
  124322. * @param scene defines the hosting scene
  124323. * @returns the dashed line mesh
  124324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124325. */
  124326. static CreateDashedLines(name: string, options: {
  124327. points: Vector3[];
  124328. dashSize?: number;
  124329. gapSize?: number;
  124330. dashNb?: number;
  124331. updatable?: boolean;
  124332. instance?: LinesMesh;
  124333. }, scene?: Nullable<Scene>): LinesMesh;
  124334. /**
  124335. * 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.
  124336. * * 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.
  124337. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124338. * * 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.
  124339. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124340. * * 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
  124341. * * 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
  124342. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124347. * @param name defines the name of the mesh
  124348. * @param options defines the options used to create the mesh
  124349. * @param scene defines the hosting scene
  124350. * @returns the extruded shape mesh
  124351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124353. */
  124354. static ExtrudeShape(name: string, options: {
  124355. shape: Vector3[];
  124356. path: Vector3[];
  124357. scale?: number;
  124358. rotation?: number;
  124359. cap?: number;
  124360. updatable?: boolean;
  124361. sideOrientation?: number;
  124362. frontUVs?: Vector4;
  124363. backUVs?: Vector4;
  124364. instance?: Mesh;
  124365. invertUV?: boolean;
  124366. }, scene?: Nullable<Scene>): Mesh;
  124367. /**
  124368. * Creates an custom extruded shape mesh.
  124369. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124370. * * 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.
  124371. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124372. * * 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
  124373. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124374. * * 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
  124375. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124376. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124377. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124378. * * 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
  124379. * * 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
  124380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124385. * @param name defines the name of the mesh
  124386. * @param options defines the options used to create the mesh
  124387. * @param scene defines the hosting scene
  124388. * @returns the custom extruded shape mesh
  124389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124390. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124392. */
  124393. static ExtrudeShapeCustom(name: string, options: {
  124394. shape: Vector3[];
  124395. path: Vector3[];
  124396. scaleFunction?: any;
  124397. rotationFunction?: any;
  124398. ribbonCloseArray?: boolean;
  124399. ribbonClosePath?: boolean;
  124400. cap?: number;
  124401. updatable?: boolean;
  124402. sideOrientation?: number;
  124403. frontUVs?: Vector4;
  124404. backUVs?: Vector4;
  124405. instance?: Mesh;
  124406. invertUV?: boolean;
  124407. }, scene?: Nullable<Scene>): Mesh;
  124408. /**
  124409. * Creates lathe mesh.
  124410. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124411. * * 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
  124412. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124413. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124414. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124415. * * 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
  124416. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124417. * * 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
  124418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124422. * @param name defines the name of the mesh
  124423. * @param options defines the options used to create the mesh
  124424. * @param scene defines the hosting scene
  124425. * @returns the lathe mesh
  124426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124427. */
  124428. static CreateLathe(name: string, options: {
  124429. shape: Vector3[];
  124430. radius?: number;
  124431. tessellation?: number;
  124432. clip?: number;
  124433. arc?: number;
  124434. closed?: boolean;
  124435. updatable?: boolean;
  124436. sideOrientation?: number;
  124437. frontUVs?: Vector4;
  124438. backUVs?: Vector4;
  124439. cap?: number;
  124440. invertUV?: boolean;
  124441. }, scene?: Nullable<Scene>): Mesh;
  124442. /**
  124443. * Creates a tiled plane mesh
  124444. * * You can set a limited pattern arrangement with the tiles
  124445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124448. * @param name defines the name of the mesh
  124449. * @param options defines the options used to create the mesh
  124450. * @param scene defines the hosting scene
  124451. * @returns the plane mesh
  124452. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124453. */
  124454. static CreateTiledPlane(name: string, options: {
  124455. pattern?: number;
  124456. tileSize?: number;
  124457. tileWidth?: number;
  124458. tileHeight?: number;
  124459. size?: number;
  124460. width?: number;
  124461. height?: number;
  124462. alignHorizontal?: number;
  124463. alignVertical?: number;
  124464. sideOrientation?: number;
  124465. frontUVs?: Vector4;
  124466. backUVs?: Vector4;
  124467. updatable?: boolean;
  124468. }, scene?: Nullable<Scene>): Mesh;
  124469. /**
  124470. * Creates a plane mesh
  124471. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124472. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124473. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124477. * @param name defines the name of the mesh
  124478. * @param options defines the options used to create the mesh
  124479. * @param scene defines the hosting scene
  124480. * @returns the plane mesh
  124481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124482. */
  124483. static CreatePlane(name: string, options: {
  124484. size?: number;
  124485. width?: number;
  124486. height?: number;
  124487. sideOrientation?: number;
  124488. frontUVs?: Vector4;
  124489. backUVs?: Vector4;
  124490. updatable?: boolean;
  124491. sourcePlane?: Plane;
  124492. }, scene?: Nullable<Scene>): Mesh;
  124493. /**
  124494. * Creates a ground mesh
  124495. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124496. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124498. * @param name defines the name of the mesh
  124499. * @param options defines the options used to create the mesh
  124500. * @param scene defines the hosting scene
  124501. * @returns the ground mesh
  124502. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124503. */
  124504. static CreateGround(name: string, options: {
  124505. width?: number;
  124506. height?: number;
  124507. subdivisions?: number;
  124508. subdivisionsX?: number;
  124509. subdivisionsY?: number;
  124510. updatable?: boolean;
  124511. }, scene?: Nullable<Scene>): Mesh;
  124512. /**
  124513. * Creates a tiled ground mesh
  124514. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124515. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124516. * * 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
  124517. * * 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
  124518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124519. * @param name defines the name of the mesh
  124520. * @param options defines the options used to create the mesh
  124521. * @param scene defines the hosting scene
  124522. * @returns the tiled ground mesh
  124523. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124524. */
  124525. static CreateTiledGround(name: string, options: {
  124526. xmin: number;
  124527. zmin: number;
  124528. xmax: number;
  124529. zmax: number;
  124530. subdivisions?: {
  124531. w: number;
  124532. h: number;
  124533. };
  124534. precision?: {
  124535. w: number;
  124536. h: number;
  124537. };
  124538. updatable?: boolean;
  124539. }, scene?: Nullable<Scene>): Mesh;
  124540. /**
  124541. * Creates a ground mesh from a height map
  124542. * * The parameter `url` sets the URL of the height map image resource.
  124543. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124544. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124545. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124546. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124547. * * 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.
  124548. * * 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).
  124549. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124551. * @param name defines the name of the mesh
  124552. * @param url defines the url to the height map
  124553. * @param options defines the options used to create the mesh
  124554. * @param scene defines the hosting scene
  124555. * @returns the ground mesh
  124556. * @see https://doc.babylonjs.com/babylon101/height_map
  124557. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124558. */
  124559. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124560. width?: number;
  124561. height?: number;
  124562. subdivisions?: number;
  124563. minHeight?: number;
  124564. maxHeight?: number;
  124565. colorFilter?: Color3;
  124566. alphaFilter?: number;
  124567. updatable?: boolean;
  124568. onReady?: (mesh: GroundMesh) => void;
  124569. }, scene?: Nullable<Scene>): GroundMesh;
  124570. /**
  124571. * Creates a polygon mesh
  124572. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124573. * * 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
  124574. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124577. * * Remember you can only change the shape positions, not their number when updating a polygon
  124578. * @param name defines the name of the mesh
  124579. * @param options defines the options used to create the mesh
  124580. * @param scene defines the hosting scene
  124581. * @param earcutInjection can be used to inject your own earcut reference
  124582. * @returns the polygon mesh
  124583. */
  124584. static CreatePolygon(name: string, options: {
  124585. shape: Vector3[];
  124586. holes?: Vector3[][];
  124587. depth?: number;
  124588. faceUV?: Vector4[];
  124589. faceColors?: Color4[];
  124590. updatable?: boolean;
  124591. sideOrientation?: number;
  124592. frontUVs?: Vector4;
  124593. backUVs?: Vector4;
  124594. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124595. /**
  124596. * Creates an extruded polygon mesh, with depth in the Y direction.
  124597. * * 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)
  124598. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124599. * @param name defines the name of the mesh
  124600. * @param options defines the options used to create the mesh
  124601. * @param scene defines the hosting scene
  124602. * @param earcutInjection can be used to inject your own earcut reference
  124603. * @returns the polygon mesh
  124604. */
  124605. static ExtrudePolygon(name: string, options: {
  124606. shape: Vector3[];
  124607. holes?: Vector3[][];
  124608. depth?: number;
  124609. faceUV?: Vector4[];
  124610. faceColors?: Color4[];
  124611. updatable?: boolean;
  124612. sideOrientation?: number;
  124613. frontUVs?: Vector4;
  124614. backUVs?: Vector4;
  124615. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124616. /**
  124617. * Creates a tube mesh.
  124618. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124619. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124620. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124621. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124622. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124623. * * 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)
  124624. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124625. * * 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
  124626. * * 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
  124627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124631. * @param name defines the name of the mesh
  124632. * @param options defines the options used to create the mesh
  124633. * @param scene defines the hosting scene
  124634. * @returns the tube mesh
  124635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124636. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124637. */
  124638. static CreateTube(name: string, options: {
  124639. path: Vector3[];
  124640. radius?: number;
  124641. tessellation?: number;
  124642. radiusFunction?: {
  124643. (i: number, distance: number): number;
  124644. };
  124645. cap?: number;
  124646. arc?: number;
  124647. updatable?: boolean;
  124648. sideOrientation?: number;
  124649. frontUVs?: Vector4;
  124650. backUVs?: Vector4;
  124651. instance?: Mesh;
  124652. invertUV?: boolean;
  124653. }, scene?: Nullable<Scene>): Mesh;
  124654. /**
  124655. * Creates a polyhedron mesh
  124656. * * 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
  124657. * * The parameter `size` (positive float, default 1) sets the polygon size
  124658. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124659. * * 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`
  124660. * * 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
  124661. * * 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)`)
  124662. * * 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
  124663. * * 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
  124664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124667. * @param name defines the name of the mesh
  124668. * @param options defines the options used to create the mesh
  124669. * @param scene defines the hosting scene
  124670. * @returns the polyhedron mesh
  124671. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124672. */
  124673. static CreatePolyhedron(name: string, options: {
  124674. type?: number;
  124675. size?: number;
  124676. sizeX?: number;
  124677. sizeY?: number;
  124678. sizeZ?: number;
  124679. custom?: any;
  124680. faceUV?: Vector4[];
  124681. faceColors?: Color4[];
  124682. flat?: boolean;
  124683. updatable?: boolean;
  124684. sideOrientation?: number;
  124685. frontUVs?: Vector4;
  124686. backUVs?: Vector4;
  124687. }, scene?: Nullable<Scene>): Mesh;
  124688. /**
  124689. * Creates a decal mesh.
  124690. * 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
  124691. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124692. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124693. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124694. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124695. * @param name defines the name of the mesh
  124696. * @param sourceMesh defines the mesh where the decal must be applied
  124697. * @param options defines the options used to create the mesh
  124698. * @param scene defines the hosting scene
  124699. * @returns the decal mesh
  124700. * @see https://doc.babylonjs.com/how_to/decals
  124701. */
  124702. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124703. position?: Vector3;
  124704. normal?: Vector3;
  124705. size?: Vector3;
  124706. angle?: number;
  124707. }): Mesh;
  124708. }
  124709. }
  124710. declare module BABYLON {
  124711. /**
  124712. * A simplifier interface for future simplification implementations
  124713. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124714. */
  124715. export interface ISimplifier {
  124716. /**
  124717. * Simplification of a given mesh according to the given settings.
  124718. * Since this requires computation, it is assumed that the function runs async.
  124719. * @param settings The settings of the simplification, including quality and distance
  124720. * @param successCallback A callback that will be called after the mesh was simplified.
  124721. * @param errorCallback in case of an error, this callback will be called. optional.
  124722. */
  124723. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124724. }
  124725. /**
  124726. * Expected simplification settings.
  124727. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124728. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124729. */
  124730. export interface ISimplificationSettings {
  124731. /**
  124732. * Gets or sets the expected quality
  124733. */
  124734. quality: number;
  124735. /**
  124736. * Gets or sets the distance when this optimized version should be used
  124737. */
  124738. distance: number;
  124739. /**
  124740. * Gets an already optimized mesh
  124741. */
  124742. optimizeMesh?: boolean;
  124743. }
  124744. /**
  124745. * Class used to specify simplification options
  124746. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124747. */
  124748. export class SimplificationSettings implements ISimplificationSettings {
  124749. /** expected quality */
  124750. quality: number;
  124751. /** distance when this optimized version should be used */
  124752. distance: number;
  124753. /** already optimized mesh */
  124754. optimizeMesh?: boolean | undefined;
  124755. /**
  124756. * Creates a SimplificationSettings
  124757. * @param quality expected quality
  124758. * @param distance distance when this optimized version should be used
  124759. * @param optimizeMesh already optimized mesh
  124760. */
  124761. constructor(
  124762. /** expected quality */
  124763. quality: number,
  124764. /** distance when this optimized version should be used */
  124765. distance: number,
  124766. /** already optimized mesh */
  124767. optimizeMesh?: boolean | undefined);
  124768. }
  124769. /**
  124770. * Interface used to define a simplification task
  124771. */
  124772. export interface ISimplificationTask {
  124773. /**
  124774. * Array of settings
  124775. */
  124776. settings: Array<ISimplificationSettings>;
  124777. /**
  124778. * Simplification type
  124779. */
  124780. simplificationType: SimplificationType;
  124781. /**
  124782. * Mesh to simplify
  124783. */
  124784. mesh: Mesh;
  124785. /**
  124786. * Callback called on success
  124787. */
  124788. successCallback?: () => void;
  124789. /**
  124790. * Defines if parallel processing can be used
  124791. */
  124792. parallelProcessing: boolean;
  124793. }
  124794. /**
  124795. * Queue used to order the simplification tasks
  124796. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124797. */
  124798. export class SimplificationQueue {
  124799. private _simplificationArray;
  124800. /**
  124801. * Gets a boolean indicating that the process is still running
  124802. */
  124803. running: boolean;
  124804. /**
  124805. * Creates a new queue
  124806. */
  124807. constructor();
  124808. /**
  124809. * Adds a new simplification task
  124810. * @param task defines a task to add
  124811. */
  124812. addTask(task: ISimplificationTask): void;
  124813. /**
  124814. * Execute next task
  124815. */
  124816. executeNext(): void;
  124817. /**
  124818. * Execute a simplification task
  124819. * @param task defines the task to run
  124820. */
  124821. runSimplification(task: ISimplificationTask): void;
  124822. private getSimplifier;
  124823. }
  124824. /**
  124825. * The implemented types of simplification
  124826. * At the moment only Quadratic Error Decimation is implemented
  124827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124828. */
  124829. export enum SimplificationType {
  124830. /** Quadratic error decimation */
  124831. QUADRATIC = 0
  124832. }
  124833. }
  124834. declare module BABYLON {
  124835. interface Scene {
  124836. /** @hidden (Backing field) */
  124837. _simplificationQueue: SimplificationQueue;
  124838. /**
  124839. * Gets or sets the simplification queue attached to the scene
  124840. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124841. */
  124842. simplificationQueue: SimplificationQueue;
  124843. }
  124844. interface Mesh {
  124845. /**
  124846. * Simplify the mesh according to the given array of settings.
  124847. * Function will return immediately and will simplify async
  124848. * @param settings a collection of simplification settings
  124849. * @param parallelProcessing should all levels calculate parallel or one after the other
  124850. * @param simplificationType the type of simplification to run
  124851. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124852. * @returns the current mesh
  124853. */
  124854. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124855. }
  124856. /**
  124857. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124858. * created in a scene
  124859. */
  124860. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124861. /**
  124862. * The component name helpfull to identify the component in the list of scene components.
  124863. */
  124864. readonly name: string;
  124865. /**
  124866. * The scene the component belongs to.
  124867. */
  124868. scene: Scene;
  124869. /**
  124870. * Creates a new instance of the component for the given scene
  124871. * @param scene Defines the scene to register the component in
  124872. */
  124873. constructor(scene: Scene);
  124874. /**
  124875. * Registers the component in a given scene
  124876. */
  124877. register(): void;
  124878. /**
  124879. * Rebuilds the elements related to this component in case of
  124880. * context lost for instance.
  124881. */
  124882. rebuild(): void;
  124883. /**
  124884. * Disposes the component and the associated ressources
  124885. */
  124886. dispose(): void;
  124887. private _beforeCameraUpdate;
  124888. }
  124889. }
  124890. declare module BABYLON {
  124891. /**
  124892. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124893. */
  124894. export interface INavigationEnginePlugin {
  124895. /**
  124896. * plugin name
  124897. */
  124898. name: string;
  124899. /**
  124900. * Creates a navigation mesh
  124901. * @param meshes array of all the geometry used to compute the navigatio mesh
  124902. * @param parameters bunch of parameters used to filter geometry
  124903. */
  124904. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124905. /**
  124906. * Create a navigation mesh debug mesh
  124907. * @param scene is where the mesh will be added
  124908. * @returns debug display mesh
  124909. */
  124910. createDebugNavMesh(scene: Scene): Mesh;
  124911. /**
  124912. * Get a navigation mesh constrained position, closest to the parameter position
  124913. * @param position world position
  124914. * @returns the closest point to position constrained by the navigation mesh
  124915. */
  124916. getClosestPoint(position: Vector3): Vector3;
  124917. /**
  124918. * Get a navigation mesh constrained position, within a particular radius
  124919. * @param position world position
  124920. * @param maxRadius the maximum distance to the constrained world position
  124921. * @returns the closest point to position constrained by the navigation mesh
  124922. */
  124923. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124924. /**
  124925. * Compute the final position from a segment made of destination-position
  124926. * @param position world position
  124927. * @param destination world position
  124928. * @returns the resulting point along the navmesh
  124929. */
  124930. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124931. /**
  124932. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124933. * @param start world position
  124934. * @param end world position
  124935. * @returns array containing world position composing the path
  124936. */
  124937. computePath(start: Vector3, end: Vector3): Vector3[];
  124938. /**
  124939. * If this plugin is supported
  124940. * @returns true if plugin is supported
  124941. */
  124942. isSupported(): boolean;
  124943. /**
  124944. * Create a new Crowd so you can add agents
  124945. * @param maxAgents the maximum agent count in the crowd
  124946. * @param maxAgentRadius the maximum radius an agent can have
  124947. * @param scene to attach the crowd to
  124948. * @returns the crowd you can add agents to
  124949. */
  124950. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124951. /**
  124952. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124953. * The queries will try to find a solution within those bounds
  124954. * default is (1,1,1)
  124955. * @param extent x,y,z value that define the extent around the queries point of reference
  124956. */
  124957. setDefaultQueryExtent(extent: Vector3): void;
  124958. /**
  124959. * Get the Bounding box extent specified by setDefaultQueryExtent
  124960. * @returns the box extent values
  124961. */
  124962. getDefaultQueryExtent(): Vector3;
  124963. /**
  124964. * Release all resources
  124965. */
  124966. dispose(): void;
  124967. }
  124968. /**
  124969. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124970. */
  124971. export interface ICrowd {
  124972. /**
  124973. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124974. * You can attach anything to that node. The node position is updated in the scene update tick.
  124975. * @param pos world position that will be constrained by the navigation mesh
  124976. * @param parameters agent parameters
  124977. * @param transform hooked to the agent that will be update by the scene
  124978. * @returns agent index
  124979. */
  124980. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124981. /**
  124982. * Returns the agent position in world space
  124983. * @param index agent index returned by addAgent
  124984. * @returns world space position
  124985. */
  124986. getAgentPosition(index: number): Vector3;
  124987. /**
  124988. * Gets the agent velocity in world space
  124989. * @param index agent index returned by addAgent
  124990. * @returns world space velocity
  124991. */
  124992. getAgentVelocity(index: number): Vector3;
  124993. /**
  124994. * remove a particular agent previously created
  124995. * @param index agent index returned by addAgent
  124996. */
  124997. removeAgent(index: number): void;
  124998. /**
  124999. * get the list of all agents attached to this crowd
  125000. * @returns list of agent indices
  125001. */
  125002. getAgents(): number[];
  125003. /**
  125004. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125005. * @param deltaTime in seconds
  125006. */
  125007. update(deltaTime: number): void;
  125008. /**
  125009. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125010. * @param index agent index returned by addAgent
  125011. * @param destination targeted world position
  125012. */
  125013. agentGoto(index: number, destination: Vector3): void;
  125014. /**
  125015. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125016. * The queries will try to find a solution within those bounds
  125017. * default is (1,1,1)
  125018. * @param extent x,y,z value that define the extent around the queries point of reference
  125019. */
  125020. setDefaultQueryExtent(extent: Vector3): void;
  125021. /**
  125022. * Get the Bounding box extent specified by setDefaultQueryExtent
  125023. * @returns the box extent values
  125024. */
  125025. getDefaultQueryExtent(): Vector3;
  125026. /**
  125027. * Release all resources
  125028. */
  125029. dispose(): void;
  125030. }
  125031. /**
  125032. * Configures an agent
  125033. */
  125034. export interface IAgentParameters {
  125035. /**
  125036. * Agent radius. [Limit: >= 0]
  125037. */
  125038. radius: number;
  125039. /**
  125040. * Agent height. [Limit: > 0]
  125041. */
  125042. height: number;
  125043. /**
  125044. * Maximum allowed acceleration. [Limit: >= 0]
  125045. */
  125046. maxAcceleration: number;
  125047. /**
  125048. * Maximum allowed speed. [Limit: >= 0]
  125049. */
  125050. maxSpeed: number;
  125051. /**
  125052. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  125053. */
  125054. collisionQueryRange: number;
  125055. /**
  125056. * The path visibility optimization range. [Limit: > 0]
  125057. */
  125058. pathOptimizationRange: number;
  125059. /**
  125060. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  125061. */
  125062. separationWeight: number;
  125063. }
  125064. /**
  125065. * Configures the navigation mesh creation
  125066. */
  125067. export interface INavMeshParameters {
  125068. /**
  125069. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  125070. */
  125071. cs: number;
  125072. /**
  125073. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  125074. */
  125075. ch: number;
  125076. /**
  125077. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  125078. */
  125079. walkableSlopeAngle: number;
  125080. /**
  125081. * Minimum floor to 'ceiling' height that will still allow the floor area to
  125082. * be considered walkable. [Limit: >= 3] [Units: vx]
  125083. */
  125084. walkableHeight: number;
  125085. /**
  125086. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125087. */
  125088. walkableClimb: number;
  125089. /**
  125090. * The distance to erode/shrink the walkable area of the heightfield away from
  125091. * obstructions. [Limit: >=0] [Units: vx]
  125092. */
  125093. walkableRadius: number;
  125094. /**
  125095. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125096. */
  125097. maxEdgeLen: number;
  125098. /**
  125099. * The maximum distance a simplfied contour's border edges should deviate
  125100. * the original raw contour. [Limit: >=0] [Units: vx]
  125101. */
  125102. maxSimplificationError: number;
  125103. /**
  125104. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125105. */
  125106. minRegionArea: number;
  125107. /**
  125108. * Any regions with a span count smaller than this value will, if possible,
  125109. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125110. */
  125111. mergeRegionArea: number;
  125112. /**
  125113. * The maximum number of vertices allowed for polygons generated during the
  125114. * contour to polygon conversion process. [Limit: >= 3]
  125115. */
  125116. maxVertsPerPoly: number;
  125117. /**
  125118. * Sets the sampling distance to use when generating the detail mesh.
  125119. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125120. */
  125121. detailSampleDist: number;
  125122. /**
  125123. * The maximum distance the detail mesh surface should deviate from heightfield
  125124. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125125. */
  125126. detailSampleMaxError: number;
  125127. }
  125128. }
  125129. declare module BABYLON {
  125130. /**
  125131. * RecastJS navigation plugin
  125132. */
  125133. export class RecastJSPlugin implements INavigationEnginePlugin {
  125134. /**
  125135. * Reference to the Recast library
  125136. */
  125137. bjsRECAST: any;
  125138. /**
  125139. * plugin name
  125140. */
  125141. name: string;
  125142. /**
  125143. * the first navmesh created. We might extend this to support multiple navmeshes
  125144. */
  125145. navMesh: any;
  125146. /**
  125147. * Initializes the recastJS plugin
  125148. * @param recastInjection can be used to inject your own recast reference
  125149. */
  125150. constructor(recastInjection?: any);
  125151. /**
  125152. * Creates a navigation mesh
  125153. * @param meshes array of all the geometry used to compute the navigatio mesh
  125154. * @param parameters bunch of parameters used to filter geometry
  125155. */
  125156. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125157. /**
  125158. * Create a navigation mesh debug mesh
  125159. * @param scene is where the mesh will be added
  125160. * @returns debug display mesh
  125161. */
  125162. createDebugNavMesh(scene: Scene): Mesh;
  125163. /**
  125164. * Get a navigation mesh constrained position, closest to the parameter position
  125165. * @param position world position
  125166. * @returns the closest point to position constrained by the navigation mesh
  125167. */
  125168. getClosestPoint(position: Vector3): Vector3;
  125169. /**
  125170. * Get a navigation mesh constrained position, within a particular radius
  125171. * @param position world position
  125172. * @param maxRadius the maximum distance to the constrained world position
  125173. * @returns the closest point to position constrained by the navigation mesh
  125174. */
  125175. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125176. /**
  125177. * Compute the final position from a segment made of destination-position
  125178. * @param position world position
  125179. * @param destination world position
  125180. * @returns the resulting point along the navmesh
  125181. */
  125182. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125183. /**
  125184. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125185. * @param start world position
  125186. * @param end world position
  125187. * @returns array containing world position composing the path
  125188. */
  125189. computePath(start: Vector3, end: Vector3): Vector3[];
  125190. /**
  125191. * Create a new Crowd so you can add agents
  125192. * @param maxAgents the maximum agent count in the crowd
  125193. * @param maxAgentRadius the maximum radius an agent can have
  125194. * @param scene to attach the crowd to
  125195. * @returns the crowd you can add agents to
  125196. */
  125197. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125198. /**
  125199. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125200. * The queries will try to find a solution within those bounds
  125201. * default is (1,1,1)
  125202. * @param extent x,y,z value that define the extent around the queries point of reference
  125203. */
  125204. setDefaultQueryExtent(extent: Vector3): void;
  125205. /**
  125206. * Get the Bounding box extent specified by setDefaultQueryExtent
  125207. * @returns the box extent values
  125208. */
  125209. getDefaultQueryExtent(): Vector3;
  125210. /**
  125211. * Disposes
  125212. */
  125213. dispose(): void;
  125214. /**
  125215. * If this plugin is supported
  125216. * @returns true if plugin is supported
  125217. */
  125218. isSupported(): boolean;
  125219. }
  125220. /**
  125221. * Recast detour crowd implementation
  125222. */
  125223. export class RecastJSCrowd implements ICrowd {
  125224. /**
  125225. * Recast/detour plugin
  125226. */
  125227. bjsRECASTPlugin: RecastJSPlugin;
  125228. /**
  125229. * Link to the detour crowd
  125230. */
  125231. recastCrowd: any;
  125232. /**
  125233. * One transform per agent
  125234. */
  125235. transforms: TransformNode[];
  125236. /**
  125237. * All agents created
  125238. */
  125239. agents: number[];
  125240. /**
  125241. * Link to the scene is kept to unregister the crowd from the scene
  125242. */
  125243. private _scene;
  125244. /**
  125245. * Observer for crowd updates
  125246. */
  125247. private _onBeforeAnimationsObserver;
  125248. /**
  125249. * Constructor
  125250. * @param plugin recastJS plugin
  125251. * @param maxAgents the maximum agent count in the crowd
  125252. * @param maxAgentRadius the maximum radius an agent can have
  125253. * @param scene to attach the crowd to
  125254. * @returns the crowd you can add agents to
  125255. */
  125256. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125257. /**
  125258. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125259. * You can attach anything to that node. The node position is updated in the scene update tick.
  125260. * @param pos world position that will be constrained by the navigation mesh
  125261. * @param parameters agent parameters
  125262. * @param transform hooked to the agent that will be update by the scene
  125263. * @returns agent index
  125264. */
  125265. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125266. /**
  125267. * Returns the agent position in world space
  125268. * @param index agent index returned by addAgent
  125269. * @returns world space position
  125270. */
  125271. getAgentPosition(index: number): Vector3;
  125272. /**
  125273. * Returns the agent velocity in world space
  125274. * @param index agent index returned by addAgent
  125275. * @returns world space velocity
  125276. */
  125277. getAgentVelocity(index: number): Vector3;
  125278. /**
  125279. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125280. * @param index agent index returned by addAgent
  125281. * @param destination targeted world position
  125282. */
  125283. agentGoto(index: number, destination: Vector3): void;
  125284. /**
  125285. * remove a particular agent previously created
  125286. * @param index agent index returned by addAgent
  125287. */
  125288. removeAgent(index: number): void;
  125289. /**
  125290. * get the list of all agents attached to this crowd
  125291. * @returns list of agent indices
  125292. */
  125293. getAgents(): number[];
  125294. /**
  125295. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125296. * @param deltaTime in seconds
  125297. */
  125298. update(deltaTime: number): void;
  125299. /**
  125300. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125301. * The queries will try to find a solution within those bounds
  125302. * default is (1,1,1)
  125303. * @param extent x,y,z value that define the extent around the queries point of reference
  125304. */
  125305. setDefaultQueryExtent(extent: Vector3): void;
  125306. /**
  125307. * Get the Bounding box extent specified by setDefaultQueryExtent
  125308. * @returns the box extent values
  125309. */
  125310. getDefaultQueryExtent(): Vector3;
  125311. /**
  125312. * Release all resources
  125313. */
  125314. dispose(): void;
  125315. }
  125316. }
  125317. declare module BABYLON {
  125318. /**
  125319. * Class used to enable access to IndexedDB
  125320. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125321. */
  125322. export class Database implements IOfflineProvider {
  125323. private _callbackManifestChecked;
  125324. private _currentSceneUrl;
  125325. private _db;
  125326. private _enableSceneOffline;
  125327. private _enableTexturesOffline;
  125328. private _manifestVersionFound;
  125329. private _mustUpdateRessources;
  125330. private _hasReachedQuota;
  125331. private _isSupported;
  125332. private _idbFactory;
  125333. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125334. private static IsUASupportingBlobStorage;
  125335. /**
  125336. * Gets a boolean indicating if Database storate is enabled (off by default)
  125337. */
  125338. static IDBStorageEnabled: boolean;
  125339. /**
  125340. * Gets a boolean indicating if scene must be saved in the database
  125341. */
  125342. readonly enableSceneOffline: boolean;
  125343. /**
  125344. * Gets a boolean indicating if textures must be saved in the database
  125345. */
  125346. readonly enableTexturesOffline: boolean;
  125347. /**
  125348. * Creates a new Database
  125349. * @param urlToScene defines the url to load the scene
  125350. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125351. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125352. */
  125353. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125354. private static _ParseURL;
  125355. private static _ReturnFullUrlLocation;
  125356. private _checkManifestFile;
  125357. /**
  125358. * Open the database and make it available
  125359. * @param successCallback defines the callback to call on success
  125360. * @param errorCallback defines the callback to call on error
  125361. */
  125362. open(successCallback: () => void, errorCallback: () => void): void;
  125363. /**
  125364. * Loads an image from the database
  125365. * @param url defines the url to load from
  125366. * @param image defines the target DOM image
  125367. */
  125368. loadImage(url: string, image: HTMLImageElement): void;
  125369. private _loadImageFromDBAsync;
  125370. private _saveImageIntoDBAsync;
  125371. private _checkVersionFromDB;
  125372. private _loadVersionFromDBAsync;
  125373. private _saveVersionIntoDBAsync;
  125374. /**
  125375. * Loads a file from database
  125376. * @param url defines the URL to load from
  125377. * @param sceneLoaded defines a callback to call on success
  125378. * @param progressCallBack defines a callback to call when progress changed
  125379. * @param errorCallback defines a callback to call on error
  125380. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125381. */
  125382. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125383. private _loadFileAsync;
  125384. private _saveFileAsync;
  125385. /**
  125386. * Validates if xhr data is correct
  125387. * @param xhr defines the request to validate
  125388. * @param dataType defines the expected data type
  125389. * @returns true if data is correct
  125390. */
  125391. private static _ValidateXHRData;
  125392. }
  125393. }
  125394. declare module BABYLON {
  125395. /** @hidden */
  125396. export var gpuUpdateParticlesPixelShader: {
  125397. name: string;
  125398. shader: string;
  125399. };
  125400. }
  125401. declare module BABYLON {
  125402. /** @hidden */
  125403. export var gpuUpdateParticlesVertexShader: {
  125404. name: string;
  125405. shader: string;
  125406. };
  125407. }
  125408. declare module BABYLON {
  125409. /** @hidden */
  125410. export var clipPlaneFragmentDeclaration2: {
  125411. name: string;
  125412. shader: string;
  125413. };
  125414. }
  125415. declare module BABYLON {
  125416. /** @hidden */
  125417. export var gpuRenderParticlesPixelShader: {
  125418. name: string;
  125419. shader: string;
  125420. };
  125421. }
  125422. declare module BABYLON {
  125423. /** @hidden */
  125424. export var clipPlaneVertexDeclaration2: {
  125425. name: string;
  125426. shader: string;
  125427. };
  125428. }
  125429. declare module BABYLON {
  125430. /** @hidden */
  125431. export var gpuRenderParticlesVertexShader: {
  125432. name: string;
  125433. shader: string;
  125434. };
  125435. }
  125436. declare module BABYLON {
  125437. /**
  125438. * This represents a GPU particle system in Babylon
  125439. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125440. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125441. */
  125442. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125443. /**
  125444. * The layer mask we are rendering the particles through.
  125445. */
  125446. layerMask: number;
  125447. private _capacity;
  125448. private _activeCount;
  125449. private _currentActiveCount;
  125450. private _accumulatedCount;
  125451. private _renderEffect;
  125452. private _updateEffect;
  125453. private _buffer0;
  125454. private _buffer1;
  125455. private _spriteBuffer;
  125456. private _updateVAO;
  125457. private _renderVAO;
  125458. private _targetIndex;
  125459. private _sourceBuffer;
  125460. private _targetBuffer;
  125461. private _engine;
  125462. private _currentRenderId;
  125463. private _started;
  125464. private _stopped;
  125465. private _timeDelta;
  125466. private _randomTexture;
  125467. private _randomTexture2;
  125468. private _attributesStrideSize;
  125469. private _updateEffectOptions;
  125470. private _randomTextureSize;
  125471. private _actualFrame;
  125472. private readonly _rawTextureWidth;
  125473. /**
  125474. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125475. */
  125476. static readonly IsSupported: boolean;
  125477. /**
  125478. * An event triggered when the system is disposed.
  125479. */
  125480. onDisposeObservable: Observable<GPUParticleSystem>;
  125481. /**
  125482. * Gets the maximum number of particles active at the same time.
  125483. * @returns The max number of active particles.
  125484. */
  125485. getCapacity(): number;
  125486. /**
  125487. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125488. * to override the particles.
  125489. */
  125490. forceDepthWrite: boolean;
  125491. /**
  125492. * Gets or set the number of active particles
  125493. */
  125494. activeParticleCount: number;
  125495. private _preWarmDone;
  125496. /**
  125497. * Is this system ready to be used/rendered
  125498. * @return true if the system is ready
  125499. */
  125500. isReady(): boolean;
  125501. /**
  125502. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125503. * @returns True if it has been started, otherwise false.
  125504. */
  125505. isStarted(): boolean;
  125506. /**
  125507. * Starts the particle system and begins to emit
  125508. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125509. */
  125510. start(delay?: number): void;
  125511. /**
  125512. * Stops the particle system.
  125513. */
  125514. stop(): void;
  125515. /**
  125516. * Remove all active particles
  125517. */
  125518. reset(): void;
  125519. /**
  125520. * Returns the string "GPUParticleSystem"
  125521. * @returns a string containing the class name
  125522. */
  125523. getClassName(): string;
  125524. private _colorGradientsTexture;
  125525. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125526. /**
  125527. * Adds a new color gradient
  125528. * @param gradient defines the gradient to use (between 0 and 1)
  125529. * @param color1 defines the color to affect to the specified gradient
  125530. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125531. * @returns the current particle system
  125532. */
  125533. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125534. /**
  125535. * Remove a specific color gradient
  125536. * @param gradient defines the gradient to remove
  125537. * @returns the current particle system
  125538. */
  125539. removeColorGradient(gradient: number): GPUParticleSystem;
  125540. private _angularSpeedGradientsTexture;
  125541. private _sizeGradientsTexture;
  125542. private _velocityGradientsTexture;
  125543. private _limitVelocityGradientsTexture;
  125544. private _dragGradientsTexture;
  125545. private _addFactorGradient;
  125546. /**
  125547. * Adds a new size gradient
  125548. * @param gradient defines the gradient to use (between 0 and 1)
  125549. * @param factor defines the size factor to affect to the specified gradient
  125550. * @returns the current particle system
  125551. */
  125552. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125553. /**
  125554. * Remove a specific size gradient
  125555. * @param gradient defines the gradient to remove
  125556. * @returns the current particle system
  125557. */
  125558. removeSizeGradient(gradient: number): GPUParticleSystem;
  125559. /**
  125560. * Adds a new angular speed gradient
  125561. * @param gradient defines the gradient to use (between 0 and 1)
  125562. * @param factor defines the angular speed to affect to the specified gradient
  125563. * @returns the current particle system
  125564. */
  125565. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125566. /**
  125567. * Remove a specific angular speed gradient
  125568. * @param gradient defines the gradient to remove
  125569. * @returns the current particle system
  125570. */
  125571. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125572. /**
  125573. * Adds a new velocity gradient
  125574. * @param gradient defines the gradient to use (between 0 and 1)
  125575. * @param factor defines the velocity to affect to the specified gradient
  125576. * @returns the current particle system
  125577. */
  125578. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125579. /**
  125580. * Remove a specific velocity gradient
  125581. * @param gradient defines the gradient to remove
  125582. * @returns the current particle system
  125583. */
  125584. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125585. /**
  125586. * Adds a new limit velocity gradient
  125587. * @param gradient defines the gradient to use (between 0 and 1)
  125588. * @param factor defines the limit velocity value to affect to the specified gradient
  125589. * @returns the current particle system
  125590. */
  125591. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125592. /**
  125593. * Remove a specific limit velocity gradient
  125594. * @param gradient defines the gradient to remove
  125595. * @returns the current particle system
  125596. */
  125597. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125598. /**
  125599. * Adds a new drag gradient
  125600. * @param gradient defines the gradient to use (between 0 and 1)
  125601. * @param factor defines the drag value to affect to the specified gradient
  125602. * @returns the current particle system
  125603. */
  125604. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125605. /**
  125606. * Remove a specific drag gradient
  125607. * @param gradient defines the gradient to remove
  125608. * @returns the current particle system
  125609. */
  125610. removeDragGradient(gradient: number): GPUParticleSystem;
  125611. /**
  125612. * Not supported by GPUParticleSystem
  125613. * @param gradient defines the gradient to use (between 0 and 1)
  125614. * @param factor defines the emit rate value to affect to the specified gradient
  125615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125616. * @returns the current particle system
  125617. */
  125618. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125619. /**
  125620. * Not supported by GPUParticleSystem
  125621. * @param gradient defines the gradient to remove
  125622. * @returns the current particle system
  125623. */
  125624. removeEmitRateGradient(gradient: number): IParticleSystem;
  125625. /**
  125626. * Not supported by GPUParticleSystem
  125627. * @param gradient defines the gradient to use (between 0 and 1)
  125628. * @param factor defines the start size value to affect to the specified gradient
  125629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125630. * @returns the current particle system
  125631. */
  125632. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125633. /**
  125634. * Not supported by GPUParticleSystem
  125635. * @param gradient defines the gradient to remove
  125636. * @returns the current particle system
  125637. */
  125638. removeStartSizeGradient(gradient: number): IParticleSystem;
  125639. /**
  125640. * Not supported by GPUParticleSystem
  125641. * @param gradient defines the gradient to use (between 0 and 1)
  125642. * @param min defines the color remap minimal range
  125643. * @param max defines the color remap maximal range
  125644. * @returns the current particle system
  125645. */
  125646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125647. /**
  125648. * Not supported by GPUParticleSystem
  125649. * @param gradient defines the gradient to remove
  125650. * @returns the current particle system
  125651. */
  125652. removeColorRemapGradient(): IParticleSystem;
  125653. /**
  125654. * Not supported by GPUParticleSystem
  125655. * @param gradient defines the gradient to use (between 0 and 1)
  125656. * @param min defines the alpha remap minimal range
  125657. * @param max defines the alpha remap maximal range
  125658. * @returns the current particle system
  125659. */
  125660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125661. /**
  125662. * Not supported by GPUParticleSystem
  125663. * @param gradient defines the gradient to remove
  125664. * @returns the current particle system
  125665. */
  125666. removeAlphaRemapGradient(): IParticleSystem;
  125667. /**
  125668. * Not supported by GPUParticleSystem
  125669. * @param gradient defines the gradient to use (between 0 and 1)
  125670. * @param color defines the color to affect to the specified gradient
  125671. * @returns the current particle system
  125672. */
  125673. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125674. /**
  125675. * Not supported by GPUParticleSystem
  125676. * @param gradient defines the gradient to remove
  125677. * @returns the current particle system
  125678. */
  125679. removeRampGradient(): IParticleSystem;
  125680. /**
  125681. * Not supported by GPUParticleSystem
  125682. * @returns the list of ramp gradients
  125683. */
  125684. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125685. /**
  125686. * Not supported by GPUParticleSystem
  125687. * Gets or sets a boolean indicating that ramp gradients must be used
  125688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125689. */
  125690. useRampGradients: boolean;
  125691. /**
  125692. * Not supported by GPUParticleSystem
  125693. * @param gradient defines the gradient to use (between 0 and 1)
  125694. * @param factor defines the life time factor to affect to the specified gradient
  125695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125696. * @returns the current particle system
  125697. */
  125698. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125699. /**
  125700. * Not supported by GPUParticleSystem
  125701. * @param gradient defines the gradient to remove
  125702. * @returns the current particle system
  125703. */
  125704. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125705. /**
  125706. * Instantiates a GPU particle system.
  125707. * 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.
  125708. * @param name The name of the particle system
  125709. * @param options The options used to create the system
  125710. * @param scene The scene the particle system belongs to
  125711. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125712. */
  125713. constructor(name: string, options: Partial<{
  125714. capacity: number;
  125715. randomTextureSize: number;
  125716. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125717. protected _reset(): void;
  125718. private _createUpdateVAO;
  125719. private _createRenderVAO;
  125720. private _initialize;
  125721. /** @hidden */
  125722. _recreateUpdateEffect(): void;
  125723. /** @hidden */
  125724. _recreateRenderEffect(): void;
  125725. /**
  125726. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125727. * @param preWarm defines if we are in the pre-warmimg phase
  125728. */
  125729. animate(preWarm?: boolean): void;
  125730. private _createFactorGradientTexture;
  125731. private _createSizeGradientTexture;
  125732. private _createAngularSpeedGradientTexture;
  125733. private _createVelocityGradientTexture;
  125734. private _createLimitVelocityGradientTexture;
  125735. private _createDragGradientTexture;
  125736. private _createColorGradientTexture;
  125737. /**
  125738. * Renders the particle system in its current state
  125739. * @param preWarm defines if the system should only update the particles but not render them
  125740. * @returns the current number of particles
  125741. */
  125742. render(preWarm?: boolean): number;
  125743. /**
  125744. * Rebuilds the particle system
  125745. */
  125746. rebuild(): void;
  125747. private _releaseBuffers;
  125748. private _releaseVAOs;
  125749. /**
  125750. * Disposes the particle system and free the associated resources
  125751. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125752. */
  125753. dispose(disposeTexture?: boolean): void;
  125754. /**
  125755. * Clones the particle system.
  125756. * @param name The name of the cloned object
  125757. * @param newEmitter The new emitter to use
  125758. * @returns the cloned particle system
  125759. */
  125760. clone(name: string, newEmitter: any): GPUParticleSystem;
  125761. /**
  125762. * Serializes the particle system to a JSON object.
  125763. * @returns the JSON object
  125764. */
  125765. serialize(): any;
  125766. /**
  125767. * Parses a JSON object to create a GPU particle system.
  125768. * @param parsedParticleSystem The JSON object to parse
  125769. * @param scene The scene to create the particle system in
  125770. * @param rootUrl The root url to use to load external dependencies like texture
  125771. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125772. * @returns the parsed GPU particle system
  125773. */
  125774. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125775. }
  125776. }
  125777. declare module BABYLON {
  125778. /**
  125779. * Represents a set of particle systems working together to create a specific effect
  125780. */
  125781. export class ParticleSystemSet implements IDisposable {
  125782. /**
  125783. * Gets or sets base Assets URL
  125784. */
  125785. static BaseAssetsUrl: string;
  125786. private _emitterCreationOptions;
  125787. private _emitterNode;
  125788. /**
  125789. * Gets the particle system list
  125790. */
  125791. systems: IParticleSystem[];
  125792. /**
  125793. * Gets the emitter node used with this set
  125794. */
  125795. readonly emitterNode: Nullable<TransformNode>;
  125796. /**
  125797. * Creates a new emitter mesh as a sphere
  125798. * @param options defines the options used to create the sphere
  125799. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125800. * @param scene defines the hosting scene
  125801. */
  125802. setEmitterAsSphere(options: {
  125803. diameter: number;
  125804. segments: number;
  125805. color: Color3;
  125806. }, renderingGroupId: number, scene: Scene): void;
  125807. /**
  125808. * Starts all particle systems of the set
  125809. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125810. */
  125811. start(emitter?: AbstractMesh): void;
  125812. /**
  125813. * Release all associated resources
  125814. */
  125815. dispose(): void;
  125816. /**
  125817. * Serialize the set into a JSON compatible object
  125818. * @returns a JSON compatible representation of the set
  125819. */
  125820. serialize(): any;
  125821. /**
  125822. * Parse a new ParticleSystemSet from a serialized source
  125823. * @param data defines a JSON compatible representation of the set
  125824. * @param scene defines the hosting scene
  125825. * @param gpu defines if we want GPU particles or CPU particles
  125826. * @returns a new ParticleSystemSet
  125827. */
  125828. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125829. }
  125830. }
  125831. declare module BABYLON {
  125832. /**
  125833. * This class is made for on one-liner static method to help creating particle system set.
  125834. */
  125835. export class ParticleHelper {
  125836. /**
  125837. * Gets or sets base Assets URL
  125838. */
  125839. static BaseAssetsUrl: string;
  125840. /**
  125841. * Create a default particle system that you can tweak
  125842. * @param emitter defines the emitter to use
  125843. * @param capacity defines the system capacity (default is 500 particles)
  125844. * @param scene defines the hosting scene
  125845. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125846. * @returns the new Particle system
  125847. */
  125848. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125849. /**
  125850. * This is the main static method (one-liner) of this helper to create different particle systems
  125851. * @param type This string represents the type to the particle system to create
  125852. * @param scene The scene where the particle system should live
  125853. * @param gpu If the system will use gpu
  125854. * @returns the ParticleSystemSet created
  125855. */
  125856. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125857. /**
  125858. * Static function used to export a particle system to a ParticleSystemSet variable.
  125859. * Please note that the emitter shape is not exported
  125860. * @param systems defines the particle systems to export
  125861. * @returns the created particle system set
  125862. */
  125863. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125864. }
  125865. }
  125866. declare module BABYLON {
  125867. interface Engine {
  125868. /**
  125869. * Create an effect to use with particle systems.
  125870. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125871. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125872. * @param uniformsNames defines a list of attribute names
  125873. * @param samplers defines an array of string used to represent textures
  125874. * @param defines defines the string containing the defines to use to compile the shaders
  125875. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125876. * @param onCompiled defines a function to call when the effect creation is successful
  125877. * @param onError defines a function to call when the effect creation has failed
  125878. * @returns the new Effect
  125879. */
  125880. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125881. }
  125882. interface Mesh {
  125883. /**
  125884. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125885. * @returns an array of IParticleSystem
  125886. */
  125887. getEmittedParticleSystems(): IParticleSystem[];
  125888. /**
  125889. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125890. * @returns an array of IParticleSystem
  125891. */
  125892. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125893. }
  125894. /**
  125895. * @hidden
  125896. */
  125897. export var _IDoNeedToBeInTheBuild: number;
  125898. }
  125899. declare module BABYLON {
  125900. /** Defines the 4 color options */
  125901. export enum PointColor {
  125902. /** color value */
  125903. Color = 2,
  125904. /** uv value */
  125905. UV = 1,
  125906. /** random value */
  125907. Random = 0,
  125908. /** stated value */
  125909. Stated = 3
  125910. }
  125911. /**
  125912. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125913. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  125914. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125915. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125916. *
  125917. * Full documentation here : TO BE ENTERED
  125918. */
  125919. export class PointsCloudSystem implements IDisposable {
  125920. /**
  125921. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125922. * Example : var p = SPS.particles[i];
  125923. */
  125924. particles: CloudPoint[];
  125925. /**
  125926. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125927. */
  125928. nbParticles: number;
  125929. /**
  125930. * This a counter for your own usage. It's not set by any SPS functions.
  125931. */
  125932. counter: number;
  125933. /**
  125934. * The PCS name. This name is also given to the underlying mesh.
  125935. */
  125936. name: string;
  125937. /**
  125938. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125939. */
  125940. mesh: Mesh;
  125941. /**
  125942. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125943. * Please read :
  125944. */
  125945. vars: any;
  125946. /**
  125947. * @hidden
  125948. */
  125949. _size: number;
  125950. private _scene;
  125951. private _promises;
  125952. private _positions;
  125953. private _indices;
  125954. private _normals;
  125955. private _colors;
  125956. private _uvs;
  125957. private _indices32;
  125958. private _positions32;
  125959. private _colors32;
  125960. private _uvs32;
  125961. private _updatable;
  125962. private _isVisibilityBoxLocked;
  125963. private _alwaysVisible;
  125964. private _groups;
  125965. private _groupCounter;
  125966. private _computeParticleColor;
  125967. private _computeParticleTexture;
  125968. private _computeParticleRotation;
  125969. private _computeBoundingBox;
  125970. private _isReady;
  125971. /**
  125972. * Creates a PCS (Points Cloud System) object
  125973. * @param name (String) is the PCS name, this will be the underlying mesh name
  125974. * @param pointSize (number) is the size for each point
  125975. * @param scene (Scene) is the scene in which the PCS is added
  125976. * @param options defines the options of the PCS e.g.
  125977. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  125978. */
  125979. constructor(name: string, pointSize: number, scene: Scene, options?: {
  125980. updatable?: boolean;
  125981. });
  125982. /**
  125983. * Builds the PCS underlying mesh. Returns a standard Mesh.
  125984. * If no points were added to the PCS, the returned mesh is just a single point.
  125985. * @returns a promise for the created mesh
  125986. */
  125987. buildMeshAsync(): Promise<Mesh>;
  125988. /**
  125989. * @hidden
  125990. */
  125991. private _buildMesh;
  125992. private _addParticle;
  125993. private _randomUnitVector;
  125994. private _getColorIndicesForCoord;
  125995. private _setPointsColorOrUV;
  125996. private _colorFromTexture;
  125997. private _calculateDensity;
  125998. /**
  125999. * Adds points to the PCS in random positions within a unit sphere
  126000. * @param nb (positive integer) the number of particles to be created from this model
  126001. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  126002. * @returns the number of groups in the system
  126003. */
  126004. addPoints(nb: number, pointFunction?: any): number;
  126005. /**
  126006. * Adds points to the PCS from the surface of the model shape
  126007. * @param mesh is any Mesh object that will be used as a surface model for the points
  126008. * @param nb (positive integer) the number of particles to be created from this model
  126009. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  126010. * @param color (color3) to be used when colorWith is stated
  126011. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126012. * @returns the number of groups in the system
  126013. */
  126014. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126015. /**
  126016. * Adds points to the PCS inside the model shape
  126017. * @param mesh is any Mesh object that will be used as a surface model for the points
  126018. * @param nb (positive integer) the number of particles to be created from this model
  126019. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  126020. * @param color (color4) to be used when colorWith is stated
  126021. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126022. * @returns the number of groups in the system
  126023. */
  126024. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126025. /**
  126026. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  126027. * This method calls `updateParticle()` for each particle of the SPS.
  126028. * For an animated SPS, it is usually called within the render loop.
  126029. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  126030. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  126031. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  126032. * @returns the PCS.
  126033. */
  126034. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  126035. /**
  126036. * Disposes the PCS.
  126037. */
  126038. dispose(): void;
  126039. /**
  126040. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  126041. * doc :
  126042. * @returns the PCS.
  126043. */
  126044. refreshVisibleSize(): PointsCloudSystem;
  126045. /**
  126046. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  126047. * @param size the size (float) of the visibility box
  126048. * note : this doesn't lock the PCS mesh bounding box.
  126049. * doc :
  126050. */
  126051. setVisibilityBox(size: number): void;
  126052. /**
  126053. * Gets whether the PCS is always visible or not
  126054. * doc :
  126055. */
  126056. /**
  126057. * Sets the PCS as always visible or not
  126058. * doc :
  126059. */
  126060. isAlwaysVisible: boolean;
  126061. /**
  126062. * Tells to `setParticles()` to compute the particle rotations or not
  126063. * Default value : false. The PCS is faster when it's set to false
  126064. * Note : particle rotations are only applied to parent particles
  126065. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  126066. */
  126067. computeParticleRotation: boolean;
  126068. /**
  126069. * Tells to `setParticles()` to compute the particle colors or not.
  126070. * Default value : true. The PCS is faster when it's set to false.
  126071. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126072. */
  126073. /**
  126074. * Gets if `setParticles()` computes the particle colors or not.
  126075. * Default value : false. The PCS is faster when it's set to false.
  126076. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126077. */
  126078. computeParticleColor: boolean;
  126079. /**
  126080. * Gets if `setParticles()` computes the particle textures or not.
  126081. * Default value : false. The PCS is faster when it's set to false.
  126082. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  126083. */
  126084. computeParticleTexture: boolean;
  126085. /**
  126086. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126087. */
  126088. /**
  126089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126090. */
  126091. computeBoundingBox: boolean;
  126092. /**
  126093. * This function does nothing. It may be overwritten to set all the particle first values.
  126094. * The PCS doesn't call this function, you may have to call it by your own.
  126095. * doc :
  126096. */
  126097. initParticles(): void;
  126098. /**
  126099. * This function does nothing. It may be overwritten to recycle a particle
  126100. * The PCS doesn't call this function, you can to call it
  126101. * doc :
  126102. * @param particle The particle to recycle
  126103. * @returns the recycled particle
  126104. */
  126105. recycleParticle(particle: CloudPoint): CloudPoint;
  126106. /**
  126107. * Updates a particle : this function should be overwritten by the user.
  126108. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126109. * doc :
  126110. * @example : just set a particle position or velocity and recycle conditions
  126111. * @param particle The particle to update
  126112. * @returns the updated particle
  126113. */
  126114. updateParticle(particle: CloudPoint): CloudPoint;
  126115. /**
  126116. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126117. * This does nothing and may be overwritten by the user.
  126118. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126120. * @param update the boolean update value actually passed to setParticles()
  126121. */
  126122. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126123. /**
  126124. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126125. * This will be passed three parameters.
  126126. * This does nothing and may be overwritten by the user.
  126127. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126128. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126129. * @param update the boolean update value actually passed to setParticles()
  126130. */
  126131. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126132. }
  126133. }
  126134. declare module BABYLON {
  126135. /**
  126136. * Represents one particle of a points cloud system.
  126137. */
  126138. export class CloudPoint {
  126139. /**
  126140. * particle global index
  126141. */
  126142. idx: number;
  126143. /**
  126144. * The color of the particle
  126145. */
  126146. color: Nullable<Color4>;
  126147. /**
  126148. * The world space position of the particle.
  126149. */
  126150. position: Vector3;
  126151. /**
  126152. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126153. */
  126154. rotation: Vector3;
  126155. /**
  126156. * The world space rotation quaternion of the particle.
  126157. */
  126158. rotationQuaternion: Nullable<Quaternion>;
  126159. /**
  126160. * The uv of the particle.
  126161. */
  126162. uv: Nullable<Vector2>;
  126163. /**
  126164. * The current speed of the particle.
  126165. */
  126166. velocity: Vector3;
  126167. /**
  126168. * The pivot point in the particle local space.
  126169. */
  126170. pivot: Vector3;
  126171. /**
  126172. * Must the particle be translated from its pivot point in its local space ?
  126173. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126174. * Default : false
  126175. */
  126176. translateFromPivot: boolean;
  126177. /**
  126178. * Index of this particle in the global "positions" array (Internal use)
  126179. * @hidden
  126180. */
  126181. _pos: number;
  126182. /**
  126183. * @hidden Index of this particle in the global "indices" array (Internal use)
  126184. */
  126185. _ind: number;
  126186. /**
  126187. * Group this particle belongs to
  126188. */
  126189. _group: PointsGroup;
  126190. /**
  126191. * Group id of this particle
  126192. */
  126193. groupId: number;
  126194. /**
  126195. * Index of the particle in its group id (Internal use)
  126196. */
  126197. idxInGroup: number;
  126198. /**
  126199. * @hidden Particle BoundingInfo object (Internal use)
  126200. */
  126201. _boundingInfo: BoundingInfo;
  126202. /**
  126203. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126204. */
  126205. _pcs: PointsCloudSystem;
  126206. /**
  126207. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126208. */
  126209. _stillInvisible: boolean;
  126210. /**
  126211. * @hidden Last computed particle rotation matrix
  126212. */
  126213. _rotationMatrix: number[];
  126214. /**
  126215. * Parent particle Id, if any.
  126216. * Default null.
  126217. */
  126218. parentId: Nullable<number>;
  126219. /**
  126220. * @hidden Internal global position in the PCS.
  126221. */
  126222. _globalPosition: Vector3;
  126223. /**
  126224. * Creates a Point Cloud object.
  126225. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126226. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126227. * @param group (PointsGroup) is the group the particle belongs to
  126228. * @param groupId (integer) is the group identifier in the PCS.
  126229. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126230. * @param pcs defines the PCS it is associated to
  126231. */
  126232. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126233. /**
  126234. * get point size
  126235. */
  126236. /**
  126237. * Set point size
  126238. */
  126239. size: Vector3;
  126240. /**
  126241. * Legacy support, changed quaternion to rotationQuaternion
  126242. */
  126243. /**
  126244. * Legacy support, changed quaternion to rotationQuaternion
  126245. */
  126246. quaternion: Nullable<Quaternion>;
  126247. /**
  126248. * Returns a boolean. True if the particle intersects a mesh, else false
  126249. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126250. * @param target is the object (point or mesh) what the intersection is computed against
  126251. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126252. * @returns true if it intersects
  126253. */
  126254. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126255. /**
  126256. * get the rotation matrix of the particle
  126257. * @hidden
  126258. */
  126259. getRotationMatrix(m: Matrix): void;
  126260. }
  126261. /**
  126262. * Represents a group of points in a points cloud system
  126263. * * PCS internal tool, don't use it manually.
  126264. */
  126265. export class PointsGroup {
  126266. /**
  126267. * The group id
  126268. * @hidden
  126269. */
  126270. groupID: number;
  126271. /**
  126272. * image data for group (internal use)
  126273. * @hidden
  126274. */
  126275. _groupImageData: Nullable<ArrayBufferView>;
  126276. /**
  126277. * Image Width (internal use)
  126278. * @hidden
  126279. */
  126280. _groupImgWidth: number;
  126281. /**
  126282. * Image Height (internal use)
  126283. * @hidden
  126284. */
  126285. _groupImgHeight: number;
  126286. /**
  126287. * Custom position function (internal use)
  126288. * @hidden
  126289. */
  126290. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126291. /**
  126292. * density per facet for surface points
  126293. * @hidden
  126294. */
  126295. _groupDensity: number[];
  126296. /**
  126297. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126298. * PCS internal tool, don't use it manually.
  126299. * @hidden
  126300. */
  126301. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126302. }
  126303. }
  126304. declare module BABYLON {
  126305. interface Scene {
  126306. /** @hidden (Backing field) */
  126307. _physicsEngine: Nullable<IPhysicsEngine>;
  126308. /**
  126309. * Gets the current physics engine
  126310. * @returns a IPhysicsEngine or null if none attached
  126311. */
  126312. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126313. /**
  126314. * Enables physics to the current scene
  126315. * @param gravity defines the scene's gravity for the physics engine
  126316. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126317. * @return a boolean indicating if the physics engine was initialized
  126318. */
  126319. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126320. /**
  126321. * Disables and disposes the physics engine associated with the scene
  126322. */
  126323. disablePhysicsEngine(): void;
  126324. /**
  126325. * Gets a boolean indicating if there is an active physics engine
  126326. * @returns a boolean indicating if there is an active physics engine
  126327. */
  126328. isPhysicsEnabled(): boolean;
  126329. /**
  126330. * Deletes a physics compound impostor
  126331. * @param compound defines the compound to delete
  126332. */
  126333. deleteCompoundImpostor(compound: any): void;
  126334. /**
  126335. * An event triggered when physic simulation is about to be run
  126336. */
  126337. onBeforePhysicsObservable: Observable<Scene>;
  126338. /**
  126339. * An event triggered when physic simulation has been done
  126340. */
  126341. onAfterPhysicsObservable: Observable<Scene>;
  126342. }
  126343. interface AbstractMesh {
  126344. /** @hidden */
  126345. _physicsImpostor: Nullable<PhysicsImpostor>;
  126346. /**
  126347. * Gets or sets impostor used for physic simulation
  126348. * @see http://doc.babylonjs.com/features/physics_engine
  126349. */
  126350. physicsImpostor: Nullable<PhysicsImpostor>;
  126351. /**
  126352. * Gets the current physics impostor
  126353. * @see http://doc.babylonjs.com/features/physics_engine
  126354. * @returns a physics impostor or null
  126355. */
  126356. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126357. /** Apply a physic impulse to the mesh
  126358. * @param force defines the force to apply
  126359. * @param contactPoint defines where to apply the force
  126360. * @returns the current mesh
  126361. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126362. */
  126363. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126364. /**
  126365. * Creates a physic joint between two meshes
  126366. * @param otherMesh defines the other mesh to use
  126367. * @param pivot1 defines the pivot to use on this mesh
  126368. * @param pivot2 defines the pivot to use on the other mesh
  126369. * @param options defines additional options (can be plugin dependent)
  126370. * @returns the current mesh
  126371. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126372. */
  126373. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126374. /** @hidden */
  126375. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126376. }
  126377. /**
  126378. * Defines the physics engine scene component responsible to manage a physics engine
  126379. */
  126380. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126381. /**
  126382. * The component name helpful to identify the component in the list of scene components.
  126383. */
  126384. readonly name: string;
  126385. /**
  126386. * The scene the component belongs to.
  126387. */
  126388. scene: Scene;
  126389. /**
  126390. * Creates a new instance of the component for the given scene
  126391. * @param scene Defines the scene to register the component in
  126392. */
  126393. constructor(scene: Scene);
  126394. /**
  126395. * Registers the component in a given scene
  126396. */
  126397. register(): void;
  126398. /**
  126399. * Rebuilds the elements related to this component in case of
  126400. * context lost for instance.
  126401. */
  126402. rebuild(): void;
  126403. /**
  126404. * Disposes the component and the associated ressources
  126405. */
  126406. dispose(): void;
  126407. }
  126408. }
  126409. declare module BABYLON {
  126410. /**
  126411. * A helper for physics simulations
  126412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126413. */
  126414. export class PhysicsHelper {
  126415. private _scene;
  126416. private _physicsEngine;
  126417. /**
  126418. * Initializes the Physics helper
  126419. * @param scene Babylon.js scene
  126420. */
  126421. constructor(scene: Scene);
  126422. /**
  126423. * Applies a radial explosion impulse
  126424. * @param origin the origin of the explosion
  126425. * @param radiusOrEventOptions the radius or the options of radial explosion
  126426. * @param strength the explosion strength
  126427. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126428. * @returns A physics radial explosion event, or null
  126429. */
  126430. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126431. /**
  126432. * Applies a radial explosion force
  126433. * @param origin the origin of the explosion
  126434. * @param radiusOrEventOptions the radius or the options of radial explosion
  126435. * @param strength the explosion strength
  126436. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126437. * @returns A physics radial explosion event, or null
  126438. */
  126439. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126440. /**
  126441. * Creates a gravitational field
  126442. * @param origin the origin of the explosion
  126443. * @param radiusOrEventOptions the radius or the options of radial explosion
  126444. * @param strength the explosion strength
  126445. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126446. * @returns A physics gravitational field event, or null
  126447. */
  126448. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126449. /**
  126450. * Creates a physics updraft event
  126451. * @param origin the origin of the updraft
  126452. * @param radiusOrEventOptions the radius or the options of the updraft
  126453. * @param strength the strength of the updraft
  126454. * @param height the height of the updraft
  126455. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126456. * @returns A physics updraft event, or null
  126457. */
  126458. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126459. /**
  126460. * Creates a physics vortex event
  126461. * @param origin the of the vortex
  126462. * @param radiusOrEventOptions the radius or the options of the vortex
  126463. * @param strength the strength of the vortex
  126464. * @param height the height of the vortex
  126465. * @returns a Physics vortex event, or null
  126466. * A physics vortex event or null
  126467. */
  126468. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126469. }
  126470. /**
  126471. * Represents a physics radial explosion event
  126472. */
  126473. class PhysicsRadialExplosionEvent {
  126474. private _scene;
  126475. private _options;
  126476. private _sphere;
  126477. private _dataFetched;
  126478. /**
  126479. * Initializes a radial explosioin event
  126480. * @param _scene BabylonJS scene
  126481. * @param _options The options for the vortex event
  126482. */
  126483. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126484. /**
  126485. * Returns the data related to the radial explosion event (sphere).
  126486. * @returns The radial explosion event data
  126487. */
  126488. getData(): PhysicsRadialExplosionEventData;
  126489. /**
  126490. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126491. * @param impostor A physics imposter
  126492. * @param origin the origin of the explosion
  126493. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126494. */
  126495. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126496. /**
  126497. * Triggers affecterd impostors callbacks
  126498. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126499. */
  126500. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126501. /**
  126502. * Disposes the sphere.
  126503. * @param force Specifies if the sphere should be disposed by force
  126504. */
  126505. dispose(force?: boolean): void;
  126506. /*** Helpers ***/
  126507. private _prepareSphere;
  126508. private _intersectsWithSphere;
  126509. }
  126510. /**
  126511. * Represents a gravitational field event
  126512. */
  126513. class PhysicsGravitationalFieldEvent {
  126514. private _physicsHelper;
  126515. private _scene;
  126516. private _origin;
  126517. private _options;
  126518. private _tickCallback;
  126519. private _sphere;
  126520. private _dataFetched;
  126521. /**
  126522. * Initializes the physics gravitational field event
  126523. * @param _physicsHelper A physics helper
  126524. * @param _scene BabylonJS scene
  126525. * @param _origin The origin position of the gravitational field event
  126526. * @param _options The options for the vortex event
  126527. */
  126528. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126529. /**
  126530. * Returns the data related to the gravitational field event (sphere).
  126531. * @returns A gravitational field event
  126532. */
  126533. getData(): PhysicsGravitationalFieldEventData;
  126534. /**
  126535. * Enables the gravitational field.
  126536. */
  126537. enable(): void;
  126538. /**
  126539. * Disables the gravitational field.
  126540. */
  126541. disable(): void;
  126542. /**
  126543. * Disposes the sphere.
  126544. * @param force The force to dispose from the gravitational field event
  126545. */
  126546. dispose(force?: boolean): void;
  126547. private _tick;
  126548. }
  126549. /**
  126550. * Represents a physics updraft event
  126551. */
  126552. class PhysicsUpdraftEvent {
  126553. private _scene;
  126554. private _origin;
  126555. private _options;
  126556. private _physicsEngine;
  126557. private _originTop;
  126558. private _originDirection;
  126559. private _tickCallback;
  126560. private _cylinder;
  126561. private _cylinderPosition;
  126562. private _dataFetched;
  126563. /**
  126564. * Initializes the physics updraft event
  126565. * @param _scene BabylonJS scene
  126566. * @param _origin The origin position of the updraft
  126567. * @param _options The options for the updraft event
  126568. */
  126569. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126570. /**
  126571. * Returns the data related to the updraft event (cylinder).
  126572. * @returns A physics updraft event
  126573. */
  126574. getData(): PhysicsUpdraftEventData;
  126575. /**
  126576. * Enables the updraft.
  126577. */
  126578. enable(): void;
  126579. /**
  126580. * Disables the updraft.
  126581. */
  126582. disable(): void;
  126583. /**
  126584. * Disposes the cylinder.
  126585. * @param force Specifies if the updraft should be disposed by force
  126586. */
  126587. dispose(force?: boolean): void;
  126588. private getImpostorHitData;
  126589. private _tick;
  126590. /*** Helpers ***/
  126591. private _prepareCylinder;
  126592. private _intersectsWithCylinder;
  126593. }
  126594. /**
  126595. * Represents a physics vortex event
  126596. */
  126597. class PhysicsVortexEvent {
  126598. private _scene;
  126599. private _origin;
  126600. private _options;
  126601. private _physicsEngine;
  126602. private _originTop;
  126603. private _tickCallback;
  126604. private _cylinder;
  126605. private _cylinderPosition;
  126606. private _dataFetched;
  126607. /**
  126608. * Initializes the physics vortex event
  126609. * @param _scene The BabylonJS scene
  126610. * @param _origin The origin position of the vortex
  126611. * @param _options The options for the vortex event
  126612. */
  126613. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126614. /**
  126615. * Returns the data related to the vortex event (cylinder).
  126616. * @returns The physics vortex event data
  126617. */
  126618. getData(): PhysicsVortexEventData;
  126619. /**
  126620. * Enables the vortex.
  126621. */
  126622. enable(): void;
  126623. /**
  126624. * Disables the cortex.
  126625. */
  126626. disable(): void;
  126627. /**
  126628. * Disposes the sphere.
  126629. * @param force
  126630. */
  126631. dispose(force?: boolean): void;
  126632. private getImpostorHitData;
  126633. private _tick;
  126634. /*** Helpers ***/
  126635. private _prepareCylinder;
  126636. private _intersectsWithCylinder;
  126637. }
  126638. /**
  126639. * Options fot the radial explosion event
  126640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126641. */
  126642. export class PhysicsRadialExplosionEventOptions {
  126643. /**
  126644. * The radius of the sphere for the radial explosion.
  126645. */
  126646. radius: number;
  126647. /**
  126648. * The strenth of the explosion.
  126649. */
  126650. strength: number;
  126651. /**
  126652. * The strenght of the force in correspondence to the distance of the affected object
  126653. */
  126654. falloff: PhysicsRadialImpulseFalloff;
  126655. /**
  126656. * Sphere options for the radial explosion.
  126657. */
  126658. sphere: {
  126659. segments: number;
  126660. diameter: number;
  126661. };
  126662. /**
  126663. * Sphere options for the radial explosion.
  126664. */
  126665. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126666. }
  126667. /**
  126668. * Options fot the updraft event
  126669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126670. */
  126671. export class PhysicsUpdraftEventOptions {
  126672. /**
  126673. * The radius of the cylinder for the vortex
  126674. */
  126675. radius: number;
  126676. /**
  126677. * The strenth of the updraft.
  126678. */
  126679. strength: number;
  126680. /**
  126681. * The height of the cylinder for the updraft.
  126682. */
  126683. height: number;
  126684. /**
  126685. * The mode for the the updraft.
  126686. */
  126687. updraftMode: PhysicsUpdraftMode;
  126688. }
  126689. /**
  126690. * Options fot the vortex event
  126691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126692. */
  126693. export class PhysicsVortexEventOptions {
  126694. /**
  126695. * The radius of the cylinder for the vortex
  126696. */
  126697. radius: number;
  126698. /**
  126699. * The strenth of the vortex.
  126700. */
  126701. strength: number;
  126702. /**
  126703. * The height of the cylinder for the vortex.
  126704. */
  126705. height: number;
  126706. /**
  126707. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126708. */
  126709. centripetalForceThreshold: number;
  126710. /**
  126711. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126712. */
  126713. centripetalForceMultiplier: number;
  126714. /**
  126715. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126716. */
  126717. centrifugalForceMultiplier: number;
  126718. /**
  126719. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126720. */
  126721. updraftForceMultiplier: number;
  126722. }
  126723. /**
  126724. * The strenght of the force in correspondence to the distance of the affected object
  126725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126726. */
  126727. export enum PhysicsRadialImpulseFalloff {
  126728. /** Defines that impulse is constant in strength across it's whole radius */
  126729. Constant = 0,
  126730. /** Defines that impulse gets weaker if it's further from the origin */
  126731. Linear = 1
  126732. }
  126733. /**
  126734. * The strength of the force in correspondence to the distance of the affected object
  126735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126736. */
  126737. export enum PhysicsUpdraftMode {
  126738. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126739. Center = 0,
  126740. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126741. Perpendicular = 1
  126742. }
  126743. /**
  126744. * Interface for a physics hit data
  126745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126746. */
  126747. export interface PhysicsHitData {
  126748. /**
  126749. * The force applied at the contact point
  126750. */
  126751. force: Vector3;
  126752. /**
  126753. * The contact point
  126754. */
  126755. contactPoint: Vector3;
  126756. /**
  126757. * The distance from the origin to the contact point
  126758. */
  126759. distanceFromOrigin: number;
  126760. }
  126761. /**
  126762. * Interface for radial explosion event data
  126763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126764. */
  126765. export interface PhysicsRadialExplosionEventData {
  126766. /**
  126767. * A sphere used for the radial explosion event
  126768. */
  126769. sphere: Mesh;
  126770. }
  126771. /**
  126772. * Interface for gravitational field event data
  126773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126774. */
  126775. export interface PhysicsGravitationalFieldEventData {
  126776. /**
  126777. * A sphere mesh used for the gravitational field event
  126778. */
  126779. sphere: Mesh;
  126780. }
  126781. /**
  126782. * Interface for updraft event data
  126783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126784. */
  126785. export interface PhysicsUpdraftEventData {
  126786. /**
  126787. * A cylinder used for the updraft event
  126788. */
  126789. cylinder: Mesh;
  126790. }
  126791. /**
  126792. * Interface for vortex event data
  126793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126794. */
  126795. export interface PhysicsVortexEventData {
  126796. /**
  126797. * A cylinder used for the vortex event
  126798. */
  126799. cylinder: Mesh;
  126800. }
  126801. /**
  126802. * Interface for an affected physics impostor
  126803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126804. */
  126805. export interface PhysicsAffectedImpostorWithData {
  126806. /**
  126807. * The impostor affected by the effect
  126808. */
  126809. impostor: PhysicsImpostor;
  126810. /**
  126811. * The data about the hit/horce from the explosion
  126812. */
  126813. hitData: PhysicsHitData;
  126814. }
  126815. }
  126816. declare module BABYLON {
  126817. /** @hidden */
  126818. export var blackAndWhitePixelShader: {
  126819. name: string;
  126820. shader: string;
  126821. };
  126822. }
  126823. declare module BABYLON {
  126824. /**
  126825. * Post process used to render in black and white
  126826. */
  126827. export class BlackAndWhitePostProcess extends PostProcess {
  126828. /**
  126829. * Linear about to convert he result to black and white (default: 1)
  126830. */
  126831. degree: number;
  126832. /**
  126833. * Creates a black and white post process
  126834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126835. * @param name The name of the effect.
  126836. * @param options The required width/height ratio to downsize to before computing the render pass.
  126837. * @param camera The camera to apply the render pass to.
  126838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126839. * @param engine The engine which the post process will be applied. (default: current engine)
  126840. * @param reusable If the post process can be reused on the same frame. (default: false)
  126841. */
  126842. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126843. }
  126844. }
  126845. declare module BABYLON {
  126846. /**
  126847. * This represents a set of one or more post processes in Babylon.
  126848. * A post process can be used to apply a shader to a texture after it is rendered.
  126849. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126850. */
  126851. export class PostProcessRenderEffect {
  126852. private _postProcesses;
  126853. private _getPostProcesses;
  126854. private _singleInstance;
  126855. private _cameras;
  126856. private _indicesForCamera;
  126857. /**
  126858. * Name of the effect
  126859. * @hidden
  126860. */
  126861. _name: string;
  126862. /**
  126863. * Instantiates a post process render effect.
  126864. * A post process can be used to apply a shader to a texture after it is rendered.
  126865. * @param engine The engine the effect is tied to
  126866. * @param name The name of the effect
  126867. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126868. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126869. */
  126870. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126871. /**
  126872. * Checks if all the post processes in the effect are supported.
  126873. */
  126874. readonly isSupported: boolean;
  126875. /**
  126876. * Updates the current state of the effect
  126877. * @hidden
  126878. */
  126879. _update(): void;
  126880. /**
  126881. * Attaches the effect on cameras
  126882. * @param cameras The camera to attach to.
  126883. * @hidden
  126884. */
  126885. _attachCameras(cameras: Camera): void;
  126886. /**
  126887. * Attaches the effect on cameras
  126888. * @param cameras The camera to attach to.
  126889. * @hidden
  126890. */
  126891. _attachCameras(cameras: Camera[]): void;
  126892. /**
  126893. * Detaches the effect on cameras
  126894. * @param cameras The camera to detatch from.
  126895. * @hidden
  126896. */
  126897. _detachCameras(cameras: Camera): void;
  126898. /**
  126899. * Detatches the effect on cameras
  126900. * @param cameras The camera to detatch from.
  126901. * @hidden
  126902. */
  126903. _detachCameras(cameras: Camera[]): void;
  126904. /**
  126905. * Enables the effect on given cameras
  126906. * @param cameras The camera to enable.
  126907. * @hidden
  126908. */
  126909. _enable(cameras: Camera): void;
  126910. /**
  126911. * Enables the effect on given cameras
  126912. * @param cameras The camera to enable.
  126913. * @hidden
  126914. */
  126915. _enable(cameras: Nullable<Camera[]>): void;
  126916. /**
  126917. * Disables the effect on the given cameras
  126918. * @param cameras The camera to disable.
  126919. * @hidden
  126920. */
  126921. _disable(cameras: Camera): void;
  126922. /**
  126923. * Disables the effect on the given cameras
  126924. * @param cameras The camera to disable.
  126925. * @hidden
  126926. */
  126927. _disable(cameras: Nullable<Camera[]>): void;
  126928. /**
  126929. * Gets a list of the post processes contained in the effect.
  126930. * @param camera The camera to get the post processes on.
  126931. * @returns The list of the post processes in the effect.
  126932. */
  126933. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126934. }
  126935. }
  126936. declare module BABYLON {
  126937. /** @hidden */
  126938. export var extractHighlightsPixelShader: {
  126939. name: string;
  126940. shader: string;
  126941. };
  126942. }
  126943. declare module BABYLON {
  126944. /**
  126945. * 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.
  126946. */
  126947. export class ExtractHighlightsPostProcess extends PostProcess {
  126948. /**
  126949. * The luminance threshold, pixels below this value will be set to black.
  126950. */
  126951. threshold: number;
  126952. /** @hidden */
  126953. _exposure: number;
  126954. /**
  126955. * Post process which has the input texture to be used when performing highlight extraction
  126956. * @hidden
  126957. */
  126958. _inputPostProcess: Nullable<PostProcess>;
  126959. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126960. }
  126961. }
  126962. declare module BABYLON {
  126963. /** @hidden */
  126964. export var bloomMergePixelShader: {
  126965. name: string;
  126966. shader: string;
  126967. };
  126968. }
  126969. declare module BABYLON {
  126970. /**
  126971. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126972. */
  126973. export class BloomMergePostProcess extends PostProcess {
  126974. /** Weight of the bloom to be added to the original input. */
  126975. weight: number;
  126976. /**
  126977. * Creates a new instance of @see BloomMergePostProcess
  126978. * @param name The name of the effect.
  126979. * @param originalFromInput Post process which's input will be used for the merge.
  126980. * @param blurred Blurred highlights post process which's output will be used.
  126981. * @param weight Weight of the bloom to be added to the original input.
  126982. * @param options The required width/height ratio to downsize to before computing the render pass.
  126983. * @param camera The camera to apply the render pass to.
  126984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126985. * @param engine The engine which the post process will be applied. (default: current engine)
  126986. * @param reusable If the post process can be reused on the same frame. (default: false)
  126987. * @param textureType Type of textures used when performing the post process. (default: 0)
  126988. * @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)
  126989. */
  126990. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  126991. /** Weight of the bloom to be added to the original input. */
  126992. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126993. }
  126994. }
  126995. declare module BABYLON {
  126996. /**
  126997. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  126998. */
  126999. export class BloomEffect extends PostProcessRenderEffect {
  127000. private bloomScale;
  127001. /**
  127002. * @hidden Internal
  127003. */
  127004. _effects: Array<PostProcess>;
  127005. /**
  127006. * @hidden Internal
  127007. */
  127008. _downscale: ExtractHighlightsPostProcess;
  127009. private _blurX;
  127010. private _blurY;
  127011. private _merge;
  127012. /**
  127013. * The luminance threshold to find bright areas of the image to bloom.
  127014. */
  127015. threshold: number;
  127016. /**
  127017. * The strength of the bloom.
  127018. */
  127019. weight: number;
  127020. /**
  127021. * Specifies the size of the bloom blur kernel, relative to the final output size
  127022. */
  127023. kernel: number;
  127024. /**
  127025. * Creates a new instance of @see BloomEffect
  127026. * @param scene The scene the effect belongs to.
  127027. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  127028. * @param bloomKernel The size of the kernel to be used when applying the blur.
  127029. * @param bloomWeight The the strength of bloom.
  127030. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127031. * @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)
  127032. */
  127033. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  127034. /**
  127035. * Disposes each of the internal effects for a given camera.
  127036. * @param camera The camera to dispose the effect on.
  127037. */
  127038. disposeEffects(camera: Camera): void;
  127039. /**
  127040. * @hidden Internal
  127041. */
  127042. _updateEffects(): void;
  127043. /**
  127044. * Internal
  127045. * @returns if all the contained post processes are ready.
  127046. * @hidden
  127047. */
  127048. _isReady(): boolean;
  127049. }
  127050. }
  127051. declare module BABYLON {
  127052. /** @hidden */
  127053. export var chromaticAberrationPixelShader: {
  127054. name: string;
  127055. shader: string;
  127056. };
  127057. }
  127058. declare module BABYLON {
  127059. /**
  127060. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  127061. */
  127062. export class ChromaticAberrationPostProcess extends PostProcess {
  127063. /**
  127064. * The amount of seperation of rgb channels (default: 30)
  127065. */
  127066. aberrationAmount: number;
  127067. /**
  127068. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  127069. */
  127070. radialIntensity: number;
  127071. /**
  127072. * 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))
  127073. */
  127074. direction: Vector2;
  127075. /**
  127076. * 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))
  127077. */
  127078. centerPosition: Vector2;
  127079. /**
  127080. * Creates a new instance ChromaticAberrationPostProcess
  127081. * @param name The name of the effect.
  127082. * @param screenWidth The width of the screen to apply the effect on.
  127083. * @param screenHeight The height of the screen to apply the effect on.
  127084. * @param options The required width/height ratio to downsize to before computing the render pass.
  127085. * @param camera The camera to apply the render pass to.
  127086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127087. * @param engine The engine which the post process will be applied. (default: current engine)
  127088. * @param reusable If the post process can be reused on the same frame. (default: false)
  127089. * @param textureType Type of textures used when performing the post process. (default: 0)
  127090. * @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)
  127091. */
  127092. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127093. }
  127094. }
  127095. declare module BABYLON {
  127096. /** @hidden */
  127097. export var circleOfConfusionPixelShader: {
  127098. name: string;
  127099. shader: string;
  127100. };
  127101. }
  127102. declare module BABYLON {
  127103. /**
  127104. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127105. */
  127106. export class CircleOfConfusionPostProcess extends PostProcess {
  127107. /**
  127108. * 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.
  127109. */
  127110. lensSize: number;
  127111. /**
  127112. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127113. */
  127114. fStop: number;
  127115. /**
  127116. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127117. */
  127118. focusDistance: number;
  127119. /**
  127120. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127121. */
  127122. focalLength: number;
  127123. private _depthTexture;
  127124. /**
  127125. * Creates a new instance CircleOfConfusionPostProcess
  127126. * @param name The name of the effect.
  127127. * @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.
  127128. * @param options The required width/height ratio to downsize to before computing the render pass.
  127129. * @param camera The camera to apply the render pass to.
  127130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127131. * @param engine The engine which the post process will be applied. (default: current engine)
  127132. * @param reusable If the post process can be reused on the same frame. (default: false)
  127133. * @param textureType Type of textures used when performing the post process. (default: 0)
  127134. * @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)
  127135. */
  127136. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127137. /**
  127138. * 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.
  127139. */
  127140. depthTexture: RenderTargetTexture;
  127141. }
  127142. }
  127143. declare module BABYLON {
  127144. /** @hidden */
  127145. export var colorCorrectionPixelShader: {
  127146. name: string;
  127147. shader: string;
  127148. };
  127149. }
  127150. declare module BABYLON {
  127151. /**
  127152. *
  127153. * This post-process allows the modification of rendered colors by using
  127154. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127155. *
  127156. * The object needs to be provided an url to a texture containing the color
  127157. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127158. * Use an image editing software to tweak the LUT to match your needs.
  127159. *
  127160. * For an example of a color LUT, see here:
  127161. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127162. * For explanations on color grading, see here:
  127163. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127164. *
  127165. */
  127166. export class ColorCorrectionPostProcess extends PostProcess {
  127167. private _colorTableTexture;
  127168. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127169. }
  127170. }
  127171. declare module BABYLON {
  127172. /** @hidden */
  127173. export var convolutionPixelShader: {
  127174. name: string;
  127175. shader: string;
  127176. };
  127177. }
  127178. declare module BABYLON {
  127179. /**
  127180. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127181. * input texture to perform effects such as edge detection or sharpening
  127182. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127183. */
  127184. export class ConvolutionPostProcess extends PostProcess {
  127185. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127186. kernel: number[];
  127187. /**
  127188. * Creates a new instance ConvolutionPostProcess
  127189. * @param name The name of the effect.
  127190. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127191. * @param options The required width/height ratio to downsize to before computing the render pass.
  127192. * @param camera The camera to apply the render pass to.
  127193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127194. * @param engine The engine which the post process will be applied. (default: current engine)
  127195. * @param reusable If the post process can be reused on the same frame. (default: false)
  127196. * @param textureType Type of textures used when performing the post process. (default: 0)
  127197. */
  127198. constructor(name: string,
  127199. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127200. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127201. /**
  127202. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127203. */
  127204. static EdgeDetect0Kernel: number[];
  127205. /**
  127206. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127207. */
  127208. static EdgeDetect1Kernel: number[];
  127209. /**
  127210. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127211. */
  127212. static EdgeDetect2Kernel: number[];
  127213. /**
  127214. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127215. */
  127216. static SharpenKernel: number[];
  127217. /**
  127218. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127219. */
  127220. static EmbossKernel: number[];
  127221. /**
  127222. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127223. */
  127224. static GaussianKernel: number[];
  127225. }
  127226. }
  127227. declare module BABYLON {
  127228. /**
  127229. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127230. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127231. * based on samples that have a large difference in distance than the center pixel.
  127232. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127233. */
  127234. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127235. direction: Vector2;
  127236. /**
  127237. * Creates a new instance CircleOfConfusionPostProcess
  127238. * @param name The name of the effect.
  127239. * @param scene The scene the effect belongs to.
  127240. * @param direction The direction the blur should be applied.
  127241. * @param kernel The size of the kernel used to blur.
  127242. * @param options The required width/height ratio to downsize to before computing the render pass.
  127243. * @param camera The camera to apply the render pass to.
  127244. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127245. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127247. * @param engine The engine which the post process will be applied. (default: current engine)
  127248. * @param reusable If the post process can be reused on the same frame. (default: false)
  127249. * @param textureType Type of textures used when performing the post process. (default: 0)
  127250. * @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)
  127251. */
  127252. 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);
  127253. }
  127254. }
  127255. declare module BABYLON {
  127256. /** @hidden */
  127257. export var depthOfFieldMergePixelShader: {
  127258. name: string;
  127259. shader: string;
  127260. };
  127261. }
  127262. declare module BABYLON {
  127263. /**
  127264. * Options to be set when merging outputs from the default pipeline.
  127265. */
  127266. export class DepthOfFieldMergePostProcessOptions {
  127267. /**
  127268. * The original image to merge on top of
  127269. */
  127270. originalFromInput: PostProcess;
  127271. /**
  127272. * Parameters to perform the merge of the depth of field effect
  127273. */
  127274. depthOfField?: {
  127275. circleOfConfusion: PostProcess;
  127276. blurSteps: Array<PostProcess>;
  127277. };
  127278. /**
  127279. * Parameters to perform the merge of bloom effect
  127280. */
  127281. bloom?: {
  127282. blurred: PostProcess;
  127283. weight: number;
  127284. };
  127285. }
  127286. /**
  127287. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127288. */
  127289. export class DepthOfFieldMergePostProcess extends PostProcess {
  127290. private blurSteps;
  127291. /**
  127292. * Creates a new instance of DepthOfFieldMergePostProcess
  127293. * @param name The name of the effect.
  127294. * @param originalFromInput Post process which's input will be used for the merge.
  127295. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127296. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127297. * @param options The required width/height ratio to downsize to before computing the render pass.
  127298. * @param camera The camera to apply the render pass to.
  127299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127300. * @param engine The engine which the post process will be applied. (default: current engine)
  127301. * @param reusable If the post process can be reused on the same frame. (default: false)
  127302. * @param textureType Type of textures used when performing the post process. (default: 0)
  127303. * @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)
  127304. */
  127305. 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);
  127306. /**
  127307. * Updates the effect with the current post process compile time values and recompiles the shader.
  127308. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127309. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127310. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127311. * @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
  127312. * @param onCompiled Called when the shader has been compiled.
  127313. * @param onError Called if there is an error when compiling a shader.
  127314. */
  127315. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127316. }
  127317. }
  127318. declare module BABYLON {
  127319. /**
  127320. * Specifies the level of max blur that should be applied when using the depth of field effect
  127321. */
  127322. export enum DepthOfFieldEffectBlurLevel {
  127323. /**
  127324. * Subtle blur
  127325. */
  127326. Low = 0,
  127327. /**
  127328. * Medium blur
  127329. */
  127330. Medium = 1,
  127331. /**
  127332. * Large blur
  127333. */
  127334. High = 2
  127335. }
  127336. /**
  127337. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127338. */
  127339. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127340. private _circleOfConfusion;
  127341. /**
  127342. * @hidden Internal, blurs from high to low
  127343. */
  127344. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127345. private _depthOfFieldBlurY;
  127346. private _dofMerge;
  127347. /**
  127348. * @hidden Internal post processes in depth of field effect
  127349. */
  127350. _effects: Array<PostProcess>;
  127351. /**
  127352. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127353. */
  127354. focalLength: number;
  127355. /**
  127356. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127357. */
  127358. fStop: number;
  127359. /**
  127360. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127361. */
  127362. focusDistance: number;
  127363. /**
  127364. * 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.
  127365. */
  127366. lensSize: number;
  127367. /**
  127368. * Creates a new instance DepthOfFieldEffect
  127369. * @param scene The scene the effect belongs to.
  127370. * @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.
  127371. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127372. * @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)
  127373. */
  127374. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127375. /**
  127376. * Get the current class name of the current effet
  127377. * @returns "DepthOfFieldEffect"
  127378. */
  127379. getClassName(): string;
  127380. /**
  127381. * 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.
  127382. */
  127383. depthTexture: RenderTargetTexture;
  127384. /**
  127385. * Disposes each of the internal effects for a given camera.
  127386. * @param camera The camera to dispose the effect on.
  127387. */
  127388. disposeEffects(camera: Camera): void;
  127389. /**
  127390. * @hidden Internal
  127391. */
  127392. _updateEffects(): void;
  127393. /**
  127394. * Internal
  127395. * @returns if all the contained post processes are ready.
  127396. * @hidden
  127397. */
  127398. _isReady(): boolean;
  127399. }
  127400. }
  127401. declare module BABYLON {
  127402. /** @hidden */
  127403. export var displayPassPixelShader: {
  127404. name: string;
  127405. shader: string;
  127406. };
  127407. }
  127408. declare module BABYLON {
  127409. /**
  127410. * DisplayPassPostProcess which produces an output the same as it's input
  127411. */
  127412. export class DisplayPassPostProcess extends PostProcess {
  127413. /**
  127414. * Creates the DisplayPassPostProcess
  127415. * @param name The name of the effect.
  127416. * @param options The required width/height ratio to downsize to before computing the render pass.
  127417. * @param camera The camera to apply the render pass to.
  127418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127419. * @param engine The engine which the post process will be applied. (default: current engine)
  127420. * @param reusable If the post process can be reused on the same frame. (default: false)
  127421. */
  127422. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127423. }
  127424. }
  127425. declare module BABYLON {
  127426. /** @hidden */
  127427. export var filterPixelShader: {
  127428. name: string;
  127429. shader: string;
  127430. };
  127431. }
  127432. declare module BABYLON {
  127433. /**
  127434. * Applies a kernel filter to the image
  127435. */
  127436. export class FilterPostProcess extends PostProcess {
  127437. /** The matrix to be applied to the image */
  127438. kernelMatrix: Matrix;
  127439. /**
  127440. *
  127441. * @param name The name of the effect.
  127442. * @param kernelMatrix The matrix to be applied to the image
  127443. * @param options The required width/height ratio to downsize to before computing the render pass.
  127444. * @param camera The camera to apply the render pass to.
  127445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127446. * @param engine The engine which the post process will be applied. (default: current engine)
  127447. * @param reusable If the post process can be reused on the same frame. (default: false)
  127448. */
  127449. constructor(name: string,
  127450. /** The matrix to be applied to the image */
  127451. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127452. }
  127453. }
  127454. declare module BABYLON {
  127455. /** @hidden */
  127456. export var fxaaPixelShader: {
  127457. name: string;
  127458. shader: string;
  127459. };
  127460. }
  127461. declare module BABYLON {
  127462. /** @hidden */
  127463. export var fxaaVertexShader: {
  127464. name: string;
  127465. shader: string;
  127466. };
  127467. }
  127468. declare module BABYLON {
  127469. /**
  127470. * Fxaa post process
  127471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127472. */
  127473. export class FxaaPostProcess extends PostProcess {
  127474. /** @hidden */
  127475. texelWidth: number;
  127476. /** @hidden */
  127477. texelHeight: number;
  127478. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127479. private _getDefines;
  127480. }
  127481. }
  127482. declare module BABYLON {
  127483. /** @hidden */
  127484. export var grainPixelShader: {
  127485. name: string;
  127486. shader: string;
  127487. };
  127488. }
  127489. declare module BABYLON {
  127490. /**
  127491. * The GrainPostProcess adds noise to the image at mid luminance levels
  127492. */
  127493. export class GrainPostProcess extends PostProcess {
  127494. /**
  127495. * The intensity of the grain added (default: 30)
  127496. */
  127497. intensity: number;
  127498. /**
  127499. * If the grain should be randomized on every frame
  127500. */
  127501. animated: boolean;
  127502. /**
  127503. * Creates a new instance of @see GrainPostProcess
  127504. * @param name The name of the effect.
  127505. * @param options The required width/height ratio to downsize to before computing the render pass.
  127506. * @param camera The camera to apply the render pass to.
  127507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127508. * @param engine The engine which the post process will be applied. (default: current engine)
  127509. * @param reusable If the post process can be reused on the same frame. (default: false)
  127510. * @param textureType Type of textures used when performing the post process. (default: 0)
  127511. * @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)
  127512. */
  127513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127514. }
  127515. }
  127516. declare module BABYLON {
  127517. /** @hidden */
  127518. export var highlightsPixelShader: {
  127519. name: string;
  127520. shader: string;
  127521. };
  127522. }
  127523. declare module BABYLON {
  127524. /**
  127525. * Extracts highlights from the image
  127526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127527. */
  127528. export class HighlightsPostProcess extends PostProcess {
  127529. /**
  127530. * Extracts highlights from the image
  127531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127532. * @param name The name of the effect.
  127533. * @param options The required width/height ratio to downsize to before computing the render pass.
  127534. * @param camera The camera to apply the render pass to.
  127535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127536. * @param engine The engine which the post process will be applied. (default: current engine)
  127537. * @param reusable If the post process can be reused on the same frame. (default: false)
  127538. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127539. */
  127540. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127541. }
  127542. }
  127543. declare module BABYLON {
  127544. /** @hidden */
  127545. export var mrtFragmentDeclaration: {
  127546. name: string;
  127547. shader: string;
  127548. };
  127549. }
  127550. declare module BABYLON {
  127551. /** @hidden */
  127552. export var geometryPixelShader: {
  127553. name: string;
  127554. shader: string;
  127555. };
  127556. }
  127557. declare module BABYLON {
  127558. /** @hidden */
  127559. export var geometryVertexShader: {
  127560. name: string;
  127561. shader: string;
  127562. };
  127563. }
  127564. declare module BABYLON {
  127565. /** @hidden */
  127566. interface ISavedTransformationMatrix {
  127567. world: Matrix;
  127568. viewProjection: Matrix;
  127569. }
  127570. /**
  127571. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127572. */
  127573. export class GeometryBufferRenderer {
  127574. /**
  127575. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127576. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127577. */
  127578. static readonly POSITION_TEXTURE_TYPE: number;
  127579. /**
  127580. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127581. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127582. */
  127583. static readonly VELOCITY_TEXTURE_TYPE: number;
  127584. /**
  127585. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127586. * in order to compute objects velocities when enableVelocity is set to "true"
  127587. * @hidden
  127588. */
  127589. _previousTransformationMatrices: {
  127590. [index: number]: ISavedTransformationMatrix;
  127591. };
  127592. /**
  127593. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127594. * in order to compute objects velocities when enableVelocity is set to "true"
  127595. * @hidden
  127596. */
  127597. _previousBonesTransformationMatrices: {
  127598. [index: number]: Float32Array;
  127599. };
  127600. /**
  127601. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127602. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127603. */
  127604. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127605. private _scene;
  127606. private _multiRenderTarget;
  127607. private _ratio;
  127608. private _enablePosition;
  127609. private _enableVelocity;
  127610. private _positionIndex;
  127611. private _velocityIndex;
  127612. protected _effect: Effect;
  127613. protected _cachedDefines: string;
  127614. /**
  127615. * Set the render list (meshes to be rendered) used in the G buffer.
  127616. */
  127617. renderList: Mesh[];
  127618. /**
  127619. * Gets wether or not G buffer are supported by the running hardware.
  127620. * This requires draw buffer supports
  127621. */
  127622. readonly isSupported: boolean;
  127623. /**
  127624. * Returns the index of the given texture type in the G-Buffer textures array
  127625. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127626. * @returns the index of the given texture type in the G-Buffer textures array
  127627. */
  127628. getTextureIndex(textureType: number): number;
  127629. /**
  127630. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127631. */
  127632. /**
  127633. * Sets whether or not objects positions are enabled for the G buffer.
  127634. */
  127635. enablePosition: boolean;
  127636. /**
  127637. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127638. */
  127639. /**
  127640. * Sets wether or not objects velocities are enabled for the G buffer.
  127641. */
  127642. enableVelocity: boolean;
  127643. /**
  127644. * Gets the scene associated with the buffer.
  127645. */
  127646. readonly scene: Scene;
  127647. /**
  127648. * Gets the ratio used by the buffer during its creation.
  127649. * How big is the buffer related to the main canvas.
  127650. */
  127651. readonly ratio: number;
  127652. /** @hidden */
  127653. static _SceneComponentInitialization: (scene: Scene) => void;
  127654. /**
  127655. * Creates a new G Buffer for the scene
  127656. * @param scene The scene the buffer belongs to
  127657. * @param ratio How big is the buffer related to the main canvas.
  127658. */
  127659. constructor(scene: Scene, ratio?: number);
  127660. /**
  127661. * Checks wether everything is ready to render a submesh to the G buffer.
  127662. * @param subMesh the submesh to check readiness for
  127663. * @param useInstances is the mesh drawn using instance or not
  127664. * @returns true if ready otherwise false
  127665. */
  127666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127667. /**
  127668. * Gets the current underlying G Buffer.
  127669. * @returns the buffer
  127670. */
  127671. getGBuffer(): MultiRenderTarget;
  127672. /**
  127673. * Gets the number of samples used to render the buffer (anti aliasing).
  127674. */
  127675. /**
  127676. * Sets the number of samples used to render the buffer (anti aliasing).
  127677. */
  127678. samples: number;
  127679. /**
  127680. * Disposes the renderer and frees up associated resources.
  127681. */
  127682. dispose(): void;
  127683. protected _createRenderTargets(): void;
  127684. private _copyBonesTransformationMatrices;
  127685. }
  127686. }
  127687. declare module BABYLON {
  127688. interface Scene {
  127689. /** @hidden (Backing field) */
  127690. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127691. /**
  127692. * Gets or Sets the current geometry buffer associated to the scene.
  127693. */
  127694. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127695. /**
  127696. * Enables a GeometryBufferRender and associates it with the scene
  127697. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127698. * @returns the GeometryBufferRenderer
  127699. */
  127700. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127701. /**
  127702. * Disables the GeometryBufferRender associated with the scene
  127703. */
  127704. disableGeometryBufferRenderer(): void;
  127705. }
  127706. /**
  127707. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127708. * in several rendering techniques.
  127709. */
  127710. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127711. /**
  127712. * The component name helpful to identify the component in the list of scene components.
  127713. */
  127714. readonly name: string;
  127715. /**
  127716. * The scene the component belongs to.
  127717. */
  127718. scene: Scene;
  127719. /**
  127720. * Creates a new instance of the component for the given scene
  127721. * @param scene Defines the scene to register the component in
  127722. */
  127723. constructor(scene: Scene);
  127724. /**
  127725. * Registers the component in a given scene
  127726. */
  127727. register(): void;
  127728. /**
  127729. * Rebuilds the elements related to this component in case of
  127730. * context lost for instance.
  127731. */
  127732. rebuild(): void;
  127733. /**
  127734. * Disposes the component and the associated ressources
  127735. */
  127736. dispose(): void;
  127737. private _gatherRenderTargets;
  127738. }
  127739. }
  127740. declare module BABYLON {
  127741. /** @hidden */
  127742. export var motionBlurPixelShader: {
  127743. name: string;
  127744. shader: string;
  127745. };
  127746. }
  127747. declare module BABYLON {
  127748. /**
  127749. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127750. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127751. * As an example, all you have to do is to create the post-process:
  127752. * var mb = new BABYLON.MotionBlurPostProcess(
  127753. * 'mb', // The name of the effect.
  127754. * scene, // The scene containing the objects to blur according to their velocity.
  127755. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127756. * camera // The camera to apply the render pass to.
  127757. * );
  127758. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127759. */
  127760. export class MotionBlurPostProcess extends PostProcess {
  127761. /**
  127762. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127763. */
  127764. motionStrength: number;
  127765. /**
  127766. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127767. */
  127768. /**
  127769. * Sets the number of iterations to be used for motion blur quality
  127770. */
  127771. motionBlurSamples: number;
  127772. private _motionBlurSamples;
  127773. private _geometryBufferRenderer;
  127774. /**
  127775. * Creates a new instance MotionBlurPostProcess
  127776. * @param name The name of the effect.
  127777. * @param scene The scene containing the objects to blur according to their velocity.
  127778. * @param options The required width/height ratio to downsize to before computing the render pass.
  127779. * @param camera The camera to apply the render pass to.
  127780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127781. * @param engine The engine which the post process will be applied. (default: current engine)
  127782. * @param reusable If the post process can be reused on the same frame. (default: false)
  127783. * @param textureType Type of textures used when performing the post process. (default: 0)
  127784. * @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)
  127785. */
  127786. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127787. /**
  127788. * Excludes the given skinned mesh from computing bones velocities.
  127789. * 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.
  127790. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127791. */
  127792. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127793. /**
  127794. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127795. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127796. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127797. */
  127798. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127799. /**
  127800. * Disposes the post process.
  127801. * @param camera The camera to dispose the post process on.
  127802. */
  127803. dispose(camera?: Camera): void;
  127804. }
  127805. }
  127806. declare module BABYLON {
  127807. /** @hidden */
  127808. export var refractionPixelShader: {
  127809. name: string;
  127810. shader: string;
  127811. };
  127812. }
  127813. declare module BABYLON {
  127814. /**
  127815. * Post process which applies a refractin texture
  127816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127817. */
  127818. export class RefractionPostProcess extends PostProcess {
  127819. /** the base color of the refraction (used to taint the rendering) */
  127820. color: Color3;
  127821. /** simulated refraction depth */
  127822. depth: number;
  127823. /** the coefficient of the base color (0 to remove base color tainting) */
  127824. colorLevel: number;
  127825. private _refTexture;
  127826. private _ownRefractionTexture;
  127827. /**
  127828. * Gets or sets the refraction texture
  127829. * Please note that you are responsible for disposing the texture if you set it manually
  127830. */
  127831. refractionTexture: Texture;
  127832. /**
  127833. * Initializes the RefractionPostProcess
  127834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127835. * @param name The name of the effect.
  127836. * @param refractionTextureUrl Url of the refraction texture to use
  127837. * @param color the base color of the refraction (used to taint the rendering)
  127838. * @param depth simulated refraction depth
  127839. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127840. * @param camera The camera to apply the render pass to.
  127841. * @param options The required width/height ratio to downsize to before computing the render pass.
  127842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127843. * @param engine The engine which the post process will be applied. (default: current engine)
  127844. * @param reusable If the post process can be reused on the same frame. (default: false)
  127845. */
  127846. constructor(name: string, refractionTextureUrl: string,
  127847. /** the base color of the refraction (used to taint the rendering) */
  127848. color: Color3,
  127849. /** simulated refraction depth */
  127850. depth: number,
  127851. /** the coefficient of the base color (0 to remove base color tainting) */
  127852. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127853. /**
  127854. * Disposes of the post process
  127855. * @param camera Camera to dispose post process on
  127856. */
  127857. dispose(camera: Camera): void;
  127858. }
  127859. }
  127860. declare module BABYLON {
  127861. /** @hidden */
  127862. export var sharpenPixelShader: {
  127863. name: string;
  127864. shader: string;
  127865. };
  127866. }
  127867. declare module BABYLON {
  127868. /**
  127869. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127870. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127871. */
  127872. export class SharpenPostProcess extends PostProcess {
  127873. /**
  127874. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127875. */
  127876. colorAmount: number;
  127877. /**
  127878. * How much sharpness should be applied (default: 0.3)
  127879. */
  127880. edgeAmount: number;
  127881. /**
  127882. * Creates a new instance ConvolutionPostProcess
  127883. * @param name The name of the effect.
  127884. * @param options The required width/height ratio to downsize to before computing the render pass.
  127885. * @param camera The camera to apply the render pass to.
  127886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127887. * @param engine The engine which the post process will be applied. (default: current engine)
  127888. * @param reusable If the post process can be reused on the same frame. (default: false)
  127889. * @param textureType Type of textures used when performing the post process. (default: 0)
  127890. * @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)
  127891. */
  127892. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127893. }
  127894. }
  127895. declare module BABYLON {
  127896. /**
  127897. * PostProcessRenderPipeline
  127898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127899. */
  127900. export class PostProcessRenderPipeline {
  127901. private engine;
  127902. private _renderEffects;
  127903. private _renderEffectsForIsolatedPass;
  127904. /**
  127905. * List of inspectable custom properties (used by the Inspector)
  127906. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127907. */
  127908. inspectableCustomProperties: IInspectable[];
  127909. /**
  127910. * @hidden
  127911. */
  127912. protected _cameras: Camera[];
  127913. /** @hidden */
  127914. _name: string;
  127915. /**
  127916. * Gets pipeline name
  127917. */
  127918. readonly name: string;
  127919. /**
  127920. * Initializes a PostProcessRenderPipeline
  127921. * @param engine engine to add the pipeline to
  127922. * @param name name of the pipeline
  127923. */
  127924. constructor(engine: Engine, name: string);
  127925. /**
  127926. * Gets the class name
  127927. * @returns "PostProcessRenderPipeline"
  127928. */
  127929. getClassName(): string;
  127930. /**
  127931. * If all the render effects in the pipeline are supported
  127932. */
  127933. readonly isSupported: boolean;
  127934. /**
  127935. * Adds an effect to the pipeline
  127936. * @param renderEffect the effect to add
  127937. */
  127938. addEffect(renderEffect: PostProcessRenderEffect): void;
  127939. /** @hidden */
  127940. _rebuild(): void;
  127941. /** @hidden */
  127942. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127943. /** @hidden */
  127944. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127945. /** @hidden */
  127946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127947. /** @hidden */
  127948. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127949. /** @hidden */
  127950. _attachCameras(cameras: Camera, unique: boolean): void;
  127951. /** @hidden */
  127952. _attachCameras(cameras: Camera[], unique: boolean): void;
  127953. /** @hidden */
  127954. _detachCameras(cameras: Camera): void;
  127955. /** @hidden */
  127956. _detachCameras(cameras: Nullable<Camera[]>): void;
  127957. /** @hidden */
  127958. _update(): void;
  127959. /** @hidden */
  127960. _reset(): void;
  127961. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127962. /**
  127963. * Disposes of the pipeline
  127964. */
  127965. dispose(): void;
  127966. }
  127967. }
  127968. declare module BABYLON {
  127969. /**
  127970. * PostProcessRenderPipelineManager class
  127971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127972. */
  127973. export class PostProcessRenderPipelineManager {
  127974. private _renderPipelines;
  127975. /**
  127976. * Initializes a PostProcessRenderPipelineManager
  127977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127978. */
  127979. constructor();
  127980. /**
  127981. * Gets the list of supported render pipelines
  127982. */
  127983. readonly supportedPipelines: PostProcessRenderPipeline[];
  127984. /**
  127985. * Adds a pipeline to the manager
  127986. * @param renderPipeline The pipeline to add
  127987. */
  127988. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  127989. /**
  127990. * Attaches a camera to the pipeline
  127991. * @param renderPipelineName The name of the pipeline to attach to
  127992. * @param cameras the camera to attach
  127993. * @param unique if the camera can be attached multiple times to the pipeline
  127994. */
  127995. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  127996. /**
  127997. * Detaches a camera from the pipeline
  127998. * @param renderPipelineName The name of the pipeline to detach from
  127999. * @param cameras the camera to detach
  128000. */
  128001. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  128002. /**
  128003. * Enables an effect by name on a pipeline
  128004. * @param renderPipelineName the name of the pipeline to enable the effect in
  128005. * @param renderEffectName the name of the effect to enable
  128006. * @param cameras the cameras that the effect should be enabled on
  128007. */
  128008. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128009. /**
  128010. * Disables an effect by name on a pipeline
  128011. * @param renderPipelineName the name of the pipeline to disable the effect in
  128012. * @param renderEffectName the name of the effect to disable
  128013. * @param cameras the cameras that the effect should be disabled on
  128014. */
  128015. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128016. /**
  128017. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  128018. */
  128019. update(): void;
  128020. /** @hidden */
  128021. _rebuild(): void;
  128022. /**
  128023. * Disposes of the manager and pipelines
  128024. */
  128025. dispose(): void;
  128026. }
  128027. }
  128028. declare module BABYLON {
  128029. interface Scene {
  128030. /** @hidden (Backing field) */
  128031. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128032. /**
  128033. * Gets the postprocess render pipeline manager
  128034. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128035. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128036. */
  128037. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128038. }
  128039. /**
  128040. * Defines the Render Pipeline scene component responsible to rendering pipelines
  128041. */
  128042. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  128043. /**
  128044. * The component name helpfull to identify the component in the list of scene components.
  128045. */
  128046. readonly name: string;
  128047. /**
  128048. * The scene the component belongs to.
  128049. */
  128050. scene: Scene;
  128051. /**
  128052. * Creates a new instance of the component for the given scene
  128053. * @param scene Defines the scene to register the component in
  128054. */
  128055. constructor(scene: Scene);
  128056. /**
  128057. * Registers the component in a given scene
  128058. */
  128059. register(): void;
  128060. /**
  128061. * Rebuilds the elements related to this component in case of
  128062. * context lost for instance.
  128063. */
  128064. rebuild(): void;
  128065. /**
  128066. * Disposes the component and the associated ressources
  128067. */
  128068. dispose(): void;
  128069. private _gatherRenderTargets;
  128070. }
  128071. }
  128072. declare module BABYLON {
  128073. /**
  128074. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  128075. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128076. */
  128077. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128078. private _scene;
  128079. private _camerasToBeAttached;
  128080. /**
  128081. * ID of the sharpen post process,
  128082. */
  128083. private readonly SharpenPostProcessId;
  128084. /**
  128085. * @ignore
  128086. * ID of the image processing post process;
  128087. */
  128088. readonly ImageProcessingPostProcessId: string;
  128089. /**
  128090. * @ignore
  128091. * ID of the Fast Approximate Anti-Aliasing post process;
  128092. */
  128093. readonly FxaaPostProcessId: string;
  128094. /**
  128095. * ID of the chromatic aberration post process,
  128096. */
  128097. private readonly ChromaticAberrationPostProcessId;
  128098. /**
  128099. * ID of the grain post process
  128100. */
  128101. private readonly GrainPostProcessId;
  128102. /**
  128103. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128104. */
  128105. sharpen: SharpenPostProcess;
  128106. private _sharpenEffect;
  128107. private bloom;
  128108. /**
  128109. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128110. */
  128111. depthOfField: DepthOfFieldEffect;
  128112. /**
  128113. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128114. */
  128115. fxaa: FxaaPostProcess;
  128116. /**
  128117. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128118. */
  128119. imageProcessing: ImageProcessingPostProcess;
  128120. /**
  128121. * Chromatic aberration post process which will shift rgb colors in the image
  128122. */
  128123. chromaticAberration: ChromaticAberrationPostProcess;
  128124. private _chromaticAberrationEffect;
  128125. /**
  128126. * Grain post process which add noise to the image
  128127. */
  128128. grain: GrainPostProcess;
  128129. private _grainEffect;
  128130. /**
  128131. * Glow post process which adds a glow to emissive areas of the image
  128132. */
  128133. private _glowLayer;
  128134. /**
  128135. * Animations which can be used to tweak settings over a period of time
  128136. */
  128137. animations: Animation[];
  128138. private _imageProcessingConfigurationObserver;
  128139. private _sharpenEnabled;
  128140. private _bloomEnabled;
  128141. private _depthOfFieldEnabled;
  128142. private _depthOfFieldBlurLevel;
  128143. private _fxaaEnabled;
  128144. private _imageProcessingEnabled;
  128145. private _defaultPipelineTextureType;
  128146. private _bloomScale;
  128147. private _chromaticAberrationEnabled;
  128148. private _grainEnabled;
  128149. private _buildAllowed;
  128150. /**
  128151. * Gets active scene
  128152. */
  128153. readonly scene: Scene;
  128154. /**
  128155. * Enable or disable the sharpen process from the pipeline
  128156. */
  128157. sharpenEnabled: boolean;
  128158. private _resizeObserver;
  128159. private _hardwareScaleLevel;
  128160. private _bloomKernel;
  128161. /**
  128162. * Specifies the size of the bloom blur kernel, relative to the final output size
  128163. */
  128164. bloomKernel: number;
  128165. /**
  128166. * Specifies the weight of the bloom in the final rendering
  128167. */
  128168. private _bloomWeight;
  128169. /**
  128170. * Specifies the luma threshold for the area that will be blurred by the bloom
  128171. */
  128172. private _bloomThreshold;
  128173. private _hdr;
  128174. /**
  128175. * The strength of the bloom.
  128176. */
  128177. bloomWeight: number;
  128178. /**
  128179. * The strength of the bloom.
  128180. */
  128181. bloomThreshold: number;
  128182. /**
  128183. * The scale of the bloom, lower value will provide better performance.
  128184. */
  128185. bloomScale: number;
  128186. /**
  128187. * Enable or disable the bloom from the pipeline
  128188. */
  128189. bloomEnabled: boolean;
  128190. private _rebuildBloom;
  128191. /**
  128192. * If the depth of field is enabled.
  128193. */
  128194. depthOfFieldEnabled: boolean;
  128195. /**
  128196. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128197. */
  128198. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128199. /**
  128200. * If the anti aliasing is enabled.
  128201. */
  128202. fxaaEnabled: boolean;
  128203. private _samples;
  128204. /**
  128205. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128206. */
  128207. samples: number;
  128208. /**
  128209. * If image processing is enabled.
  128210. */
  128211. imageProcessingEnabled: boolean;
  128212. /**
  128213. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128214. */
  128215. glowLayerEnabled: boolean;
  128216. /**
  128217. * Gets the glow layer (or null if not defined)
  128218. */
  128219. readonly glowLayer: Nullable<GlowLayer>;
  128220. /**
  128221. * Enable or disable the chromaticAberration process from the pipeline
  128222. */
  128223. chromaticAberrationEnabled: boolean;
  128224. /**
  128225. * Enable or disable the grain process from the pipeline
  128226. */
  128227. grainEnabled: boolean;
  128228. /**
  128229. * @constructor
  128230. * @param name - The rendering pipeline name (default: "")
  128231. * @param hdr - If high dynamic range textures should be used (default: true)
  128232. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128233. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128234. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128235. */
  128236. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128237. /**
  128238. * Get the class name
  128239. * @returns "DefaultRenderingPipeline"
  128240. */
  128241. getClassName(): string;
  128242. /**
  128243. * Force the compilation of the entire pipeline.
  128244. */
  128245. prepare(): void;
  128246. private _hasCleared;
  128247. private _prevPostProcess;
  128248. private _prevPrevPostProcess;
  128249. private _setAutoClearAndTextureSharing;
  128250. private _depthOfFieldSceneObserver;
  128251. private _buildPipeline;
  128252. private _disposePostProcesses;
  128253. /**
  128254. * Adds a camera to the pipeline
  128255. * @param camera the camera to be added
  128256. */
  128257. addCamera(camera: Camera): void;
  128258. /**
  128259. * Removes a camera from the pipeline
  128260. * @param camera the camera to remove
  128261. */
  128262. removeCamera(camera: Camera): void;
  128263. /**
  128264. * Dispose of the pipeline and stop all post processes
  128265. */
  128266. dispose(): void;
  128267. /**
  128268. * Serialize the rendering pipeline (Used when exporting)
  128269. * @returns the serialized object
  128270. */
  128271. serialize(): any;
  128272. /**
  128273. * Parse the serialized pipeline
  128274. * @param source Source pipeline.
  128275. * @param scene The scene to load the pipeline to.
  128276. * @param rootUrl The URL of the serialized pipeline.
  128277. * @returns An instantiated pipeline from the serialized object.
  128278. */
  128279. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /** @hidden */
  128284. export var lensHighlightsPixelShader: {
  128285. name: string;
  128286. shader: string;
  128287. };
  128288. }
  128289. declare module BABYLON {
  128290. /** @hidden */
  128291. export var depthOfFieldPixelShader: {
  128292. name: string;
  128293. shader: string;
  128294. };
  128295. }
  128296. declare module BABYLON {
  128297. /**
  128298. * BABYLON.JS Chromatic Aberration GLSL Shader
  128299. * Author: Olivier Guyot
  128300. * Separates very slightly R, G and B colors on the edges of the screen
  128301. * Inspired by Francois Tarlier & Martins Upitis
  128302. */
  128303. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128304. /**
  128305. * @ignore
  128306. * The chromatic aberration PostProcess id in the pipeline
  128307. */
  128308. LensChromaticAberrationEffect: string;
  128309. /**
  128310. * @ignore
  128311. * The highlights enhancing PostProcess id in the pipeline
  128312. */
  128313. HighlightsEnhancingEffect: string;
  128314. /**
  128315. * @ignore
  128316. * The depth-of-field PostProcess id in the pipeline
  128317. */
  128318. LensDepthOfFieldEffect: string;
  128319. private _scene;
  128320. private _depthTexture;
  128321. private _grainTexture;
  128322. private _chromaticAberrationPostProcess;
  128323. private _highlightsPostProcess;
  128324. private _depthOfFieldPostProcess;
  128325. private _edgeBlur;
  128326. private _grainAmount;
  128327. private _chromaticAberration;
  128328. private _distortion;
  128329. private _highlightsGain;
  128330. private _highlightsThreshold;
  128331. private _dofDistance;
  128332. private _dofAperture;
  128333. private _dofDarken;
  128334. private _dofPentagon;
  128335. private _blurNoise;
  128336. /**
  128337. * @constructor
  128338. *
  128339. * Effect parameters are as follow:
  128340. * {
  128341. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128342. * edge_blur: number; // from 0 to x (1 for realism)
  128343. * distortion: number; // from 0 to x (1 for realism)
  128344. * grain_amount: number; // from 0 to 1
  128345. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128346. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128347. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128348. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128349. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128350. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128351. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128352. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128353. * }
  128354. * Note: if an effect parameter is unset, effect is disabled
  128355. *
  128356. * @param name The rendering pipeline name
  128357. * @param parameters - An object containing all parameters (see above)
  128358. * @param scene The scene linked to this pipeline
  128359. * @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)
  128360. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128361. */
  128362. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128363. /**
  128364. * Get the class name
  128365. * @returns "LensRenderingPipeline"
  128366. */
  128367. getClassName(): string;
  128368. /**
  128369. * Gets associated scene
  128370. */
  128371. readonly scene: Scene;
  128372. /**
  128373. * Gets or sets the edge blur
  128374. */
  128375. edgeBlur: number;
  128376. /**
  128377. * Gets or sets the grain amount
  128378. */
  128379. grainAmount: number;
  128380. /**
  128381. * Gets or sets the chromatic aberration amount
  128382. */
  128383. chromaticAberration: number;
  128384. /**
  128385. * Gets or sets the depth of field aperture
  128386. */
  128387. dofAperture: number;
  128388. /**
  128389. * Gets or sets the edge distortion
  128390. */
  128391. edgeDistortion: number;
  128392. /**
  128393. * Gets or sets the depth of field distortion
  128394. */
  128395. dofDistortion: number;
  128396. /**
  128397. * Gets or sets the darken out of focus amount
  128398. */
  128399. darkenOutOfFocus: number;
  128400. /**
  128401. * Gets or sets a boolean indicating if blur noise is enabled
  128402. */
  128403. blurNoise: boolean;
  128404. /**
  128405. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128406. */
  128407. pentagonBokeh: boolean;
  128408. /**
  128409. * Gets or sets the highlight grain amount
  128410. */
  128411. highlightsGain: number;
  128412. /**
  128413. * Gets or sets the highlight threshold
  128414. */
  128415. highlightsThreshold: number;
  128416. /**
  128417. * Sets the amount of blur at the edges
  128418. * @param amount blur amount
  128419. */
  128420. setEdgeBlur(amount: number): void;
  128421. /**
  128422. * Sets edge blur to 0
  128423. */
  128424. disableEdgeBlur(): void;
  128425. /**
  128426. * Sets the amout of grain
  128427. * @param amount Amount of grain
  128428. */
  128429. setGrainAmount(amount: number): void;
  128430. /**
  128431. * Set grain amount to 0
  128432. */
  128433. disableGrain(): void;
  128434. /**
  128435. * Sets the chromatic aberration amount
  128436. * @param amount amount of chromatic aberration
  128437. */
  128438. setChromaticAberration(amount: number): void;
  128439. /**
  128440. * Sets chromatic aberration amount to 0
  128441. */
  128442. disableChromaticAberration(): void;
  128443. /**
  128444. * Sets the EdgeDistortion amount
  128445. * @param amount amount of EdgeDistortion
  128446. */
  128447. setEdgeDistortion(amount: number): void;
  128448. /**
  128449. * Sets edge distortion to 0
  128450. */
  128451. disableEdgeDistortion(): void;
  128452. /**
  128453. * Sets the FocusDistance amount
  128454. * @param amount amount of FocusDistance
  128455. */
  128456. setFocusDistance(amount: number): void;
  128457. /**
  128458. * Disables depth of field
  128459. */
  128460. disableDepthOfField(): void;
  128461. /**
  128462. * Sets the Aperture amount
  128463. * @param amount amount of Aperture
  128464. */
  128465. setAperture(amount: number): void;
  128466. /**
  128467. * Sets the DarkenOutOfFocus amount
  128468. * @param amount amount of DarkenOutOfFocus
  128469. */
  128470. setDarkenOutOfFocus(amount: number): void;
  128471. private _pentagonBokehIsEnabled;
  128472. /**
  128473. * Creates a pentagon bokeh effect
  128474. */
  128475. enablePentagonBokeh(): void;
  128476. /**
  128477. * Disables the pentagon bokeh effect
  128478. */
  128479. disablePentagonBokeh(): void;
  128480. /**
  128481. * Enables noise blur
  128482. */
  128483. enableNoiseBlur(): void;
  128484. /**
  128485. * Disables noise blur
  128486. */
  128487. disableNoiseBlur(): void;
  128488. /**
  128489. * Sets the HighlightsGain amount
  128490. * @param amount amount of HighlightsGain
  128491. */
  128492. setHighlightsGain(amount: number): void;
  128493. /**
  128494. * Sets the HighlightsThreshold amount
  128495. * @param amount amount of HighlightsThreshold
  128496. */
  128497. setHighlightsThreshold(amount: number): void;
  128498. /**
  128499. * Disables highlights
  128500. */
  128501. disableHighlights(): void;
  128502. /**
  128503. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128504. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128505. */
  128506. dispose(disableDepthRender?: boolean): void;
  128507. private _createChromaticAberrationPostProcess;
  128508. private _createHighlightsPostProcess;
  128509. private _createDepthOfFieldPostProcess;
  128510. private _createGrainTexture;
  128511. }
  128512. }
  128513. declare module BABYLON {
  128514. /** @hidden */
  128515. export var ssao2PixelShader: {
  128516. name: string;
  128517. shader: string;
  128518. };
  128519. }
  128520. declare module BABYLON {
  128521. /** @hidden */
  128522. export var ssaoCombinePixelShader: {
  128523. name: string;
  128524. shader: string;
  128525. };
  128526. }
  128527. declare module BABYLON {
  128528. /**
  128529. * Render pipeline to produce ssao effect
  128530. */
  128531. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128532. /**
  128533. * @ignore
  128534. * The PassPostProcess id in the pipeline that contains the original scene color
  128535. */
  128536. SSAOOriginalSceneColorEffect: string;
  128537. /**
  128538. * @ignore
  128539. * The SSAO PostProcess id in the pipeline
  128540. */
  128541. SSAORenderEffect: string;
  128542. /**
  128543. * @ignore
  128544. * The horizontal blur PostProcess id in the pipeline
  128545. */
  128546. SSAOBlurHRenderEffect: string;
  128547. /**
  128548. * @ignore
  128549. * The vertical blur PostProcess id in the pipeline
  128550. */
  128551. SSAOBlurVRenderEffect: string;
  128552. /**
  128553. * @ignore
  128554. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128555. */
  128556. SSAOCombineRenderEffect: string;
  128557. /**
  128558. * The output strength of the SSAO post-process. Default value is 1.0.
  128559. */
  128560. totalStrength: number;
  128561. /**
  128562. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128563. */
  128564. maxZ: number;
  128565. /**
  128566. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128567. */
  128568. minZAspect: number;
  128569. private _samples;
  128570. /**
  128571. * Number of samples used for the SSAO calculations. Default value is 8
  128572. */
  128573. samples: number;
  128574. private _textureSamples;
  128575. /**
  128576. * Number of samples to use for antialiasing
  128577. */
  128578. textureSamples: number;
  128579. /**
  128580. * Ratio object used for SSAO ratio and blur ratio
  128581. */
  128582. private _ratio;
  128583. /**
  128584. * Dynamically generated sphere sampler.
  128585. */
  128586. private _sampleSphere;
  128587. /**
  128588. * Blur filter offsets
  128589. */
  128590. private _samplerOffsets;
  128591. private _expensiveBlur;
  128592. /**
  128593. * If bilateral blur should be used
  128594. */
  128595. expensiveBlur: boolean;
  128596. /**
  128597. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128598. */
  128599. radius: number;
  128600. /**
  128601. * The base color of the SSAO post-process
  128602. * The final result is "base + ssao" between [0, 1]
  128603. */
  128604. base: number;
  128605. /**
  128606. * Support test.
  128607. */
  128608. static readonly IsSupported: boolean;
  128609. private _scene;
  128610. private _depthTexture;
  128611. private _normalTexture;
  128612. private _randomTexture;
  128613. private _originalColorPostProcess;
  128614. private _ssaoPostProcess;
  128615. private _blurHPostProcess;
  128616. private _blurVPostProcess;
  128617. private _ssaoCombinePostProcess;
  128618. private _firstUpdate;
  128619. /**
  128620. * Gets active scene
  128621. */
  128622. readonly scene: Scene;
  128623. /**
  128624. * @constructor
  128625. * @param name The rendering pipeline name
  128626. * @param scene The scene linked to this pipeline
  128627. * @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 }
  128628. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128629. */
  128630. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128631. /**
  128632. * Get the class name
  128633. * @returns "SSAO2RenderingPipeline"
  128634. */
  128635. getClassName(): string;
  128636. /**
  128637. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128638. */
  128639. dispose(disableGeometryBufferRenderer?: boolean): void;
  128640. private _createBlurPostProcess;
  128641. /** @hidden */
  128642. _rebuild(): void;
  128643. private _bits;
  128644. private _radicalInverse_VdC;
  128645. private _hammersley;
  128646. private _hemisphereSample_uniform;
  128647. private _generateHemisphere;
  128648. private _createSSAOPostProcess;
  128649. private _createSSAOCombinePostProcess;
  128650. private _createRandomTexture;
  128651. /**
  128652. * Serialize the rendering pipeline (Used when exporting)
  128653. * @returns the serialized object
  128654. */
  128655. serialize(): any;
  128656. /**
  128657. * Parse the serialized pipeline
  128658. * @param source Source pipeline.
  128659. * @param scene The scene to load the pipeline to.
  128660. * @param rootUrl The URL of the serialized pipeline.
  128661. * @returns An instantiated pipeline from the serialized object.
  128662. */
  128663. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128664. }
  128665. }
  128666. declare module BABYLON {
  128667. /** @hidden */
  128668. export var ssaoPixelShader: {
  128669. name: string;
  128670. shader: string;
  128671. };
  128672. }
  128673. declare module BABYLON {
  128674. /**
  128675. * Render pipeline to produce ssao effect
  128676. */
  128677. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128678. /**
  128679. * @ignore
  128680. * The PassPostProcess id in the pipeline that contains the original scene color
  128681. */
  128682. SSAOOriginalSceneColorEffect: string;
  128683. /**
  128684. * @ignore
  128685. * The SSAO PostProcess id in the pipeline
  128686. */
  128687. SSAORenderEffect: string;
  128688. /**
  128689. * @ignore
  128690. * The horizontal blur PostProcess id in the pipeline
  128691. */
  128692. SSAOBlurHRenderEffect: string;
  128693. /**
  128694. * @ignore
  128695. * The vertical blur PostProcess id in the pipeline
  128696. */
  128697. SSAOBlurVRenderEffect: string;
  128698. /**
  128699. * @ignore
  128700. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128701. */
  128702. SSAOCombineRenderEffect: string;
  128703. /**
  128704. * The output strength of the SSAO post-process. Default value is 1.0.
  128705. */
  128706. totalStrength: number;
  128707. /**
  128708. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128709. */
  128710. radius: number;
  128711. /**
  128712. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128713. * Must not be equal to fallOff and superior to fallOff.
  128714. * Default value is 0.0075
  128715. */
  128716. area: number;
  128717. /**
  128718. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128719. * Must not be equal to area and inferior to area.
  128720. * Default value is 0.000001
  128721. */
  128722. fallOff: number;
  128723. /**
  128724. * The base color of the SSAO post-process
  128725. * The final result is "base + ssao" between [0, 1]
  128726. */
  128727. base: number;
  128728. private _scene;
  128729. private _depthTexture;
  128730. private _randomTexture;
  128731. private _originalColorPostProcess;
  128732. private _ssaoPostProcess;
  128733. private _blurHPostProcess;
  128734. private _blurVPostProcess;
  128735. private _ssaoCombinePostProcess;
  128736. private _firstUpdate;
  128737. /**
  128738. * Gets active scene
  128739. */
  128740. readonly scene: Scene;
  128741. /**
  128742. * @constructor
  128743. * @param name - The rendering pipeline name
  128744. * @param scene - The scene linked to this pipeline
  128745. * @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 }
  128746. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128747. */
  128748. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128749. /**
  128750. * Get the class name
  128751. * @returns "SSAORenderingPipeline"
  128752. */
  128753. getClassName(): string;
  128754. /**
  128755. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128756. */
  128757. dispose(disableDepthRender?: boolean): void;
  128758. private _createBlurPostProcess;
  128759. /** @hidden */
  128760. _rebuild(): void;
  128761. private _createSSAOPostProcess;
  128762. private _createSSAOCombinePostProcess;
  128763. private _createRandomTexture;
  128764. }
  128765. }
  128766. declare module BABYLON {
  128767. /** @hidden */
  128768. export var standardPixelShader: {
  128769. name: string;
  128770. shader: string;
  128771. };
  128772. }
  128773. declare module BABYLON {
  128774. /**
  128775. * Standard rendering pipeline
  128776. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128777. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128778. */
  128779. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128780. /**
  128781. * Public members
  128782. */
  128783. /**
  128784. * Post-process which contains the original scene color before the pipeline applies all the effects
  128785. */
  128786. originalPostProcess: Nullable<PostProcess>;
  128787. /**
  128788. * Post-process used to down scale an image x4
  128789. */
  128790. downSampleX4PostProcess: Nullable<PostProcess>;
  128791. /**
  128792. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128793. */
  128794. brightPassPostProcess: Nullable<PostProcess>;
  128795. /**
  128796. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128797. */
  128798. blurHPostProcesses: PostProcess[];
  128799. /**
  128800. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128801. */
  128802. blurVPostProcesses: PostProcess[];
  128803. /**
  128804. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128805. */
  128806. textureAdderPostProcess: Nullable<PostProcess>;
  128807. /**
  128808. * Post-process used to create volumetric lighting effect
  128809. */
  128810. volumetricLightPostProcess: Nullable<PostProcess>;
  128811. /**
  128812. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128813. */
  128814. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128815. /**
  128816. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128817. */
  128818. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128819. /**
  128820. * Post-process used to merge the volumetric light effect and the real scene color
  128821. */
  128822. volumetricLightMergePostProces: Nullable<PostProcess>;
  128823. /**
  128824. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128825. */
  128826. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128827. /**
  128828. * Base post-process used to calculate the average luminance of the final image for HDR
  128829. */
  128830. luminancePostProcess: Nullable<PostProcess>;
  128831. /**
  128832. * Post-processes used to create down sample post-processes in order to get
  128833. * the average luminance of the final image for HDR
  128834. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128835. */
  128836. luminanceDownSamplePostProcesses: PostProcess[];
  128837. /**
  128838. * Post-process used to create a HDR effect (light adaptation)
  128839. */
  128840. hdrPostProcess: Nullable<PostProcess>;
  128841. /**
  128842. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128843. */
  128844. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128845. /**
  128846. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128847. */
  128848. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128849. /**
  128850. * Post-process used to merge the final HDR post-process and the real scene color
  128851. */
  128852. hdrFinalPostProcess: Nullable<PostProcess>;
  128853. /**
  128854. * Post-process used to create a lens flare effect
  128855. */
  128856. lensFlarePostProcess: Nullable<PostProcess>;
  128857. /**
  128858. * Post-process that merges the result of the lens flare post-process and the real scene color
  128859. */
  128860. lensFlareComposePostProcess: Nullable<PostProcess>;
  128861. /**
  128862. * Post-process used to create a motion blur effect
  128863. */
  128864. motionBlurPostProcess: Nullable<PostProcess>;
  128865. /**
  128866. * Post-process used to create a depth of field effect
  128867. */
  128868. depthOfFieldPostProcess: Nullable<PostProcess>;
  128869. /**
  128870. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128871. */
  128872. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128873. /**
  128874. * Represents the brightness threshold in order to configure the illuminated surfaces
  128875. */
  128876. brightThreshold: number;
  128877. /**
  128878. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128879. */
  128880. blurWidth: number;
  128881. /**
  128882. * Sets if the blur for highlighted surfaces must be only horizontal
  128883. */
  128884. horizontalBlur: boolean;
  128885. /**
  128886. * Gets the overall exposure used by the pipeline
  128887. */
  128888. /**
  128889. * Sets the overall exposure used by the pipeline
  128890. */
  128891. exposure: number;
  128892. /**
  128893. * Texture used typically to simulate "dirty" on camera lens
  128894. */
  128895. lensTexture: Nullable<Texture>;
  128896. /**
  128897. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128898. */
  128899. volumetricLightCoefficient: number;
  128900. /**
  128901. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128902. */
  128903. volumetricLightPower: number;
  128904. /**
  128905. * Used the set the blur intensity to smooth the volumetric lights
  128906. */
  128907. volumetricLightBlurScale: number;
  128908. /**
  128909. * Light (spot or directional) used to generate the volumetric lights rays
  128910. * The source light must have a shadow generate so the pipeline can get its
  128911. * depth map
  128912. */
  128913. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128914. /**
  128915. * For eye adaptation, represents the minimum luminance the eye can see
  128916. */
  128917. hdrMinimumLuminance: number;
  128918. /**
  128919. * For eye adaptation, represents the decrease luminance speed
  128920. */
  128921. hdrDecreaseRate: number;
  128922. /**
  128923. * For eye adaptation, represents the increase luminance speed
  128924. */
  128925. hdrIncreaseRate: number;
  128926. /**
  128927. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128928. */
  128929. /**
  128930. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128931. */
  128932. hdrAutoExposure: boolean;
  128933. /**
  128934. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128935. */
  128936. lensColorTexture: Nullable<Texture>;
  128937. /**
  128938. * The overall strengh for the lens flare effect
  128939. */
  128940. lensFlareStrength: number;
  128941. /**
  128942. * Dispersion coefficient for lens flare ghosts
  128943. */
  128944. lensFlareGhostDispersal: number;
  128945. /**
  128946. * Main lens flare halo width
  128947. */
  128948. lensFlareHaloWidth: number;
  128949. /**
  128950. * Based on the lens distortion effect, defines how much the lens flare result
  128951. * is distorted
  128952. */
  128953. lensFlareDistortionStrength: number;
  128954. /**
  128955. * Configures the blur intensity used for for lens flare (halo)
  128956. */
  128957. lensFlareBlurWidth: number;
  128958. /**
  128959. * Lens star texture must be used to simulate rays on the flares and is available
  128960. * in the documentation
  128961. */
  128962. lensStarTexture: Nullable<Texture>;
  128963. /**
  128964. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128965. * flare effect by taking account of the dirt texture
  128966. */
  128967. lensFlareDirtTexture: Nullable<Texture>;
  128968. /**
  128969. * Represents the focal length for the depth of field effect
  128970. */
  128971. depthOfFieldDistance: number;
  128972. /**
  128973. * Represents the blur intensity for the blurred part of the depth of field effect
  128974. */
  128975. depthOfFieldBlurWidth: number;
  128976. /**
  128977. * Gets how much the image is blurred by the movement while using the motion blur post-process
  128978. */
  128979. /**
  128980. * Sets how much the image is blurred by the movement while using the motion blur post-process
  128981. */
  128982. motionStrength: number;
  128983. /**
  128984. * Gets wether or not the motion blur post-process is object based or screen based.
  128985. */
  128986. /**
  128987. * Sets wether or not the motion blur post-process should be object based or screen based
  128988. */
  128989. objectBasedMotionBlur: boolean;
  128990. /**
  128991. * List of animations for the pipeline (IAnimatable implementation)
  128992. */
  128993. animations: Animation[];
  128994. /**
  128995. * Private members
  128996. */
  128997. private _scene;
  128998. private _currentDepthOfFieldSource;
  128999. private _basePostProcess;
  129000. private _fixedExposure;
  129001. private _currentExposure;
  129002. private _hdrAutoExposure;
  129003. private _hdrCurrentLuminance;
  129004. private _motionStrength;
  129005. private _isObjectBasedMotionBlur;
  129006. private _floatTextureType;
  129007. private _camerasToBeAttached;
  129008. private _ratio;
  129009. private _bloomEnabled;
  129010. private _depthOfFieldEnabled;
  129011. private _vlsEnabled;
  129012. private _lensFlareEnabled;
  129013. private _hdrEnabled;
  129014. private _motionBlurEnabled;
  129015. private _fxaaEnabled;
  129016. private _motionBlurSamples;
  129017. private _volumetricLightStepsCount;
  129018. private _samples;
  129019. /**
  129020. * @ignore
  129021. * Specifies if the bloom pipeline is enabled
  129022. */
  129023. BloomEnabled: boolean;
  129024. /**
  129025. * @ignore
  129026. * Specifies if the depth of field pipeline is enabed
  129027. */
  129028. DepthOfFieldEnabled: boolean;
  129029. /**
  129030. * @ignore
  129031. * Specifies if the lens flare pipeline is enabed
  129032. */
  129033. LensFlareEnabled: boolean;
  129034. /**
  129035. * @ignore
  129036. * Specifies if the HDR pipeline is enabled
  129037. */
  129038. HDREnabled: boolean;
  129039. /**
  129040. * @ignore
  129041. * Specifies if the volumetric lights scattering effect is enabled
  129042. */
  129043. VLSEnabled: boolean;
  129044. /**
  129045. * @ignore
  129046. * Specifies if the motion blur effect is enabled
  129047. */
  129048. MotionBlurEnabled: boolean;
  129049. /**
  129050. * Specifies if anti-aliasing is enabled
  129051. */
  129052. fxaaEnabled: boolean;
  129053. /**
  129054. * Specifies the number of steps used to calculate the volumetric lights
  129055. * Typically in interval [50, 200]
  129056. */
  129057. volumetricLightStepsCount: number;
  129058. /**
  129059. * Specifies the number of samples used for the motion blur effect
  129060. * Typically in interval [16, 64]
  129061. */
  129062. motionBlurSamples: number;
  129063. /**
  129064. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129065. */
  129066. samples: number;
  129067. /**
  129068. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129069. * @constructor
  129070. * @param name The rendering pipeline name
  129071. * @param scene The scene linked to this pipeline
  129072. * @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)
  129073. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  129074. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129075. */
  129076. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  129077. private _buildPipeline;
  129078. private _createDownSampleX4PostProcess;
  129079. private _createBrightPassPostProcess;
  129080. private _createBlurPostProcesses;
  129081. private _createTextureAdderPostProcess;
  129082. private _createVolumetricLightPostProcess;
  129083. private _createLuminancePostProcesses;
  129084. private _createHdrPostProcess;
  129085. private _createLensFlarePostProcess;
  129086. private _createDepthOfFieldPostProcess;
  129087. private _createMotionBlurPostProcess;
  129088. private _getDepthTexture;
  129089. private _disposePostProcesses;
  129090. /**
  129091. * Dispose of the pipeline and stop all post processes
  129092. */
  129093. dispose(): void;
  129094. /**
  129095. * Serialize the rendering pipeline (Used when exporting)
  129096. * @returns the serialized object
  129097. */
  129098. serialize(): any;
  129099. /**
  129100. * Parse the serialized pipeline
  129101. * @param source Source pipeline.
  129102. * @param scene The scene to load the pipeline to.
  129103. * @param rootUrl The URL of the serialized pipeline.
  129104. * @returns An instantiated pipeline from the serialized object.
  129105. */
  129106. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129107. /**
  129108. * Luminance steps
  129109. */
  129110. static LuminanceSteps: number;
  129111. }
  129112. }
  129113. declare module BABYLON {
  129114. /** @hidden */
  129115. export var tonemapPixelShader: {
  129116. name: string;
  129117. shader: string;
  129118. };
  129119. }
  129120. declare module BABYLON {
  129121. /** Defines operator used for tonemapping */
  129122. export enum TonemappingOperator {
  129123. /** Hable */
  129124. Hable = 0,
  129125. /** Reinhard */
  129126. Reinhard = 1,
  129127. /** HejiDawson */
  129128. HejiDawson = 2,
  129129. /** Photographic */
  129130. Photographic = 3
  129131. }
  129132. /**
  129133. * Defines a post process to apply tone mapping
  129134. */
  129135. export class TonemapPostProcess extends PostProcess {
  129136. private _operator;
  129137. /** Defines the required exposure adjustement */
  129138. exposureAdjustment: number;
  129139. /**
  129140. * Creates a new TonemapPostProcess
  129141. * @param name defines the name of the postprocess
  129142. * @param _operator defines the operator to use
  129143. * @param exposureAdjustment defines the required exposure adjustement
  129144. * @param camera defines the camera to use (can be null)
  129145. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129146. * @param engine defines the hosting engine (can be ignore if camera is set)
  129147. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129148. */
  129149. constructor(name: string, _operator: TonemappingOperator,
  129150. /** Defines the required exposure adjustement */
  129151. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129152. }
  129153. }
  129154. declare module BABYLON {
  129155. /** @hidden */
  129156. export var depthVertexShader: {
  129157. name: string;
  129158. shader: string;
  129159. };
  129160. }
  129161. declare module BABYLON {
  129162. /** @hidden */
  129163. export var volumetricLightScatteringPixelShader: {
  129164. name: string;
  129165. shader: string;
  129166. };
  129167. }
  129168. declare module BABYLON {
  129169. /** @hidden */
  129170. export var volumetricLightScatteringPassVertexShader: {
  129171. name: string;
  129172. shader: string;
  129173. };
  129174. }
  129175. declare module BABYLON {
  129176. /** @hidden */
  129177. export var volumetricLightScatteringPassPixelShader: {
  129178. name: string;
  129179. shader: string;
  129180. };
  129181. }
  129182. declare module BABYLON {
  129183. /**
  129184. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129185. */
  129186. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129187. private _volumetricLightScatteringPass;
  129188. private _volumetricLightScatteringRTT;
  129189. private _viewPort;
  129190. private _screenCoordinates;
  129191. private _cachedDefines;
  129192. /**
  129193. * If not undefined, the mesh position is computed from the attached node position
  129194. */
  129195. attachedNode: {
  129196. position: Vector3;
  129197. };
  129198. /**
  129199. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129200. */
  129201. customMeshPosition: Vector3;
  129202. /**
  129203. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129204. */
  129205. useCustomMeshPosition: boolean;
  129206. /**
  129207. * If the post-process should inverse the light scattering direction
  129208. */
  129209. invert: boolean;
  129210. /**
  129211. * The internal mesh used by the post-process
  129212. */
  129213. mesh: Mesh;
  129214. /**
  129215. * @hidden
  129216. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129217. */
  129218. useDiffuseColor: boolean;
  129219. /**
  129220. * Array containing the excluded meshes not rendered in the internal pass
  129221. */
  129222. excludedMeshes: AbstractMesh[];
  129223. /**
  129224. * Controls the overall intensity of the post-process
  129225. */
  129226. exposure: number;
  129227. /**
  129228. * Dissipates each sample's contribution in range [0, 1]
  129229. */
  129230. decay: number;
  129231. /**
  129232. * Controls the overall intensity of each sample
  129233. */
  129234. weight: number;
  129235. /**
  129236. * Controls the density of each sample
  129237. */
  129238. density: number;
  129239. /**
  129240. * @constructor
  129241. * @param name The post-process name
  129242. * @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)
  129243. * @param camera The camera that the post-process will be attached to
  129244. * @param mesh The mesh used to create the light scattering
  129245. * @param samples The post-process quality, default 100
  129246. * @param samplingModeThe post-process filtering mode
  129247. * @param engine The babylon engine
  129248. * @param reusable If the post-process is reusable
  129249. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129250. */
  129251. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129252. /**
  129253. * Returns the string "VolumetricLightScatteringPostProcess"
  129254. * @returns "VolumetricLightScatteringPostProcess"
  129255. */
  129256. getClassName(): string;
  129257. private _isReady;
  129258. /**
  129259. * Sets the new light position for light scattering effect
  129260. * @param position The new custom light position
  129261. */
  129262. setCustomMeshPosition(position: Vector3): void;
  129263. /**
  129264. * Returns the light position for light scattering effect
  129265. * @return Vector3 The custom light position
  129266. */
  129267. getCustomMeshPosition(): Vector3;
  129268. /**
  129269. * Disposes the internal assets and detaches the post-process from the camera
  129270. */
  129271. dispose(camera: Camera): void;
  129272. /**
  129273. * Returns the render target texture used by the post-process
  129274. * @return the render target texture used by the post-process
  129275. */
  129276. getPass(): RenderTargetTexture;
  129277. private _meshExcluded;
  129278. private _createPass;
  129279. private _updateMeshScreenCoordinates;
  129280. /**
  129281. * Creates a default mesh for the Volumeric Light Scattering post-process
  129282. * @param name The mesh name
  129283. * @param scene The scene where to create the mesh
  129284. * @return the default mesh
  129285. */
  129286. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129287. }
  129288. }
  129289. declare module BABYLON {
  129290. interface Scene {
  129291. /** @hidden (Backing field) */
  129292. _boundingBoxRenderer: BoundingBoxRenderer;
  129293. /** @hidden (Backing field) */
  129294. _forceShowBoundingBoxes: boolean;
  129295. /**
  129296. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129297. */
  129298. forceShowBoundingBoxes: boolean;
  129299. /**
  129300. * Gets the bounding box renderer associated with the scene
  129301. * @returns a BoundingBoxRenderer
  129302. */
  129303. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129304. }
  129305. interface AbstractMesh {
  129306. /** @hidden (Backing field) */
  129307. _showBoundingBox: boolean;
  129308. /**
  129309. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129310. */
  129311. showBoundingBox: boolean;
  129312. }
  129313. /**
  129314. * Component responsible of rendering the bounding box of the meshes in a scene.
  129315. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129316. */
  129317. export class BoundingBoxRenderer implements ISceneComponent {
  129318. /**
  129319. * The component name helpfull to identify the component in the list of scene components.
  129320. */
  129321. readonly name: string;
  129322. /**
  129323. * The scene the component belongs to.
  129324. */
  129325. scene: Scene;
  129326. /**
  129327. * Color of the bounding box lines placed in front of an object
  129328. */
  129329. frontColor: Color3;
  129330. /**
  129331. * Color of the bounding box lines placed behind an object
  129332. */
  129333. backColor: Color3;
  129334. /**
  129335. * Defines if the renderer should show the back lines or not
  129336. */
  129337. showBackLines: boolean;
  129338. /**
  129339. * @hidden
  129340. */
  129341. renderList: SmartArray<BoundingBox>;
  129342. private _colorShader;
  129343. private _vertexBuffers;
  129344. private _indexBuffer;
  129345. private _fillIndexBuffer;
  129346. private _fillIndexData;
  129347. /**
  129348. * Instantiates a new bounding box renderer in a scene.
  129349. * @param scene the scene the renderer renders in
  129350. */
  129351. constructor(scene: Scene);
  129352. /**
  129353. * Registers the component in a given scene
  129354. */
  129355. register(): void;
  129356. private _evaluateSubMesh;
  129357. private _activeMesh;
  129358. private _prepareRessources;
  129359. private _createIndexBuffer;
  129360. /**
  129361. * Rebuilds the elements related to this component in case of
  129362. * context lost for instance.
  129363. */
  129364. rebuild(): void;
  129365. /**
  129366. * @hidden
  129367. */
  129368. reset(): void;
  129369. /**
  129370. * Render the bounding boxes of a specific rendering group
  129371. * @param renderingGroupId defines the rendering group to render
  129372. */
  129373. render(renderingGroupId: number): void;
  129374. /**
  129375. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129376. * @param mesh Define the mesh to render the occlusion bounding box for
  129377. */
  129378. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129379. /**
  129380. * Dispose and release the resources attached to this renderer.
  129381. */
  129382. dispose(): void;
  129383. }
  129384. }
  129385. declare module BABYLON {
  129386. /** @hidden */
  129387. export var depthPixelShader: {
  129388. name: string;
  129389. shader: string;
  129390. };
  129391. }
  129392. declare module BABYLON {
  129393. /**
  129394. * This represents a depth renderer in Babylon.
  129395. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129396. */
  129397. export class DepthRenderer {
  129398. private _scene;
  129399. private _depthMap;
  129400. private _effect;
  129401. private readonly _storeNonLinearDepth;
  129402. private readonly _clearColor;
  129403. /** Get if the depth renderer is using packed depth or not */
  129404. readonly isPacked: boolean;
  129405. private _cachedDefines;
  129406. private _camera;
  129407. /**
  129408. * Specifiess that the depth renderer will only be used within
  129409. * the camera it is created for.
  129410. * This can help forcing its rendering during the camera processing.
  129411. */
  129412. useOnlyInActiveCamera: boolean;
  129413. /** @hidden */
  129414. static _SceneComponentInitialization: (scene: Scene) => void;
  129415. /**
  129416. * Instantiates a depth renderer
  129417. * @param scene The scene the renderer belongs to
  129418. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129419. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129420. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129421. */
  129422. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129423. /**
  129424. * Creates the depth rendering effect and checks if the effect is ready.
  129425. * @param subMesh The submesh to be used to render the depth map of
  129426. * @param useInstances If multiple world instances should be used
  129427. * @returns if the depth renderer is ready to render the depth map
  129428. */
  129429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129430. /**
  129431. * Gets the texture which the depth map will be written to.
  129432. * @returns The depth map texture
  129433. */
  129434. getDepthMap(): RenderTargetTexture;
  129435. /**
  129436. * Disposes of the depth renderer.
  129437. */
  129438. dispose(): void;
  129439. }
  129440. }
  129441. declare module BABYLON {
  129442. interface Scene {
  129443. /** @hidden (Backing field) */
  129444. _depthRenderer: {
  129445. [id: string]: DepthRenderer;
  129446. };
  129447. /**
  129448. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129449. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129450. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129451. * @returns the created depth renderer
  129452. */
  129453. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129454. /**
  129455. * Disables a depth renderer for a given camera
  129456. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129457. */
  129458. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129459. }
  129460. /**
  129461. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129462. * in several rendering techniques.
  129463. */
  129464. export class DepthRendererSceneComponent implements ISceneComponent {
  129465. /**
  129466. * The component name helpfull to identify the component in the list of scene components.
  129467. */
  129468. readonly name: string;
  129469. /**
  129470. * The scene the component belongs to.
  129471. */
  129472. scene: Scene;
  129473. /**
  129474. * Creates a new instance of the component for the given scene
  129475. * @param scene Defines the scene to register the component in
  129476. */
  129477. constructor(scene: Scene);
  129478. /**
  129479. * Registers the component in a given scene
  129480. */
  129481. register(): void;
  129482. /**
  129483. * Rebuilds the elements related to this component in case of
  129484. * context lost for instance.
  129485. */
  129486. rebuild(): void;
  129487. /**
  129488. * Disposes the component and the associated ressources
  129489. */
  129490. dispose(): void;
  129491. private _gatherRenderTargets;
  129492. private _gatherActiveCameraRenderTargets;
  129493. }
  129494. }
  129495. declare module BABYLON {
  129496. /** @hidden */
  129497. export var outlinePixelShader: {
  129498. name: string;
  129499. shader: string;
  129500. };
  129501. }
  129502. declare module BABYLON {
  129503. /** @hidden */
  129504. export var outlineVertexShader: {
  129505. name: string;
  129506. shader: string;
  129507. };
  129508. }
  129509. declare module BABYLON {
  129510. interface Scene {
  129511. /** @hidden */
  129512. _outlineRenderer: OutlineRenderer;
  129513. /**
  129514. * Gets the outline renderer associated with the scene
  129515. * @returns a OutlineRenderer
  129516. */
  129517. getOutlineRenderer(): OutlineRenderer;
  129518. }
  129519. interface AbstractMesh {
  129520. /** @hidden (Backing field) */
  129521. _renderOutline: boolean;
  129522. /**
  129523. * Gets or sets a boolean indicating if the outline must be rendered as well
  129524. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129525. */
  129526. renderOutline: boolean;
  129527. /** @hidden (Backing field) */
  129528. _renderOverlay: boolean;
  129529. /**
  129530. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129531. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129532. */
  129533. renderOverlay: boolean;
  129534. }
  129535. /**
  129536. * This class is responsible to draw bothe outline/overlay of meshes.
  129537. * It should not be used directly but through the available method on mesh.
  129538. */
  129539. export class OutlineRenderer implements ISceneComponent {
  129540. /**
  129541. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129542. */
  129543. private static _StencilReference;
  129544. /**
  129545. * The name of the component. Each component must have a unique name.
  129546. */
  129547. name: string;
  129548. /**
  129549. * The scene the component belongs to.
  129550. */
  129551. scene: Scene;
  129552. /**
  129553. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129554. */
  129555. zOffset: number;
  129556. private _engine;
  129557. private _effect;
  129558. private _cachedDefines;
  129559. private _savedDepthWrite;
  129560. /**
  129561. * Instantiates a new outline renderer. (There could be only one per scene).
  129562. * @param scene Defines the scene it belongs to
  129563. */
  129564. constructor(scene: Scene);
  129565. /**
  129566. * Register the component to one instance of a scene.
  129567. */
  129568. register(): void;
  129569. /**
  129570. * Rebuilds the elements related to this component in case of
  129571. * context lost for instance.
  129572. */
  129573. rebuild(): void;
  129574. /**
  129575. * Disposes the component and the associated ressources.
  129576. */
  129577. dispose(): void;
  129578. /**
  129579. * Renders the outline in the canvas.
  129580. * @param subMesh Defines the sumesh to render
  129581. * @param batch Defines the batch of meshes in case of instances
  129582. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129583. */
  129584. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129585. /**
  129586. * Returns whether or not the outline renderer is ready for a given submesh.
  129587. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129588. * @param subMesh Defines the submesh to check readyness for
  129589. * @param useInstances Defines wheter wee are trying to render instances or not
  129590. * @returns true if ready otherwise false
  129591. */
  129592. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129593. private _beforeRenderingMesh;
  129594. private _afterRenderingMesh;
  129595. }
  129596. }
  129597. declare module BABYLON {
  129598. /**
  129599. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129600. * @see http://doc.babylonjs.com/babylon101/sprites
  129601. */
  129602. export class SpritePackedManager extends SpriteManager {
  129603. /** defines the packed manager's name */
  129604. name: string;
  129605. /**
  129606. * Creates a new sprite manager from a packed sprite sheet
  129607. * @param name defines the manager's name
  129608. * @param imgUrl defines the sprite sheet url
  129609. * @param capacity defines the maximum allowed number of sprites
  129610. * @param scene defines the hosting scene
  129611. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129612. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129613. * @param samplingMode defines the smapling mode to use with spritesheet
  129614. * @param fromPacked set to true; do not alter
  129615. */
  129616. constructor(
  129617. /** defines the packed manager's name */
  129618. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129619. }
  129620. }
  129621. declare module BABYLON {
  129622. /**
  129623. * Defines the list of states available for a task inside a AssetsManager
  129624. */
  129625. export enum AssetTaskState {
  129626. /**
  129627. * Initialization
  129628. */
  129629. INIT = 0,
  129630. /**
  129631. * Running
  129632. */
  129633. RUNNING = 1,
  129634. /**
  129635. * Done
  129636. */
  129637. DONE = 2,
  129638. /**
  129639. * Error
  129640. */
  129641. ERROR = 3
  129642. }
  129643. /**
  129644. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129645. */
  129646. export abstract class AbstractAssetTask {
  129647. /**
  129648. * Task name
  129649. */ name: string;
  129650. /**
  129651. * Callback called when the task is successful
  129652. */
  129653. onSuccess: (task: any) => void;
  129654. /**
  129655. * Callback called when the task is not successful
  129656. */
  129657. onError: (task: any, message?: string, exception?: any) => void;
  129658. /**
  129659. * Creates a new AssetsManager
  129660. * @param name defines the name of the task
  129661. */
  129662. constructor(
  129663. /**
  129664. * Task name
  129665. */ name: string);
  129666. private _isCompleted;
  129667. private _taskState;
  129668. private _errorObject;
  129669. /**
  129670. * Get if the task is completed
  129671. */
  129672. readonly isCompleted: boolean;
  129673. /**
  129674. * Gets the current state of the task
  129675. */
  129676. readonly taskState: AssetTaskState;
  129677. /**
  129678. * Gets the current error object (if task is in error)
  129679. */
  129680. readonly errorObject: {
  129681. message?: string;
  129682. exception?: any;
  129683. };
  129684. /**
  129685. * Internal only
  129686. * @hidden
  129687. */
  129688. _setErrorObject(message?: string, exception?: any): void;
  129689. /**
  129690. * Execute the current task
  129691. * @param scene defines the scene where you want your assets to be loaded
  129692. * @param onSuccess is a callback called when the task is successfully executed
  129693. * @param onError is a callback called if an error occurs
  129694. */
  129695. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129696. /**
  129697. * Execute the current task
  129698. * @param scene defines the scene where you want your assets to be loaded
  129699. * @param onSuccess is a callback called when the task is successfully executed
  129700. * @param onError is a callback called if an error occurs
  129701. */
  129702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129703. /**
  129704. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129705. * This can be used with failed tasks that have the reason for failure fixed.
  129706. */
  129707. reset(): void;
  129708. private onErrorCallback;
  129709. private onDoneCallback;
  129710. }
  129711. /**
  129712. * Define the interface used by progress events raised during assets loading
  129713. */
  129714. export interface IAssetsProgressEvent {
  129715. /**
  129716. * Defines the number of remaining tasks to process
  129717. */
  129718. remainingCount: number;
  129719. /**
  129720. * Defines the total number of tasks
  129721. */
  129722. totalCount: number;
  129723. /**
  129724. * Defines the task that was just processed
  129725. */
  129726. task: AbstractAssetTask;
  129727. }
  129728. /**
  129729. * Class used to share progress information about assets loading
  129730. */
  129731. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129732. /**
  129733. * Defines the number of remaining tasks to process
  129734. */
  129735. remainingCount: number;
  129736. /**
  129737. * Defines the total number of tasks
  129738. */
  129739. totalCount: number;
  129740. /**
  129741. * Defines the task that was just processed
  129742. */
  129743. task: AbstractAssetTask;
  129744. /**
  129745. * Creates a AssetsProgressEvent
  129746. * @param remainingCount defines the number of remaining tasks to process
  129747. * @param totalCount defines the total number of tasks
  129748. * @param task defines the task that was just processed
  129749. */
  129750. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129751. }
  129752. /**
  129753. * Define a task used by AssetsManager to load meshes
  129754. */
  129755. export class MeshAssetTask extends AbstractAssetTask {
  129756. /**
  129757. * Defines the name of the task
  129758. */
  129759. name: string;
  129760. /**
  129761. * Defines the list of mesh's names you want to load
  129762. */
  129763. meshesNames: any;
  129764. /**
  129765. * Defines the root url to use as a base to load your meshes and associated resources
  129766. */
  129767. rootUrl: string;
  129768. /**
  129769. * Defines the filename of the scene to load from
  129770. */
  129771. sceneFilename: string;
  129772. /**
  129773. * Gets the list of loaded meshes
  129774. */
  129775. loadedMeshes: Array<AbstractMesh>;
  129776. /**
  129777. * Gets the list of loaded particle systems
  129778. */
  129779. loadedParticleSystems: Array<IParticleSystem>;
  129780. /**
  129781. * Gets the list of loaded skeletons
  129782. */
  129783. loadedSkeletons: Array<Skeleton>;
  129784. /**
  129785. * Gets the list of loaded animation groups
  129786. */
  129787. loadedAnimationGroups: Array<AnimationGroup>;
  129788. /**
  129789. * Callback called when the task is successful
  129790. */
  129791. onSuccess: (task: MeshAssetTask) => void;
  129792. /**
  129793. * Callback called when the task is successful
  129794. */
  129795. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129796. /**
  129797. * Creates a new MeshAssetTask
  129798. * @param name defines the name of the task
  129799. * @param meshesNames defines the list of mesh's names you want to load
  129800. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129801. * @param sceneFilename defines the filename of the scene to load from
  129802. */
  129803. constructor(
  129804. /**
  129805. * Defines the name of the task
  129806. */
  129807. name: string,
  129808. /**
  129809. * Defines the list of mesh's names you want to load
  129810. */
  129811. meshesNames: any,
  129812. /**
  129813. * Defines the root url to use as a base to load your meshes and associated resources
  129814. */
  129815. rootUrl: string,
  129816. /**
  129817. * Defines the filename of the scene to load from
  129818. */
  129819. sceneFilename: string);
  129820. /**
  129821. * Execute the current task
  129822. * @param scene defines the scene where you want your assets to be loaded
  129823. * @param onSuccess is a callback called when the task is successfully executed
  129824. * @param onError is a callback called if an error occurs
  129825. */
  129826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129827. }
  129828. /**
  129829. * Define a task used by AssetsManager to load text content
  129830. */
  129831. export class TextFileAssetTask extends AbstractAssetTask {
  129832. /**
  129833. * Defines the name of the task
  129834. */
  129835. name: string;
  129836. /**
  129837. * Defines the location of the file to load
  129838. */
  129839. url: string;
  129840. /**
  129841. * Gets the loaded text string
  129842. */
  129843. text: string;
  129844. /**
  129845. * Callback called when the task is successful
  129846. */
  129847. onSuccess: (task: TextFileAssetTask) => void;
  129848. /**
  129849. * Callback called when the task is successful
  129850. */
  129851. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129852. /**
  129853. * Creates a new TextFileAssetTask object
  129854. * @param name defines the name of the task
  129855. * @param url defines the location of the file to load
  129856. */
  129857. constructor(
  129858. /**
  129859. * Defines the name of the task
  129860. */
  129861. name: string,
  129862. /**
  129863. * Defines the location of the file to load
  129864. */
  129865. url: string);
  129866. /**
  129867. * Execute the current task
  129868. * @param scene defines the scene where you want your assets to be loaded
  129869. * @param onSuccess is a callback called when the task is successfully executed
  129870. * @param onError is a callback called if an error occurs
  129871. */
  129872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129873. }
  129874. /**
  129875. * Define a task used by AssetsManager to load binary data
  129876. */
  129877. export class BinaryFileAssetTask extends AbstractAssetTask {
  129878. /**
  129879. * Defines the name of the task
  129880. */
  129881. name: string;
  129882. /**
  129883. * Defines the location of the file to load
  129884. */
  129885. url: string;
  129886. /**
  129887. * Gets the lodaded data (as an array buffer)
  129888. */
  129889. data: ArrayBuffer;
  129890. /**
  129891. * Callback called when the task is successful
  129892. */
  129893. onSuccess: (task: BinaryFileAssetTask) => void;
  129894. /**
  129895. * Callback called when the task is successful
  129896. */
  129897. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129898. /**
  129899. * Creates a new BinaryFileAssetTask object
  129900. * @param name defines the name of the new task
  129901. * @param url defines the location of the file to load
  129902. */
  129903. constructor(
  129904. /**
  129905. * Defines the name of the task
  129906. */
  129907. name: string,
  129908. /**
  129909. * Defines the location of the file to load
  129910. */
  129911. url: string);
  129912. /**
  129913. * Execute the current task
  129914. * @param scene defines the scene where you want your assets to be loaded
  129915. * @param onSuccess is a callback called when the task is successfully executed
  129916. * @param onError is a callback called if an error occurs
  129917. */
  129918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129919. }
  129920. /**
  129921. * Define a task used by AssetsManager to load images
  129922. */
  129923. export class ImageAssetTask extends AbstractAssetTask {
  129924. /**
  129925. * Defines the name of the task
  129926. */
  129927. name: string;
  129928. /**
  129929. * Defines the location of the image to load
  129930. */
  129931. url: string;
  129932. /**
  129933. * Gets the loaded images
  129934. */
  129935. image: HTMLImageElement;
  129936. /**
  129937. * Callback called when the task is successful
  129938. */
  129939. onSuccess: (task: ImageAssetTask) => void;
  129940. /**
  129941. * Callback called when the task is successful
  129942. */
  129943. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129944. /**
  129945. * Creates a new ImageAssetTask
  129946. * @param name defines the name of the task
  129947. * @param url defines the location of the image to load
  129948. */
  129949. constructor(
  129950. /**
  129951. * Defines the name of the task
  129952. */
  129953. name: string,
  129954. /**
  129955. * Defines the location of the image to load
  129956. */
  129957. url: string);
  129958. /**
  129959. * Execute the current task
  129960. * @param scene defines the scene where you want your assets to be loaded
  129961. * @param onSuccess is a callback called when the task is successfully executed
  129962. * @param onError is a callback called if an error occurs
  129963. */
  129964. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129965. }
  129966. /**
  129967. * Defines the interface used by texture loading tasks
  129968. */
  129969. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129970. /**
  129971. * Gets the loaded texture
  129972. */
  129973. texture: TEX;
  129974. }
  129975. /**
  129976. * Define a task used by AssetsManager to load 2D textures
  129977. */
  129978. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  129979. /**
  129980. * Defines the name of the task
  129981. */
  129982. name: string;
  129983. /**
  129984. * Defines the location of the file to load
  129985. */
  129986. url: string;
  129987. /**
  129988. * Defines if mipmap should not be generated (default is false)
  129989. */
  129990. noMipmap?: boolean | undefined;
  129991. /**
  129992. * Defines if texture must be inverted on Y axis (default is false)
  129993. */
  129994. invertY?: boolean | undefined;
  129995. /**
  129996. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129997. */
  129998. samplingMode: number;
  129999. /**
  130000. * Gets the loaded texture
  130001. */
  130002. texture: Texture;
  130003. /**
  130004. * Callback called when the task is successful
  130005. */
  130006. onSuccess: (task: TextureAssetTask) => void;
  130007. /**
  130008. * Callback called when the task is successful
  130009. */
  130010. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  130011. /**
  130012. * Creates a new TextureAssetTask object
  130013. * @param name defines the name of the task
  130014. * @param url defines the location of the file to load
  130015. * @param noMipmap defines if mipmap should not be generated (default is false)
  130016. * @param invertY defines if texture must be inverted on Y axis (default is false)
  130017. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130018. */
  130019. constructor(
  130020. /**
  130021. * Defines the name of the task
  130022. */
  130023. name: string,
  130024. /**
  130025. * Defines the location of the file to load
  130026. */
  130027. url: string,
  130028. /**
  130029. * Defines if mipmap should not be generated (default is false)
  130030. */
  130031. noMipmap?: boolean | undefined,
  130032. /**
  130033. * Defines if texture must be inverted on Y axis (default is false)
  130034. */
  130035. invertY?: boolean | undefined,
  130036. /**
  130037. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130038. */
  130039. samplingMode?: number);
  130040. /**
  130041. * Execute the current task
  130042. * @param scene defines the scene where you want your assets to be loaded
  130043. * @param onSuccess is a callback called when the task is successfully executed
  130044. * @param onError is a callback called if an error occurs
  130045. */
  130046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130047. }
  130048. /**
  130049. * Define a task used by AssetsManager to load cube textures
  130050. */
  130051. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  130052. /**
  130053. * Defines the name of the task
  130054. */
  130055. name: string;
  130056. /**
  130057. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130058. */
  130059. url: string;
  130060. /**
  130061. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130062. */
  130063. extensions?: string[] | undefined;
  130064. /**
  130065. * Defines if mipmaps should not be generated (default is false)
  130066. */
  130067. noMipmap?: boolean | undefined;
  130068. /**
  130069. * Defines the explicit list of files (undefined by default)
  130070. */
  130071. files?: string[] | undefined;
  130072. /**
  130073. * Gets the loaded texture
  130074. */
  130075. texture: CubeTexture;
  130076. /**
  130077. * Callback called when the task is successful
  130078. */
  130079. onSuccess: (task: CubeTextureAssetTask) => void;
  130080. /**
  130081. * Callback called when the task is successful
  130082. */
  130083. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  130084. /**
  130085. * Creates a new CubeTextureAssetTask
  130086. * @param name defines the name of the task
  130087. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130088. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130089. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130090. * @param files defines the explicit list of files (undefined by default)
  130091. */
  130092. constructor(
  130093. /**
  130094. * Defines the name of the task
  130095. */
  130096. name: string,
  130097. /**
  130098. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130099. */
  130100. url: string,
  130101. /**
  130102. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130103. */
  130104. extensions?: string[] | undefined,
  130105. /**
  130106. * Defines if mipmaps should not be generated (default is false)
  130107. */
  130108. noMipmap?: boolean | undefined,
  130109. /**
  130110. * Defines the explicit list of files (undefined by default)
  130111. */
  130112. files?: string[] | undefined);
  130113. /**
  130114. * Execute the current task
  130115. * @param scene defines the scene where you want your assets to be loaded
  130116. * @param onSuccess is a callback called when the task is successfully executed
  130117. * @param onError is a callback called if an error occurs
  130118. */
  130119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130120. }
  130121. /**
  130122. * Define a task used by AssetsManager to load HDR cube textures
  130123. */
  130124. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130125. /**
  130126. * Defines the name of the task
  130127. */
  130128. name: string;
  130129. /**
  130130. * Defines the location of the file to load
  130131. */
  130132. url: string;
  130133. /**
  130134. * Defines the desired size (the more it increases the longer the generation will be)
  130135. */
  130136. size: number;
  130137. /**
  130138. * Defines if mipmaps should not be generated (default is false)
  130139. */
  130140. noMipmap: boolean;
  130141. /**
  130142. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130143. */
  130144. generateHarmonics: boolean;
  130145. /**
  130146. * 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)
  130147. */
  130148. gammaSpace: boolean;
  130149. /**
  130150. * Internal Use Only
  130151. */
  130152. reserved: boolean;
  130153. /**
  130154. * Gets the loaded texture
  130155. */
  130156. texture: HDRCubeTexture;
  130157. /**
  130158. * Callback called when the task is successful
  130159. */
  130160. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130161. /**
  130162. * Callback called when the task is successful
  130163. */
  130164. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130165. /**
  130166. * Creates a new HDRCubeTextureAssetTask object
  130167. * @param name defines the name of the task
  130168. * @param url defines the location of the file to load
  130169. * @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.
  130170. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130171. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130172. * @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)
  130173. * @param reserved Internal use only
  130174. */
  130175. constructor(
  130176. /**
  130177. * Defines the name of the task
  130178. */
  130179. name: string,
  130180. /**
  130181. * Defines the location of the file to load
  130182. */
  130183. url: string,
  130184. /**
  130185. * Defines the desired size (the more it increases the longer the generation will be)
  130186. */
  130187. size: number,
  130188. /**
  130189. * Defines if mipmaps should not be generated (default is false)
  130190. */
  130191. noMipmap?: boolean,
  130192. /**
  130193. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130194. */
  130195. generateHarmonics?: boolean,
  130196. /**
  130197. * 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)
  130198. */
  130199. gammaSpace?: boolean,
  130200. /**
  130201. * Internal Use Only
  130202. */
  130203. reserved?: boolean);
  130204. /**
  130205. * Execute the current task
  130206. * @param scene defines the scene where you want your assets to be loaded
  130207. * @param onSuccess is a callback called when the task is successfully executed
  130208. * @param onError is a callback called if an error occurs
  130209. */
  130210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130211. }
  130212. /**
  130213. * Define a task used by AssetsManager to load Equirectangular cube textures
  130214. */
  130215. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130216. /**
  130217. * Defines the name of the task
  130218. */
  130219. name: string;
  130220. /**
  130221. * Defines the location of the file to load
  130222. */
  130223. url: string;
  130224. /**
  130225. * Defines the desired size (the more it increases the longer the generation will be)
  130226. */
  130227. size: number;
  130228. /**
  130229. * Defines if mipmaps should not be generated (default is false)
  130230. */
  130231. noMipmap: boolean;
  130232. /**
  130233. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130234. * but the standard material would require them in Gamma space) (default is true)
  130235. */
  130236. gammaSpace: boolean;
  130237. /**
  130238. * Gets the loaded texture
  130239. */
  130240. texture: EquiRectangularCubeTexture;
  130241. /**
  130242. * Callback called when the task is successful
  130243. */
  130244. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130245. /**
  130246. * Callback called when the task is successful
  130247. */
  130248. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130249. /**
  130250. * Creates a new EquiRectangularCubeTextureAssetTask object
  130251. * @param name defines the name of the task
  130252. * @param url defines the location of the file to load
  130253. * @param size defines the desired size (the more it increases the longer the generation will be)
  130254. * If the size is omitted this implies you are using a preprocessed cubemap.
  130255. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130256. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130257. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130258. * (default is true)
  130259. */
  130260. constructor(
  130261. /**
  130262. * Defines the name of the task
  130263. */
  130264. name: string,
  130265. /**
  130266. * Defines the location of the file to load
  130267. */
  130268. url: string,
  130269. /**
  130270. * Defines the desired size (the more it increases the longer the generation will be)
  130271. */
  130272. size: number,
  130273. /**
  130274. * Defines if mipmaps should not be generated (default is false)
  130275. */
  130276. noMipmap?: boolean,
  130277. /**
  130278. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130279. * but the standard material would require them in Gamma space) (default is true)
  130280. */
  130281. gammaSpace?: boolean);
  130282. /**
  130283. * Execute the current task
  130284. * @param scene defines the scene where you want your assets to be loaded
  130285. * @param onSuccess is a callback called when the task is successfully executed
  130286. * @param onError is a callback called if an error occurs
  130287. */
  130288. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130289. }
  130290. /**
  130291. * This class can be used to easily import assets into a scene
  130292. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130293. */
  130294. export class AssetsManager {
  130295. private _scene;
  130296. private _isLoading;
  130297. protected _tasks: AbstractAssetTask[];
  130298. protected _waitingTasksCount: number;
  130299. protected _totalTasksCount: number;
  130300. /**
  130301. * Callback called when all tasks are processed
  130302. */
  130303. onFinish: (tasks: AbstractAssetTask[]) => void;
  130304. /**
  130305. * Callback called when a task is successful
  130306. */
  130307. onTaskSuccess: (task: AbstractAssetTask) => void;
  130308. /**
  130309. * Callback called when a task had an error
  130310. */
  130311. onTaskError: (task: AbstractAssetTask) => void;
  130312. /**
  130313. * Callback called when a task is done (whatever the result is)
  130314. */
  130315. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130316. /**
  130317. * Observable called when all tasks are processed
  130318. */
  130319. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130320. /**
  130321. * Observable called when a task had an error
  130322. */
  130323. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130324. /**
  130325. * Observable called when all tasks were executed
  130326. */
  130327. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130328. /**
  130329. * Observable called when a task is done (whatever the result is)
  130330. */
  130331. onProgressObservable: Observable<IAssetsProgressEvent>;
  130332. /**
  130333. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130334. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130335. */
  130336. useDefaultLoadingScreen: boolean;
  130337. /**
  130338. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130339. * when all assets have been downloaded.
  130340. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130341. */
  130342. autoHideLoadingUI: boolean;
  130343. /**
  130344. * Creates a new AssetsManager
  130345. * @param scene defines the scene to work on
  130346. */
  130347. constructor(scene: Scene);
  130348. /**
  130349. * Add a MeshAssetTask to the list of active tasks
  130350. * @param taskName defines the name of the new task
  130351. * @param meshesNames defines the name of meshes to load
  130352. * @param rootUrl defines the root url to use to locate files
  130353. * @param sceneFilename defines the filename of the scene file
  130354. * @returns a new MeshAssetTask object
  130355. */
  130356. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130357. /**
  130358. * Add a TextFileAssetTask to the list of active tasks
  130359. * @param taskName defines the name of the new task
  130360. * @param url defines the url of the file to load
  130361. * @returns a new TextFileAssetTask object
  130362. */
  130363. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130364. /**
  130365. * Add a BinaryFileAssetTask to the list of active tasks
  130366. * @param taskName defines the name of the new task
  130367. * @param url defines the url of the file to load
  130368. * @returns a new BinaryFileAssetTask object
  130369. */
  130370. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130371. /**
  130372. * Add a ImageAssetTask to the list of active tasks
  130373. * @param taskName defines the name of the new task
  130374. * @param url defines the url of the file to load
  130375. * @returns a new ImageAssetTask object
  130376. */
  130377. addImageTask(taskName: string, url: string): ImageAssetTask;
  130378. /**
  130379. * Add a TextureAssetTask to the list of active tasks
  130380. * @param taskName defines the name of the new task
  130381. * @param url defines the url of the file to load
  130382. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130383. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130384. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130385. * @returns a new TextureAssetTask object
  130386. */
  130387. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130388. /**
  130389. * Add a CubeTextureAssetTask to the list of active tasks
  130390. * @param taskName defines the name of the new task
  130391. * @param url defines the url of the file to load
  130392. * @param extensions defines the extension to use to load the cube map (can be null)
  130393. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130394. * @param files defines the list of files to load (can be null)
  130395. * @returns a new CubeTextureAssetTask object
  130396. */
  130397. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130398. /**
  130399. *
  130400. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130401. * @param taskName defines the name of the new task
  130402. * @param url defines the url of the file to load
  130403. * @param size defines the size you want for the cubemap (can be null)
  130404. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130405. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130406. * @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)
  130407. * @param reserved Internal use only
  130408. * @returns a new HDRCubeTextureAssetTask object
  130409. */
  130410. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130411. /**
  130412. *
  130413. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130414. * @param taskName defines the name of the new task
  130415. * @param url defines the url of the file to load
  130416. * @param size defines the size you want for the cubemap (can be null)
  130417. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130418. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130419. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130420. * @returns a new EquiRectangularCubeTextureAssetTask object
  130421. */
  130422. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130423. /**
  130424. * Remove a task from the assets manager.
  130425. * @param task the task to remove
  130426. */
  130427. removeTask(task: AbstractAssetTask): void;
  130428. private _decreaseWaitingTasksCount;
  130429. private _runTask;
  130430. /**
  130431. * Reset the AssetsManager and remove all tasks
  130432. * @return the current instance of the AssetsManager
  130433. */
  130434. reset(): AssetsManager;
  130435. /**
  130436. * Start the loading process
  130437. * @return the current instance of the AssetsManager
  130438. */
  130439. load(): AssetsManager;
  130440. /**
  130441. * Start the loading process as an async operation
  130442. * @return a promise returning the list of failed tasks
  130443. */
  130444. loadAsync(): Promise<void>;
  130445. }
  130446. }
  130447. declare module BABYLON {
  130448. /**
  130449. * Wrapper class for promise with external resolve and reject.
  130450. */
  130451. export class Deferred<T> {
  130452. /**
  130453. * The promise associated with this deferred object.
  130454. */
  130455. readonly promise: Promise<T>;
  130456. private _resolve;
  130457. private _reject;
  130458. /**
  130459. * The resolve method of the promise associated with this deferred object.
  130460. */
  130461. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130462. /**
  130463. * The reject method of the promise associated with this deferred object.
  130464. */
  130465. readonly reject: (reason?: any) => void;
  130466. /**
  130467. * Constructor for this deferred object.
  130468. */
  130469. constructor();
  130470. }
  130471. }
  130472. declare module BABYLON {
  130473. /**
  130474. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130475. */
  130476. export class MeshExploder {
  130477. private _centerMesh;
  130478. private _meshes;
  130479. private _meshesOrigins;
  130480. private _toCenterVectors;
  130481. private _scaledDirection;
  130482. private _newPosition;
  130483. private _centerPosition;
  130484. /**
  130485. * Explodes meshes from a center mesh.
  130486. * @param meshes The meshes to explode.
  130487. * @param centerMesh The mesh to be center of explosion.
  130488. */
  130489. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130490. private _setCenterMesh;
  130491. /**
  130492. * Get class name
  130493. * @returns "MeshExploder"
  130494. */
  130495. getClassName(): string;
  130496. /**
  130497. * "Exploded meshes"
  130498. * @returns Array of meshes with the centerMesh at index 0.
  130499. */
  130500. getMeshes(): Array<Mesh>;
  130501. /**
  130502. * Explodes meshes giving a specific direction
  130503. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130504. */
  130505. explode(direction?: number): void;
  130506. }
  130507. }
  130508. declare module BABYLON {
  130509. /**
  130510. * Class used to help managing file picking and drag'n'drop
  130511. */
  130512. export class FilesInput {
  130513. /**
  130514. * List of files ready to be loaded
  130515. */
  130516. static readonly FilesToLoad: {
  130517. [key: string]: File;
  130518. };
  130519. /**
  130520. * Callback called when a file is processed
  130521. */
  130522. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130523. private _engine;
  130524. private _currentScene;
  130525. private _sceneLoadedCallback;
  130526. private _progressCallback;
  130527. private _additionalRenderLoopLogicCallback;
  130528. private _textureLoadingCallback;
  130529. private _startingProcessingFilesCallback;
  130530. private _onReloadCallback;
  130531. private _errorCallback;
  130532. private _elementToMonitor;
  130533. private _sceneFileToLoad;
  130534. private _filesToLoad;
  130535. /**
  130536. * Creates a new FilesInput
  130537. * @param engine defines the rendering engine
  130538. * @param scene defines the hosting scene
  130539. * @param sceneLoadedCallback callback called when scene is loaded
  130540. * @param progressCallback callback called to track progress
  130541. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130542. * @param textureLoadingCallback callback called when a texture is loading
  130543. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130544. * @param onReloadCallback callback called when a reload is requested
  130545. * @param errorCallback callback call if an error occurs
  130546. */
  130547. 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);
  130548. private _dragEnterHandler;
  130549. private _dragOverHandler;
  130550. private _dropHandler;
  130551. /**
  130552. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130553. * @param elementToMonitor defines the DOM element to track
  130554. */
  130555. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130556. /**
  130557. * Release all associated resources
  130558. */
  130559. dispose(): void;
  130560. private renderFunction;
  130561. private drag;
  130562. private drop;
  130563. private _traverseFolder;
  130564. private _processFiles;
  130565. /**
  130566. * Load files from a drop event
  130567. * @param event defines the drop event to use as source
  130568. */
  130569. loadFiles(event: any): void;
  130570. private _processReload;
  130571. /**
  130572. * Reload the current scene from the loaded files
  130573. */
  130574. reload(): void;
  130575. }
  130576. }
  130577. declare module BABYLON {
  130578. /**
  130579. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130581. */
  130582. export class SceneOptimization {
  130583. /**
  130584. * Defines the priority of this optimization (0 by default which means first in the list)
  130585. */
  130586. priority: number;
  130587. /**
  130588. * Gets a string describing the action executed by the current optimization
  130589. * @returns description string
  130590. */
  130591. getDescription(): string;
  130592. /**
  130593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130594. * @param scene defines the current scene where to apply this optimization
  130595. * @param optimizer defines the current optimizer
  130596. * @returns true if everything that can be done was applied
  130597. */
  130598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130599. /**
  130600. * Creates the SceneOptimization object
  130601. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130602. * @param desc defines the description associated with the optimization
  130603. */
  130604. constructor(
  130605. /**
  130606. * Defines the priority of this optimization (0 by default which means first in the list)
  130607. */
  130608. priority?: number);
  130609. }
  130610. /**
  130611. * Defines an optimization used to reduce the size of render target textures
  130612. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130613. */
  130614. export class TextureOptimization extends SceneOptimization {
  130615. /**
  130616. * Defines the priority of this optimization (0 by default which means first in the list)
  130617. */
  130618. priority: number;
  130619. /**
  130620. * 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
  130621. */
  130622. maximumSize: number;
  130623. /**
  130624. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130625. */
  130626. step: number;
  130627. /**
  130628. * Gets a string describing the action executed by the current optimization
  130629. * @returns description string
  130630. */
  130631. getDescription(): string;
  130632. /**
  130633. * Creates the TextureOptimization object
  130634. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130635. * @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
  130636. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130637. */
  130638. constructor(
  130639. /**
  130640. * Defines the priority of this optimization (0 by default which means first in the list)
  130641. */
  130642. priority?: number,
  130643. /**
  130644. * 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
  130645. */
  130646. maximumSize?: number,
  130647. /**
  130648. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130649. */
  130650. step?: number);
  130651. /**
  130652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130653. * @param scene defines the current scene where to apply this optimization
  130654. * @param optimizer defines the current optimizer
  130655. * @returns true if everything that can be done was applied
  130656. */
  130657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130658. }
  130659. /**
  130660. * Defines an optimization used to increase or decrease the rendering resolution
  130661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130662. */
  130663. export class HardwareScalingOptimization extends SceneOptimization {
  130664. /**
  130665. * Defines the priority of this optimization (0 by default which means first in the list)
  130666. */
  130667. priority: number;
  130668. /**
  130669. * Defines the maximum scale to use (2 by default)
  130670. */
  130671. maximumScale: number;
  130672. /**
  130673. * Defines the step to use between two passes (0.5 by default)
  130674. */
  130675. step: number;
  130676. private _currentScale;
  130677. private _directionOffset;
  130678. /**
  130679. * Gets a string describing the action executed by the current optimization
  130680. * @return description string
  130681. */
  130682. getDescription(): string;
  130683. /**
  130684. * Creates the HardwareScalingOptimization object
  130685. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130686. * @param maximumScale defines the maximum scale to use (2 by default)
  130687. * @param step defines the step to use between two passes (0.5 by default)
  130688. */
  130689. constructor(
  130690. /**
  130691. * Defines the priority of this optimization (0 by default which means first in the list)
  130692. */
  130693. priority?: number,
  130694. /**
  130695. * Defines the maximum scale to use (2 by default)
  130696. */
  130697. maximumScale?: number,
  130698. /**
  130699. * Defines the step to use between two passes (0.5 by default)
  130700. */
  130701. step?: number);
  130702. /**
  130703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130704. * @param scene defines the current scene where to apply this optimization
  130705. * @param optimizer defines the current optimizer
  130706. * @returns true if everything that can be done was applied
  130707. */
  130708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130709. }
  130710. /**
  130711. * Defines an optimization used to remove shadows
  130712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130713. */
  130714. export class ShadowsOptimization extends SceneOptimization {
  130715. /**
  130716. * Gets a string describing the action executed by the current optimization
  130717. * @return description string
  130718. */
  130719. getDescription(): string;
  130720. /**
  130721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130722. * @param scene defines the current scene where to apply this optimization
  130723. * @param optimizer defines the current optimizer
  130724. * @returns true if everything that can be done was applied
  130725. */
  130726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130727. }
  130728. /**
  130729. * Defines an optimization used to turn post-processes off
  130730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130731. */
  130732. export class PostProcessesOptimization extends SceneOptimization {
  130733. /**
  130734. * Gets a string describing the action executed by the current optimization
  130735. * @return description string
  130736. */
  130737. getDescription(): string;
  130738. /**
  130739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130740. * @param scene defines the current scene where to apply this optimization
  130741. * @param optimizer defines the current optimizer
  130742. * @returns true if everything that can be done was applied
  130743. */
  130744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130745. }
  130746. /**
  130747. * Defines an optimization used to turn lens flares off
  130748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130749. */
  130750. export class LensFlaresOptimization extends SceneOptimization {
  130751. /**
  130752. * Gets a string describing the action executed by the current optimization
  130753. * @return description string
  130754. */
  130755. getDescription(): string;
  130756. /**
  130757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130758. * @param scene defines the current scene where to apply this optimization
  130759. * @param optimizer defines the current optimizer
  130760. * @returns true if everything that can be done was applied
  130761. */
  130762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130763. }
  130764. /**
  130765. * Defines an optimization based on user defined callback.
  130766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130767. */
  130768. export class CustomOptimization extends SceneOptimization {
  130769. /**
  130770. * Callback called to apply the custom optimization.
  130771. */
  130772. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130773. /**
  130774. * Callback called to get custom description
  130775. */
  130776. onGetDescription: () => string;
  130777. /**
  130778. * Gets a string describing the action executed by the current optimization
  130779. * @returns description string
  130780. */
  130781. getDescription(): string;
  130782. /**
  130783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130784. * @param scene defines the current scene where to apply this optimization
  130785. * @param optimizer defines the current optimizer
  130786. * @returns true if everything that can be done was applied
  130787. */
  130788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130789. }
  130790. /**
  130791. * Defines an optimization used to turn particles off
  130792. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130793. */
  130794. export class ParticlesOptimization extends SceneOptimization {
  130795. /**
  130796. * Gets a string describing the action executed by the current optimization
  130797. * @return description string
  130798. */
  130799. getDescription(): string;
  130800. /**
  130801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130802. * @param scene defines the current scene where to apply this optimization
  130803. * @param optimizer defines the current optimizer
  130804. * @returns true if everything that can be done was applied
  130805. */
  130806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130807. }
  130808. /**
  130809. * Defines an optimization used to turn render targets off
  130810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130811. */
  130812. export class RenderTargetsOptimization extends SceneOptimization {
  130813. /**
  130814. * Gets a string describing the action executed by the current optimization
  130815. * @return description string
  130816. */
  130817. getDescription(): string;
  130818. /**
  130819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130820. * @param scene defines the current scene where to apply this optimization
  130821. * @param optimizer defines the current optimizer
  130822. * @returns true if everything that can be done was applied
  130823. */
  130824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130825. }
  130826. /**
  130827. * Defines an optimization used to merge meshes with compatible materials
  130828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130829. */
  130830. export class MergeMeshesOptimization extends SceneOptimization {
  130831. private static _UpdateSelectionTree;
  130832. /**
  130833. * Gets or sets a boolean which defines if optimization octree has to be updated
  130834. */
  130835. /**
  130836. * Gets or sets a boolean which defines if optimization octree has to be updated
  130837. */
  130838. static UpdateSelectionTree: boolean;
  130839. /**
  130840. * Gets a string describing the action executed by the current optimization
  130841. * @return description string
  130842. */
  130843. getDescription(): string;
  130844. private _canBeMerged;
  130845. /**
  130846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130847. * @param scene defines the current scene where to apply this optimization
  130848. * @param optimizer defines the current optimizer
  130849. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130850. * @returns true if everything that can be done was applied
  130851. */
  130852. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130853. }
  130854. /**
  130855. * Defines a list of options used by SceneOptimizer
  130856. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130857. */
  130858. export class SceneOptimizerOptions {
  130859. /**
  130860. * Defines the target frame rate to reach (60 by default)
  130861. */
  130862. targetFrameRate: number;
  130863. /**
  130864. * Defines the interval between two checkes (2000ms by default)
  130865. */
  130866. trackerDuration: number;
  130867. /**
  130868. * Gets the list of optimizations to apply
  130869. */
  130870. optimizations: SceneOptimization[];
  130871. /**
  130872. * Creates a new list of options used by SceneOptimizer
  130873. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130874. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130875. */
  130876. constructor(
  130877. /**
  130878. * Defines the target frame rate to reach (60 by default)
  130879. */
  130880. targetFrameRate?: number,
  130881. /**
  130882. * Defines the interval between two checkes (2000ms by default)
  130883. */
  130884. trackerDuration?: number);
  130885. /**
  130886. * Add a new optimization
  130887. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130888. * @returns the current SceneOptimizerOptions
  130889. */
  130890. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130891. /**
  130892. * Add a new custom optimization
  130893. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130894. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130895. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130896. * @returns the current SceneOptimizerOptions
  130897. */
  130898. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130899. /**
  130900. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130901. * @param targetFrameRate defines the target frame rate (60 by default)
  130902. * @returns a SceneOptimizerOptions object
  130903. */
  130904. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130905. /**
  130906. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130907. * @param targetFrameRate defines the target frame rate (60 by default)
  130908. * @returns a SceneOptimizerOptions object
  130909. */
  130910. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130911. /**
  130912. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130913. * @param targetFrameRate defines the target frame rate (60 by default)
  130914. * @returns a SceneOptimizerOptions object
  130915. */
  130916. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130917. }
  130918. /**
  130919. * Class used to run optimizations in order to reach a target frame rate
  130920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130921. */
  130922. export class SceneOptimizer implements IDisposable {
  130923. private _isRunning;
  130924. private _options;
  130925. private _scene;
  130926. private _currentPriorityLevel;
  130927. private _targetFrameRate;
  130928. private _trackerDuration;
  130929. private _currentFrameRate;
  130930. private _sceneDisposeObserver;
  130931. private _improvementMode;
  130932. /**
  130933. * Defines an observable called when the optimizer reaches the target frame rate
  130934. */
  130935. onSuccessObservable: Observable<SceneOptimizer>;
  130936. /**
  130937. * Defines an observable called when the optimizer enables an optimization
  130938. */
  130939. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130940. /**
  130941. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130942. */
  130943. onFailureObservable: Observable<SceneOptimizer>;
  130944. /**
  130945. * Gets a boolean indicating if the optimizer is in improvement mode
  130946. */
  130947. readonly isInImprovementMode: boolean;
  130948. /**
  130949. * Gets the current priority level (0 at start)
  130950. */
  130951. readonly currentPriorityLevel: number;
  130952. /**
  130953. * Gets the current frame rate checked by the SceneOptimizer
  130954. */
  130955. readonly currentFrameRate: number;
  130956. /**
  130957. * Gets or sets the current target frame rate (60 by default)
  130958. */
  130959. /**
  130960. * Gets or sets the current target frame rate (60 by default)
  130961. */
  130962. targetFrameRate: number;
  130963. /**
  130964. * Gets or sets the current interval between two checks (every 2000ms by default)
  130965. */
  130966. /**
  130967. * Gets or sets the current interval between two checks (every 2000ms by default)
  130968. */
  130969. trackerDuration: number;
  130970. /**
  130971. * Gets the list of active optimizations
  130972. */
  130973. readonly optimizations: SceneOptimization[];
  130974. /**
  130975. * Creates a new SceneOptimizer
  130976. * @param scene defines the scene to work on
  130977. * @param options defines the options to use with the SceneOptimizer
  130978. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  130979. * @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)
  130980. */
  130981. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  130982. /**
  130983. * Stops the current optimizer
  130984. */
  130985. stop(): void;
  130986. /**
  130987. * Reset the optimizer to initial step (current priority level = 0)
  130988. */
  130989. reset(): void;
  130990. /**
  130991. * Start the optimizer. By default it will try to reach a specific framerate
  130992. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  130993. */
  130994. start(): void;
  130995. private _checkCurrentState;
  130996. /**
  130997. * Release all resources
  130998. */
  130999. dispose(): void;
  131000. /**
  131001. * Helper function to create a SceneOptimizer with one single line of code
  131002. * @param scene defines the scene to work on
  131003. * @param options defines the options to use with the SceneOptimizer
  131004. * @param onSuccess defines a callback to call on success
  131005. * @param onFailure defines a callback to call on failure
  131006. * @returns the new SceneOptimizer object
  131007. */
  131008. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  131009. }
  131010. }
  131011. declare module BABYLON {
  131012. /**
  131013. * Class used to serialize a scene into a string
  131014. */
  131015. export class SceneSerializer {
  131016. /**
  131017. * Clear cache used by a previous serialization
  131018. */
  131019. static ClearCache(): void;
  131020. /**
  131021. * Serialize a scene into a JSON compatible object
  131022. * @param scene defines the scene to serialize
  131023. * @returns a JSON compatible object
  131024. */
  131025. static Serialize(scene: Scene): any;
  131026. /**
  131027. * Serialize a mesh into a JSON compatible object
  131028. * @param toSerialize defines the mesh to serialize
  131029. * @param withParents defines if parents must be serialized as well
  131030. * @param withChildren defines if children must be serialized as well
  131031. * @returns a JSON compatible object
  131032. */
  131033. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  131034. }
  131035. }
  131036. declare module BABYLON {
  131037. /**
  131038. * Class used to host texture specific utilities
  131039. */
  131040. export class TextureTools {
  131041. /**
  131042. * Uses the GPU to create a copy texture rescaled at a given size
  131043. * @param texture Texture to copy from
  131044. * @param width defines the desired width
  131045. * @param height defines the desired height
  131046. * @param useBilinearMode defines if bilinear mode has to be used
  131047. * @return the generated texture
  131048. */
  131049. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  131050. }
  131051. }
  131052. declare module BABYLON {
  131053. /**
  131054. * This represents the different options available for the video capture.
  131055. */
  131056. export interface VideoRecorderOptions {
  131057. /** Defines the mime type of the video. */
  131058. mimeType: string;
  131059. /** Defines the FPS the video should be recorded at. */
  131060. fps: number;
  131061. /** Defines the chunk size for the recording data. */
  131062. recordChunckSize: number;
  131063. /** The audio tracks to attach to the recording. */
  131064. audioTracks?: MediaStreamTrack[];
  131065. }
  131066. /**
  131067. * This can help with recording videos from BabylonJS.
  131068. * This is based on the available WebRTC functionalities of the browser.
  131069. *
  131070. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  131071. */
  131072. export class VideoRecorder {
  131073. private static readonly _defaultOptions;
  131074. /**
  131075. * Returns whether or not the VideoRecorder is available in your browser.
  131076. * @param engine Defines the Babylon Engine.
  131077. * @returns true if supported otherwise false.
  131078. */
  131079. static IsSupported(engine: Engine): boolean;
  131080. private readonly _options;
  131081. private _canvas;
  131082. private _mediaRecorder;
  131083. private _recordedChunks;
  131084. private _fileName;
  131085. private _resolve;
  131086. private _reject;
  131087. /**
  131088. * True when a recording is already in progress.
  131089. */
  131090. readonly isRecording: boolean;
  131091. /**
  131092. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131093. * @param engine Defines the BabylonJS Engine you wish to record.
  131094. * @param options Defines options that can be used to customize the capture.
  131095. */
  131096. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131097. /**
  131098. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131099. */
  131100. stopRecording(): void;
  131101. /**
  131102. * Starts recording the canvas for a max duration specified in parameters.
  131103. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131104. * If null no automatic download will start and you can rely on the promise to get the data back.
  131105. * @param maxDuration Defines the maximum recording time in seconds.
  131106. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131107. * @return A promise callback at the end of the recording with the video data in Blob.
  131108. */
  131109. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131110. /**
  131111. * Releases internal resources used during the recording.
  131112. */
  131113. dispose(): void;
  131114. private _handleDataAvailable;
  131115. private _handleError;
  131116. private _handleStop;
  131117. }
  131118. }
  131119. declare module BABYLON {
  131120. /**
  131121. * Class containing a set of static utilities functions for screenshots
  131122. */
  131123. export class ScreenshotTools {
  131124. /**
  131125. * Captures a screenshot of the current rendering
  131126. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131127. * @param engine defines the rendering engine
  131128. * @param camera defines the source camera
  131129. * @param size This parameter can be set to a single number or to an object with the
  131130. * following (optional) properties: precision, width, height. If a single number is passed,
  131131. * it will be used for both width and height. If an object is passed, the screenshot size
  131132. * will be derived from the parameters. The precision property is a multiplier allowing
  131133. * rendering at a higher or lower resolution
  131134. * @param successCallback defines the callback receives a single parameter which contains the
  131135. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131136. * src parameter of an <img> to display it
  131137. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131138. * Check your browser for supported MIME types
  131139. */
  131140. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131141. /**
  131142. * Captures a screenshot of the current rendering
  131143. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131144. * @param engine defines the rendering engine
  131145. * @param camera defines the source camera
  131146. * @param size This parameter can be set to a single number or to an object with the
  131147. * following (optional) properties: precision, width, height. If a single number is passed,
  131148. * it will be used for both width and height. If an object is passed, the screenshot size
  131149. * will be derived from the parameters. The precision property is a multiplier allowing
  131150. * rendering at a higher or lower resolution
  131151. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131152. * Check your browser for supported MIME types
  131153. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131154. * to the src parameter of an <img> to display it
  131155. */
  131156. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131157. /**
  131158. * Generates an image screenshot from the specified camera.
  131159. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131160. * @param engine The engine to use for rendering
  131161. * @param camera The camera to use for rendering
  131162. * @param size This parameter can be set to a single number or to an object with the
  131163. * following (optional) properties: precision, width, height. If a single number is passed,
  131164. * it will be used for both width and height. If an object is passed, the screenshot size
  131165. * will be derived from the parameters. The precision property is a multiplier allowing
  131166. * rendering at a higher or lower resolution
  131167. * @param successCallback The callback receives a single parameter which contains the
  131168. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131169. * src parameter of an <img> to display it
  131170. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131171. * Check your browser for supported MIME types
  131172. * @param samples Texture samples (default: 1)
  131173. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131174. * @param fileName A name for for the downloaded file.
  131175. */
  131176. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131177. /**
  131178. * Generates an image screenshot from the specified camera.
  131179. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131180. * @param engine The engine to use for rendering
  131181. * @param camera The camera to use for rendering
  131182. * @param size This parameter can be set to a single number or to an object with the
  131183. * following (optional) properties: precision, width, height. If a single number is passed,
  131184. * it will be used for both width and height. If an object is passed, the screenshot size
  131185. * will be derived from the parameters. The precision property is a multiplier allowing
  131186. * rendering at a higher or lower resolution
  131187. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131188. * Check your browser for supported MIME types
  131189. * @param samples Texture samples (default: 1)
  131190. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131191. * @param fileName A name for for the downloaded file.
  131192. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131193. * to the src parameter of an <img> to display it
  131194. */
  131195. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131196. /**
  131197. * Gets height and width for screenshot size
  131198. * @private
  131199. */
  131200. private static _getScreenshotSize;
  131201. }
  131202. }
  131203. declare module BABYLON {
  131204. /**
  131205. * A cursor which tracks a point on a path
  131206. */
  131207. export class PathCursor {
  131208. private path;
  131209. /**
  131210. * Stores path cursor callbacks for when an onchange event is triggered
  131211. */
  131212. private _onchange;
  131213. /**
  131214. * The value of the path cursor
  131215. */
  131216. value: number;
  131217. /**
  131218. * The animation array of the path cursor
  131219. */
  131220. animations: Animation[];
  131221. /**
  131222. * Initializes the path cursor
  131223. * @param path The path to track
  131224. */
  131225. constructor(path: Path2);
  131226. /**
  131227. * Gets the cursor point on the path
  131228. * @returns A point on the path cursor at the cursor location
  131229. */
  131230. getPoint(): Vector3;
  131231. /**
  131232. * Moves the cursor ahead by the step amount
  131233. * @param step The amount to move the cursor forward
  131234. * @returns This path cursor
  131235. */
  131236. moveAhead(step?: number): PathCursor;
  131237. /**
  131238. * Moves the cursor behind by the step amount
  131239. * @param step The amount to move the cursor back
  131240. * @returns This path cursor
  131241. */
  131242. moveBack(step?: number): PathCursor;
  131243. /**
  131244. * Moves the cursor by the step amount
  131245. * If the step amount is greater than one, an exception is thrown
  131246. * @param step The amount to move the cursor
  131247. * @returns This path cursor
  131248. */
  131249. move(step: number): PathCursor;
  131250. /**
  131251. * Ensures that the value is limited between zero and one
  131252. * @returns This path cursor
  131253. */
  131254. private ensureLimits;
  131255. /**
  131256. * Runs onchange callbacks on change (used by the animation engine)
  131257. * @returns This path cursor
  131258. */
  131259. private raiseOnChange;
  131260. /**
  131261. * Executes a function on change
  131262. * @param f A path cursor onchange callback
  131263. * @returns This path cursor
  131264. */
  131265. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131266. }
  131267. }
  131268. declare module BABYLON {
  131269. /** @hidden */
  131270. export var blurPixelShader: {
  131271. name: string;
  131272. shader: string;
  131273. };
  131274. }
  131275. declare module BABYLON {
  131276. /** @hidden */
  131277. export var pointCloudVertexDeclaration: {
  131278. name: string;
  131279. shader: string;
  131280. };
  131281. }
  131282. // Mixins
  131283. interface Window {
  131284. mozIndexedDB: IDBFactory;
  131285. webkitIndexedDB: IDBFactory;
  131286. msIndexedDB: IDBFactory;
  131287. webkitURL: typeof URL;
  131288. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131289. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131290. WebGLRenderingContext: WebGLRenderingContext;
  131291. MSGesture: MSGesture;
  131292. CANNON: any;
  131293. AudioContext: AudioContext;
  131294. webkitAudioContext: AudioContext;
  131295. PointerEvent: any;
  131296. Math: Math;
  131297. Uint8Array: Uint8ArrayConstructor;
  131298. Float32Array: Float32ArrayConstructor;
  131299. mozURL: typeof URL;
  131300. msURL: typeof URL;
  131301. VRFrameData: any; // WebVR, from specs 1.1
  131302. DracoDecoderModule: any;
  131303. setImmediate(handler: (...args: any[]) => void): number;
  131304. }
  131305. interface HTMLCanvasElement {
  131306. requestPointerLock(): void;
  131307. msRequestPointerLock?(): void;
  131308. mozRequestPointerLock?(): void;
  131309. webkitRequestPointerLock?(): void;
  131310. /** Track wether a record is in progress */
  131311. isRecording: boolean;
  131312. /** Capture Stream method defined by some browsers */
  131313. captureStream(fps?: number): MediaStream;
  131314. }
  131315. interface CanvasRenderingContext2D {
  131316. msImageSmoothingEnabled: boolean;
  131317. }
  131318. interface MouseEvent {
  131319. mozMovementX: number;
  131320. mozMovementY: number;
  131321. webkitMovementX: number;
  131322. webkitMovementY: number;
  131323. msMovementX: number;
  131324. msMovementY: number;
  131325. }
  131326. interface Navigator {
  131327. mozGetVRDevices: (any: any) => any;
  131328. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131329. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131330. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131331. webkitGetGamepads(): Gamepad[];
  131332. msGetGamepads(): Gamepad[];
  131333. webkitGamepads(): Gamepad[];
  131334. }
  131335. interface HTMLVideoElement {
  131336. mozSrcObject: any;
  131337. }
  131338. interface Math {
  131339. fround(x: number): number;
  131340. imul(a: number, b: number): number;
  131341. }
  131342. interface WebGLRenderingContext {
  131343. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131344. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131345. vertexAttribDivisor(index: number, divisor: number): void;
  131346. createVertexArray(): any;
  131347. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131348. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131349. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131350. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131351. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131352. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131353. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131354. // Queries
  131355. createQuery(): WebGLQuery;
  131356. deleteQuery(query: WebGLQuery): void;
  131357. beginQuery(target: number, query: WebGLQuery): void;
  131358. endQuery(target: number): void;
  131359. getQueryParameter(query: WebGLQuery, pname: number): any;
  131360. getQuery(target: number, pname: number): any;
  131361. MAX_SAMPLES: number;
  131362. RGBA8: number;
  131363. READ_FRAMEBUFFER: number;
  131364. DRAW_FRAMEBUFFER: number;
  131365. UNIFORM_BUFFER: number;
  131366. HALF_FLOAT_OES: number;
  131367. RGBA16F: number;
  131368. RGBA32F: number;
  131369. R32F: number;
  131370. RG32F: number;
  131371. RGB32F: number;
  131372. R16F: number;
  131373. RG16F: number;
  131374. RGB16F: number;
  131375. RED: number;
  131376. RG: number;
  131377. R8: number;
  131378. RG8: number;
  131379. UNSIGNED_INT_24_8: number;
  131380. DEPTH24_STENCIL8: number;
  131381. MIN: number;
  131382. MAX: number;
  131383. /* Multiple Render Targets */
  131384. drawBuffers(buffers: number[]): void;
  131385. readBuffer(src: number): void;
  131386. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131387. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131388. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131389. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131390. // Occlusion Query
  131391. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131392. ANY_SAMPLES_PASSED: number;
  131393. QUERY_RESULT_AVAILABLE: number;
  131394. QUERY_RESULT: number;
  131395. }
  131396. interface WebGLProgram {
  131397. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131398. }
  131399. interface EXT_disjoint_timer_query {
  131400. QUERY_COUNTER_BITS_EXT: number;
  131401. TIME_ELAPSED_EXT: number;
  131402. TIMESTAMP_EXT: number;
  131403. GPU_DISJOINT_EXT: number;
  131404. QUERY_RESULT_EXT: number;
  131405. QUERY_RESULT_AVAILABLE_EXT: number;
  131406. queryCounterEXT(query: WebGLQuery, target: number): void;
  131407. createQueryEXT(): WebGLQuery;
  131408. beginQueryEXT(target: number, query: WebGLQuery): void;
  131409. endQueryEXT(target: number): void;
  131410. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131411. deleteQueryEXT(query: WebGLQuery): void;
  131412. }
  131413. interface WebGLUniformLocation {
  131414. _currentState: any;
  131415. }
  131416. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131417. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131418. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131419. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131420. interface WebGLRenderingContext {
  131421. readonly RASTERIZER_DISCARD: number;
  131422. readonly DEPTH_COMPONENT24: number;
  131423. readonly TEXTURE_3D: number;
  131424. readonly TEXTURE_2D_ARRAY: number;
  131425. readonly TEXTURE_COMPARE_FUNC: number;
  131426. readonly TEXTURE_COMPARE_MODE: number;
  131427. readonly COMPARE_REF_TO_TEXTURE: number;
  131428. readonly TEXTURE_WRAP_R: number;
  131429. readonly HALF_FLOAT: number;
  131430. readonly RGB8: number;
  131431. readonly RED_INTEGER: number;
  131432. readonly RG_INTEGER: number;
  131433. readonly RGB_INTEGER: number;
  131434. readonly RGBA_INTEGER: number;
  131435. readonly R8_SNORM: number;
  131436. readonly RG8_SNORM: number;
  131437. readonly RGB8_SNORM: number;
  131438. readonly RGBA8_SNORM: number;
  131439. readonly R8I: number;
  131440. readonly RG8I: number;
  131441. readonly RGB8I: number;
  131442. readonly RGBA8I: number;
  131443. readonly R8UI: number;
  131444. readonly RG8UI: number;
  131445. readonly RGB8UI: number;
  131446. readonly RGBA8UI: number;
  131447. readonly R16I: number;
  131448. readonly RG16I: number;
  131449. readonly RGB16I: number;
  131450. readonly RGBA16I: number;
  131451. readonly R16UI: number;
  131452. readonly RG16UI: number;
  131453. readonly RGB16UI: number;
  131454. readonly RGBA16UI: number;
  131455. readonly R32I: number;
  131456. readonly RG32I: number;
  131457. readonly RGB32I: number;
  131458. readonly RGBA32I: number;
  131459. readonly R32UI: number;
  131460. readonly RG32UI: number;
  131461. readonly RGB32UI: number;
  131462. readonly RGBA32UI: number;
  131463. readonly RGB10_A2UI: number;
  131464. readonly R11F_G11F_B10F: number;
  131465. readonly RGB9_E5: number;
  131466. readonly RGB10_A2: number;
  131467. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131468. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131469. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131470. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131471. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131472. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131473. 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;
  131474. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131475. readonly TRANSFORM_FEEDBACK: number;
  131476. readonly INTERLEAVED_ATTRIBS: number;
  131477. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131478. createTransformFeedback(): WebGLTransformFeedback;
  131479. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131480. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131481. beginTransformFeedback(primitiveMode: number): void;
  131482. endTransformFeedback(): void;
  131483. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131484. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131485. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131486. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131487. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131488. }
  131489. interface ImageBitmap {
  131490. readonly width: number;
  131491. readonly height: number;
  131492. close(): void;
  131493. }
  131494. interface WebGLQuery extends WebGLObject {
  131495. }
  131496. declare var WebGLQuery: {
  131497. prototype: WebGLQuery;
  131498. new(): WebGLQuery;
  131499. };
  131500. interface WebGLSampler extends WebGLObject {
  131501. }
  131502. declare var WebGLSampler: {
  131503. prototype: WebGLSampler;
  131504. new(): WebGLSampler;
  131505. };
  131506. interface WebGLSync extends WebGLObject {
  131507. }
  131508. declare var WebGLSync: {
  131509. prototype: WebGLSync;
  131510. new(): WebGLSync;
  131511. };
  131512. interface WebGLTransformFeedback extends WebGLObject {
  131513. }
  131514. declare var WebGLTransformFeedback: {
  131515. prototype: WebGLTransformFeedback;
  131516. new(): WebGLTransformFeedback;
  131517. };
  131518. interface WebGLVertexArrayObject extends WebGLObject {
  131519. }
  131520. declare var WebGLVertexArrayObject: {
  131521. prototype: WebGLVertexArrayObject;
  131522. new(): WebGLVertexArrayObject;
  131523. };
  131524. // Type definitions for WebVR API
  131525. // Project: https://w3c.github.io/webvr/
  131526. // Definitions by: six a <https://github.com/lostfictions>
  131527. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131528. interface VRDisplay extends EventTarget {
  131529. /**
  131530. * Dictionary of capabilities describing the VRDisplay.
  131531. */
  131532. readonly capabilities: VRDisplayCapabilities;
  131533. /**
  131534. * z-depth defining the far plane of the eye view frustum
  131535. * enables mapping of values in the render target depth
  131536. * attachment to scene coordinates. Initially set to 10000.0.
  131537. */
  131538. depthFar: number;
  131539. /**
  131540. * z-depth defining the near plane of the eye view frustum
  131541. * enables mapping of values in the render target depth
  131542. * attachment to scene coordinates. Initially set to 0.01.
  131543. */
  131544. depthNear: number;
  131545. /**
  131546. * An identifier for this distinct VRDisplay. Used as an
  131547. * association point in the Gamepad API.
  131548. */
  131549. readonly displayId: number;
  131550. /**
  131551. * A display name, a user-readable name identifying it.
  131552. */
  131553. readonly displayName: string;
  131554. readonly isConnected: boolean;
  131555. readonly isPresenting: boolean;
  131556. /**
  131557. * If this VRDisplay supports room-scale experiences, the optional
  131558. * stage attribute contains details on the room-scale parameters.
  131559. */
  131560. readonly stageParameters: VRStageParameters | null;
  131561. /**
  131562. * Passing the value returned by `requestAnimationFrame` to
  131563. * `cancelAnimationFrame` will unregister the callback.
  131564. * @param handle Define the hanle of the request to cancel
  131565. */
  131566. cancelAnimationFrame(handle: number): void;
  131567. /**
  131568. * Stops presenting to the VRDisplay.
  131569. * @returns a promise to know when it stopped
  131570. */
  131571. exitPresent(): Promise<void>;
  131572. /**
  131573. * Return the current VREyeParameters for the given eye.
  131574. * @param whichEye Define the eye we want the parameter for
  131575. * @returns the eye parameters
  131576. */
  131577. getEyeParameters(whichEye: string): VREyeParameters;
  131578. /**
  131579. * Populates the passed VRFrameData with the information required to render
  131580. * the current frame.
  131581. * @param frameData Define the data structure to populate
  131582. * @returns true if ok otherwise false
  131583. */
  131584. getFrameData(frameData: VRFrameData): boolean;
  131585. /**
  131586. * Get the layers currently being presented.
  131587. * @returns the list of VR layers
  131588. */
  131589. getLayers(): VRLayer[];
  131590. /**
  131591. * Return a VRPose containing the future predicted pose of the VRDisplay
  131592. * when the current frame will be presented. The value returned will not
  131593. * change until JavaScript has returned control to the browser.
  131594. *
  131595. * The VRPose will contain the position, orientation, velocity,
  131596. * and acceleration of each of these properties.
  131597. * @returns the pose object
  131598. */
  131599. getPose(): VRPose;
  131600. /**
  131601. * Return the current instantaneous pose of the VRDisplay, with no
  131602. * prediction applied.
  131603. * @returns the current instantaneous pose
  131604. */
  131605. getImmediatePose(): VRPose;
  131606. /**
  131607. * The callback passed to `requestAnimationFrame` will be called
  131608. * any time a new frame should be rendered. When the VRDisplay is
  131609. * presenting the callback will be called at the native refresh
  131610. * rate of the HMD. When not presenting this function acts
  131611. * identically to how window.requestAnimationFrame acts. Content should
  131612. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131613. * asynchronously from other displays and at differing refresh rates.
  131614. * @param callback Define the eaction to run next frame
  131615. * @returns the request handle it
  131616. */
  131617. requestAnimationFrame(callback: FrameRequestCallback): number;
  131618. /**
  131619. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131620. * Repeat calls while already presenting will update the VRLayers being displayed.
  131621. * @param layers Define the list of layer to present
  131622. * @returns a promise to know when the request has been fulfilled
  131623. */
  131624. requestPresent(layers: VRLayer[]): Promise<void>;
  131625. /**
  131626. * Reset the pose for this display, treating its current position and
  131627. * orientation as the "origin/zero" values. VRPose.position,
  131628. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131629. * updated when calling resetPose(). This should be called in only
  131630. * sitting-space experiences.
  131631. */
  131632. resetPose(): void;
  131633. /**
  131634. * The VRLayer provided to the VRDisplay will be captured and presented
  131635. * in the HMD. Calling this function has the same effect on the source
  131636. * canvas as any other operation that uses its source image, and canvases
  131637. * created without preserveDrawingBuffer set to true will be cleared.
  131638. * @param pose Define the pose to submit
  131639. */
  131640. submitFrame(pose?: VRPose): void;
  131641. }
  131642. declare var VRDisplay: {
  131643. prototype: VRDisplay;
  131644. new(): VRDisplay;
  131645. };
  131646. interface VRLayer {
  131647. leftBounds?: number[] | Float32Array | null;
  131648. rightBounds?: number[] | Float32Array | null;
  131649. source?: HTMLCanvasElement | null;
  131650. }
  131651. interface VRDisplayCapabilities {
  131652. readonly canPresent: boolean;
  131653. readonly hasExternalDisplay: boolean;
  131654. readonly hasOrientation: boolean;
  131655. readonly hasPosition: boolean;
  131656. readonly maxLayers: number;
  131657. }
  131658. interface VREyeParameters {
  131659. /** @deprecated */
  131660. readonly fieldOfView: VRFieldOfView;
  131661. readonly offset: Float32Array;
  131662. readonly renderHeight: number;
  131663. readonly renderWidth: number;
  131664. }
  131665. interface VRFieldOfView {
  131666. readonly downDegrees: number;
  131667. readonly leftDegrees: number;
  131668. readonly rightDegrees: number;
  131669. readonly upDegrees: number;
  131670. }
  131671. interface VRFrameData {
  131672. readonly leftProjectionMatrix: Float32Array;
  131673. readonly leftViewMatrix: Float32Array;
  131674. readonly pose: VRPose;
  131675. readonly rightProjectionMatrix: Float32Array;
  131676. readonly rightViewMatrix: Float32Array;
  131677. readonly timestamp: number;
  131678. }
  131679. interface VRPose {
  131680. readonly angularAcceleration: Float32Array | null;
  131681. readonly angularVelocity: Float32Array | null;
  131682. readonly linearAcceleration: Float32Array | null;
  131683. readonly linearVelocity: Float32Array | null;
  131684. readonly orientation: Float32Array | null;
  131685. readonly position: Float32Array | null;
  131686. readonly timestamp: number;
  131687. }
  131688. interface VRStageParameters {
  131689. sittingToStandingTransform?: Float32Array;
  131690. sizeX?: number;
  131691. sizeY?: number;
  131692. }
  131693. interface Navigator {
  131694. getVRDisplays(): Promise<VRDisplay[]>;
  131695. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131696. }
  131697. interface Window {
  131698. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131699. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131700. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131701. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131702. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131703. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131704. }
  131705. interface Gamepad {
  131706. readonly displayId: number;
  131707. }
  131708. type XRSessionMode =
  131709. | "inline"
  131710. | "immersive-vr"
  131711. | "immersive-ar";
  131712. type XRReferenceSpaceType =
  131713. | "viewer"
  131714. | "local"
  131715. | "local-floor"
  131716. | "bounded-floor"
  131717. | "unbounded";
  131718. type XREnvironmentBlendMode =
  131719. | "opaque"
  131720. | "additive"
  131721. | "alpha-blend";
  131722. type XRVisibilityState =
  131723. | "visible"
  131724. | "visible-blurred"
  131725. | "hidden";
  131726. type XRHandedness =
  131727. | "none"
  131728. | "left"
  131729. | "right";
  131730. type XRTargetRayMode =
  131731. | "gaze"
  131732. | "tracked-pointer"
  131733. | "screen";
  131734. type XREye =
  131735. | "none"
  131736. | "left"
  131737. | "right";
  131738. interface XRSpace extends EventTarget {
  131739. }
  131740. interface XRRenderState {
  131741. depthNear?: number;
  131742. depthFar?: number;
  131743. inlineVerticalFieldOfView?: number;
  131744. baseLayer?: XRWebGLLayer;
  131745. }
  131746. interface XRInputSource {
  131747. handedness: XRHandedness;
  131748. targetRayMode: XRTargetRayMode;
  131749. targetRaySpace: XRSpace;
  131750. gripSpace: XRSpace | undefined;
  131751. gamepad: Gamepad | undefined;
  131752. profiles: Array<string>;
  131753. }
  131754. interface XRSession {
  131755. addEventListener: Function;
  131756. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131757. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131758. requestAnimationFrame: Function;
  131759. end(): Promise<void>;
  131760. renderState: XRRenderState;
  131761. inputSources: Array<XRInputSource>;
  131762. }
  131763. interface XRReferenceSpace extends XRSpace {
  131764. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131765. onreset: any;
  131766. }
  131767. interface XRFrame {
  131768. session: XRSession;
  131769. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131770. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131771. }
  131772. interface XRViewerPose extends XRPose {
  131773. views: Array<XRView>;
  131774. }
  131775. interface XRPose {
  131776. transform: XRRigidTransform;
  131777. emulatedPosition: boolean;
  131778. }
  131779. declare var XRWebGLLayer: {
  131780. prototype: XRWebGLLayer;
  131781. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131782. };
  131783. interface XRWebGLLayer {
  131784. framebuffer: WebGLFramebuffer;
  131785. framebufferWidth: number;
  131786. framebufferHeight: number;
  131787. getViewport: Function;
  131788. }
  131789. interface XRRigidTransform {
  131790. position: DOMPointReadOnly;
  131791. orientation: DOMPointReadOnly;
  131792. matrix: Float32Array;
  131793. inverse: XRRigidTransform;
  131794. }
  131795. interface XRView {
  131796. eye: XREye;
  131797. projectionMatrix: Float32Array;
  131798. transform: XRRigidTransform;
  131799. }
  131800. interface XRInputSourceChangeEvent {
  131801. session: XRSession;
  131802. removed: Array<XRInputSource>;
  131803. added: Array<XRInputSource>;
  131804. }